Skip to content

Commit

Permalink
pci+linuxio: cleanup the avoidance of duplicate PCI discovery
Browse files Browse the repository at this point in the history
Signed-off-by: Brice Goglin <Brice.Goglin@inria.fr>
  • Loading branch information
bgoglin committed Aug 1, 2018
1 parent e49bfb5 commit f5c7fca
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
12 changes: 7 additions & 5 deletions hwloc/topology-linux.c
Expand Up @@ -5890,7 +5890,7 @@ hwloc_look_linuxfs_io(struct hwloc_backend *backend)
enum hwloc_type_filter_e pfilter, bfilter, ofilter, mfilter;
int root_fd = -1;
#ifdef HWLOC_HAVE_LINUXPCI
struct hwloc_obj *tmp;
struct hwloc_obj *child;
int needpcidiscovery;
#endif

Expand Down Expand Up @@ -5928,10 +5928,12 @@ hwloc_look_linuxfs_io(struct hwloc_backend *backend)
* (they are attached to root until later in the core discovery)
*/
needpcidiscovery = 1;
for_each_io_child(tmp, hwloc_get_root_obj(topology)) {
if (tmp->type == HWLOC_OBJ_PCI_DEVICE
|| (tmp->type == HWLOC_OBJ_BRIDGE && tmp->attr->bridge.downstream_type == HWLOC_OBJ_BRIDGE_PCI)) {
hwloc_debug("%s", "PCI objects already added, ignoring linuxio PCI discovery.\n");
for_each_io_child(child, hwloc_get_root_obj(topology)) {
if (child->type == HWLOC_OBJ_PCI_DEVICE
|| (child->type == HWLOC_OBJ_BRIDGE &&
(child->attr->bridge.upstream_type == HWLOC_OBJ_BRIDGE_PCI
|| child->attr->bridge.downstream_type == HWLOC_OBJ_BRIDGE_PCI))) {
hwloc_debug("%s", "Topology already contains PCI objects, skipping linuxio PCI discovery.\n");
needpcidiscovery = 0;
break;
}
Expand Down
14 changes: 7 additions & 7 deletions hwloc/topology-pci.c
Expand Up @@ -92,7 +92,7 @@ hwloc_look_pci(struct hwloc_backend *backend)
{
struct hwloc_topology *topology = backend->topology;
enum hwloc_type_filter_e pfilter, bfilter;
struct hwloc_obj *tree = NULL, *tmp;
struct hwloc_obj *tree = NULL, *child;
int ret;
struct pci_device_iterator *iter;
struct pci_device *pcidev;
Expand All @@ -106,14 +106,14 @@ hwloc_look_pci(struct hwloc_backend *backend)
/* don't do anything if another backend attached PCI already
* (they are attached to root until later in the core discovery)
*/
tmp = hwloc_get_root_obj(topology)->io_first_child;
while (tmp) {
if (tmp->type == HWLOC_OBJ_PCI_DEVICE
|| (tmp->type == HWLOC_OBJ_BRIDGE && tmp->attr->bridge.downstream_type == HWLOC_OBJ_BRIDGE_PCI)) {
hwloc_debug("%s", "PCI objects already added, ignoring linuxpci backend.\n");
for_each_io_child(child, hwloc_get_root_obj(topology)) {
if (child->type == HWLOC_OBJ_PCI_DEVICE
|| (child->type == HWLOC_OBJ_BRIDGE &&
(child->attr->bridge.upstream_type == HWLOC_OBJ_BRIDGE_PCI
|| child->attr->bridge.downstream_type == HWLOC_OBJ_BRIDGE_PCI))) {
hwloc_debug("%s", "Topology already contains PCI objects, skipping PCI backend.\n");
return 0;
}
tmp = tmp->next_sibling;
}

hwloc_debug("%s", "\nScanning PCI buses...\n");
Expand Down

0 comments on commit f5c7fca

Please sign in to comment.