Skip to content

Commit 3b4b84b

Browse files
committed
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
2 parents 145ff1e + aa251fc commit 3b4b84b

File tree

10 files changed

+56
-2
lines changed

10 files changed

+56
-2
lines changed

arch/mips/pci/pci-xtalk-bridge.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,15 +728,18 @@ static int bridge_probe(struct platform_device *pdev)
728728
pci_free_resource_list(&host->windows);
729729
err_remove_domain:
730730
irq_domain_remove(domain);
731+
irq_domain_free_fwnode(fn);
731732
return err;
732733
}
733734

734735
static int bridge_remove(struct platform_device *pdev)
735736
{
736737
struct pci_bus *bus = platform_get_drvdata(pdev);
737738
struct bridge_controller *bc = BRIDGE_CONTROLLER(bus);
739+
struct fwnode_handle *fn = bc->domain->fwnode;
738740

739741
irq_domain_remove(bc->domain);
742+
irq_domain_free_fwnode(fn);
740743
pci_lock_rescan_remove();
741744
pci_stop_root_bus(bus);
742745
pci_remove_root_bus(bus);

arch/x86/kernel/apic/io_apic.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2335,8 +2335,13 @@ static int mp_irqdomain_create(int ioapic)
23352335

23362336
static void ioapic_destroy_irqdomain(int idx)
23372337
{
2338+
struct ioapic_domain_cfg *cfg = &ioapics[idx].irqdomain_cfg;
2339+
struct fwnode_handle *fn = ioapics[idx].irqdomain->fwnode;
2340+
23382341
if (ioapics[idx].irqdomain) {
23392342
irq_domain_remove(ioapics[idx].irqdomain);
2343+
if (!cfg->dev)
2344+
irq_domain_free_fwnode(fn);
23402345
ioapics[idx].irqdomain = NULL;
23412346
}
23422347
}

arch/x86/kernel/apic/vector.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,10 @@ static int x86_vector_alloc_irqs(struct irq_domain *domain, unsigned int virq,
560560
* as that can corrupt the affinity move state.
561561
*/
562562
irqd_set_handle_enforce_irqctx(irqd);
563+
564+
/* Don't invoke affinity setter on deactivated interrupts */
565+
irqd_set_affinity_on_activate(irqd);
566+
563567
/*
564568
* Legacy vectors are already assigned when the IOAPIC
565569
* takes them over. They stay on the same vector. This is

drivers/iommu/intel/irq_remapping.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,13 +628,21 @@ static int intel_setup_irq_remapping(struct intel_iommu *iommu)
628628

629629
static void intel_teardown_irq_remapping(struct intel_iommu *iommu)
630630
{
631+
struct fwnode_handle *fn;
632+
631633
if (iommu && iommu->ir_table) {
632634
if (iommu->ir_msi_domain) {
635+
fn = iommu->ir_msi_domain->fwnode;
636+
633637
irq_domain_remove(iommu->ir_msi_domain);
638+
irq_domain_free_fwnode(fn);
634639
iommu->ir_msi_domain = NULL;
635640
}
636641
if (iommu->ir_domain) {
642+
fn = iommu->ir_domain->fwnode;
643+
637644
irq_domain_remove(iommu->ir_domain);
645+
irq_domain_free_fwnode(fn);
638646
iommu->ir_domain = NULL;
639647
}
640648
free_pages((unsigned long)iommu->ir_table->base,

drivers/irqchip/irq-gic-v3-its.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3523,6 +3523,7 @@ static int its_irq_domain_alloc(struct irq_domain *domain, unsigned int virq,
35233523
msi_alloc_info_t *info = args;
35243524
struct its_device *its_dev = info->scratchpad[0].ptr;
35253525
struct its_node *its = its_dev->its;
3526+
struct irq_data *irqd;
35263527
irq_hw_number_t hwirq;
35273528
int err;
35283529
int i;
@@ -3542,7 +3543,9 @@ static int its_irq_domain_alloc(struct irq_domain *domain, unsigned int virq,
35423543

35433544
irq_domain_set_hwirq_and_chip(domain, virq + i,
35443545
hwirq + i, &its_irq_chip, its_dev);
3545-
irqd_set_single_target(irq_desc_get_irq_data(irq_to_desc(virq + i)));
3546+
irqd = irq_get_irq_data(virq + i);
3547+
irqd_set_single_target(irqd);
3548+
irqd_set_affinity_on_activate(irqd);
35463549
pr_debug("ID:%d pID:%d vID:%d\n",
35473550
(int)(hwirq + i - its_dev->event_map.lpi_base),
35483551
(int)(hwirq + i), virq + i);

drivers/mfd/ioc3.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,10 @@ static int ioc3_mfd_probe(struct pci_dev *pdev,
616616
/* Remove all already added MFD devices */
617617
mfd_remove_devices(&ipd->pdev->dev);
618618
if (ipd->domain) {
619+
struct fwnode_handle *fn = ipd->domain->fwnode;
620+
619621
irq_domain_remove(ipd->domain);
622+
irq_domain_free_fwnode(fn);
620623
free_irq(ipd->domain_irq, (void *)ipd);
621624
}
622625
pci_iounmap(pdev, regs);
@@ -643,7 +646,10 @@ static void ioc3_mfd_remove(struct pci_dev *pdev)
643646
/* Release resources */
644647
mfd_remove_devices(&ipd->pdev->dev);
645648
if (ipd->domain) {
649+
struct fwnode_handle *fn = ipd->domain->fwnode;
650+
646651
irq_domain_remove(ipd->domain);
652+
irq_domain_free_fwnode(fn);
647653
free_irq(ipd->domain_irq, (void *)ipd);
648654
}
649655
pci_iounmap(pdev, ipd->regs);

drivers/pci/controller/vmd.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,7 @@ static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features)
560560
if (!vmd->bus) {
561561
pci_free_resource_list(&resources);
562562
irq_domain_remove(vmd->irq_domain);
563+
irq_domain_free_fwnode(fn);
563564
return -ENODEV;
564565
}
565566

@@ -673,13 +674,15 @@ static void vmd_cleanup_srcu(struct vmd_dev *vmd)
673674
static void vmd_remove(struct pci_dev *dev)
674675
{
675676
struct vmd_dev *vmd = pci_get_drvdata(dev);
677+
struct fwnode_handle *fn = vmd->irq_domain->fwnode;
676678

677679
sysfs_remove_link(&vmd->dev->dev.kobj, "domain");
678680
pci_stop_root_bus(vmd->bus);
679681
pci_remove_root_bus(vmd->bus);
680682
vmd_cleanup_srcu(vmd);
681683
vmd_detach_resources(vmd);
682684
irq_domain_remove(vmd->irq_domain);
685+
irq_domain_free_fwnode(fn);
683686
}
684687

685688
#ifdef CONFIG_PM_SLEEP

include/linux/irq.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,8 @@ struct irq_data {
213213
* required
214214
* IRQD_HANDLE_ENFORCE_IRQCTX - Enforce that handle_irq_*() is only invoked
215215
* from actual interrupt context.
216+
* IRQD_AFFINITY_ON_ACTIVATE - Affinity is set on activation. Don't call
217+
* irq_chip::irq_set_affinity() when deactivated.
216218
*/
217219
enum {
218220
IRQD_TRIGGER_MASK = 0xf,
@@ -237,6 +239,7 @@ enum {
237239
IRQD_CAN_RESERVE = (1 << 26),
238240
IRQD_MSI_NOMASK_QUIRK = (1 << 27),
239241
IRQD_HANDLE_ENFORCE_IRQCTX = (1 << 28),
242+
IRQD_AFFINITY_ON_ACTIVATE = (1 << 29),
240243
};
241244

242245
#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)
421424
return __irqd_to_state(d) & IRQD_MSI_NOMASK_QUIRK;
422425
}
423426

427+
static inline void irqd_set_affinity_on_activate(struct irq_data *d)
428+
{
429+
__irqd_to_state(d) |= IRQD_AFFINITY_ON_ACTIVATE;
430+
}
431+
432+
static inline bool irqd_affinity_on_activate(struct irq_data *d)
433+
{
434+
return __irqd_to_state(d) & IRQD_AFFINITY_ON_ACTIVATE;
435+
}
436+
424437
#undef __irqd_to_state
425438

426439
static inline irq_hw_number_t irqd_to_hwirq(struct irq_data *d)

kernel/irq/debugfs.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ static const struct irq_bit_descr irqdata_states[] = {
112112
BIT_MASK_DESCR(IRQD_AFFINITY_SET),
113113
BIT_MASK_DESCR(IRQD_SETAFFINITY_PENDING),
114114
BIT_MASK_DESCR(IRQD_AFFINITY_MANAGED),
115+
BIT_MASK_DESCR(IRQD_AFFINITY_ON_ACTIVATE),
115116
BIT_MASK_DESCR(IRQD_MANAGED_SHUTDOWN),
116117
BIT_MASK_DESCR(IRQD_CAN_RESERVE),
117118
BIT_MASK_DESCR(IRQD_MSI_NOMASK_QUIRK),
@@ -120,6 +121,10 @@ static const struct irq_bit_descr irqdata_states[] = {
120121

121122
BIT_MASK_DESCR(IRQD_WAKEUP_STATE),
122123
BIT_MASK_DESCR(IRQD_WAKEUP_ARMED),
124+
125+
BIT_MASK_DESCR(IRQD_DEFAULT_TRIGGER_SET),
126+
127+
BIT_MASK_DESCR(IRQD_HANDLE_ENFORCE_IRQCTX),
123128
};
124129

125130
static const struct irq_bit_descr irqdesc_states[] = {

kernel/irq/manage.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,12 +320,16 @@ static bool irq_set_affinity_deactivated(struct irq_data *data,
320320
struct irq_desc *desc = irq_data_to_desc(data);
321321

322322
/*
323+
* Handle irq chips which can handle affinity only in activated
324+
* state correctly
325+
*
323326
* If the interrupt is not yet activated, just store the affinity
324327
* mask and do not call the chip driver at all. On activation the
325328
* driver has to make sure anyway that the interrupt is in a
326329
* useable state so startup works.
327330
*/
328-
if (!IS_ENABLED(CONFIG_IRQ_DOMAIN_HIERARCHY) || irqd_is_activated(data))
331+
if (!IS_ENABLED(CONFIG_IRQ_DOMAIN_HIERARCHY) ||
332+
irqd_is_activated(data) || !irqd_affinity_on_activate(data))
329333
return false;
330334

331335
cpumask_copy(desc->irq_common_data.affinity, mask);

0 commit comments

Comments
 (0)