From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751305AbdFDMus (ORCPT ); Sun, 4 Jun 2017 08:50:48 -0400 Received: from terminus.zytor.com ([65.50.211.136]:47707 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751139AbdFDMuk (ORCPT ); Sun, 4 Jun 2017 08:50:40 -0400 Date: Sun, 4 Jun 2017 05:48:27 -0700 From: tip-bot for Thomas Gleixner Message-ID: Cc: marc.zyngier@arm.com, tglx@linutronix.de, linux-kernel@vger.kernel.org, jeffy.chen@rock-chips.com, hpa@zytor.com, mingo@kernel.org, briannorris@chromium.org Reply-To: jeffy.chen@rock-chips.com, hpa@zytor.com, mingo@kernel.org, briannorris@chromium.org, marc.zyngier@arm.com, tglx@linutronix.de, linux-kernel@vger.kernel.org In-Reply-To: <20170531100212.210682135@linutronix.de> References: <20170531100212.210682135@linutronix.de> To: linux-tip-commits@vger.kernel.org Subject: [tip:irq/core] genirq: Warn when IRQ_NOAUTOEN is used with shared interrupts Git-Commit-ID: 04c848d398797a626608ff48804d809ae6687163 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 04c848d398797a626608ff48804d809ae6687163 Gitweb: http://git.kernel.org/tip/04c848d398797a626608ff48804d809ae6687163 Author: Thomas Gleixner AuthorDate: Wed, 31 May 2017 11:58:33 +0200 Committer: Thomas Gleixner CommitDate: Sun, 4 Jun 2017 14:38:41 +0200 genirq: Warn when IRQ_NOAUTOEN is used with shared interrupts Shared interrupts do not go well with disabling auto enable: 1) The sharing interrupt might request it while it's still disabled and then wait for interrupts forever. 2) The interrupt might have been requested by the driver sharing the line before IRQ_NOAUTOEN has been set. So the driver which expects that disabled state after calling request_irq() will not get what it wants. Even worse, when it calls enable_irq() later, it will trigger the unbalanced enable_irq() warning. Reported-by: Brian Norris Signed-off-by: Thomas Gleixner Cc: dianders@chromium.org Cc: jeffy Cc: Marc Zyngier Cc: tfiga@chromium.org Link: http://lkml.kernel.org/r/20170531100212.210682135@linutronix.de --- kernel/irq/chip.c | 7 +++++++ kernel/irq/manage.c | 12 ++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c index e0051d5..bc1331f 100644 --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c @@ -935,6 +935,13 @@ void irq_modify_status(unsigned int irq, unsigned long clr, unsigned long set) if (!desc) return; + + /* + * Warn when a driver sets the no autoenable flag on an already + * active interrupt. + */ + WARN_ON_ONCE(!desc->depth && (set & _IRQ_NOAUTOEN)); + irq_settings_clr_and_set(desc, clr, set); irqd_clear(&desc->irq_data, IRQD_NO_BALANCING | IRQD_PER_CPU | diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index 5705610..49c37f1 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -1334,11 +1334,19 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new) if (new->flags & IRQF_ONESHOT) desc->istate |= IRQS_ONESHOT; - if (irq_settings_can_autoenable(desc)) + if (irq_settings_can_autoenable(desc)) { irq_startup(desc, true); - else + } else { + /* + * Shared interrupts do not go well with disabling + * auto enable. The sharing interrupt might request + * it while it's still disabled and then wait for + * interrupts forever. + */ + WARN_ON_ONCE(new->flags & IRQF_SHARED); /* Undo nested disables: */ desc->depth = 1; + } /* Exclude IRQ from balancing if requested */ if (new->flags & IRQF_NOBALANCING) {