[PATCH libpciaccess] linux: support 32 bit PCI domains

Stephen Hemminger stephen at networkplumber.org
Mon Jul 10 18:35:36 UTC 2017


The PCI domain maybe larger than 16 bits on Microsoft Azure and other
virtual environments. PCI busses reported by ACPI are limited to
16 bits, but in Azure the domain value for pass through devices is
intentionally larger than 16 bits to avoid clashing with local
devices. This is needed to support pass through of GPU devices.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=101744
Signed-off-by: Stephen Hemminger <sthemmin at microsoft.com>
---
 include/pciaccess.h |  2 +-
 src/linux_sysfs.c   | 16 +++-------------
 2 files changed, 4 insertions(+), 14 deletions(-)

diff --git a/include/pciaccess.h b/include/pciaccess.h
index 1d7aa4beabfd..93ed76f3cd25 100644
--- a/include/pciaccess.h
+++ b/include/pciaccess.h
@@ -321,7 +321,7 @@ struct pci_device {
      * the domain will always be zero.
      */
     /*@{*/
-    uint16_t    domain;
+    uint32_t    domain;
     uint8_t     bus;
     uint8_t     dev;
     uint8_t     func;
diff --git a/src/linux_sysfs.c b/src/linux_sysfs.c
index dd8ef3e489b1..1d6e34cb883e 100644
--- a/src/linux_sysfs.c
+++ b/src/linux_sysfs.c
@@ -118,28 +118,18 @@ pci_system_linux_sysfs_create( void )
 
 
 /**
- * Filter out the names "." and ".." from the scanned sysfs entries, and
- * domains requiring 32-bits.
+ * Filter out the names "." and ".." from the scanned sysfs entries.
  *
  * \param d  Directory entry being processed by \c scandir.
  *
  * \return
- * Zero if the entry name matches either "." or "..", or the domain requires
- * 32 bits, non-zero otherwise.
+ * Zero if the entry name matches either "." or ".."
  *
  * \sa scandir, populate_entries
  */
 static int
 scan_sys_pci_filter( const struct dirent * d )
 {
-    if (d->d_name[0] != '.') {
-        unsigned dom = 0;
-
-        sscanf(d->d_name, "%x:", &dom);
-        if (dom > USHRT_MAX)
-            return 0;
-    }
-
     return !((strcmp( d->d_name, "." ) == 0)
 	     || (strcmp( d->d_name, ".." ) == 0));
 }
@@ -218,7 +208,7 @@ populate_entries( struct pci_system * p )
 			(struct pci_device_private *) &p->devices[i];
 
 
-		sscanf(devices[i]->d_name, "%04x:%02x:%02x.%1u",
+		sscanf(devices[i]->d_name, "%x:%02x:%02x.%1u",
 		       & dom, & bus, & dev, & func);
 
 		device->base.domain = dom;
-- 
2.11.0



More information about the xorg-devel mailing list