Received: by 10.213.65.68 with SMTP id h4csp216316imn; Fri, 23 Mar 2018 03:06:26 -0700 (PDT) X-Google-Smtp-Source: AG47ELt0Nm6RSOZPT41CCCd0p0UnUva2eM+rrKeFj77yNG2uDA10B51bP1JqpzPxNSxNRUME83i0 X-Received: by 10.101.101.139 with SMTP id u11mr14493142pgv.436.1521799586338; Fri, 23 Mar 2018 03:06:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521799586; cv=none; d=google.com; s=arc-20160816; b=qv8wozLDrspQN+b7Jx0ApPhXGk370ejQcAsjCLxmdYgTGUAZA0gDFSppsuMy4bIhLW oQljH3Xo+Mdh9Mg047eF9PVm0g3ByGWaR0wdJwqCh+OeF1zZvxvmM4nwarGAfcwKdFhU Ev+b8oinxjqK2f9tj79iRkBhQx9q8xSFkR0Raqw7iD7OdOi0gFqTd+uNcpOLQZumv8k8 sjVqTpgqMHaKiI/LtR52faOz3ZL2yrs58KRXZ0xmvC+rN+6wWXKwURuX4emVTWa1hIkQ +NLMAaSgbH8KlCKR1ZdGFymZItBrfYqoSxZAlMSk9zYStjQtpxHDukJvRnDbSFAKObYN mQLQ== 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=VD101qZEauVY2zUFJnRD7TI6jNsX+ZAd45nhdpnjqXY=; b=m303emNua0z95h3h+/Y4QtjpJrnZcC4n8gxfcPKuE4zcvHYWH1Qpk0ZzT3eTzImmwn 3FHSNBFZiOZkFMGvNB13rmBtS1Jcb0D3KXRiMvPTQp9X8sgNax1GIEyf+xuZ2n6ospOk DU4FWKmAq3l5qPyG9//HfVIk35DOXJ4RjbtN4RYcwiP3hOjF4xv4ZRAwCKCkzCONCoX8 4RO2qWqXB6vigpWmVqESLBj1kZcyHASadDyeKUJa/1ZCOpcDQZwdgn16NVhQZbdAg++V bHcyA+qNRPQswS4PN6Z3uxRIxEM+hwau3EmW1o13vX7182T1DR3KzqPAkVG0tET1ByHl VqBA== 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 x4si5683129pgv.315.2018.03.23.03.06.11; Fri, 23 Mar 2018 03:06:26 -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 S1754932AbeCWKFR (ORCPT + 99 others); Fri, 23 Mar 2018 06:05:17 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:39566 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754917AbeCWKFP (ORCPT ); Fri, 23 Mar 2018 06:05:15 -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 51E8613FF; Fri, 23 Mar 2018 10:05:14 +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 4.9 019/177] genirq: Use irqd_get_trigger_type to compare the trigger type for shared IRQs Date: Fri, 23 Mar 2018 10:52:27 +0100 Message-Id: <20180323094206.041734272@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180323094205.090519271@linuxfoundation.org> References: <20180323094205.090519271@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 4.9-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 @@ -1210,8 +1210,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;