From patchwork Fri Nov 29 18:04:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Valentine Barshak X-Patchwork-Id: 3259251 Return-Path: X-Original-To: patchwork-linux-sh@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 515D0BEEAD for ; Fri, 29 Nov 2013 18:04:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8064120610 for ; Fri, 29 Nov 2013 18:04:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8F5F120616 for ; Fri, 29 Nov 2013 18:04:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752088Ab3K2SEO (ORCPT ); Fri, 29 Nov 2013 13:04:14 -0500 Received: from mail-la0-f47.google.com ([209.85.215.47]:55355 "EHLO mail-la0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752201Ab3K2SEN (ORCPT ); Fri, 29 Nov 2013 13:04:13 -0500 Received: by mail-la0-f47.google.com with SMTP id ep20so7011865lab.34 for ; Fri, 29 Nov 2013 10:04:12 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=uV5nEL+G80gyDjC+/ZgYjPc9yNV2jBvvwNRdq4X2nbA=; b=Co3mGCeKZDsoQAaT1WykPBSGiUS709ARWzV+BMx+zC1p/KEqdgE3O4DBE82a0hRmGH AphK4G1QLnrik2bcVWb6FHShAxcMOHXqJvC9wMj76CESGVfi+RPr3+bwfYh7dlegaHGX iF1Knmhp8xuEN8OdhgKyXDpSRdw5M1MZu6/FdaRiiXt8jWWI3Ycr3nXGaVIJD34/vcOF 5E9N0N69n1a96+YbNQzCys5qdrO8Ph321K9MNLC7IvKOY3T3jjS2URtIJJ5oK/Wqvrsm ULoK9mSJKXQn12wapEu/MOWIXVlifXYkH4u3IGA5UyUZDVJkmBozE3DDunDHBCP9eK0w x9eg== X-Gm-Message-State: ALoCoQlpm3/zyo/HfE+kSnuVSnhQiSeuWb5n4j1vonlFek4w90Z7ppQKl+byCaGhSqzy1a0Nyc9K X-Received: by 10.112.157.234 with SMTP id wp10mr1720342lbb.50.1385748252124; Fri, 29 Nov 2013 10:04:12 -0800 (PST) Received: from black.localnet ([93.100.122.208]) by mx.google.com with ESMTPSA id np10sm30251989lbb.7.2013.11.29.10.04.10 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Nov 2013 10:04:11 -0800 (PST) From: Valentine Barshak To: linux-sh@vger.kernel.org, linux-gpio@vger.kernel.org Cc: Simon Horman , Magnus Damm , Laurent Pinchart , Linus Walleij Subject: [PATCH V2] gpio: rcar: Fix level interrupt handling Date: Fri, 29 Nov 2013 22:04:09 +0400 Message-Id: <1385748249-27170-1-git-send-email-valentine.barshak@cogentembedded.com> X-Mailer: git-send-email 1.8.3.1 Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 According to the manual, if a port is set for level detection using the corresponding bit in the edge/level select register and an external level interrupt signal is asserted, the corresponding bit in INTDT does not use the FF to hold the input. Thus, writing 1 to the corresponding bits in INTCLR cannot clear the corresponding bits in the INTDT register. Instead, when an external input signal is stopped, the corresponding bit in INTDT is cleared automatically. Since the INTDT bit cannot be cleared for the level interrupts until the interrupt signal is stopped, we end up with the infinite loop when using deferred (threaded) IRQ handling. Since a deferred interrupt is disabled by the low-level handler and re-enabled only when the deferred handler is completed, Fix the issue by dropping disabled interrupts from the pending mask as suggested by Laurent Pinchart Changes in V2: * Drop disabled interrupts from pending mask altogether instead of dropping level interrupts one by one once they get handled. Signed-off-by: Valentine Barshak Acked-by: Laurent Pinchart Acked-by: Magnus Damm --- drivers/gpio/gpio-rcar.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c index d3f15ae..fd2d827 100644 --- a/drivers/gpio/gpio-rcar.c +++ b/drivers/gpio/gpio-rcar.c @@ -169,7 +169,8 @@ static irqreturn_t gpio_rcar_irq_handler(int irq, void *dev_id) u32 pending; unsigned int offset, irqs_handled = 0; - while ((pending = gpio_rcar_read(p, INTDT))) { + while ((pending = gpio_rcar_read(p, INTDT) & + gpio_rcar_read(p, INTMSK))) { offset = __ffs(pending); gpio_rcar_write(p, INTCLR, BIT(offset)); generic_handle_irq(irq_find_mapping(p->irq_domain, offset));