]> mj.ucw.cz Git - pciutils.git/commitdiff
Domains: Legacy 16-bit domain numbers are maintained in generic code
authorMartin Mares <mj@ucw.cz>
Sat, 14 May 2016 09:57:01 +0000 (11:57 +0200)
committerMartin Mares <mj@ucw.cz>
Sat, 14 May 2016 09:57:01 +0000 (11:57 +0200)
Previously, backward compatibility was kept only with the sysfs
back-end.

Also, domains which do not fit in 16 bits are replaced by 0xffff.

lib/access.c
lib/pci.h
lib/sysfs.c

index 17b8bed1230bce94c074d51e77977bfccc1d575d..d9911292f2e05efef8ede4144a494c73be316f86 100644 (file)
@@ -40,6 +40,18 @@ pci_link_dev(struct pci_access *a, struct pci_dev *d)
   d->next = a->devices;
   a->devices = d;
 
+  /*
+   * Applications compiled with older versions of libpci do not expect
+   * 32-bit domain numbers. To keep them working, we keep a 16-bit
+   * version of the domain number at the previous location in struct
+   * pci_dev. This will keep backward compatibility on systems which
+   * don't require large domain numbers.
+   */
+  if (d->domain > 0xffff)
+    d->domain_16 = 0xffff;
+  else
+    d->domain_16 = d->domain;
+
   return 1;
 }
 
index 47610f371e6c70141510e7681707f7748593e055..e3175a3b59984265b24cacc4cbf1249eac48aaf2 100644 (file)
--- a/lib/pci.h
+++ b/lib/pci.h
@@ -119,7 +119,8 @@ struct pci_param *pci_walk_params(struct pci_access *acc, struct pci_param *prev
 
 struct pci_dev {
   struct pci_dev *next;                        /* Next device in the chain */
-  u16 domain_16;                       /* 16-bit PCI domain (host bridge) */
+  u16 domain_16;                       /* 16-bit version of the PCI domain for backward compatibility */
+                                       /* 0xffff if the real domain doesn't fit in 16 bits */
   u8 bus, dev, func;                   /* Bus inside domain, device and function */
 
   /* These fields are set by pci_fill_info() */
@@ -138,7 +139,7 @@ struct pci_dev {
   int numa_node;                       /* NUMA node */
   pciaddr_t flags[6];                  /* PCI_IORESOURCE_* flags for regions */
   pciaddr_t rom_flags;                 /* PCI_IORESOURCE_* flags for expansion ROM */
-  int domain;                          /* 32-bit PCI domain (host bridge) */
+  int domain;                          /* PCI domain (host bridge) */
 
   /* Fields used internally: */
   struct pci_access *access;
index 877310c584352c6b8bb3f355054bea056cf09333..577982480fbc87f3c2d51f76307e7fe8123c58e2 100644 (file)
@@ -199,16 +199,8 @@ static void sysfs_scan(struct pci_access *a)
 
       /* Ensure kernel provided domain that fits in a signed integer */
       if (dom > 0x7fffffff)
-       a->error("sysfs_scan: invalid domain:%x", dom);
+       a->error("sysfs_scan: Invalid domain %x", dom);
 
-      /*
-       * The domain value is truncated to 16 bits and stored in the pci_dev
-       * structure's legacy 16-bit domain offset for compatibility with
-       * applications compiled with libpci pre-32 bit domains. Such
-       * applications may not work as expected if they are on a machine
-       * utilizing PCI domain numbers requiring more than 16 bits.
-       */
-      d->domain_16 = dom;
       d->domain = dom;
       d->bus = bus;
       d->dev = dev;