libpciaccess - New module for the Hurd && x86 improvements

Submitted by Damien Zammit on Nov. 25, 2018, 1:50 a.m.

Details

Message ID a5fdc3fb-e522-2a83-89c4-0fd568a0160e@zamaudio.com
State New
Headers show
Series "libpciaccess - New module for the Hurd && x86 improvements" ( rev: 1 ) in X.org

Not browsing as part of any series.

Commit Message

Damien Zammit Nov. 25, 2018, 1:50 a.m.
Hi libpciaccess devs,

Please find attached a new module for review for GNU/Hurd access method.
This has been a work in progress for quite some time.
The corresponding server code has already been merged upstream in hurd
to use this method as an arbiter for other processes to use the hurdish
method. (it starts by using the x86 access method).

I also provide two patches to improve the x86 access method.

In summary, these three patches provide:

0001) New access method for Hurd

0002) Better probe cmds for non-VGA PCI roms and regions on x86 and add
a recursive scan-bus routine that uses the new probe cmds
(it also splits the conf1 and conf2 methods into separate methods)

0003) Switch over to the new scan-bus routine in x86 method

I wish to thank Joan Lledó for doing most of this work, I am following
up to get this merged upstream into pciaccess.

Cheers,
Damien Zammit

Patch hide | download patch | download mbox

From 7263ba69531faf05bcaacb98c995159bf0b83f91 Mon Sep 17 00:00:00 2001
From: Damien Zammit <damien@zamaudio.com>
Date: Sat, 10 Nov 2018 06:48:42 -0500
Subject: [PATCH libpciaccess 3/3] Use recursive scan bus

Switch over to the new recursive scan bus routine for x86
---
 src/x86_pci.c | 82 +++++++--------------------------------------------
 1 file changed, 11 insertions(+), 71 deletions(-)

diff --git a/src/x86_pci.c b/src/x86_pci.c
index cdfc2ef..786ee3c 100644
--- a/src/x86_pci.c
+++ b/src/x86_pci.c
@@ -1131,11 +1131,6 @@  static int pci_probe(void)
 _pci_hidden int
 pci_system_x86_create(void)
 {
-    uint8_t nfuncs = 0;
-    uint8_t bus, dev, func;
-    uint32_t reg = 0, ndevs;
-    struct pci_device tmpdev = { 0 };
-    struct pci_device_private *device;
     error_t err;
     int confx;
 
@@ -1143,23 +1138,6 @@  pci_system_x86_create(void)
     if (err)
         return err;
 
-    ndevs = 0;
-    for (bus = 0; bus < 256; bus++) {
-       tmpdev.bus = bus;
-       for (dev = 0; dev < 32; dev++) {
-           tmpdev.dev = dev;
-           pci_nfuncs(&tmpdev, &nfuncs);
-           for (func = 0; func < nfuncs; func++) {
-               if (pci_device_cfg_read_u32(&tmpdev, &reg, PCI_VENDOR_ID))
-                   continue;
-               if (PCI_VENDOR(reg) == PCI_VENDOR_INVALID ||
-                   PCI_VENDOR(reg) == 0)
-                   continue;
-               ndevs++;
-           }
-       }
-    }
-
     pci_sys = calloc (1, sizeof (struct pci_system));
     if (pci_sys == NULL)
     {
@@ -1167,17 +1145,9 @@  pci_system_x86_create(void)
         return ENOMEM;
     }
 
-    pci_sys->num_devices = ndevs;
-    pci_sys->devices = calloc(ndevs, sizeof(struct pci_device_private));
-    if (pci_sys->devices == NULL) {
-        x86_disable_io();
-        free(pci_sys);
-        pci_sys = NULL;
-        return ENOMEM;
-    }
-
     confx = pci_probe ();
-    if (!confx) {
+    if (!confx)
+    {
         x86_disable_io ();
         free (pci_sys);
         pci_sys = NULL;
@@ -1188,45 +1158,15 @@  pci_system_x86_create(void)
     else
         pci_sys->methods = &x86_pci_method_conf2;
 
-    device = pci_sys->devices;
-    for (bus = 0; bus < 256; bus++) {
-       tmpdev.bus = bus;
-       for (dev = 0; dev < 32; dev++) {
-           tmpdev.dev = dev;
-           err = pci_nfuncs(&tmpdev, &nfuncs);
-           if (err) {
-               x86_disable_io ();
-               free (pci_sys);
-               pci_sys = NULL;
-               return ENODEV;
-           }
-           for (func = 0; func < nfuncs; func++) {
-               tmpdev.func = func;
-               if (pci_device_cfg_read_u32(&tmpdev, &reg, PCI_VENDOR_ID))
-                   continue;
-               if (PCI_VENDOR(reg) == PCI_VENDOR_INVALID ||
-                   PCI_VENDOR(reg) == 0)
-                   continue;
-               device->base.domain = device->base.domain_16 = 0;
-               device->base.bus = bus;
-               device->base.dev = dev;
-               device->base.func = func;
-               device->base.vendor_id = PCI_VENDOR(reg);
-               device->base.device_id = PCI_DEVICE(reg);
-
-               if (pci_device_cfg_read_u32(&tmpdev, &reg, PCI_CLASS))
-                   continue;
-               device->base.device_class = (reg >> 8) & 0xFF;
-               device->base.revision = reg & 0xFF;
-
-               if (pci_device_cfg_read_u32(&tmpdev, &reg, PCI_SUB_VENDOR_ID))
-                   continue;
-               device->base.subvendor_id = PCI_VENDOR(reg);
-               device->base.subdevice_id = PCI_DEVICE(reg);
-
-               device++;
-           }
-       }
+    /* Recursive scan */
+    pci_sys->num_devices = 0;
+    err = pci_system_x86_scan_bus (0);
+    if (err)
+    {
+        x86_disable_io ();
+        free (pci_sys);
+        pci_sys = NULL;
+        return err;
     }
 
     return 0;
-- 
2.17.1


Comments

Dear ajax and/or others,

On 25/11/18 12:50, Damien Zammit wrote:
> Please find attached a new module for review for GNU/Hurd access method

Bumping this thread in case it was missed.
(I forgot to put [PATCH] in the subject line).

Please see previous post in this thread for 3x patches and the details.

Thanks,
Damien