Module Name: src
Committed By: knakahara
Date: Fri Nov 25 12:10:59 UTC 2016
Modified Files:
src/sys/dev/pci: pci_stub.c pcivar.h
Log Message:
provide all PCI MSI/MSI-X manipulation stub functions.
"#ifdef __HAVE_PCI_MSI_MSIX" workaround such as nvme_pci(4) is not required
any more.
http://mail-index.netbsd.org/source-changes/2016/09/17/msg077799.html
To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/pci/pci_stub.c
cvs rdiff -u -r1.108 -r1.109 src/sys/dev/pci/pcivar.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/pci/pci_stub.c
diff -u src/sys/dev/pci/pci_stub.c:1.5 src/sys/dev/pci/pci_stub.c:1.6
--- src/sys/dev/pci/pci_stub.c:1.5 Mon Jul 11 06:14:51 2016
+++ src/sys/dev/pci/pci_stub.c Fri Nov 25 12:10:59 2016
@@ -1,5 +1,5 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pci_stub.c,v 1.5 2016/07/11 06:14:51 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_stub.c,v 1.6 2016/11/25 12:10:59 knakahara Exp $");
#ifdef _KERNEL_OPT
#include "opt_pci.h"
@@ -17,22 +17,11 @@ int default_pci_bus_devorder(pci_chipset
int default_pci_chipset_tag_create(pci_chipset_tag_t, uint64_t,
const struct pci_overrides *, void *, pci_chipset_tag_t *);
void default_pci_chipset_tag_destroy(pci_chipset_tag_t);
-pci_intr_type_t default_pci_intr_type(pci_chipset_tag_t, pci_intr_handle_t);
-int default_pci_intr_alloc(const struct pci_attach_args *,
- pci_intr_handle_t **, int *, pci_intr_type_t);
-void default_pci_intr_release(pci_chipset_tag_t, pci_intr_handle_t *, int);
-void *default_pci_intr_establish_xname(pci_chipset_tag_t, pci_intr_handle_t,
- int, int (*)(void *), void *, const char *);
__strict_weak_alias(pci_bus_devorder, default_pci_bus_devorder);
__strict_weak_alias(pci_chipset_tag_create, default_pci_chipset_tag_create);
__strict_weak_alias(pci_chipset_tag_destroy, default_pci_chipset_tag_destroy);
-__strict_weak_alias(pci_intr_type, default_pci_intr_type);
-__strict_weak_alias(pci_intr_alloc, default_pci_intr_alloc);
-__strict_weak_alias(pci_intr_release, default_pci_intr_release);
-__strict_weak_alias(pci_intr_establish_xname, default_pci_intr_establish_xname);
-
int
default_pci_bus_devorder(pci_chipset_tag_t pc, int bus, uint8_t *devs,
int maxdevs)
@@ -58,47 +47,98 @@ default_pci_chipset_tag_create(pci_chips
return EOPNOTSUPP;
}
+#ifndef __HAVE_PCI_MSI_MSIX
pci_intr_type_t
-default_pci_intr_type(pci_chipset_tag_t pc, pci_intr_handle_t ih)
+pci_intr_type(pci_chipset_tag_t pc, pci_intr_handle_t ih)
{
return PCI_INTR_TYPE_INTX;
}
int
-default_pci_intr_alloc(const struct pci_attach_args *pa,
- pci_intr_handle_t **ihps, int *counts, pci_intr_type_t max_type)
+pci_intr_alloc(const struct pci_attach_args *pa, pci_intr_handle_t **ihps,
+ int *counts, pci_intr_type_t max_type)
{
- pci_intr_handle_t *ihp;
if (counts != NULL && counts[PCI_INTR_TYPE_INTX] == 0)
return EINVAL;
- ihp = kmem_alloc(sizeof(*ihp), KM_SLEEP);
+ return pci_intx_alloc(pa, ihps);
+}
+
+void
+pci_intr_release(pci_chipset_tag_t pc, pci_intr_handle_t *pih, int count)
+{
+
+ kmem_free(pih, sizeof(*pih));
+}
+
+void *
+pci_intr_establish_xname(pci_chipset_tag_t pc, pci_intr_handle_t ih, int level,
+ int (*func)(void *), void *arg, const char *__nouse)
+{
+
+ return pci_intr_establish(pc, ih, level, func, arg);
+}
+
+int
+pci_intx_alloc(const struct pci_attach_args *pa, pci_intr_handle_t **ihp)
+{
+ pci_intr_handle_t *pih;
+
if (ihp == NULL)
+ return EINVAL;
+
+ pih = kmem_alloc(sizeof(*pih), KM_SLEEP);
+ if (pih == NULL)
return ENOMEM;
- if (pci_intr_map(pa, ihp)) {
- kmem_free(ihp, sizeof(*ihp));
+ if (pci_intr_map(pa, pih)) {
+ kmem_free(pih, sizeof(*pih));
return EINVAL;
}
- ihps[0] = ihp;
+ *ihp = pih;
return 0;
}
-void
-default_pci_intr_release(pci_chipset_tag_t pc, pci_intr_handle_t *pih,
+int
+pci_msi_alloc(const struct pci_attach_args *pa, pci_intr_handle_t **ihps,
+ int *count)
+{
+
+ return EOPNOTSUPP;
+}
+
+int
+pci_msi_alloc_exact(const struct pci_attach_args *pa, pci_intr_handle_t **ihps,
int count)
{
- kmem_free(pih, sizeof(*pih));
+ return EOPNOTSUPP;
}
-void *
-default_pci_intr_establish_xname(pci_chipset_tag_t pc, pci_intr_handle_t ih,
- int level, int (*func)(void *), void *arg, const char *__nouse)
+int
+pci_msix_alloc(const struct pci_attach_args *pa, pci_intr_handle_t **ihps,
+ int *count)
{
- return pci_intr_establish(pc, ih, level, func, arg);
+ return EOPNOTSUPP;
+}
+
+int
+pci_msix_alloc_exact(const struct pci_attach_args *pa, pci_intr_handle_t **ihps,
+ int count)
+{
+
+ return EOPNOTSUPP;
+}
+
+int
+pci_msix_alloc_map(const struct pci_attach_args *pa, pci_intr_handle_t **ihps,
+ u_int *table_indexes, int count)
+{
+
+ return EOPNOTSUPP;
}
+#endif /* __HAVE_PCI_MSI_MSIX */
Index: src/sys/dev/pci/pcivar.h
diff -u src/sys/dev/pci/pcivar.h:1.108 src/sys/dev/pci/pcivar.h:1.109
--- src/sys/dev/pci/pcivar.h:1.108 Mon Jul 11 06:14:51 2016
+++ src/sys/dev/pci/pcivar.h Fri Nov 25 12:10:59 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: pcivar.h,v 1.108 2016/07/11 06:14:51 knakahara Exp $ */
+/* $NetBSD: pcivar.h,v 1.109 2016/11/25 12:10:59 knakahara Exp $ */
/*
* Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.
@@ -361,8 +361,19 @@ typedef enum {
pci_intr_type_t
pci_intr_type(pci_chipset_tag_t, pci_intr_handle_t);
int pci_intr_alloc(const struct pci_attach_args *, pci_intr_handle_t **,
- int *, pci_intr_type_t);
+ int *, pci_intr_type_t);
void pci_intr_release(pci_chipset_tag_t, pci_intr_handle_t *, int);
+int pci_intx_alloc(const struct pci_attach_args *, pci_intr_handle_t **);
+int pci_msi_alloc(const struct pci_attach_args *, pci_intr_handle_t **,
+ int *);
+int pci_msi_alloc_exact(const struct pci_attach_args *,
+ pci_intr_handle_t **, int);
+int pci_msix_alloc(const struct pci_attach_args *, pci_intr_handle_t **,
+ int *);
+int pci_msix_alloc_exact(const struct pci_attach_args *,
+ pci_intr_handle_t **, int);
+int pci_msix_alloc_map(const struct pci_attach_args *, pci_intr_handle_t **,
+ u_int *, int);
#endif
/*