Received: by 10.213.65.68 with SMTP id h4csp249986imn; Fri, 23 Mar 2018 03:56:38 -0700 (PDT) X-Google-Smtp-Source: AG47ELsO6w9YC9QEInMRNLrd4hQXIENr9n+HHH6AgCZrlYNRcTe66HgvKbEuBCf8M0utgpgBHVzI X-Received: by 2002:a17:902:b691:: with SMTP id c17-v6mr29075650pls.308.1521802598810; Fri, 23 Mar 2018 03:56:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521802598; cv=none; d=google.com; s=arc-20160816; b=ILfDnJ7YBebLrU5ASvNEZjymOgQO1tVod+Klnf9IH9euzQcqPvCa5b5bEzdiRSIttv fAWaz5g+Ljh2g49PFgPV6WThrnmOHF3U5rJkOTUkJRRY91IUh7irRYyOcOBxFfF01yWi bQIOSbjCg5NNhMoc/KwfNPUUZintGXSJ9w7Y98GTejw+5b1qxZx3NeWtqinzsFFGuBLF 3ibK/jbyv72ASjgjRzB9y6HOaVtp5GEbAzovJKWzoNIX3KP2r+a8jEADMDQS74fqqpiv NlS6bXa6Hzi1liXm5Ebb/GfYbQfOwXZox7iMxkGiAmBie3Ey4lBGhw81mES0tA8RcrtP BzEA== 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=DiKYlXPTSvkBsA4bPRGOLoM6ABdwZ4g1rUb5n0CB0yM=; b=ZZRMkfeMTtkUXtnxWfk6/pEYOL1HEtO6TeGF8iPgTisMw/E+BGsdywWBq4F/DbMhZs HLa2jcb22dgNAAGhv8N3pkdbsaRQPuxY+04MMy9LX+46dI3RJjB5GvZkZrsPvNtuNjtz Vt+sbi4vZkq3UTDd+oQGyKz4PCm1qO7NFDbVWMxrlkRwPOmMzq/gIGXVNbMbuHF9H9br Pal7Wt5L1Nq17u1l6P3cGUJgX/V+jy8DxX2AnUGXp+FMtD5Ir85t2sriujmDJOh4qFPb H7uPdEzmNZxwA2tDet1wYONWPDwH9fi+QNcLUUiVGk7TgZkwNyIama945pk3EOPhfSC2 JBew== 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 bc5-v6si8028853plb.506.2018.03.23.03.56.24; Fri, 23 Mar 2018 03:56:38 -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 S1755102AbeCWKzg (ORCPT + 99 others); Fri, 23 Mar 2018 06:55:36 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:44730 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755820AbeCWKNQ (ORCPT ); Fri, 23 Mar 2018 06:13:16 -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 0761E11E4; Fri, 23 Mar 2018 10:13:15 +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.4 15/97] genirq: Use irqd_get_trigger_type to compare the trigger type for shared IRQs Date: Fri, 23 Mar 2018 10:54:02 +0100 Message-Id: <20180323094158.346866234@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180323094157.535925724@linuxfoundation.org> References: <20180323094157.535925724@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.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); 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;