Received: by 10.213.65.68 with SMTP id h4csp1804036imn; Thu, 29 Mar 2018 11:20:08 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/lrGUouUlH3Ms2GLqKqEjLWor+4JRwZ66agQXex+m29MHOZaPKvo2fAAj1G60FB+Rggvc/ X-Received: by 10.99.97.143 with SMTP id v137mr6148835pgb.175.1522347607901; Thu, 29 Mar 2018 11:20:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522347607; cv=none; d=google.com; s=arc-20160816; b=QCbgIl0kbvJ8bXu/kNRhHB4f6gQUvfCGpfKQSiTZZsgKyKNPFk6b5FyVGuVWbDDBhE aV6MqK9m9u2DvyjuopkU8jlJ7LbZ3mlLxx+m/lv+jcEki9gQBtd8X6ZROyOtLPeOe00o dmyYzZ8DFhjT0E3ZtG9PA+EIQewNjOgxIGWXgG6K7LFy/nmZ1bdunFoTZ5Td3bBWI3aN M0S7nhYIRRuli97LMd9wok0E3LKe4WwRGPb+SogKALOOp0oQjFZ+5P5pop329ijn931H jyFqgO/1/zPn6NKjJr0y69Zs3ijqRnLrH0+H1zOrLbzLNAko8VHhKXU82jjIvaV17O4A GBdQ== 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=3I+yHrf+CPCpqQ4y6behOmiRZal4KpLvAy3mURHlHyc=; b=YrKYleBlOSRBClTprUkI6OH/0QkGvIj4XYS56qCbTEg3NzOFujHcLZBeZY7dlB9wAR xTUMtLNr7gxLTnv5M7+/OuyxPYyytH/7YoXXvGuC34rkfb+nz7ktTVLGU+zL4YSqIgbh 7kVc5qbCUetyW0SM4HHKa4//QSHUNHS9dXPh3ymRILGSJRzd2Q+JOGIdySjwTeIFbL/2 z8FUIyY2cmkvukiSl0YN7PoGhaaHXz9HAxfA8EQUZ/i5uNn4s03XsWvMunhSKRwi7E+A 89KbBsxuKwhB3djv9gwXzaU04Ue+eHWxNz+5Fhrn4BQdoaCAq/tjg6Bi3ciBMBZBdhje rOjw== 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 z10si4292581pgp.190.2018.03.29.11.19.53; Thu, 29 Mar 2018 11:20:07 -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 S1753812AbeC2SGq (ORCPT + 99 others); Thu, 29 Mar 2018 14:06:46 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:59736 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752862AbeC2SGm (ORCPT ); Thu, 29 Mar 2018 14:06:42 -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 188CF93E; Thu, 29 Mar 2018 18:06:41 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marc Zyngier , Guenter Roeck Subject: [PATCH 4.9 02/28] genirq: Track whether the trigger type has been set Date: Thu, 29 Mar 2018 20:00:21 +0200 Message-Id: <20180329175733.738322674@linuxfoundation.org> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180329175733.447823703@linuxfoundation.org> References: <20180329175733.447823703@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: Marc Zyngier commit 4f8413a3a799c958f7a10a6310a451e6b8aef5ad upstream. When requesting a shared interrupt, we assume that the firmware support code (DT or ACPI) has called irqd_set_trigger_type already, so that we can retrieve it and check that the requester is being reasonnable. Unfortunately, we still have non-DT, non-ACPI systems around, and these guys won't call irqd_set_trigger_type before requesting the interrupt. The consequence is that we fail the request that would have worked before. We can either chase all these use cases (boring), or address it in core code (easier). Let's have a per-irq_desc flag that indicates whether irqd_set_trigger_type has been called, and let's just check it when checking for a shared interrupt. If it hasn't been set, just take whatever the interrupt requester asks. Fixes: 382bd4de6182 ("genirq: Use irqd_get_trigger_type to compare the trigger type for shared IRQs") Cc: stable@vger.kernel.org Reported-and-tested-by: Petr Cvek Signed-off-by: Marc Zyngier Cc: Guenter Roeck Signed-off-by: Greg Kroah-Hartman --- include/linux/irq.h | 11 ++++++++++- kernel/irq/manage.c | 13 ++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -199,6 +199,7 @@ struct irq_data { * IRQD_WAKEUP_ARMED - Wakeup mode armed * IRQD_FORWARDED_TO_VCPU - The interrupt is forwarded to a VCPU * IRQD_AFFINITY_MANAGED - Affinity is auto-managed by the kernel + * IRQD_DEFAULT_TRIGGER_SET - Expected trigger already been set */ enum { IRQD_TRIGGER_MASK = 0xf, @@ -216,6 +217,7 @@ enum { IRQD_WAKEUP_ARMED = (1 << 19), IRQD_FORWARDED_TO_VCPU = (1 << 20), IRQD_AFFINITY_MANAGED = (1 << 21), + IRQD_DEFAULT_TRIGGER_SET = (1 << 25), }; #define __irqd_to_state(d) ACCESS_PRIVATE((d)->common, state_use_accessors) @@ -245,18 +247,25 @@ static inline void irqd_mark_affinity_wa __irqd_to_state(d) |= IRQD_AFFINITY_SET; } +static inline bool irqd_trigger_type_was_set(struct irq_data *d) +{ + return __irqd_to_state(d) & IRQD_DEFAULT_TRIGGER_SET; +} + static inline u32 irqd_get_trigger_type(struct irq_data *d) { return __irqd_to_state(d) & IRQD_TRIGGER_MASK; } /* - * Must only be called inside irq_chip.irq_set_type() functions. + * Must only be called inside irq_chip.irq_set_type() functions or + * from the DT/ACPI setup code. */ static inline void irqd_set_trigger_type(struct irq_data *d, u32 type) { __irqd_to_state(d) &= ~IRQD_TRIGGER_MASK; __irqd_to_state(d) |= type & IRQD_TRIGGER_MASK; + __irqd_to_state(d) |= IRQD_DEFAULT_TRIGGER_SET; } static inline bool irqd_is_level_type(struct irq_data *d) --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -1210,7 +1210,18 @@ __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); + unsigned int oldtype; + + /* + * If nobody did set the configuration before, inherit + * the one provided by the requester. + */ + if (irqd_trigger_type_was_set(&desc->irq_data)) { + oldtype = irqd_get_trigger_type(&desc->irq_data); + } else { + oldtype = new->flags & IRQF_TRIGGER_MASK; + irqd_set_trigger_type(&desc->irq_data, oldtype); + } if (!((old->flags & new->flags) & IRQF_SHARED) || (oldtype != (new->flags & IRQF_TRIGGER_MASK)) ||