From patchwork Thu Feb 6 21:11:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlo Caione X-Patchwork-Id: 3598431 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 191F0BF418 for ; Thu, 6 Feb 2014 21:13:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4822F2012F for ; Thu, 6 Feb 2014 21:13:38 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4568D20115 for ; Thu, 6 Feb 2014 21:13:37 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WBWG4-0005oj-3g; Thu, 06 Feb 2014 21:13:16 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WBWFx-0003Hj-6X; Thu, 06 Feb 2014 21:13:09 +0000 Received: from mail-ea0-f181.google.com ([209.85.215.181]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WBWFt-0003Gr-7h for linux-arm-kernel@lists.infradead.org; Thu, 06 Feb 2014 21:13:06 +0000 Received: by mail-ea0-f181.google.com with SMTP id m10so1174025eaj.40 for ; Thu, 06 Feb 2014 13:12:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=from:to:cc:subject:date:message-id; bh=ybEKo75MXFoKyBjKtCIhFWsioXuOKeeXT3IXh+XtHus=; b=XnzNl/hogU8nqpPHvlAOPeyVb2M4G0AqqOhHvv8YPdJX6HGzgK2deRAcoCxBwHQOpN mhoQzhr9ss7orcY2pVKSQhbRBAyPglPfYilWhvAwHzk2/2SrEOO0OwYD+TdX77axfRKN dFqsfVpYnJNRy2Fv+OWwWHOolYQPCRW5KlBHFc+GvO3DHm78+HvHC2f35CS6Aybh2a7W VazztDpji+/XNz0xbha7bUjam8YCQONgqTJg9h/USsLk6fgzejrQUOmIIxxx2yfpW9xq yF0fogkoil1ZGYjRyvay3hpnXjC/qgPtIbCkplm4I0Tsi9v9S5bhttWC8L31xUVMBgRC Xu0g== X-Received: by 10.14.93.199 with SMTP id l47mr11775173eef.58.1391721161945; Thu, 06 Feb 2014 13:12:41 -0800 (PST) Received: from mac.fastwebnet.it (2-238-57-164.ip242.fastwebnet.it. [2.238.57.164]) by mx.google.com with ESMTPSA id 8sm8146866eeq.15.2014.02.06.13.12.39 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 06 Feb 2014 13:12:41 -0800 (PST) From: Carlo Caione To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@googlegroups.com, maxime.ripard@free-electrons.com, hdegoede@redhat.com, tglx@linutronix.de, emilio@elopez.com.ar Subject: [PATCH] irq: Add new flag to ack level-triggered interrupts before unmasking Date: Thu, 6 Feb 2014 22:11:57 +0100 Message-Id: <1391721117-27446-1-git-send-email-carlo@caione.org> X-Mailer: git-send-email 1.8.5.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140206_161305_398551_C3B953C3 X-CRM114-Status: GOOD ( 12.17 ) X-Spam-Score: -2.6 (--) Cc: Carlo Caione X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Several irqchip drivers require the level-triggered interrupt to be acked before unmasking to avoid that a second interrupt is immediately triggered. This small patch introduces a new irqchip flags that is used to ack the IRQ line before it is unmasked. Signed-off-by: Carlo Caione --- include/linux/irq.h | 2 ++ kernel/irq/chip.c | 10 ++++++++++ kernel/irq/internals.h | 1 + kernel/irq/manage.c | 2 +- 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/include/linux/irq.h b/include/linux/irq.h index 7dc1003..2cbe8d1 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -349,6 +349,7 @@ struct irq_chip { * IRQCHIP_ONOFFLINE_ENABLED: Only call irq_on/off_line callbacks * when irq enabled * IRQCHIP_SKIP_SET_WAKE: Skip chip.irq_set_wake(), for this irq chip + * IRQCHIP_ACK_ON_UNMASK: Ack level interrupts right before unmask */ enum { IRQCHIP_SET_TYPE_MASKED = (1 << 0), @@ -357,6 +358,7 @@ enum { IRQCHIP_ONOFFLINE_ENABLED = (1 << 3), IRQCHIP_SKIP_SET_WAKE = (1 << 4), IRQCHIP_ONESHOT_SAFE = (1 << 5), + IRQCHIP_ACK_ON_UNMASK = (1 << 6), }; /* This include will go away once we isolated irq_desc usage to core code */ diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c index dc04c16..9d2d2e2 100644 --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c @@ -265,6 +265,16 @@ static inline void mask_ack_irq(struct irq_desc *desc) irq_state_set_masked(desc); } +void ack_unmask_irq(struct irq_desc *desc) +{ + if ((desc->irq_data.chip->flags & IRQCHIP_ACK_ON_UNMASK) && + (irqd_get_trigger_type(&desc->irq_data) & IRQ_TYPE_LEVEL_MASK) && + desc->irq_data.chip->irq_ack) + desc->irq_data.chip->irq_ack(&desc->irq_data); + + unmask_irq(desc); +} + void mask_irq(struct irq_desc *desc) { if (desc->irq_data.chip->irq_mask) { diff --git a/kernel/irq/internals.h b/kernel/irq/internals.h index 001fa5b..06ff850 100644 --- a/kernel/irq/internals.h +++ b/kernel/irq/internals.h @@ -73,6 +73,7 @@ extern void irq_percpu_enable(struct irq_desc *desc, unsigned int cpu); extern void irq_percpu_disable(struct irq_desc *desc, unsigned int cpu); extern void mask_irq(struct irq_desc *desc); extern void unmask_irq(struct irq_desc *desc); +extern void ack_unmask_irq(struct irq_desc *desc); extern void init_kstat_irqs(struct irq_desc *desc, int node, int nr); diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index 481a13c..39505d8 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -718,7 +718,7 @@ again: if (!desc->threads_oneshot && !irqd_irq_disabled(&desc->irq_data) && irqd_irq_masked(&desc->irq_data)) - unmask_irq(desc); + ack_unmask_irq(desc); out_unlock: raw_spin_unlock_irq(&desc->lock);