]> xenbits.xensource.com Git - people/andrewcoop/hwloc.git/commitdiff
Remove the need to conflicts between PCI backen...
authorBrice Goglin <brice.goglin@inria.fr>
Thu, 20 Jun 2013 09:08:15 +0000 (09:08 +0000)
committerBrice Goglin <brice.goglin@inria.fr>
Thu, 20 Jun 2013 09:08:15 +0000 (09:08 +0000)
Remove the need to conflicts between PCI backends

Force a level reconnect before running their discover callback,
and check whether there are already some PCI devices.

On !Linux, the reconnect won't happen by default because
another one is done earlier nothing was added in the middle
(PCI comes right after CPU/GLOBAL by default).

On Linux, we have an additional reconnect (can't be merged
with the final one because we remove ignored things in the middle).

By the way, add some debug messages about these forced reconnects.

This commit was SVN r5688.

src/topology-linux.c
src/topology-pci.c
src/topology.c

index fe3364531334b22d738f18684150b8d6d208c150..1d72621ae4c32b42cf2db64bef4c024dcdaf006c 100644 (file)
@@ -4287,6 +4287,11 @@ hwloc_look_linuxfs_pci(struct hwloc_backend *backend)
   if (!(hwloc_topology_get_flags(topology) & (HWLOC_TOPOLOGY_FLAG_IO_DEVICES|HWLOC_TOPOLOGY_FLAG_WHOLE_IO)))
     return 0;
 
+  if (hwloc_get_next_pcidev(topology, NULL)) {
+    hwloc_debug("%s", "PCI objects already added, ignoring linuxpci backend.\n");
+    return 0;
+  }
+
   /* hackily find the linux backend to steal its fsroot */
   tmpbackend = topology->backends;
   while (tmpbackend) {
@@ -4533,6 +4538,7 @@ hwloc_linuxpci_component_instantiate(struct hwloc_disc_component *component,
   backend = hwloc_backend_alloc(component);
   if (!backend)
     return NULL;
+  backend->flags = HWLOC_BACKEND_FLAG_NEED_LEVELS;
   backend->discover = hwloc_look_linuxfs_pci;
   return backend;
 }
@@ -4540,7 +4546,7 @@ hwloc_linuxpci_component_instantiate(struct hwloc_disc_component *component,
 static struct hwloc_disc_component hwloc_linuxpci_disc_component = {
   HWLOC_DISC_COMPONENT_TYPE_PCI,
   "linuxpci",
-  HWLOC_DISC_COMPONENT_TYPE_PCI | HWLOC_DISC_COMPONENT_TYPE_GLOBAL,
+  HWLOC_DISC_COMPONENT_TYPE_GLOBAL,
   hwloc_linuxpci_component_instantiate,
   19, /* after pci */
   NULL
index a7f60d08ca80c72db6f9a491a7a3777ecae03c7d..b74deefca71b91a6e3f41ffe66122a0dbcee8c4e 100644 (file)
@@ -385,6 +385,12 @@ hwloc_look_pci(struct hwloc_backend *backend)
   if (!(hwloc_topology_get_flags(topology) & (HWLOC_TOPOLOGY_FLAG_IO_DEVICES|HWLOC_TOPOLOGY_FLAG_WHOLE_IO)))
     return 0;
 
+  if (hwloc_get_next_pcidev(topology, NULL)) {
+    hwloc_debug("%s", "PCI objects already added, ignoring pci backend.\n");
+    return 0;
+  }
+  printf("doing pci discovery\n");
+
   if (!hwloc_topology_is_thissystem(topology)) {
     hwloc_debug("%s", "\nno PCI detection (not thissystem)\n");
     return 0;
@@ -738,6 +744,7 @@ hwloc_pci_component_instantiate(struct hwloc_disc_component *component,
   backend = hwloc_backend_alloc(component);
   if (!backend)
     return NULL;
+  backend->flags = HWLOC_BACKEND_FLAG_NEED_LEVELS;
   backend->discover = hwloc_look_pci;
   backend->disable = hwloc_pci_backend_disable;
   return backend;
@@ -746,7 +753,7 @@ hwloc_pci_component_instantiate(struct hwloc_disc_component *component,
 static struct hwloc_disc_component hwloc_pci_disc_component = {
   HWLOC_DISC_COMPONENT_TYPE_PCI,
   "pci",
-  HWLOC_DISC_COMPONENT_TYPE_PCI | HWLOC_DISC_COMPONENT_TYPE_GLOBAL,
+  HWLOC_DISC_COMPONENT_TYPE_GLOBAL,
   hwloc_pci_component_instantiate,
   20,
   NULL
index a2e241b78f5db62076acb4564ebbfedabd629dd6..e48bb8110fe6906c37f2980c2f85aa1b7822815c 100644 (file)
@@ -2251,6 +2251,7 @@ hwloc_discover(struct hwloc_topology *topology)
       goto next_cpubackend;
 
     if (need_reconnect && (backend->flags & HWLOC_BACKEND_FLAG_NEED_LEVELS)) {
+      hwloc_debug("Backend %s forcing a reconnect of levels\n", backend->component->name);
       hwloc_connect_children(topology->levels[0][0]);
       if (hwloc_connect_levels(topology) < 0)
        return -1;
@@ -2342,6 +2343,7 @@ next_cpubackend:
       goto next_noncpubackend;
 
     if (need_reconnect && (backend->flags & HWLOC_BACKEND_FLAG_NEED_LEVELS)) {
+      hwloc_debug("Backend %s forcing a reconnect of levels\n", backend->component->name);
       hwloc_connect_children(topology->levels[0][0]);
       if (hwloc_connect_levels(topology) < 0)
        return -1;