[PATCH libpciaccess] Support for 32-bit domains

Keith Busch keith.busch at intel.com
Thu Aug 11 19:59:45 UTC 2016


On Thu, Aug 11, 2016 at 12:03:30PM -0700, Eric Anholt wrote:
> Given that libpciaccess allocates the struct, and the struct isn't
> embedded in any other public structs, I think you could just tack a
> "uint16_t domain_high;" at the end of the struct and fill that with the
> high bits.

Hmm, then we have to change every usage of domain to combine the two,
and every usage thereafter must do the same.

How about tacking 'uint32_t domain' to the end for the full domain,
rename the existing 'uint16_t domain' to 'domain_low', and then just
copy the lower bits from the full domain into there? That should satisfy
legacy usage, and everywhere else will automatically use the full value.

Does something like this look more reasonable?

---
diff --git a/include/pciaccess.h b/include/pciaccess.h
index 1d7aa4b..e095dfb 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;
+    uint16_t    domain_low;
     uint8_t     bus;
     uint8_t     dev;
     uint8_t     func;
@@ -385,6 +385,12 @@ struct pci_device {
       * Used by the VGA arbiter. Type of resource decoded by the device
       * and
       * the file descriptor (/dev/vga_arbiter). */
     int vgaarb_rsrc;
+
+    /**
+     * The 32-bit pci domain. The lower 16 bits are copied into the
+     * domain_low field for ABI compatibility.
+     */
+    uint32_t    domain;
 };


diff --git a/src/linux_sysfs.c b/src/linux_sysfs.c
index 6367b11..c640f41 100644
--- a/src/linux_sysfs.c
+++ b/src/linux_sysfs.c
@@ -159,10 +159,11 @@ 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;
+               device->base.domain_low = dom;
                device->base.bus = bus;
                device->base.dev = dev;
                device->base.func = func;
--


More information about the xorg-devel mailing list