Skip to contentSkip to conversation

pci: Fix INTx routing notifier recursion

PATCH Applied Alex Williamson 2 participants 2 messages Mar 7, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pci: Fix INTx routing notifier recursion

For some reason we recurse to fire the INTx routing notifier for each child of a bus, for each possible device of a bus. That means that if we add a root port, the notifier gets called for that bridge 256 times. If we add an upstream switch behind that root port, 256^2. But of course we need a downstream switch, 256^3. This starts to be noticeable. Stop the insanity.

---
 hw/pci/pci.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
hw/pci/pci.c +4 -3
index 8772707..f24c389 100644
@@ -1215,9 +1215,10 @@ void pci_bus_fire_intx_routing_notifier(PCIBus *bus)
         if (dev && dev->intx_routing_notifier) {
             dev->intx_routing_notifier(dev);
         }
-        QLIST_FOREACH(sec, &bus->child, sibling) {
-            pci_bus_fire_intx_routing_notifier(sec);
-        }
+    }
+
+    QLIST_FOREACH(sec, &bus->child, sibling) {
+        pci_bus_fire_intx_routing_notifier(sec);
     }
 }
 
#1 lore raw
Quoted 8 lines · Alex Williamson

For some reason we recurse to fire the INTx routing notifier for each child of a bus, for each possible device of a bus. That means that if we add a root port, the notifier gets called for that bridge 256 times. If we add an upstream switch behind that root port, 256^2. But of course we need a downstream switch, 256^3. This starts to be noticeable. Stop the insanity.

Applied, thanks.

Quoted 22 lines
---
 hw/pci/pci.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
hw/pci/pci.c +4 -3
index 8772707..f24c389 100644
@@ -1215,9 +1215,10 @@ void pci_bus_fire_intx_routing_notifier(PCIBus *bus)
         if (dev && dev->intx_routing_notifier) {
             dev->intx_routing_notifier(dev);
         }
-        QLIST_FOREACH(sec, &bus->child, sibling) {
-            pci_bus_fire_intx_routing_notifier(sec);
-        }
+    }
+
+    QLIST_FOREACH(sec, &bus->child, sibling) {
+        pci_bus_fire_intx_routing_notifier(sec);
     }
 }