Skip to contentSkip to conversation

Remove PCIE root bridge LSI on powernv

PATCH Applied Frederic Barrat 3 participants 8 messages Apr 8, 2022 – Apr 20, 2022

lore
Share & tools
lore
#0 lore raw

v2 cover Remove PCIE root bridge LSI on powernv

The powernv8/powernv9/powernv10 machines allocate a LSI for their root port bridge, which is not the case on real hardware. The default root port implementation in qemu requests a LSI. Since the powernv implementation derives from it, that's where the LSI is coming from. This series fixes it, so that the model matches the hardware.

However, the code in hw/pci to handle AER and hotplug events assume a LSI is defined. It tends to assert/deassert a LSI if MSI or MSIX is not enabled. Since we have hardware where that is not true, this patch also fixes a few code paths to check if a LSI is configured before trying to trigger it.

Changes from v1:
- addressed comments from Daniel

Frederic Barrat (2):
pcie: Don't try triggering a LSI when not defined ppc/pnv: Remove LSI on the PCIE host bridge

 hw/pci-host/pnv_phb3.c | 1 +
 hw/pci-host/pnv_phb4.c | 1 +
 hw/pci/pcie.c          | 5 +++--
 hw/pci/pcie_aer.c      | 2 +-
 4 files changed, 6 insertions(+), 3 deletions(-)
Signature · 1 line
2.35.1
#1 lore raw

PATCH v2 1/2 pcie: Don't try triggering a LSI when not defined

This patch skips [de]asserting a LSI interrupt if the device doesn't have any LSI defined. Doing so would trigger an assert in pci_irq_handler().

The PCIE root port implementation in qemu requests a LSI (INTA), but a subclass may want to change that behavior since it's a valid configuration. For example on the POWER8/POWER9/POWER10 systems, the root bridge doesn't request any LSI.

---
 hw/pci/pcie.c     | 5 +++--
 hw/pci/pcie_aer.c | 2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)
hw/pci/pcie.c +3 -2
index 67a5d67372..68a62da0b5 100644
@@ -353,7 +353,7 @@ static void hotplug_event_notify(PCIDevice *dev)
         msix_notify(dev, pcie_cap_flags_get_vector(dev));
     } else if (msi_enabled(dev)) {
         msi_notify(dev, pcie_cap_flags_get_vector(dev));
-    } else {
+    } else if (pci_intx(dev) != -1) {
         pci_set_irq(dev, dev->exp.hpev_notified);
     }
 }
@@ -361,7 +361,8 @@ static void hotplug_event_notify(PCIDevice *dev)
 static void hotplug_event_clear(PCIDevice *dev)
 {
     hotplug_event_update_event_status(dev);
-    if (!msix_enabled(dev) && !msi_enabled(dev) && !dev->exp.hpev_notified) {
+    if (!msix_enabled(dev) && !msi_enabled(dev) && pci_intx(dev) != -1 &&
+        !dev->exp.hpev_notified) {
         pci_irq_deassert(dev);
     }
 }
hw/pci/pcie_aer.c +1 -1
index e1a8a88c8c..92bd0530dd 100644
@@ -290,7 +290,7 @@ static void pcie_aer_root_notify(PCIDevice *dev)
         msix_notify(dev, pcie_aer_root_get_vector(dev));
     } else if (msi_enabled(dev)) {
         msi_notify(dev, pcie_aer_root_get_vector(dev));
-    } else {
+    } else if (pci_intx(dev) != -1) {
         pci_irq_assert(dev);
     }
 }
Signature · 1 line
2.35.1
Reviewed-by on v2 1/2
#2 lore raw

Re: [PATCH v2 1/2] pcie: Don't try triggering a LSI when not defined

Quoted 11 lines · Frederic Barrat

This patch skips [de]asserting a LSI interrupt if the device doesn't have any LSI defined. Doing so would trigger an assert in pci_irq_handler().

The PCIE root port implementation in qemu requests a LSI (INTA), but a subclass may want to change that behavior since it's a valid configuration. For example on the POWER8/POWER9/POWER10 systems, the root bridge doesn't request any LSI.

---

Quoted 40 lines
  hw/pci/pcie.c     | 5 +++--
  hw/pci/pcie_aer.c | 2 +-
  2 files changed, 4 insertions(+), 3 deletions(-)
hw/pci/pcie.c +3 -2
index 67a5d67372..68a62da0b5 100644
@@ -353,7 +353,7 @@ static void hotplug_event_notify(PCIDevice *dev)
          msix_notify(dev, pcie_cap_flags_get_vector(dev));
      } else if (msi_enabled(dev)) {
          msi_notify(dev, pcie_cap_flags_get_vector(dev));
-    } else {
+    } else if (pci_intx(dev) != -1) {
          pci_set_irq(dev, dev->exp.hpev_notified);
      }
  }
@@ -361,7 +361,8 @@ static void hotplug_event_notify(PCIDevice *dev)
  static void hotplug_event_clear(PCIDevice *dev)
  {
      hotplug_event_update_event_status(dev);
-    if (!msix_enabled(dev) && !msi_enabled(dev) && !dev->exp.hpev_notified) {
+    if (!msix_enabled(dev) && !msi_enabled(dev) && pci_intx(dev) != -1 &&
+        !dev->exp.hpev_notified) {
          pci_irq_deassert(dev);
      }
  }
hw/pci/pcie_aer.c +1 -1
index e1a8a88c8c..92bd0530dd 100644
@@ -290,7 +290,7 @@ static void pcie_aer_root_notify(PCIDevice *dev)
          msix_notify(dev, pcie_aer_root_get_vector(dev));
      } else if (msi_enabled(dev)) {
          msi_notify(dev, pcie_aer_root_get_vector(dev));
-    } else {
+    } else if (pci_intx(dev) != -1) {
          pci_irq_assert(dev);
      }
  }
#3 lore raw

Re: [PATCH v2 1/2] pcie: Don't try triggering a LSI when not defined

In reply to Frederic Barrat

Michael,

Let me know if you want me to grab this patch from the ppc tree. I'm going to send a PR in the next few days.

Thanks,

Daniel

Quoted 51 lines · Frederic Barrat

This patch skips [de]asserting a LSI interrupt if the device doesn't have any LSI defined. Doing so would trigger an assert in pci_irq_handler().

The PCIE root port implementation in qemu requests a LSI (INTA), but a subclass may want to change that behavior since it's a valid configuration. For example on the POWER8/POWER9/POWER10 systems, the root bridge doesn't request any LSI.

---
  hw/pci/pcie.c     | 5 +++--
  hw/pci/pcie_aer.c | 2 +-
  2 files changed, 4 insertions(+), 3 deletions(-)
hw/pci/pcie.c +3 -2
index 67a5d67372..68a62da0b5 100644
@@ -353,7 +353,7 @@ static void hotplug_event_notify(PCIDevice *dev)
          msix_notify(dev, pcie_cap_flags_get_vector(dev));
      } else if (msi_enabled(dev)) {
          msi_notify(dev, pcie_cap_flags_get_vector(dev));
-    } else {
+    } else if (pci_intx(dev) != -1) {
          pci_set_irq(dev, dev->exp.hpev_notified);
      }
  }
@@ -361,7 +361,8 @@ static void hotplug_event_notify(PCIDevice *dev)
  static void hotplug_event_clear(PCIDevice *dev)
  {
      hotplug_event_update_event_status(dev);
-    if (!msix_enabled(dev) && !msi_enabled(dev) && !dev->exp.hpev_notified) {
+    if (!msix_enabled(dev) && !msi_enabled(dev) && pci_intx(dev) != -1 &&
+        !dev->exp.hpev_notified) {
          pci_irq_deassert(dev);
      }
  }
hw/pci/pcie_aer.c +1 -1
index e1a8a88c8c..92bd0530dd 100644
@@ -290,7 +290,7 @@ static void pcie_aer_root_notify(PCIDevice *dev)
          msix_notify(dev, pcie_aer_root_get_vector(dev));
      } else if (msi_enabled(dev)) {
          msi_notify(dev, pcie_aer_root_get_vector(dev));
-    } else {
+    } else if (pci_intx(dev) != -1) {
          pci_irq_assert(dev);
      }
  }
Reviewed-by on v2 1/2
#4 lore raw

Re: [PATCH v2 1/2] pcie: Don't try triggering a LSI when not defined

In reply to Frederic Barrat
Quoted 10 lines · Frederic Barrat

This patch skips [de]asserting a LSI interrupt if the device doesn't have any LSI defined. Doing so would trigger an assert in pci_irq_handler().

The PCIE root port implementation in qemu requests a LSI (INTA), but a subclass may want to change that behavior since it's a valid configuration. For example on the POWER8/POWER9/POWER10 systems, the root bridge doesn't request any LSI.

Feel free to merge with the second patch. Thanks!

Quoted 43 lines
---
 hw/pci/pcie.c     | 5 +++--
 hw/pci/pcie_aer.c | 2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)
hw/pci/pcie.c +3 -2
index 67a5d67372..68a62da0b5 100644
@@ -353,7 +353,7 @@ static void hotplug_event_notify(PCIDevice *dev)
         msix_notify(dev, pcie_cap_flags_get_vector(dev));
     } else if (msi_enabled(dev)) {
         msi_notify(dev, pcie_cap_flags_get_vector(dev));
-    } else {
+    } else if (pci_intx(dev) != -1) {
         pci_set_irq(dev, dev->exp.hpev_notified);
     }
 }
@@ -361,7 +361,8 @@ static void hotplug_event_notify(PCIDevice *dev)
 static void hotplug_event_clear(PCIDevice *dev)
 {
     hotplug_event_update_event_status(dev);
-    if (!msix_enabled(dev) && !msi_enabled(dev) && !dev->exp.hpev_notified) {
+    if (!msix_enabled(dev) && !msi_enabled(dev) && pci_intx(dev) != -1 &&
+        !dev->exp.hpev_notified) {
         pci_irq_deassert(dev);
     }
 }
hw/pci/pcie_aer.c +1 -1
index e1a8a88c8c..92bd0530dd 100644
@@ -290,7 +290,7 @@ static void pcie_aer_root_notify(PCIDevice *dev)
         msix_notify(dev, pcie_aer_root_get_vector(dev));
     } else if (msi_enabled(dev)) {
         msi_notify(dev, pcie_aer_root_get_vector(dev));
-    } else {
+    } else if (pci_intx(dev) != -1) {
         pci_irq_assert(dev);
     }
 }
Signature · 1 line
2.35.1
#5 lore raw

PATCH v2 2/2 ppc/pnv: Remove LSI on the PCIE host bridge

In reply to Frederic Barrat

The phb3/phb4/phb5 root ports inherit from the default PCIE root port implementation, which requests a LSI interrupt (#INTA). On real hardware (POWER8/POWER9/POWER10), there is no such LSI. This patch corrects it so that it matches the hardware.

As a consequence, the device tree previously generated was bogus, as the root bridge LSI was not properly mapped. On some implementation (powernv9), it was leading to inconsistent interrupt controller (xive) data. With this patch, it is now clean.

---
 hw/pci-host/pnv_phb3.c | 1 +
 hw/pci-host/pnv_phb4.c | 1 +
 2 files changed, 2 insertions(+)
hw/pci-host/pnv_phb3.c +1 -0
index 6e9aa9d6ac..6a884833a8 100644
@@ -1162,6 +1162,7 @@ static void pnv_phb3_root_port_realize(DeviceState *dev, Error **errp)
         error_propagate(errp, local_err);
         return;
     }
+    pci_config_set_interrupt_pin(pci->config, 0);
 }
 
 static void pnv_phb3_root_port_class_init(ObjectClass *klass, void *data)
hw/pci-host/pnv_phb4.c +1 -0
index 11c97e27eb..dd81e940b7 100644
@@ -1772,6 +1772,7 @@ static void pnv_phb4_root_port_reset(DeviceState *dev)
     pci_set_word(conf + PCI_PREF_MEMORY_LIMIT, 0xfff1);
     pci_set_long(conf + PCI_PREF_BASE_UPPER32, 0x1); /* Hack */
     pci_set_long(conf + PCI_PREF_LIMIT_UPPER32, 0xffffffff);
+    pci_config_set_interrupt_pin(conf, 0);
 }
 
 static void pnv_phb4_root_port_realize(DeviceState *dev, Error **errp)
Signature · 1 line
2.35.1
Reviewed-by on v2 2/2
#6 lore raw

Re: [PATCH v2 2/2] ppc/pnv: Remove LSI on the PCIE host bridge

Quoted 5 lines · Frederic Barrat

The phb3/phb4/phb5 root ports inherit from the default PCIE root port implementation, which requests a LSI interrupt (#INTA). On real hardware (POWER8/POWER9/POWER10), there is no such LSI. This patch corrects it so that it matches the hardware.

Quoted 7 lines

As a consequence, the device tree previously generated was bogus, as the root bridge LSI was not properly mapped. On some implementation (powernv9), it was leading to inconsistent interrupt controller (xive) data. With this patch, it is now clean.

---

Quoted 28 lines
  hw/pci-host/pnv_phb3.c | 1 +
  hw/pci-host/pnv_phb4.c | 1 +
  2 files changed, 2 insertions(+)
hw/pci-host/pnv_phb3.c +1 -0
index 6e9aa9d6ac..6a884833a8 100644
@@ -1162,6 +1162,7 @@ static void pnv_phb3_root_port_realize(DeviceState *dev, Error **errp)
          error_propagate(errp, local_err);
          return;
      }
+    pci_config_set_interrupt_pin(pci->config, 0);
  }
 
  static void pnv_phb3_root_port_class_init(ObjectClass *klass, void *data)
hw/pci-host/pnv_phb4.c +1 -0
index 11c97e27eb..dd81e940b7 100644
@@ -1772,6 +1772,7 @@ static void pnv_phb4_root_port_reset(DeviceState *dev)
      pci_set_word(conf + PCI_PREF_MEMORY_LIMIT, 0xfff1);
      pci_set_long(conf + PCI_PREF_BASE_UPPER32, 0x1); /* Hack */
      pci_set_long(conf + PCI_PREF_LIMIT_UPPER32, 0xffffffff);
+    pci_config_set_interrupt_pin(conf, 0);
  }
 
  static void pnv_phb4_root_port_realize(DeviceState *dev, Error **errp)
#7 lore raw
In reply to Frederic Barrat

Queued in gitlab.com/danielhb/qemu/tree/ppc-next. Thanks,

Daniel

Quoted 27 lines · Frederic Barrat

The powernv8/powernv9/powernv10 machines allocate a LSI for their root port bridge, which is not the case on real hardware. The default root port implementation in qemu requests a LSI. Since the powernv implementation derives from it, that's where the LSI is coming from. This series fixes it, so that the model matches the hardware.

However, the code in hw/pci to handle AER and hotplug events assume a LSI is defined. It tends to assert/deassert a LSI if MSI or MSIX is not enabled. Since we have hardware where that is not true, this patch also fixes a few code paths to check if a LSI is configured before trying to trigger it.

Changes from v1:
- addressed comments from Daniel

Frederic Barrat (2):
pcie: Don't try triggering a LSI when not defined ppc/pnv: Remove LSI on the PCIE host bridge

  hw/pci-host/pnv_phb3.c | 1 +
  hw/pci-host/pnv_phb4.c | 1 +
  hw/pci/pcie.c          | 5 +++--
  hw/pci/pcie_aer.c      | 2 +-
  4 files changed, 6 insertions(+), 3 deletions(-)