Received: by 10.213.65.68 with SMTP id h4csp225979imn; Fri, 23 Mar 2018 03:19:54 -0700 (PDT) X-Google-Smtp-Source: AG47ELvTUq0VC1fTY5H17g32IzJGW6A73PM3fOluntaDmcHyVclIopyIKXFyiYDpw5e700gpanUr X-Received: by 10.98.93.26 with SMTP id r26mr23386869pfb.159.1521800394665; Fri, 23 Mar 2018 03:19:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521800394; cv=none; d=google.com; s=arc-20160816; b=tqfvCHM3CXhZt+CgDAS+bFSayxgTdWSGoiUPZtpFq8h3Csrh1wf2AqVczXlEq/9lSt Zmi6MJdVNnDENF0PXhFNnt2PTLhbvvx23Zj5YqRbCPuDy4GlvVEl0CpNn6MZ6x3gRU3I dvrG9HIhDs1NoiwdOgEkqnsO/K79OYKdAAlF53G+Jq91RXrrmI6rB6yJ4JUOntv5/cIx ll4KdmOxmwjZzuugc5U0rOA0jkp9oQnISDZf8dcdj6J5fCVcAAr3ex/wTBoiHY6SPuhh FRT28eEfgxKF01KBdXeFyfepgKIAKy3X/YI4GX1NghWf88xz3VSIPLLTrapEFPLmKG6H z4Ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=eeHu/SaUIiqDsfRXW7m2Yk8mcqsCtOcDN38FFjRjNR0=; b=ZdjuUPPzM3VTxYkKjxnEQXhfOJDEguP4tQuxqAVusHLVYLFVpnVMiD2CKGeEKS9FBR bNw9AKArbl9oYkEou22Jjg+8FCh7oraj53e8gRAZPzPJ4iBe2iySIu6BJJvXsazOBhRR /x8KGQiYVcEr3B7qq/feNjGUsqra3M0fvEubR+Ok0CQ6SEdh8dhWQjo67A/aZ6ahePFX 9mpBCQwQOMU129Fef8TpSi5jMWEK2n5cUxRl35H1ZwCCgvizaNBFZC2ZSDfsQD+MoUS1 aE8vcE42IJ5xu4aG0vfsLk//wdUFluyry+s+v7yUCUBmw4J9MwmbHvk6R/g++t4heMch jXrA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h9si6569434pfh.48.2018.03.23.03.19.40; Fri, 23 Mar 2018 03:19: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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756114AbeCWKSZ (ORCPT + 99 others); Fri, 23 Mar 2018 06:18:25 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:47594 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756087AbeCWKSV (ORCPT ); Fri, 23 Mar 2018 06:18:21 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 106DBF2C; Fri, 23 Mar 2018 10:18:20 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thomas Gleixner , Hans de Goede , Marc Zyngier , Sasha Levin Subject: [PATCH 3.18 06/47] genirq: Use irqd_get_trigger_type to compare the trigger type for shared IRQs Date: Fri, 23 Mar 2018 10:54:57 +0100 Message-Id: <20180323094248.385615324@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180323094248.117679641@linuxfoundation.org> References: <20180323094248.117679641@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.18-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); 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 @@ -1058,8 +1058,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;