Skip to content

Commit 5e7afb2

Browse files
hcodinaKAGA-KOKO
authored andcommitted
genirq/generic_chip: Make irq_remove_generic_chip() irqdomain aware
irq_remove_generic_chip() calculates the Linux interrupt number for removing the handler and interrupt chip based on gc::irq_base as a linear function of the bit positions of set bits in the @msk argument. When the generic chip is present in an irq domain, i.e. created with a call to irq_alloc_domain_generic_chips(), gc::irq_base contains not the base Linux interrupt number. It contains the base hardware interrupt for this chip. It is set to 0 for the first chip in the domain, 0 + N for the next chip, where $N is the number of hardware interrupts per chip. That means the Linux interrupt number cannot be calculated based on gc::irq_base for irqdomain based chips without a domain map lookup, which is currently missing. Rework the code to take the irqdomain case into account and calculate the Linux interrupt number by a irqdomain lookup of the domain specific hardware interrupt number. [ tglx: Massage changelog. Reshuffle the logic and add a proper comment. ] Fixes: cfefd21 ("genirq: Add chip suspend and resume callbacks") Signed-off-by: Herve Codina <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected]
1 parent a0b0bad commit 5e7afb2

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

kernel/irq/generic-chip.c

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -548,21 +548,34 @@ EXPORT_SYMBOL_GPL(irq_setup_alt_chip);
548548
void irq_remove_generic_chip(struct irq_chip_generic *gc, u32 msk,
549549
unsigned int clr, unsigned int set)
550550
{
551-
unsigned int i = gc->irq_base;
551+
unsigned int i, virq;
552552

553553
raw_spin_lock(&gc_lock);
554554
list_del(&gc->list);
555555
raw_spin_unlock(&gc_lock);
556556

557-
for (; msk; msk >>= 1, i++) {
557+
for (i = 0; msk; msk >>= 1, i++) {
558558
if (!(msk & 0x01))
559559
continue;
560560

561+
/*
562+
* Interrupt domain based chips store the base hardware
563+
* interrupt number in gc::irq_base. Otherwise gc::irq_base
564+
* contains the base Linux interrupt number.
565+
*/
566+
if (gc->domain) {
567+
virq = irq_find_mapping(gc->domain, gc->irq_base + i);
568+
if (!virq)
569+
continue;
570+
} else {
571+
virq = gc->irq_base + i;
572+
}
573+
561574
/* Remove handler first. That will mask the irq line */
562-
irq_set_handler(i, NULL);
563-
irq_set_chip(i, &no_irq_chip);
564-
irq_set_chip_data(i, NULL);
565-
irq_modify_status(i, clr, set);
575+
irq_set_handler(virq, NULL);
576+
irq_set_chip(virq, &no_irq_chip);
577+
irq_set_chip_data(virq, NULL);
578+
irq_modify_status(virq, clr, set);
566579
}
567580
}
568581
EXPORT_SYMBOL_GPL(irq_remove_generic_chip);

0 commit comments

Comments
 (0)