Commit 3b4b84b2 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'irq-urgent-2020-08-02' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull irq fixes from Ingo Molnar:
 "Fix a recent IRQ affinities regression, add in a missing debugfs
  printout that helps the debugging of IRQ affinity logic bugs, and fix
  a memory leak"

* tag 'irq-urgent-2020-08-02' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  genirq/debugfs: Add missing irqchip flags
  genirq/affinity: Make affinity setting if activated opt-in
  irqdomain/treewide: Free firmware node after domain removal
parents 145ff1ec aa251fc5
...@@ -728,6 +728,7 @@ static int bridge_probe(struct platform_device *pdev) ...@@ -728,6 +728,7 @@ static int bridge_probe(struct platform_device *pdev)
pci_free_resource_list(&host->windows); pci_free_resource_list(&host->windows);
err_remove_domain: err_remove_domain:
irq_domain_remove(domain); irq_domain_remove(domain);
irq_domain_free_fwnode(fn);
return err; return err;
} }
...@@ -735,8 +736,10 @@ static int bridge_remove(struct platform_device *pdev) ...@@ -735,8 +736,10 @@ static int bridge_remove(struct platform_device *pdev)
{ {
struct pci_bus *bus = platform_get_drvdata(pdev); struct pci_bus *bus = platform_get_drvdata(pdev);
struct bridge_controller *bc = BRIDGE_CONTROLLER(bus); struct bridge_controller *bc = BRIDGE_CONTROLLER(bus);
struct fwnode_handle *fn = bc->domain->fwnode;
irq_domain_remove(bc->domain); irq_domain_remove(bc->domain);
irq_domain_free_fwnode(fn);
pci_lock_rescan_remove(); pci_lock_rescan_remove();
pci_stop_root_bus(bus); pci_stop_root_bus(bus);
pci_remove_root_bus(bus); pci_remove_root_bus(bus);
......
...@@ -2335,8 +2335,13 @@ static int mp_irqdomain_create(int ioapic) ...@@ -2335,8 +2335,13 @@ static int mp_irqdomain_create(int ioapic)
static void ioapic_destroy_irqdomain(int idx) static void ioapic_destroy_irqdomain(int idx)
{ {
struct ioapic_domain_cfg *cfg = &ioapics[idx].irqdomain_cfg;
struct fwnode_handle *fn = ioapics[idx].irqdomain->fwnode;
if (ioapics[idx].irqdomain) { if (ioapics[idx].irqdomain) {
irq_domain_remove(ioapics[idx].irqdomain); irq_domain_remove(ioapics[idx].irqdomain);
if (!cfg->dev)
irq_domain_free_fwnode(fn);
ioapics[idx].irqdomain = NULL; ioapics[idx].irqdomain = NULL;
} }
} }
......
...@@ -560,6 +560,10 @@ static int x86_vector_alloc_irqs(struct irq_domain *domain, unsigned int virq, ...@@ -560,6 +560,10 @@ static int x86_vector_alloc_irqs(struct irq_domain *domain, unsigned int virq,
* as that can corrupt the affinity move state. * as that can corrupt the affinity move state.
*/ */
irqd_set_handle_enforce_irqctx(irqd); irqd_set_handle_enforce_irqctx(irqd);
/* Don't invoke affinity setter on deactivated interrupts */
irqd_set_affinity_on_activate(irqd);
/* /*
* Legacy vectors are already assigned when the IOAPIC * Legacy vectors are already assigned when the IOAPIC
* takes them over. They stay on the same vector. This is * takes them over. They stay on the same vector. This is
......
...@@ -628,13 +628,21 @@ static int intel_setup_irq_remapping(struct intel_iommu *iommu) ...@@ -628,13 +628,21 @@ static int intel_setup_irq_remapping(struct intel_iommu *iommu)
static void intel_teardown_irq_remapping(struct intel_iommu *iommu) static void intel_teardown_irq_remapping(struct intel_iommu *iommu)
{ {
struct fwnode_handle *fn;
if (iommu && iommu->ir_table) { if (iommu && iommu->ir_table) {
if (iommu->ir_msi_domain) { if (iommu->ir_msi_domain) {
fn = iommu->ir_msi_domain->fwnode;
irq_domain_remove(iommu->ir_msi_domain); irq_domain_remove(iommu->ir_msi_domain);
irq_domain_free_fwnode(fn);
iommu->ir_msi_domain = NULL; iommu->ir_msi_domain = NULL;
} }
if (iommu->ir_domain) { if (iommu->ir_domain) {
fn = iommu->ir_domain->fwnode;
irq_domain_remove(iommu->ir_domain); irq_domain_remove(iommu->ir_domain);
irq_domain_free_fwnode(fn);
iommu->ir_domain = NULL; iommu->ir_domain = NULL;
} }
free_pages((unsigned long)iommu->ir_table->base, free_pages((unsigned long)iommu->ir_table->base,
......
...@@ -3523,6 +3523,7 @@ static int its_irq_domain_alloc(struct irq_domain *domain, unsigned int virq, ...@@ -3523,6 +3523,7 @@ static int its_irq_domain_alloc(struct irq_domain *domain, unsigned int virq,
msi_alloc_info_t *info = args; msi_alloc_info_t *info = args;
struct its_device *its_dev = info->scratchpad[0].ptr; struct its_device *its_dev = info->scratchpad[0].ptr;
struct its_node *its = its_dev->its; struct its_node *its = its_dev->its;
struct irq_data *irqd;
irq_hw_number_t hwirq; irq_hw_number_t hwirq;
int err; int err;
int i; int i;
...@@ -3542,7 +3543,9 @@ static int its_irq_domain_alloc(struct irq_domain *domain, unsigned int virq, ...@@ -3542,7 +3543,9 @@ static int its_irq_domain_alloc(struct irq_domain *domain, unsigned int virq,
irq_domain_set_hwirq_and_chip(domain, virq + i, irq_domain_set_hwirq_and_chip(domain, virq + i,
hwirq + i, &its_irq_chip, its_dev); hwirq + i, &its_irq_chip, its_dev);
irqd_set_single_target(irq_desc_get_irq_data(irq_to_desc(virq + i))); irqd = irq_get_irq_data(virq + i);
irqd_set_single_target(irqd);
irqd_set_affinity_on_activate(irqd);
pr_debug("ID:%d pID:%d vID:%d\n", pr_debug("ID:%d pID:%d vID:%d\n",
(int)(hwirq + i - its_dev->event_map.lpi_base), (int)(hwirq + i - its_dev->event_map.lpi_base),
(int)(hwirq + i), virq + i); (int)(hwirq + i), virq + i);
......
...@@ -616,7 +616,10 @@ static int ioc3_mfd_probe(struct pci_dev *pdev, ...@@ -616,7 +616,10 @@ static int ioc3_mfd_probe(struct pci_dev *pdev,
/* Remove all already added MFD devices */ /* Remove all already added MFD devices */
mfd_remove_devices(&ipd->pdev->dev); mfd_remove_devices(&ipd->pdev->dev);
if (ipd->domain) { if (ipd->domain) {
struct fwnode_handle *fn = ipd->domain->fwnode;
irq_domain_remove(ipd->domain); irq_domain_remove(ipd->domain);
irq_domain_free_fwnode(fn);
free_irq(ipd->domain_irq, (void *)ipd); free_irq(ipd->domain_irq, (void *)ipd);
} }
pci_iounmap(pdev, regs); pci_iounmap(pdev, regs);
...@@ -643,7 +646,10 @@ static void ioc3_mfd_remove(struct pci_dev *pdev) ...@@ -643,7 +646,10 @@ static void ioc3_mfd_remove(struct pci_dev *pdev)
/* Release resources */ /* Release resources */
mfd_remove_devices(&ipd->pdev->dev); mfd_remove_devices(&ipd->pdev->dev);
if (ipd->domain) { if (ipd->domain) {
struct fwnode_handle *fn = ipd->domain->fwnode;
irq_domain_remove(ipd->domain); irq_domain_remove(ipd->domain);
irq_domain_free_fwnode(fn);
free_irq(ipd->domain_irq, (void *)ipd); free_irq(ipd->domain_irq, (void *)ipd);
} }
pci_iounmap(pdev, ipd->regs); pci_iounmap(pdev, ipd->regs);
......
...@@ -560,6 +560,7 @@ static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features) ...@@ -560,6 +560,7 @@ static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features)
if (!vmd->bus) { if (!vmd->bus) {
pci_free_resource_list(&resources); pci_free_resource_list(&resources);
irq_domain_remove(vmd->irq_domain); irq_domain_remove(vmd->irq_domain);
irq_domain_free_fwnode(fn);
return -ENODEV; return -ENODEV;
} }
...@@ -673,6 +674,7 @@ static void vmd_cleanup_srcu(struct vmd_dev *vmd) ...@@ -673,6 +674,7 @@ static void vmd_cleanup_srcu(struct vmd_dev *vmd)
static void vmd_remove(struct pci_dev *dev) static void vmd_remove(struct pci_dev *dev)
{ {
struct vmd_dev *vmd = pci_get_drvdata(dev); struct vmd_dev *vmd = pci_get_drvdata(dev);
struct fwnode_handle *fn = vmd->irq_domain->fwnode;
sysfs_remove_link(&vmd->dev->dev.kobj, "domain"); sysfs_remove_link(&vmd->dev->dev.kobj, "domain");
pci_stop_root_bus(vmd->bus); pci_stop_root_bus(vmd->bus);
...@@ -680,6 +682,7 @@ static void vmd_remove(struct pci_dev *dev) ...@@ -680,6 +682,7 @@ static void vmd_remove(struct pci_dev *dev)
vmd_cleanup_srcu(vmd); vmd_cleanup_srcu(vmd);
vmd_detach_resources(vmd); vmd_detach_resources(vmd);
irq_domain_remove(vmd->irq_domain); irq_domain_remove(vmd->irq_domain);
irq_domain_free_fwnode(fn);
} }
#ifdef CONFIG_PM_SLEEP #ifdef CONFIG_PM_SLEEP
......
...@@ -213,6 +213,8 @@ struct irq_data { ...@@ -213,6 +213,8 @@ struct irq_data {
* required * required
* IRQD_HANDLE_ENFORCE_IRQCTX - Enforce that handle_irq_*() is only invoked * IRQD_HANDLE_ENFORCE_IRQCTX - Enforce that handle_irq_*() is only invoked
* from actual interrupt context. * from actual interrupt context.
* IRQD_AFFINITY_ON_ACTIVATE - Affinity is set on activation. Don't call
* irq_chip::irq_set_affinity() when deactivated.
*/ */
enum { enum {
IRQD_TRIGGER_MASK = 0xf, IRQD_TRIGGER_MASK = 0xf,
...@@ -237,6 +239,7 @@ enum { ...@@ -237,6 +239,7 @@ enum {
IRQD_CAN_RESERVE = (1 << 26), IRQD_CAN_RESERVE = (1 << 26),
IRQD_MSI_NOMASK_QUIRK = (1 << 27), IRQD_MSI_NOMASK_QUIRK = (1 << 27),
IRQD_HANDLE_ENFORCE_IRQCTX = (1 << 28), IRQD_HANDLE_ENFORCE_IRQCTX = (1 << 28),
IRQD_AFFINITY_ON_ACTIVATE = (1 << 29),
}; };
#define __irqd_to_state(d) ACCESS_PRIVATE((d)->common, state_use_accessors) #define __irqd_to_state(d) ACCESS_PRIVATE((d)->common, state_use_accessors)
...@@ -421,6 +424,16 @@ static inline bool irqd_msi_nomask_quirk(struct irq_data *d) ...@@ -421,6 +424,16 @@ static inline bool irqd_msi_nomask_quirk(struct irq_data *d)
return __irqd_to_state(d) & IRQD_MSI_NOMASK_QUIRK; return __irqd_to_state(d) & IRQD_MSI_NOMASK_QUIRK;
} }
static inline void irqd_set_affinity_on_activate(struct irq_data *d)
{
__irqd_to_state(d) |= IRQD_AFFINITY_ON_ACTIVATE;
}
static inline bool irqd_affinity_on_activate(struct irq_data *d)
{
return __irqd_to_state(d) & IRQD_AFFINITY_ON_ACTIVATE;
}
#undef __irqd_to_state #undef __irqd_to_state
static inline irq_hw_number_t irqd_to_hwirq(struct irq_data *d) static inline irq_hw_number_t irqd_to_hwirq(struct irq_data *d)
......
...@@ -112,6 +112,7 @@ static const struct irq_bit_descr irqdata_states[] = { ...@@ -112,6 +112,7 @@ static const struct irq_bit_descr irqdata_states[] = {
BIT_MASK_DESCR(IRQD_AFFINITY_SET), BIT_MASK_DESCR(IRQD_AFFINITY_SET),
BIT_MASK_DESCR(IRQD_SETAFFINITY_PENDING), BIT_MASK_DESCR(IRQD_SETAFFINITY_PENDING),
BIT_MASK_DESCR(IRQD_AFFINITY_MANAGED), BIT_MASK_DESCR(IRQD_AFFINITY_MANAGED),
BIT_MASK_DESCR(IRQD_AFFINITY_ON_ACTIVATE),
BIT_MASK_DESCR(IRQD_MANAGED_SHUTDOWN), BIT_MASK_DESCR(IRQD_MANAGED_SHUTDOWN),
BIT_MASK_DESCR(IRQD_CAN_RESERVE), BIT_MASK_DESCR(IRQD_CAN_RESERVE),
BIT_MASK_DESCR(IRQD_MSI_NOMASK_QUIRK), BIT_MASK_DESCR(IRQD_MSI_NOMASK_QUIRK),
...@@ -120,6 +121,10 @@ static const struct irq_bit_descr irqdata_states[] = { ...@@ -120,6 +121,10 @@ static const struct irq_bit_descr irqdata_states[] = {
BIT_MASK_DESCR(IRQD_WAKEUP_STATE), BIT_MASK_DESCR(IRQD_WAKEUP_STATE),
BIT_MASK_DESCR(IRQD_WAKEUP_ARMED), BIT_MASK_DESCR(IRQD_WAKEUP_ARMED),
BIT_MASK_DESCR(IRQD_DEFAULT_TRIGGER_SET),
BIT_MASK_DESCR(IRQD_HANDLE_ENFORCE_IRQCTX),
}; };
static const struct irq_bit_descr irqdesc_states[] = { static const struct irq_bit_descr irqdesc_states[] = {
......
...@@ -320,12 +320,16 @@ static bool irq_set_affinity_deactivated(struct irq_data *data, ...@@ -320,12 +320,16 @@ static bool irq_set_affinity_deactivated(struct irq_data *data,
struct irq_desc *desc = irq_data_to_desc(data); struct irq_desc *desc = irq_data_to_desc(data);
/* /*
* Handle irq chips which can handle affinity only in activated
* state correctly
*
* If the interrupt is not yet activated, just store the affinity * If the interrupt is not yet activated, just store the affinity
* mask and do not call the chip driver at all. On activation the * mask and do not call the chip driver at all. On activation the
* driver has to make sure anyway that the interrupt is in a * driver has to make sure anyway that the interrupt is in a
* useable state so startup works. * useable state so startup works.
*/ */
if (!IS_ENABLED(CONFIG_IRQ_DOMAIN_HIERARCHY) || irqd_is_activated(data)) if (!IS_ENABLED(CONFIG_IRQ_DOMAIN_HIERARCHY) ||
irqd_is_activated(data) || !irqd_affinity_on_activate(data))
return false; return false;
cpumask_copy(desc->irq_common_data.affinity, mask); cpumask_copy(desc->irq_common_data.affinity, mask);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment