diff mbox

pci: Fix INTx routing notifier recursion

Message ID 20130307182853.22096.81037.stgit@bling.home
State New
Headers show

Commit Message

Alex Williamson March 7, 2013, 6:29 p.m. UTC
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.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
 hw/pci/pci.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Michael S. Tsirkin March 7, 2013, 6:47 p.m. UTC | #1
On Thu, Mar 07, 2013 at 11:29:19AM -0700, Alex Williamson wrote:
> 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.
> 
> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>

Applied, thanks.

> ---
>  hw/pci/pci.c |    7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/pci/pci.c b/hw/pci/pci.c
> index 8772707..f24c389 100644
> --- a/hw/pci/pci.c
> +++ b/hw/pci/pci.c
> @@ -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);
>      }
>  }
>
diff mbox

Patch

diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 8772707..f24c389 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -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);
     }
 }