Received: by 10.213.65.68 with SMTP id h4csp3573557imn; Tue, 3 Apr 2018 07:18:54 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+5eEPYVLfXlM7gNrOB+4sUP2pXjbU0vEScLeVxuDcaLhXr7FwYF6ArNXURzzgNcZnj+rUY X-Received: by 10.98.7.83 with SMTP id b80mr10794292pfd.133.1522765134950; Tue, 03 Apr 2018 07:18:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522765134; cv=none; d=google.com; s=arc-20160816; b=LtczdlZV/2UUz61rCN1ukJ/mNn6a90LN3qVw7LobFWIdZyr8fXdNfKMsd6LKATOV3w gFNx5Bl9yYgrv7Ql+edwU51QXio6X28b8tRdfXi221GaQX808aC9D5eOyVyig8mXtxWl PxUbpiSPTH3hb598d2yiIocq0TAG6pi1+Mxg+8PV0iPd4RS5ZYJidgp+yh5v3wrDQNuZ DgULx7AfXJlindxIs1eAyqCNhQaxP2MGPYUJ12iJzVpbiLiQJfyUG1nX3d6u6Ezi1W/w /Gla2ToZwdxKiKVKyKudQ77EyTLd9iiG5zclxLZsQ9XMnT7YrjwJXUog3i6PtXiY13F1 BNHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:date:cc:to:from:subject :message-id:arc-authentication-results; bh=i4oG3/e+b5AkvZdvzcSjtjXBeD+h+s4mlxER4B+qeRA=; b=L5vmzka/KElSUCvCltTl+HA59Ag+hF5YNOnuFqNwDR0i54kVTsc6oNQb3NC2929zsF T+0WObPO0IAr2mO8+kG0Ns3c5bSsYN1PFhvzvomyNszVVKxKf8vMBQoxeSymQXmzKxbf psL4Orhb6EypWZtWJqFD02pwxk40fEmbUVl3nLgrLG7pYWyZdPTLT6KMDyOYdUIf2P7x Yr3J2QRsypGXc9F7rvP8eq6B7ksfS1G1VZjq3W+292MCV3RJni9WU7T8v1wyp4NLMEdS HTaFtrAftF9bNHMMIYm0AayRUZAk74cPN1QUV8swdkNBoakzsHIQbQwQm6t6M937A8gM FHKg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=codethink.co.uk Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x1si427575pgp.89.2018.04.03.07.18.40; Tue, 03 Apr 2018 07:18:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=codethink.co.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751397AbeDCORU (ORCPT + 99 others); Tue, 3 Apr 2018 10:17:20 -0400 Received: from imap1.codethink.co.uk ([176.9.8.82]:55454 "EHLO imap1.codethink.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751270AbeDCORT (ORCPT ); Tue, 3 Apr 2018 10:17:19 -0400 Received: from 167-98-27-229.cust-167.exponential-e.net ([167.98.27.229] helo=xylophone) by imap1.codethink.co.uk with esmtpsa (Exim 4.84_2 #1 (Debian)) id 1f3MkP-0007cT-E3; Tue, 03 Apr 2018 15:17:17 +0100 Message-ID: <1522765036.2654.99.camel@codethink.co.uk> Subject: Re: [PATCH 4.4 15/97] genirq: Use irqd_get_trigger_type to compare the trigger type for shared IRQs From: Ben Hutchings To: Greg Kroah-Hartman , linux-kernel@vger.kernel.org Cc: stable@vger.kernel.org, Thomas Gleixner , Hans de Goede , Marc Zyngier , Sasha Levin Date: Tue, 03 Apr 2018 15:17:16 +0100 In-Reply-To: <20180323094158.346866234@linuxfoundation.org> References: <20180323094157.535925724@linuxfoundation.org> <20180323094158.346866234@linuxfoundation.org> Organization: Codethink Ltd. Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.22.6-1+deb9u1 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2018-03-23 at 10:54 +0100, Greg Kroah-Hartman wrote: > 4.4-stable review patch.  If anyone has any objections, please let me know. > > ------------------ > > From: Hans de Goede > > > [ Upstream commit 382bd4de61827dbaaf5fb4fb7b1f4be4a86505e7 ] > > 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); The code above was added to __setup_irq() in 4.8, so I don't think this fix is needed in 3.18 or 4.4; and I suspect it might cause a regression there. Ben. > 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 > > Fix 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 > Acked-by: Marc Zyngier > Link: http://lkml.kernel.org/r/20170415100831.17073-1-hdegoede@redhat.com > Signed-off-by: Thomas Gleixner > Signed-off-by: Sasha Levin > Signed-off-by: Greg Kroah-Hartman > --- >  kernel/irq/manage.c |    4 +++- >  1 file changed, 3 insertions(+), 1 deletion(-) > > --- a/kernel/irq/manage.c > +++ b/kernel/irq/manage.c > @@ -1189,8 +1189,10 @@ __setup_irq(unsigned int irq, struct irq >    * 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; >   -- Ben Hutchings Software Developer, Codethink Ltd.