Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys - Don't take pci_attach_args as an argument in pci_msi[x...
details: https://anonhg.NetBSD.org/src/rev/614c1f4fde14
branches: trunk
changeset: 339838:614c1f4fde14
user: msaitoh <msaitoh%NetBSD.org@localhost>
date: Thu Aug 13 04:39:33 2015 +0000
description:
- Don't take pci_attach_args as an argument in pci_msi[x]_count().
- Move prototypes of pci_msi[x]_count() from x86/x86/pci_machdep_common to
sys/dev/pci/pcivar.h.
- Move pci_msi[x]_count() from x86/pci/pci_msi_machdep.c to sys/dev/pci/pci.c
diffstat:
sys/arch/x86/include/pci_machdep_common.h | 4 +-
sys/arch/x86/pci/msipic.c | 6 +-
sys/arch/x86/pci/pci_intr_machdep.c | 8 +-
sys/arch/x86/pci/pci_msi_machdep.c | 65 +++---------------------------
sys/dev/pci/pci.c | 47 +++++++++++++++++++++-
sys/dev/pci/pcivar.h | 4 +-
6 files changed, 63 insertions(+), 71 deletions(-)
diffs (truncated from 301 to 300 lines):
diff -r 0588a8a34b89 -r 614c1f4fde14 sys/arch/x86/include/pci_machdep_common.h
--- a/sys/arch/x86/include/pci_machdep_common.h Thu Aug 13 04:27:36 2015 +0000
+++ b/sys/arch/x86/include/pci_machdep_common.h Thu Aug 13 04:39:33 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pci_machdep_common.h,v 1.19 2015/07/21 03:10:42 knakahara Exp $ */
+/* $NetBSD: pci_machdep_common.h,v 1.20 2015/08/13 04:39:33 msaitoh Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
@@ -145,14 +145,12 @@
pci_intr_handle_t **, int *, pci_intr_type_t);
/* experimental MSI support */
-int pci_msi_count(const struct pci_attach_args *);
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);
/* experimental MSI-X support */
-int pci_msix_count(const struct pci_attach_args *);
int pci_msix_alloc(const struct pci_attach_args *,
pci_intr_handle_t **, int *);
int pci_msix_alloc_exact(const struct pci_attach_args *,
diff -r 0588a8a34b89 -r 614c1f4fde14 sys/arch/x86/pci/msipic.c
--- a/sys/arch/x86/pci/msipic.c Thu Aug 13 04:27:36 2015 +0000
+++ b/sys/arch/x86/pci/msipic.c Thu Aug 13 04:39:33 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: msipic.c,v 1.5 2015/08/11 04:04:36 msaitoh Exp $ */
+/* $NetBSD: msipic.c,v 1.6 2015/08/13 04:39:33 msaitoh Exp $ */
/*
* Copyright (c) 2015 Internet Initiative Japan Inc.
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: msipic.c,v 1.5 2015/08/11 04:04:36 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msipic.c,v 1.6 2015/08/13 04:39:33 msaitoh Exp $");
#include "opt_intrdebug.h"
@@ -622,7 +622,7 @@
int bir, bar, err, off, table_nentry;
char pic_name_buf[MSIPICNAMEBUF];
- table_nentry = pci_msix_count(pa);
+ table_nentry = pci_msix_count(pa->pa_pc, pa->pa_tag);
if (table_nentry == 0) {
DPRINTF(("MSI-X table entry is 0.\n"));
return NULL;
diff -r 0588a8a34b89 -r 614c1f4fde14 sys/arch/x86/pci/pci_intr_machdep.c
--- a/sys/arch/x86/pci/pci_intr_machdep.c Thu Aug 13 04:27:36 2015 +0000
+++ b/sys/arch/x86/pci/pci_intr_machdep.c Thu Aug 13 04:39:33 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pci_intr_machdep.c,v 1.35 2015/07/24 06:49:58 knakahara Exp $ */
+/* $NetBSD: pci_intr_machdep.c,v 1.36 2015/08/13 04:39:33 msaitoh Exp $ */
/*-
* Copyright (c) 1997, 1998, 2009 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pci_intr_machdep.c,v 1.35 2015/07/24 06:49:58 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_intr_machdep.c,v 1.36 2015/08/13 04:39:33 msaitoh Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -490,7 +490,7 @@
/* try MSI-X */
if (msix_count == -1) /* use hardware max */
- msix_count = pci_msix_count(pa);
+ msix_count = pci_msix_count(pa->pa_pc, pa->pa_tag);
if (msix_count > 0) {
error = pci_msix_alloc_exact(pa, ihps, msix_count);
if (error == 0) {
@@ -503,7 +503,7 @@
/* try MSI */
if (msi_count == -1) /* use hardware max */
- msi_count = pci_msi_count(pa);
+ msi_count = pci_msi_count(pa->pa_pc, pa->pa_tag);
if (msi_count > 0) {
error = pci_msi_alloc_exact(pa, ihps, msi_count);
if (error == 0) {
diff -r 0588a8a34b89 -r 614c1f4fde14 sys/arch/x86/pci/pci_msi_machdep.c
--- a/sys/arch/x86/pci/pci_msi_machdep.c Thu Aug 13 04:27:36 2015 +0000
+++ b/sys/arch/x86/pci/pci_msi_machdep.c Thu Aug 13 04:39:33 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pci_msi_machdep.c,v 1.7 2015/08/11 04:04:36 msaitoh Exp $ */
+/* $NetBSD: pci_msi_machdep.c,v 1.8 2015/08/13 04:39:33 msaitoh Exp $ */
/*
* Copyright (c) 2015 Internet Initiative Japan Inc.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pci_msi_machdep.c,v 1.7 2015/08/11 04:04:36 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_msi_machdep.c,v 1.8 2015/08/13 04:39:33 msaitoh Exp $");
#include "opt_intrdebug.h"
@@ -472,35 +472,6 @@
*/
/*
- * return number of the devices's MSI vectors
- * return 0 if the device does not support MSI
- */
-int
-pci_msi_count(const struct pci_attach_args *pa)
-{
- pci_chipset_tag_t pc;
- pcitag_t tag;
- pcireg_t reg;
- uint32_t mmc;
- int count, offset;
-
- pc = pa->pa_pc;
- tag = pa->pa_tag;
- if (pci_get_capability(pc, tag, PCI_CAP_MSI, &offset, NULL) == 0)
- return 0;
-
- reg = pci_conf_read(pc, tag, offset + PCI_MSI_CTL);
- mmc = PCI_MSI_CTL_MMC(reg);
- count = 1 << mmc;
- if (count > PCI_MSI_MAX_VECTORS) {
- aprint_error("detect an illegal device! The device use reserved MMC values.\n");
- return 0;
- }
-
- return count;
-}
-
-/*
* This function is used by device drivers like pci_intr_map().
*
* "ihps" is the array of vector numbers which MSI used instead of IRQ number.
@@ -518,7 +489,7 @@
KASSERT(*count > 0);
KASSERT(((*count - 1) & *count) == 0);
- hw_max = pci_msi_count(pa);
+ hw_max = pci_msi_count(pa->pa_pc, pa->pa_tag);
if (hw_max == 0)
return ENODEV;
@@ -548,7 +519,7 @@
KASSERT(count > 0);
KASSERT(((count - 1) & count) == 0);
- hw_max = pci_msi_count(pa);
+ hw_max = pci_msi_count(pa->pa_pc, pa->pa_tag);
if (hw_max == 0)
return ENODEV;
@@ -561,28 +532,6 @@
}
/*
- * return number of the devices's MSI-X vectors
- * return 0 if the device does not support MSI-X
- */
-int
-pci_msix_count(const struct pci_attach_args *pa)
-{
- pci_chipset_tag_t pc;
- pcitag_t tag;
- pcireg_t reg;
- int offset;
-
- pc = pa->pa_pc;
- tag = pa->pa_tag;
- if (pci_get_capability(pc, tag, PCI_CAP_MSIX, &offset, NULL) == 0)
- return 0;
-
- reg = pci_conf_read(pc, tag, offset + PCI_MSIX_CTL);
-
- return PCI_MSIX_CTL_TBLSIZE(reg);
-}
-
-/*
* This function is used by device drivers like pci_intr_map().
*
* "ihps" is the array of vector numbers which MSI-X used instead of IRQ number.
@@ -597,7 +546,7 @@
KASSERT(*count > 0);
- hw_max = pci_msix_count(pa);
+ hw_max = pci_msix_count(pa->pa_pc, pa->pa_tag);
if (hw_max == 0)
return ENODEV;
@@ -624,7 +573,7 @@
KASSERT(count > 0);
- hw_max = pci_msix_count(pa);
+ hw_max = pci_msix_count(pa->pa_pc, pa->pa_tag);
if (hw_max == 0)
return ENODEV;
@@ -658,7 +607,7 @@
KASSERT(count > 0);
- hw_max = pci_msix_count(pa);
+ hw_max = pci_msix_count(pa->pa_pc, pa->pa_tag);
if (hw_max == 0)
return ENODEV;
diff -r 0588a8a34b89 -r 614c1f4fde14 sys/dev/pci/pci.c
--- a/sys/dev/pci/pci.c Thu Aug 13 04:27:36 2015 +0000
+++ b/sys/dev/pci/pci.c Thu Aug 13 04:39:33 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pci.c,v 1.146 2015/04/27 07:03:58 knakahara Exp $ */
+/* $NetBSD: pci.c,v 1.147 2015/08/13 04:39:33 msaitoh Exp $ */
/*
* Copyright (c) 1995, 1996, 1997, 1998
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pci.c,v 1.146 2015/04/27 07:03:58 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci.c,v 1.147 2015/08/13 04:39:33 msaitoh Exp $");
#include "opt_pci.h"
@@ -568,6 +568,49 @@
return 0;
}
+/*
+ * return number of the devices's MSI vectors
+ * return 0 if the device does not support MSI
+ */
+int
+pci_msi_count(pci_chipset_tag_t pc, pcitag_t tag)
+{
+ pcireg_t reg;
+ uint32_t mmc;
+ int count, offset;
+
+ if (pci_get_capability(pc, tag, PCI_CAP_MSI, &offset, NULL) == 0)
+ return 0;
+
+ reg = pci_conf_read(pc, tag, offset + PCI_MSI_CTL);
+ mmc = PCI_MSI_CTL_MMC(reg);
+ count = 1 << mmc;
+ if (count > PCI_MSI_MAX_VECTORS) {
+ aprint_error("detect an illegal device! The device use reserved MMC values.\n");
+ return 0;
+ }
+
+ return count;
+}
+
+/*
+ * return number of the devices's MSI-X vectors
+ * return 0 if the device does not support MSI-X
+ */
+int
+pci_msix_count(pci_chipset_tag_t pc, pcitag_t tag)
+{
+ pcireg_t reg;
+ int offset;
+
+ if (pci_get_capability(pc, tag, PCI_CAP_MSIX, &offset, NULL) == 0)
+ return 0;
+
+ reg = pci_conf_read(pc, tag, offset + PCI_MSIX_CTL);
+
+ return PCI_MSIX_CTL_TBLSIZE(reg);
+}
+
int
pci_find_device(struct pci_attach_args *pa,
int (*match)(const struct pci_attach_args *))
diff -r 0588a8a34b89 -r 614c1f4fde14 sys/dev/pci/pcivar.h
--- a/sys/dev/pci/pcivar.h Thu Aug 13 04:27:36 2015 +0000
+++ b/sys/dev/pci/pcivar.h Thu Aug 13 04:39:33 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pcivar.h,v 1.102 2015/04/27 07:03:58 knakahara Exp $ */
+/* $NetBSD: pcivar.h,v 1.103 2015/08/13 04:39:33 msaitoh Exp $ */
/*
* Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.
@@ -280,6 +280,8 @@
int pci_get_capability(pci_chipset_tag_t, pcitag_t, int, int *, pcireg_t *);
int pci_get_ht_capability(pci_chipset_tag_t, pcitag_t, int, int *, pcireg_t *);
+int pci_msi_count(pci_chipset_tag_t, pcitag_t);
+int pci_msix_count(pci_chipset_tag_t, pcitag_t);
/*
Home |
Main Index |
Thread Index |
Old Index