From patchwork Sat Sep 30 03:40:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Berger X-Patchwork-Id: 9979101 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 071636037F for ; Sat, 30 Sep 2017 03:45:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EAAB6298D9 for ; Sat, 30 Sep 2017 03:45:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DED6F298DB; Sat, 30 Sep 2017 03:45:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 73722298D9 for ; Sat, 30 Sep 2017 03:45:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=UlA7zWw4KqTGJraQQCHkP9jk7eyVcN6yRxZ91R6Qywc=; b=GBV4YHnUTOQB5Y0Fft0mIw3hrz dkpkGhnYcKuMtvlUYepTmLiMAQHKmghgAxtNAOZ5Jlr/jzkWQJBOzi3WZsrKgMp+tZ+UJ0XhDZKHy gTDt0nwxqmHQeaT5c6jmzSj2n9nAq+oaUdCipUThMB16eh4kDTzuNwLYakAs0UY3ZONb53v9DwFzd CahRtX86DpU30wTFln3W20vApgSklsNn0HmAoQorFfaCd0k8gYWDXbV0dsTk3RZWeUyJHMfPzgPIO clCtXSwiELQnZ9fso/n5Lz0ubbKb2Syped5OHgW8gUNLvuLkImeVbnrEZvdTNdnZDfmC5aoh3HU8T gx6CEzsw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dy8i1-0007o8-U8; Sat, 30 Sep 2017 03:44:57 +0000 Received: from mail-qt0-x244.google.com ([2607:f8b0:400d:c0d::244]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dy8fJ-0005JB-Mx for linux-arm-kernel@lists.infradead.org; Sat, 30 Sep 2017 03:42:13 +0000 Received: by mail-qt0-x244.google.com with SMTP id o13so1899682qtf.1 for ; Fri, 29 Sep 2017 20:41:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=FyABxmWy5nrr1PpioWyaMI/mwwiWrA4IpD/v6WFMK0w=; b=ZKSnhrTAywqMurTKCaNzz29C3xDt+PyQpz56REkbMZRwCij8nncHNCWYo8hR+QG3Cs R3cR0w6nr/w5A5b41tPAiM2PkzQm0Q7safO5x0zrMqup8SjZAl2vZTDnlsSDZIl9e3D+ c3oqg4/mnzDb+pGqz9URgIU7jjJF0lZl4HczNgcyIjywLHZwHyIoTPy2j6zrcRJy2x4s r/Zwdwcj0tlxFrTAZFbzSy726Io7Fr/q1r2hA8FdpQhqyiqDwSt1wDJKPVc3RcBO9AO3 tisISIFOHa9wwOwO/DJoJctzkFvYrz96PZOSzg+sVnmMlqJ9WjalSncEPciWZDB999BQ /TVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=FyABxmWy5nrr1PpioWyaMI/mwwiWrA4IpD/v6WFMK0w=; b=oIhcTr8hrSsAk+QXRlwKqRvBYrgb8A3UsQKOHwnRmAKP6HbQmN/Skp1uLMCeIqauR8 mx86c4bLX4mGXtSYafgAhmeH00rUpL2FL1L3YnxyF4elTtxA7EM//VuM2vaoU/ofbH2h oZM9kNsxoJvjtHkQpYUSdWBQ2bEqay+C+Rdw622ZKKa4uCtfxovrumi4x5z6jAx2C4rj frAiB7CBqMNIsQIql0noUuWqyA7naQmGH9V54YHrQGX1Ud3UWWWykXKbYk9SJN3e13Ft gswwJWYvBuntC1aIR5C/WGR5uyShqecKcjrD6SzeLgwqa5L/obhK6CZ7DFMswPCctoIC 3m7A== X-Gm-Message-State: AMCzsaXPwZZu1YhLzBLuFR0KdvdrRCXntvu18Wo3LYVE1lN6QQpOvrj3 b2CUqi8i+5zzwknkFpacvQg= X-Google-Smtp-Source: AOwi7QBYZYwtuNnHIg0H8Fy8mhPLMiJ2Bu959u9e3JLDruB3i1y9hxPungwPnHAr+WfqnKwR+zaf9Q== X-Received: by 10.200.25.137 with SMTP id u9mr9731351qtj.81.1506742908133; Fri, 29 Sep 2017 20:41:48 -0700 (PDT) Received: from stb-bld-02.irv.broadcom.com ([192.19.255.250]) by smtp.gmail.com with ESMTPSA id 4sm3574693qke.50.2017.09.29.20.41.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Sep 2017 20:41:47 -0700 (PDT) From: Doug Berger To: Gregory Fong Subject: [PATCH 3/7] gpio: brcmstb: switch to handle_level_irq flow Date: Fri, 29 Sep 2017 20:40:53 -0700 Message-Id: <20170930034057.15166-4-opendmb@gmail.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170930034057.15166-1-opendmb@gmail.com> References: <20170930034057.15166-1-opendmb@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170929_204210_033821_FFCA3C5C X-CRM114-Status: GOOD ( 12.15 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Florian Fainelli , Linus Walleij , linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Doug Berger , bcm-kernel-feedback-list@broadcom.com, Brian Norris , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Reading and writing the gpio bank status register each time a pending interrupt bit is serviced could cause new pending bits to be cleared without servicing the associated interrupts. By using the handle_level_irq flow instead of the handle_simple_irq flow we get proper handling of interrupt masking as well as acking of interrupts. The irq_ack method is added to support this. Fixes: 19a7b6940b78 ("gpio: brcmstb: Add interrupt and wakeup source support") Signed-off-by: Doug Berger Acked-by: Gregory Fong --- drivers/gpio/gpio-brcmstb.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/gpio/gpio-brcmstb.c b/drivers/gpio/gpio-brcmstb.c index 8945861876f9..c186141927bb 100644 --- a/drivers/gpio/gpio-brcmstb.c +++ b/drivers/gpio/gpio-brcmstb.c @@ -114,6 +114,16 @@ static void brcmstb_gpio_irq_unmask(struct irq_data *d) brcmstb_gpio_set_imask(bank, d->hwirq, true); } +static void brcmstb_gpio_irq_ack(struct irq_data *d) +{ + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); + struct brcmstb_gpio_bank *bank = gpiochip_get_data(gc); + struct brcmstb_gpio_priv *priv = bank->parent_priv; + u32 mask = BIT(d->hwirq); + + gc->write_reg(priv->reg_base + GIO_STAT(bank->id), mask); +} + static int brcmstb_gpio_irq_set_type(struct irq_data *d, unsigned int type) { struct gpio_chip *gc = irq_data_get_irq_chip_data(d); @@ -217,21 +227,16 @@ static void brcmstb_gpio_irq_bank_handler(struct brcmstb_gpio_bank *bank) { struct brcmstb_gpio_priv *priv = bank->parent_priv; struct irq_domain *irq_domain = bank->gc.irqdomain; - void __iomem *reg_base = priv->reg_base; unsigned long status; while ((status = brcmstb_gpio_get_active_irqs(bank))) { int bit; for_each_set_bit(bit, &status, 32) { - u32 stat = bank->gc.read_reg(reg_base + - GIO_STAT(bank->id)); if (bit >= bank->width) dev_warn(&priv->pdev->dev, "IRQ for invalid GPIO (bank=%d, offset=%d)\n", bank->id, bit); - bank->gc.write_reg(reg_base + GIO_STAT(bank->id), - stat | BIT(bit)); generic_handle_irq(irq_find_mapping(irq_domain, bit)); } } @@ -354,6 +359,7 @@ static int brcmstb_gpio_irq_setup(struct platform_device *pdev, bank->irq_chip.name = dev_name(dev); bank->irq_chip.irq_mask = brcmstb_gpio_irq_mask; bank->irq_chip.irq_unmask = brcmstb_gpio_irq_unmask; + bank->irq_chip.irq_ack = brcmstb_gpio_irq_ack; bank->irq_chip.irq_set_type = brcmstb_gpio_irq_set_type; /* Ensures that all non-wakeup IRQs are disabled at suspend */ @@ -394,7 +400,7 @@ static int brcmstb_gpio_irq_setup(struct platform_device *pdev, bank->irq_chip.irq_set_wake = brcmstb_gpio_irq_set_wake; err = gpiochip_irqchip_add(&bank->gc, &bank->irq_chip, 0, - handle_simple_irq, IRQ_TYPE_NONE); + handle_level_irq, IRQ_TYPE_NONE); if (err) return err; gpiochip_set_chained_irqchip(&bank->gc, &bank->irq_chip,