Skip to contentSkip to conversation

powerpc/pci: unmap legacy INTx interrupts when a PHB is removed

PATCH In review Cédric Le Goater 1 participant 2 messages Sep 23, 2020 – Sep 25, 2020 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 powerpc/pci: unmap legacy INTx interrupts when a PHB is removed

When a passthrough IO adapter is removed from a pseries machine using hash MMU and the XIVE interrupt mode, the POWER hypervisor expects the guest OS to clear all page table entries related to the adapter. If some are still present, the RTAS call which isolates the PCI slot returns error 9001 "valid outstanding translations" and the removal of the IO adapter fails. This is because when the PHBs are scanned, Linux maps automatically the INTx interrupts in the Linux interrupt number space but these are never removed.

To solve this problem, we introduce a PPC platform specific pcibios_remove_bus() routine which clears all interrupt mappings when the bus is removed. This also clears the associated page table entries of the ESB pages when using XIVE.

For this purpose, we record the logical interrupt numbers of the mapped interrupt under the PHB structure and let pcibios_remove_bus() do the clean up.

Since some PCI adapters, like GPUs, use the "interrupt-map" property to describe interrupt mappings other than the legacy INTx interrupts, we can not restrict the size of the mapping array to PCI_NUM_INTX. The number of interrupt mappings is computed from the "interrupt-map" property and the mapping array is allocated accordingly.

Cc "Oliver O'Halloran" <[email protected]>
Cc Alexey Kardashevskiy <[email protected]>

---

Changes in v3 :

- NULLified 'irq_map' in pci_irq_map_dispose()

 arch/powerpc/include/asm/pci-bridge.h |   6 ++
 arch/powerpc/kernel/pci-common.c      | 115 ++++++++++++++++++++++++++
 2 files changed, 121 insertions(+)
arch/powerpc/include/asm/pci-bridge.h +6 -0
index d2a2a14e56f9..d21e070352dc 100644
@@ -48,6 +48,9 @@ struct pci_controller_ops {
 
 /*
  * Structure of a PCI controller (host bridge)
+ *
+ * @irq_count: number of interrupt mappings
+ * @irq_map: interrupt mappings
  */
 struct pci_controller {
 	struct pci_bus *bus;
@@ -127,6 +130,9 @@ struct pci_controller {
 
 	void *private_data;
 	struct npu *npu;
+
+	unsigned int irq_count;
+	unsigned int *irq_map;
 };
 
 /* These are used for config access before all the PCI probing
arch/powerpc/kernel/pci-common.c +115 -0

133 lines not on this page · raw message

Signature · 1 line
2.25.4
#1 lore raw
Quoted 28 lines · Cédric Le Goater

When a passthrough IO adapter is removed from a pseries machine using hash MMU and the XIVE interrupt mode, the POWER hypervisor expects the guest OS to clear all page table entries related to the adapter. If some are still present, the RTAS call which isolates the PCI slot returns error 9001 "valid outstanding translations" and the removal of the IO adapter fails. This is because when the PHBs are scanned, Linux maps automatically the INTx interrupts in the Linux interrupt number space but these are never removed.

To solve this problem, we introduce a PPC platform specific pcibios_remove_bus() routine which clears all interrupt mappings when the bus is removed. This also clears the associated page table entries of the ESB pages when using XIVE.

For this purpose, we record the logical interrupt numbers of the mapped interrupt under the PHB structure and let pcibios_remove_bus() do the clean up.

Since some PCI adapters, like GPUs, use the "interrupt-map" property to describe interrupt mappings other than the legacy INTx interrupts, we can not restrict the size of the mapping array to PCI_NUM_INTX. The number of interrupt mappings is computed from the "interrupt-map" property and the mapping array is allocated accordingly.

Cc "Oliver O'Halloran" <[email protected]>
Cc Alexey Kardashevskiy <[email protected]>
Quoted 5 lines

---

Changes in v3 :

- NULLified 'irq_map' in pci_irq_map_dispose()

Forge that. I am going to move the kfree() in the routine freeing the PCI controller structure.

Thanks,

C.