tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
argument of pci_msi[x]_count()
Hi, all.
Currently, pci_msi_count() and pci_msix_count() take one pci_attach_args argument.
These functions may be used in other than attach function. So, it might be
better to use pci_chipset_tag_t and pcitag_t.
Is the following diff better than current specification?
Index: share/man/man9/pci_msi.9
===================================================================
RCS file: /cvsroot/src/share/man/man9/pci_msi.9,v
retrieving revision 1.6
diff -u -p -r1.6 pci_msi.9
--- share/man/man9/pci_msi.9 24 Jul 2015 07:40:58 -0000 1.6
+++ share/man/man9/pci_msi.9 6 Aug 2015 11:24:57 -0000
@@ -44,7 +44,8 @@
.Nd PCI MSI{,-X} manipulation functions
.Sh SYNOPSIS
.Ft int
-.Fn pci_msi_count "struct pci_attach_args *pa"
+.Fn pci_msi_count "pci_chipset_tag_t pc" \
+"pcitag_t tag"
.Ft int
.Fn pci_msi_alloc "struct pci_attach_args *pa" \
"pci_intr_handle_t **ihps" "int *count"
@@ -52,7 +53,8 @@
.Fn pci_msi_alloc_exect "struct pci_attach_args *pa" \
"pci_intr_handle_t **ihps" "int count"
.Ft int
-.Fn pci_msix_count "struct pci_attach_args *pa"
+.Fn pci_msix_count "pci_chipset_tag_t pc" \
+"pcitag_t tag"
.Ft int
.Fn pci_msix_alloc "struct pci_attach_args *pa" \
"pci_intr_handle_t **ihps" "int *count"
Index: sys/arch/x86/include/pci_machdep_common.h
===================================================================
RCS file: /cvsroot/src/sys/arch/x86/include/pci_machdep_common.h,v
retrieving revision 1.19
diff -u -p -r1.19 pci_machdep_common.h
--- sys/arch/x86/include/pci_machdep_common.h 21 Jul 2015 03:10:42 -0000 1.19
+++ sys/arch/x86/include/pci_machdep_common.h 6 Aug 2015 11:24:57 -0000
@@ -145,14 +145,14 @@ int pci_intr_alloc(const struct pci_att
pci_intr_handle_t **, int *, pci_intr_type_t);
/* experimental MSI support */
-int pci_msi_count(const struct pci_attach_args *);
+int pci_msi_count(pci_chipset_tag_t, pcitag_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);
/* experimental MSI-X support */
-int pci_msix_count(const struct pci_attach_args *);
+int pci_msix_count(pci_chipset_tag_t, pcitag_t);
int pci_msix_alloc(const struct pci_attach_args *,
pci_intr_handle_t **, int *);
int pci_msix_alloc_exact(const struct pci_attach_args *,
Index: sys/arch/x86/pci/msipic.c
===================================================================
RCS file: /cvsroot/src/sys/arch/x86/pci/msipic.c,v
retrieving revision 1.4
diff -u -p -r1.4 msipic.c
--- sys/arch/x86/pci/msipic.c 8 May 2015 04:27:48 -0000 1.4
+++ sys/arch/x86/pci/msipic.c 6 Aug 2015 11:24:58 -0000
@@ -620,7 +620,7 @@ msipic_construct_msix_pic(const struct p
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;
Index: sys/arch/x86/pci/pci_intr_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/x86/pci/pci_intr_machdep.c,v
retrieving revision 1.35
diff -u -p -r1.35 pci_intr_machdep.c
--- sys/arch/x86/pci/pci_intr_machdep.c 24 Jul 2015 06:49:58 -0000 1.35
+++ sys/arch/x86/pci/pci_intr_machdep.c 6 Aug 2015 11:24:58 -0000
@@ -490,7 +490,7 @@ pci_intr_alloc(const struct pci_attach_a
/* 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 @@ pci_intr_alloc(const struct pci_attach_a
/* 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) {
Index: sys/arch/x86/pci/pci_msi_machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/x86/pci/pci_msi_machdep.c,v
retrieving revision 1.6
diff -u -p -r1.6 pci_msi_machdep.c
--- sys/arch/x86/pci/pci_msi_machdep.c 22 Jun 2015 03:57:01 -0000 1.6
+++ sys/arch/x86/pci/pci_msi_machdep.c 6 Aug 2015 11:24:58 -0000
@@ -474,16 +474,12 @@ x86_pci_msix_disestablish(pci_chipset_ta
* return 0 if the device does not support MSI
*/
int
-pci_msi_count(const struct pci_attach_args *pa)
+pci_msi_count(pci_chipset_tag_t pc, pcitag_t tag)
{
- 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;
@@ -516,7 +512,7 @@ pci_msi_alloc(const struct pci_attach_ar
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;
@@ -546,7 +542,7 @@ pci_msi_alloc_exact(const struct pci_att
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;
@@ -563,15 +559,11 @@ pci_msi_alloc_exact(const struct pci_att
* return 0 if the device does not support MSI-X
*/
int
-pci_msix_count(const struct pci_attach_args *pa)
+pci_msix_count(pci_chipset_tag_t pc, pcitag_t tag)
{
- 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;
@@ -595,7 +587,7 @@ pci_msix_alloc(const struct pci_attach_a
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;
@@ -622,7 +614,7 @@ pci_msix_alloc_exact(const struct pci_at
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;
@@ -656,7 +648,7 @@ pci_msix_alloc_map(const struct pci_atta
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;
--
-----------------------------------------------
SAITOH Masanobu (msaitoh%execsw.org@localhost
msaitoh%netbsd.org@localhost)
Home |
Main Index |
Thread Index |
Old Index