* [RFC] Fix shared irq trigger-flags conflict when old irqaction uses IRQF_TRIGGER_NONE
@ 2017-04-09 19:59 Hans de Goede
2017-04-10 10:13 ` Marc Zyngier
0 siblings, 1 reply; 4+ messages in thread
From: Hans de Goede @ 2017-04-09 19:59 UTC (permalink / raw)
To: Thomas Gleixner; +Cc: Hans de Goede, linux-acpi, x86, linux-kernel
While writing a driver for the INT0002 ACPI device found on Intel
Bay and Cherry Trail devices I hit the following error:
"genirq: Flags mismatch irq 9. 00000084 (INT0002) vs. 00000080 (acpi)"
This is caused by drivers/acpi/osl.c first doing:
request_irq(irq, acpi_irq, IRQF_SHARED, "acpi", acpi_irq)
While the irqdata for the irq contains no trigger flags, resulting
in an irqaction with IRQF_TRIGGER_NONE.
And then the INT0002 driver I'm working on calling platform_get_irq
which does: irqd_set_trigger_type(irqd, r->flags & IORESOURCE_BITS);
And then request_irq(irq, ..., IRQF_SHARED, ...) on the irq returned
by platform_get_irq causes the error quoted above.
Arguably the genirq code should not hit the shared irq trigger-flags
mismatch code if the old irqaction has IRQF_TRIGGER_NONE as flags.
This patch is an attempt at fixing this, but I'm not sure it is the
right fix, hence it RFC status.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
kernel/irq/manage.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index a4afe5c..24e5eef 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -1212,8 +1212,13 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new)
* set the trigger type must match. Also all must
* agree on ONESHOT.
*/
+ unsigned int old_msk = old->flags & IRQF_TRIGGER_MASK;
+
+ if (!old_msk)
+ old_msk = irqd_get_trigger_type(&desc->irq_data);
+
if (!((old->flags & new->flags) & IRQF_SHARED) ||
- ((old->flags ^ new->flags) & IRQF_TRIGGER_MASK) ||
+ ((old_msk ^ new->flags) & IRQF_TRIGGER_MASK) ||
((old->flags ^ new->flags) & IRQF_ONESHOT))
goto mismatch;
--
2.9.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [RFC] Fix shared irq trigger-flags conflict when old irqaction uses IRQF_TRIGGER_NONE
2017-04-09 19:59 [RFC] Fix shared irq trigger-flags conflict when old irqaction uses IRQF_TRIGGER_NONE Hans de Goede
@ 2017-04-10 10:13 ` Marc Zyngier
2017-04-10 11:04 ` Hans de Goede
0 siblings, 1 reply; 4+ messages in thread
From: Marc Zyngier @ 2017-04-10 10:13 UTC (permalink / raw)
To: Hans de Goede, Thomas Gleixner; +Cc: linux-acpi, x86, linux-kernel
Hi Hans,
On 09/04/17 20:59, Hans de Goede wrote:
> While writing a driver for the INT0002 ACPI device found on Intel
> Bay and Cherry Trail devices I hit the following error:
>
> "genirq: Flags mismatch irq 9. 00000084 (INT0002) vs. 00000080 (acpi)"
>
> This is caused by drivers/acpi/osl.c first doing:
>
> request_irq(irq, acpi_irq, IRQF_SHARED, "acpi", acpi_irq)
>
> While the irqdata for the irq contains no trigger flags, resulting
> in an irqaction with IRQF_TRIGGER_NONE.
>
> And then the INT0002 driver I'm working on calling platform_get_irq
> which does: irqd_set_trigger_type(irqd, r->flags & IORESOURCE_BITS);
>
> And then request_irq(irq, ..., IRQF_SHARED, ...) on the irq returned
> by platform_get_irq causes the error quoted above.
>
> Arguably the genirq code should not hit the shared irq trigger-flags
> mismatch code if the old irqaction has IRQF_TRIGGER_NONE as flags.
>
> This patch is an attempt at fixing this, but I'm not sure it is the
> right fix, hence it RFC status.
>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
> kernel/irq/manage.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
> index a4afe5c..24e5eef 100644
> --- a/kernel/irq/manage.c
> +++ b/kernel/irq/manage.c
> @@ -1212,8 +1212,13 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new)
> * set the trigger type must match. Also all must
> * agree on ONESHOT.
> */
> + unsigned int old_msk = old->flags & IRQF_TRIGGER_MASK;
> +
> + if (!old_msk)
> + old_msk = irqd_get_trigger_type(&desc->irq_data);
> +
> if (!((old->flags & new->flags) & IRQF_SHARED) ||
> - ((old->flags ^ new->flags) & IRQF_TRIGGER_MASK) ||
> + ((old_msk ^ new->flags) & IRQF_TRIGGER_MASK) ||
> ((old->flags ^ new->flags) & IRQF_ONESHOT))
> goto mismatch;
>
>
I'm afraid you're just papering over the issue here, as you leave the
"old" descriptor in an inconsistent state w.r.t. the "new" descriptor.
My view is that the old irq_desc should be "upgraded" to the new trigger
configuration, because they are sharing a line and must have compatible
behaviours. NONE is effectively a wildcard, and the second interrupt
request should turn this wildcard into the real thing.
The opposite case also exists (request a LEVEL interrupt first, then a
NONE), and should be resolved the same way (NONE becomes LEVEL).
Thoughts?
M.
--
Jazz is not dead. It just smells funny...
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC] Fix shared irq trigger-flags conflict when old irqaction uses IRQF_TRIGGER_NONE
2017-04-10 10:13 ` Marc Zyngier
@ 2017-04-10 11:04 ` Hans de Goede
2017-04-14 9:34 ` Thomas Gleixner
0 siblings, 1 reply; 4+ messages in thread
From: Hans de Goede @ 2017-04-10 11:04 UTC (permalink / raw)
To: Marc Zyngier, Thomas Gleixner; +Cc: linux-acpi, x86, linux-kernel
HI,
On 10-04-17 12:13, Marc Zyngier wrote:
> Hi Hans,
>
> On 09/04/17 20:59, Hans de Goede wrote:
>> While writing a driver for the INT0002 ACPI device found on Intel
>> Bay and Cherry Trail devices I hit the following error:
>>
>> "genirq: Flags mismatch irq 9. 00000084 (INT0002) vs. 00000080 (acpi)"
>>
>> This is caused by drivers/acpi/osl.c first doing:
>>
>> request_irq(irq, acpi_irq, IRQF_SHARED, "acpi", acpi_irq)
>>
>> While the irqdata for the irq contains no trigger flags, resulting
>> in an irqaction with IRQF_TRIGGER_NONE.
>>
>> And then the INT0002 driver I'm working on calling platform_get_irq
>> which does: irqd_set_trigger_type(irqd, r->flags & IORESOURCE_BITS);
>>
>> And then request_irq(irq, ..., IRQF_SHARED, ...) on the irq returned
>> by platform_get_irq causes the error quoted above.
>>
>> Arguably the genirq code should not hit the shared irq trigger-flags
>> mismatch code if the old irqaction has IRQF_TRIGGER_NONE as flags.
>>
>> This patch is an attempt at fixing this, but I'm not sure it is the
>> right fix, hence it RFC status.
>>
>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>> ---
>> kernel/irq/manage.c | 7 ++++++-
>> 1 file changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
>> index a4afe5c..24e5eef 100644
>> --- a/kernel/irq/manage.c
>> +++ b/kernel/irq/manage.c
>> @@ -1212,8 +1212,13 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new)
>> * set the trigger type must match. Also all must
>> * agree on ONESHOT.
>> */
>> + unsigned int old_msk = old->flags & IRQF_TRIGGER_MASK;
>> +
>> + if (!old_msk)
>> + old_msk = irqd_get_trigger_type(&desc->irq_data);
>> +
>> if (!((old->flags & new->flags) & IRQF_SHARED) ||
>> - ((old->flags ^ new->flags) & IRQF_TRIGGER_MASK) ||
>> + ((old_msk ^ new->flags) & IRQF_TRIGGER_MASK) ||
>> ((old->flags ^ new->flags) & IRQF_ONESHOT))
>> goto mismatch;
>>
>>
>
> I'm afraid you're just papering over the issue here, as you leave the
> "old" descriptor in an inconsistent state w.r.t. the "new" descriptor.
>
> My view is that the old irq_desc should be "upgraded" to the new trigger
> configuration, because they are sharing a line and must have compatible
> behaviours.
There is no old irq_desc only an old ircaction, but yes that can easily
be updated to reflect the mask from the irq_data, or maybe we should not use
the oldaction for the trigger_mask bits at all and instead use
the trigger_mask from the irq_data as done in:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/kernel/irq/manage.c?id=7ee7e87dfb158e79019ea1d5ea1b0e6f2bc93ee4
For a different code path ? Thomas?
> NONE is effectively a wildcard, and the second interrupt
> request should turn this wildcard into the real thing.
>
> The opposite case also exists (request a LEVEL interrupt first, then a
> NONE), and should be resolved the same way (NONE becomes LEVEL).
The 2nd order of requesting irqs will already work because of:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/kernel/irq/manage.c?id=4b357daed698c95d6b5eacc1c3c4afa206071ba2
Where the new_action trigger_mask gets filled with the triger_mask
from the irq_data, which is a further hint that looking at
irqd_get_trigger_type(&desc->irq_data) rather then at
(old->flags IRQF_TRIGGER_MASK) is probably the right fix.
Note btw that 4b357daed698 is (part of) what is breaking things for
my use-case, I request the irq with IRQF_TRIGGER_NONE but
4b357daed698 modifies that before comparing the new trigger flags
to the old.
Regards,
Hans
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC] Fix shared irq trigger-flags conflict when old irqaction uses IRQF_TRIGGER_NONE
2017-04-10 11:04 ` Hans de Goede
@ 2017-04-14 9:34 ` Thomas Gleixner
0 siblings, 0 replies; 4+ messages in thread
From: Thomas Gleixner @ 2017-04-14 9:34 UTC (permalink / raw)
To: Hans de Goede; +Cc: Marc Zyngier, linux-acpi, x86, linux-kernel
On Mon, 10 Apr 2017, Hans de Goede wrote:
> Where the new_action trigger_mask gets filled with the triger_mask
> from the irq_data, which is a further hint that looking at
> irqd_get_trigger_type(&desc->irq_data) rather then at
> (old->flags IRQF_TRIGGER_MASK) is probably the right fix.
>
> Note btw that 4b357daed698 is (part of) what is breaking things for
> my use-case, I request the irq with IRQF_TRIGGER_NONE but
> 4b357daed698 modifies that before comparing the new trigger flags
> to the old.
The issue here is, that at the time of the first setup_irq() the trigger
type in irq_data is NONE. As a consequence the following is a NOOP:
if (!new->trigger)
new->flags |= get_type(irqdata);
Now the irq is started up for the first time and then the actual trigger
type gets established, but that's to late to fix up new->flags.
So yes, we should change the logic for the shared case to:
if (old) {
oldtype = get_type(irqdata);
if (oldtype != newtype)
goto mismatch;
That should cover all cases.
Thanks,
tglx
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-04-14 9:34 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-09 19:59 [RFC] Fix shared irq trigger-flags conflict when old irqaction uses IRQF_TRIGGER_NONE Hans de Goede
2017-04-10 10:13 ` Marc Zyngier
2017-04-10 11:04 ` Hans de Goede
2017-04-14 9:34 ` Thomas Gleixner
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.