Received: by 10.213.65.68 with SMTP id h4csp1794572imn; Thu, 29 Mar 2018 11:09:09 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/n+/4865URgmYLLInWVi0C+6anan7l9oI5O7nWvswTy8f5Vb62bgsg2Wwvm12L6oftKSou X-Received: by 2002:a17:902:20eb:: with SMTP id v40-v6mr9463306plg.277.1522346949233; Thu, 29 Mar 2018 11:09:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522346949; cv=none; d=google.com; s=arc-20160816; b=ss/gSReBcdIqdoYpCJqQYHqvrghaj9x1ocOp/e6Kbfh5YdcZJgLHxfGRuJiHjf9C6d HMiksr89zIE8q6aFm6QMAYuNvfRTbuaM6HcOz2ctDjrbhc9yUJWWge1js1W5k43Q0j6J QN69+qXBB+Uti+i5m/v/89f9oiI3C8LodCvhMR8GAknXZSSkPFf6vKE2LteHGpgZq0EA NA1S/jwClWS+48OooAUo7PlIqfiuC2ECcKo7J7stxECJUBtAEKoKhO3b33SYEaU3gSBa M3X3Ne37NRQdOCrGFTEwqaGNX042GbK55c1r2dAvCEHj2qWuRLNO1FcbF+ojE8N/DAFS KTUQ== 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=k/cq8lIz+kGARkAVE3c9g1II+1SHl6eze3i+QKhCGXA=; b=NMgahiTwqwUooHyLpFzkPYrQh92kUstPGCL5rL570aLRNsO4bBytAC85tMtJsLHmAF 0Cbp7SBarYg71YGX2WgQtxkfZxcz5C+TBZMuid08OPFU9gab4lrnCvZNLw46/Q9vU+0N B6dd86lUWjw+Tmzby0X/o+xMe1hyfqBKJE5wBwJc6AW/OIyBDsYTimnYCDsb3stx3sWx +IhvJjau1kMgn7EKgwZ3vzTx9czdvUmqCRfjxsxo0YvG6jm9L3LJy/iCa0hVwI4wD2WR gm7u1lC/TKxqh05U1r09R7BJwMx1zZxPvJ+Da7PhcbkAazbgmf1BX6DtvS4wj9K6IkB5 Mm8w== 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 h70si4767118pfc.269.2018.03.29.11.08.54; Thu, 29 Mar 2018 11:09:09 -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 S1754134AbeC2SHs (ORCPT + 99 others); Thu, 29 Mar 2018 14:07:48 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:60134 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754076AbeC2SHp (ORCPT ); Thu, 29 Mar 2018 14:07:45 -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 5EEA0B00; Thu, 29 Mar 2018 18:07:44 +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.4 02/20] genirq: Track whether the trigger type has been set Date: Thu, 29 Mar 2018 20:00:38 +0200 Message-Id: <20180329175741.988003717@linuxfoundation.org> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180329175741.886181131@linuxfoundation.org> References: <20180329175741.886181131@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: 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 @@ -191,6 +191,7 @@ struct irq_data { * IRQD_IRQ_INPROGRESS - In progress state of the interrupt * IRQD_WAKEUP_ARMED - Wakeup mode armed * IRQD_FORWARDED_TO_VCPU - The interrupt is forwarded to a VCPU + * IRQD_DEFAULT_TRIGGER_SET - Expected trigger already been set */ enum { IRQD_TRIGGER_MASK = 0xf, @@ -206,6 +207,7 @@ enum { IRQD_IRQ_INPROGRESS = (1 << 18), IRQD_WAKEUP_ARMED = (1 << 19), IRQD_FORWARDED_TO_VCPU = (1 << 20), + IRQD_DEFAULT_TRIGGER_SET = (1 << 25), }; #define __irqd_to_state(d) ((d)->common->state_use_accessors) @@ -235,18 +237,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 @@ -1189,7 +1189,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)) ||