diff mbox series

[2/2] hw/pci: Trace IRQ routing on PCI topology

Message ID 20230211152239.88106-3-philmd@linaro.org
State New
Headers show
Series hw/pci: Trace IRQ routing on PCI topology and fix a typo | expand

Commit Message

Philippe Mathieu-Daudé Feb. 11, 2023, 3:22 p.m. UTC
Trace how IRQ are rooted from EP to RC.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/pci/pci.c        | 8 ++++++++
 hw/pci/trace-events | 1 +
 2 files changed, 9 insertions(+)

Comments

Philippe Mathieu-Daudé Feb. 28, 2023, 1:37 p.m. UTC | #1
ping

On 11/2/23 16:22, Philippe Mathieu-Daudé wrote:
> Trace how IRQ are rooted from EP to RC.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   hw/pci/pci.c        | 8 ++++++++
>   hw/pci/trace-events | 1 +
>   2 files changed, 9 insertions(+)
> 
> diff --git a/hw/pci/pci.c b/hw/pci/pci.c
> index 805e4b0c68..2e785e3aef 100644
> --- a/hw/pci/pci.c
> +++ b/hw/pci/pci.c
> @@ -279,9 +279,13 @@ static void pci_change_irq_level(PCIDevice *pci_dev, int irq_num, int change)
>   {
>       PCIBus *bus;
>       for (;;) {
> +        int dev_irq = irq_num;
>           bus = pci_get_bus(pci_dev);
>           assert(bus->map_irq);
>           irq_num = bus->map_irq(pci_dev, irq_num);
> +        trace_pci_route_irq(dev_irq, DEVICE(pci_dev)->canonical_path, irq_num,
> +                            pci_bus_is_root(bus) ? "root-complex"
> +                                    : DEVICE(bus->parent_dev)->canonical_path);
>           if (bus->set_irq)
>               break;
>           pci_dev = bus->parent_dev;
> @@ -1600,8 +1604,12 @@ PCIINTxRoute pci_device_route_intx_to_irq(PCIDevice *dev, int pin)
>       PCIBus *bus;
>   
>       do {
> +        int dev_irq = pin;
>           bus = pci_get_bus(dev);
>           pin = bus->map_irq(dev, pin);
> +        trace_pci_route_irq(dev_irq, DEVICE(dev)->canonical_path, pin,
> +                            pci_bus_is_root(bus) ? "root-complex"
> +                                    : DEVICE(bus->parent_dev)->canonical_path);
>           dev = bus->parent_dev;
>       } while (dev);
>   
> diff --git a/hw/pci/trace-events b/hw/pci/trace-events
> index aaf46bc92d..42430869ce 100644
> --- a/hw/pci/trace-events
> +++ b/hw/pci/trace-events
> @@ -3,6 +3,7 @@
>   # pci.c
>   pci_update_mappings_del(const char *dev, uint32_t bus, uint32_t slot, uint32_t func, int bar, uint64_t addr, uint64_t size) "%s %02x:%02x.%x %d,0x%"PRIx64"+0x%"PRIx64
>   pci_update_mappings_add(const char *dev, uint32_t bus, uint32_t slot, uint32_t func, int bar, uint64_t addr, uint64_t size) "%s %02x:%02x.%x %d,0x%"PRIx64"+0x%"PRIx64
> +pci_route_irq(int dev_irq, const char *dev_path, int parent_irq, const char *parent_path) "IRQ %d @%s -> IRQ %d @%s"
>   
>   # pci_host.c
>   pci_cfg_read(const char *dev, uint32_t bus, uint32_t slot, uint32_t func, unsigned offs, unsigned val) "%s %02x:%02x.%x @0x%x -> 0x%x"
diff mbox series

Patch

diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 805e4b0c68..2e785e3aef 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -279,9 +279,13 @@  static void pci_change_irq_level(PCIDevice *pci_dev, int irq_num, int change)
 {
     PCIBus *bus;
     for (;;) {
+        int dev_irq = irq_num;
         bus = pci_get_bus(pci_dev);
         assert(bus->map_irq);
         irq_num = bus->map_irq(pci_dev, irq_num);
+        trace_pci_route_irq(dev_irq, DEVICE(pci_dev)->canonical_path, irq_num,
+                            pci_bus_is_root(bus) ? "root-complex"
+                                    : DEVICE(bus->parent_dev)->canonical_path);
         if (bus->set_irq)
             break;
         pci_dev = bus->parent_dev;
@@ -1600,8 +1604,12 @@  PCIINTxRoute pci_device_route_intx_to_irq(PCIDevice *dev, int pin)
     PCIBus *bus;
 
     do {
+        int dev_irq = pin;
         bus = pci_get_bus(dev);
         pin = bus->map_irq(dev, pin);
+        trace_pci_route_irq(dev_irq, DEVICE(dev)->canonical_path, pin,
+                            pci_bus_is_root(bus) ? "root-complex"
+                                    : DEVICE(bus->parent_dev)->canonical_path);
         dev = bus->parent_dev;
     } while (dev);
 
diff --git a/hw/pci/trace-events b/hw/pci/trace-events
index aaf46bc92d..42430869ce 100644
--- a/hw/pci/trace-events
+++ b/hw/pci/trace-events
@@ -3,6 +3,7 @@ 
 # pci.c
 pci_update_mappings_del(const char *dev, uint32_t bus, uint32_t slot, uint32_t func, int bar, uint64_t addr, uint64_t size) "%s %02x:%02x.%x %d,0x%"PRIx64"+0x%"PRIx64
 pci_update_mappings_add(const char *dev, uint32_t bus, uint32_t slot, uint32_t func, int bar, uint64_t addr, uint64_t size) "%s %02x:%02x.%x %d,0x%"PRIx64"+0x%"PRIx64
+pci_route_irq(int dev_irq, const char *dev_path, int parent_irq, const char *parent_path) "IRQ %d @%s -> IRQ %d @%s"
 
 # pci_host.c
 pci_cfg_read(const char *dev, uint32_t bus, uint32_t slot, uint32_t func, unsigned offs, unsigned val) "%s %02x:%02x.%x @0x%x -> 0x%x"