@@ -11,6 +11,7 @@
#include <linux/errno.h>
#include <linux/export.h>
#include <linux/interrupt.h>
+#include <linux/irqdomain.h>
#include <linux/pci.h>
#include "pci.h"
@@ -259,6 +260,26 @@ bool pci_check_and_unmask_intx(struct pci_dev *dev)
}
EXPORT_SYMBOL_GPL(pci_check_and_unmask_intx);
+#ifdef CONFIG_IRQ_DOMAIN
+/**
+ * pci_remove_irq_domain - dispose all IRQ mappings and remove IRQ domain
+ * @domain: the IRQ domain to be removed
+ *
+ * Disposes all IRQ mappings of a given IRQ domain before removing the domain.
+ */
+void pci_remove_irq_domain(struct irq_domain *domain)
+{
+ for (irq_hw_number_t i = 0; i < domain->hwirq_max; i++) {
+ unsigned int virq = irq_find_mapping(domain, i);
+
+ if (virq)
+ irq_dispose_mapping(virq);
+ }
+
+ irq_domain_remove(domain);
+}
+#endif
+
/**
* pcibios_penalize_isa_irq - penalize an ISA IRQ
* @irq: ISA IRQ to penalize
@@ -170,6 +170,13 @@ void pci_no_msi(void);
static inline void pci_no_msi(void) { }
#endif
+struct irq_domain;
+#ifdef CONFIG_IRQ_DOMAIN
+void pci_remove_irq_domain(struct irq_domain *domain);
+#else
+static inline void pci_remove_irq_domain(struct irq_domain *domain) { }
+#endif
+
void pci_realloc_get_opt(char *);
static inline int pci_no_d1d2(struct pci_dev *dev)
Add a helper function pci_remove_irq_domain() for disposing all interrupt mappings of an IRQ domain and then removing said IRQ domain. As explained in the attached link, the PCI INTX interrupt may be shared, and so the PCI device drivers do not dispose mapped interrupts when they are unbound from a device, since other devices may be still using those mapped interrupts. Thus the interrupts must be disposed by the PCI controller driver when the IRQ domain is being removed. This function may be used by PCI controller drivers that wish to be removable / modular. Link: https://lore.kernel.org/linux-pci/878qy5rrq7.ffs@tglx/ Signed-off-by: Marek BehĂșn <kabel@kernel.org> --- drivers/pci/irq.c | 21 +++++++++++++++++++++ drivers/pci/pci.h | 7 +++++++ 2 files changed, 28 insertions(+)