[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v3 01/18] pci: Use pci_sbdf_t in pci_device_detect()



Use a single pci_sbdf_t instead of each of its part as individual parameters.

Signed-off-by: Teddy Astie <teddy.astie@xxxxxxxxxx>
---
v3: Don't adjust adjacent code.
---
 xen/drivers/char/ehci-dbgp.c       | 4 ++--
 xen/drivers/passthrough/pci.c      | 6 +++---
 xen/drivers/passthrough/vtd/dmar.c | 9 +++++----
 xen/include/xen/pci.h              | 2 +-
 4 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/xen/drivers/char/ehci-dbgp.c b/xen/drivers/char/ehci-dbgp.c
index a5c79f56fc..2a58213cab 100644
--- a/xen/drivers/char/ehci-dbgp.c
+++ b/xen/drivers/char/ehci-dbgp.c
@@ -706,7 +706,7 @@ static unsigned int __init find_dbgp(struct ehci_dbgp *dbgp,
             {
                 unsigned int cap;
 
-                if ( !pci_device_detect(0, bus, slot, func) )
+                if ( !pci_device_detect(PCI_SBDF(0, bus, slot, func)) )
                 {
                     if ( !func )
                         break;
@@ -1520,7 +1520,7 @@ void __init ehci_dbgp_init(void)
         dbgp->slot = slot;
         dbgp->func = func;
 
-        if ( !pci_device_detect(0, bus, slot, func) )
+        if ( !pci_device_detect(PCI_SBDF(0, bus, slot, func)) )
             return;
 
         dbgp->cap = __find_dbgp(bus, slot, func);
diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c
index d37ceb7b6c..0adf573150 100644
--- a/xen/drivers/passthrough/pci.c
+++ b/xen/drivers/passthrough/pci.c
@@ -1166,11 +1166,11 @@ out:
     return ret;
 }
 
-bool __init pci_device_detect(u16 seg, u8 bus, u8 dev, u8 func)
+bool __init pci_device_detect(pci_sbdf_t sbdf)
 {
     u32 vendor;
 
-    vendor = pci_conf_read32(PCI_SBDF(seg, bus, dev, func), PCI_VENDOR_ID);
+    vendor = pci_conf_read32(sbdf, PCI_VENDOR_ID);
     /* some broken boards return 0 or ~0 if a slot is empty: */
     if ( (vendor == 0xffffffffU) || (vendor == 0x00000000U) ||
          (vendor == 0x0000ffffU) || (vendor == 0xffff0000U) )
@@ -1221,7 +1221,7 @@ static int __init cf_check _scan_pci_devices(struct 
pci_seg *pseg, void *arg)
         {
             for ( func = 0; func < 8; func++ )
             {
-                if ( !pci_device_detect(pseg->nr, bus, dev, func) )
+                if ( !pci_device_detect(PCI_SBDF(pseg->nr, bus, dev, func)) )
                 {
                     if ( !func )
                         break;
diff --git a/xen/drivers/passthrough/vtd/dmar.c 
b/xen/drivers/passthrough/vtd/dmar.c
index 2a756831a6..8db9591a36 100644
--- a/xen/drivers/passthrough/vtd/dmar.c
+++ b/xen/drivers/passthrough/vtd/dmar.c
@@ -389,7 +389,8 @@ static int __init acpi_parse_dev_scope(
                 printk(VTDPREFIX " endpoint: %pp\n",
                        &PCI_SBDF(seg, bus, path->dev, path->fn));
 
-            if ( drhd && pci_device_detect(seg, bus, path->dev, path->fn) )
+            if ( drhd && pci_device_detect(PCI_SBDF(seg, bus, path->dev,
+                                                    path->fn)) )
             {
                 if ( pci_conf_read8(PCI_SBDF(seg, bus, path->dev, path->fn),
                                     PCI_CLASS_DEVICE + 1) != 0x03
@@ -537,7 +538,7 @@ acpi_parse_one_drhd(struct acpi_dmar_header *header)
             d = PCI_SLOT(dmaru->scope.devices[i]);
             f = PCI_FUNC(dmaru->scope.devices[i]);
 
-            if ( !pci_device_detect(drhd->segment, b, d, f) )
+            if ( !pci_device_detect(PCI_SBDF(drhd->segment, b, d, f)) )
                 printk(XENLOG_WARNING VTDPREFIX
                        " Non-existent device (%pp) in this DRHD's scope!\n",
                        &PCI_SBDF(drhd->segment, b, d, f));
@@ -573,7 +574,7 @@ static int __init register_one_rmrr(struct acpi_rmrr_unit 
*rmrru)
         u8 d = PCI_SLOT(rmrru->scope.devices[i]);
         u8 f = PCI_FUNC(rmrru->scope.devices[i]);
 
-        if ( pci_device_detect(rmrru->segment, b, d, f) == 0 )
+        if ( pci_device_detect(PCI_SBDF(rmrru->segment, b, d, f)) == 0 )
         {
             dprintk(XENLOG_WARNING VTDPREFIX,
                     " Non-existent device (%pp) is reported"
@@ -767,7 +768,7 @@ static int __init register_one_satc(struct acpi_satc_unit 
*satcu)
         uint8_t d = PCI_SLOT(satcu->scope.devices[i]);
         uint8_t f = PCI_FUNC(satcu->scope.devices[i]);
 
-        if ( !pci_device_detect(satcu->segment, b, d, f) )
+        if ( !pci_device_detect(PCI_SBDF(satcu->segment, b, d, f)) )
         {
             dprintk(XENLOG_WARNING VTDPREFIX,
                     " Non-existent device (%pp) is reported in SATC scope!\n",
diff --git a/xen/include/xen/pci.h b/xen/include/xen/pci.h
index afb6bbf50d..ade882caee 100644
--- a/xen/include/xen/pci.h
+++ b/xen/include/xen/pci.h
@@ -218,7 +218,7 @@ static always_inline bool pcidevs_trylock(void)
 #endif
 
 bool pci_known_segment(u16 seg);
-bool pci_device_detect(u16 seg, u8 bus, u8 dev, u8 func);
+bool pci_device_detect(pci_sbdf_t sbdf);
 int scan_pci_devices(void);
 enum pdev_type pdev_type(u16 seg, u8 bus, u8 devfn);
 int find_upstream_bridge(u16 seg, u8 *bus, u8 *devfn, u8 *secbus);
-- 
2.54.0



--
Teddy Astie | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.