From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753940AbdDONbH (ORCPT ); Sat, 15 Apr 2017 09:31:07 -0400 Received: from foss.arm.com ([217.140.101.70]:40230 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751582AbdDONbE (ORCPT ); Sat, 15 Apr 2017 09:31:04 -0400 From: Marc Zyngier To: Hans de Goede Cc: Thomas Gleixner , , Subject: Re: [PATCH] genirq: Use irqd_get_trigger_type to compare the trigger type for shared IRQs In-Reply-To: <20170415100831.17073-1-hdegoede@redhat.com> (Hans de Goede's message of "Sat, 15 Apr 2017 12:08:31 +0200") Organization: ARM Ltd References: <20170415100831.17073-1-hdegoede@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) Date: Sat, 15 Apr 2017 14:30:58 +0100 Message-ID: <87h91ppzl9.fsf@on-the-bus.cambridge.arm.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Apr 15 2017 at 11:08:31 am BST, Hans de Goede wrote: > When requesting a shared irq with IRQF_TRIGGER_NONE then the irqaction > flags get filled with the trigger type from the irq_data: > > if (!(new->flags & IRQF_TRIGGER_MASK)) > new->flags |= irqd_get_trigger_type(&desc->irq_data); > > On the first setup_irq() the trigger type in irq_data is NONE when the > above code executes, then the irq is started up for the first time and > then the actual trigger type gets established, but that's too late to fix > up new->flags. > > When then a second user of the irq requests the irq with IRQF_TRIGGER_NONE > its irqaction's triggertype gets set to the actual trigger type and the > following check fails: > > if (!((old->flags ^ new->flags) & IRQF_TRIGGER_MASK)) > > Resulting in the request_irq failing with -EBUSY even though both > users requested the irq with IRQF_SHARED | IRQF_TRIGGER_NONE > > This commit fixes this by comparing the new irqaction's trigger type > to the trigger type stored in the irq_data which correctly reflects > the actual trigger type being used for the irq. > > Suggested-by: Thomas Gleixner > Signed-off-by: Hans de Goede > --- > kernel/irq/manage.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c > index a4afe5c..d63e91f 100644 > --- a/kernel/irq/manage.c > +++ b/kernel/irq/manage.c > @@ -1212,8 +1212,10 @@ __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 oldtype = irqd_get_trigger_type(&desc->irq_data); > + > if (!((old->flags & new->flags) & IRQF_SHARED) || > - ((old->flags ^ new->flags) & IRQF_TRIGGER_MASK) || > + (oldtype != (new->flags & IRQF_TRIGGER_MASK)) || > ((old->flags ^ new->flags) & IRQF_ONESHOT)) > goto mismatch; Looks sensible to me. Acked-by: Marc Zyngier M. -- Jazz is not dead, it just smell funny.