Re: [PATCH] irq: fix the interrupt trigger type override issue

From: Thomas Gleixner
Date: Mon Sep 02 2024 - 03:34:30 EST


Richard!

On Mon, Sep 02 2024 at 11:17, Richard Clark wrote:

The subsystem prefix is 'irqdomain' not 'irq'

# git log --online $FILE

gives you a decent hint.

> In current implementation, the trigger type in 'flags' when calling request_irq
> will override the type value get from the firmware(dt/acpi node) if they are
> not consistent, and the overrided trigger type value will be retained by irq_data,
> consequently the type value get from the firmware will not match the retained one
> next time in case the virq is available.
>
> Thus below error message will be observed by the __2nd__ 'insmod' within the
> 'insmod - rmmod - insmod' operation sequence for the same device driver kernel
> module, in which request_irq(..., IRQ_TYPE_LEVEL_HIGH, ...) is used:
>
> irq: type mismatch, failed to map hwirq-182 for interrupt-controller!

How so?

1) insmod()
irq_create_fwspec_mapping(fwspec)
irq_domain_translate(fwspec, ... &type); <- Sets type to the FW value

virq = irq_find_mapping(domain, hwirq);
if (virq) {
// Path not taken
}

// Map interrupt
...

irqd_set_trigger_type(..., type);

2) rmmod()
tears down mapping

3) insmod()

Should be exactly the same as #1 because the previous mapping was
torn down by rmmod()

Even if the first mapping is not torn down by rmmod(), which is a bug in
itself, then the type is exactly the same as the firmware describes it, no?

So how exactly does that happen what you describe?

> The corresponding 'interrupts' property of that device node is:
> interrupts = <0 150 1>;
>
> This commit fixes the above issue by adding a new checker -
> irqd_trigger_type_was_set:

This commit is equaly redundant as 'This patch'

# git grep 'This patch' Documentation/process/

Also 'new checker' is not really a technical term.

Thanks,

tglx