From patchwork Tue Oct 24 19:54:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Berger X-Patchwork-Id: 10025453 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 5894360375 for ; Tue, 24 Oct 2017 19:57:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4945F28A67 for ; Tue, 24 Oct 2017 19:57:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3E43A28A6A; Tue, 24 Oct 2017 19:57:46 +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 C312B28A67 for ; Tue, 24 Oct 2017 19:57:45 +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=LYAIF2QxbK/4mVOITiCEbn9dJE7T+14KDTDfE3Ny8Rg=; b=c005PGdAzUqhGvLr4xRWZLEktW mXU9vMS/tYBJK+s4ZQb8CUCPyLpwRxO4wDJQXfq76EZ+hQrj99T7dk0x1xsUrhJXpZGeeFveJHE3g bCIuwIzULhvpfEaGi+02QLI1T3aLGAg9ksDMuEMOpY9V3ixlBaNjqliM8rm/lNiuSxa563JP9XwJV Gwnsdd50mftrgaLPPeV7yLnJoEhrzhuXggTGV/Vyd2nt1pmXdlrrsIW8+ys2OIeJnVd39fiChZUoi fQ8cwOG4byp02LY6smv88q66mHK/AXl0B1F6MuvUH07qWqJb69ktVtFWWy+wyimVkd2/02rEPYauW mQpKwwRQ==; 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 1e75KU-0001D3-Ov; Tue, 24 Oct 2017 19:57:38 +0000 Received: from mail-qk0-x243.google.com ([2607:f8b0:400d:c09::243]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1e75Iz-0008NU-Go for linux-arm-kernel@lists.infradead.org; Tue, 24 Oct 2017 19:56:11 +0000 Received: by mail-qk0-x243.google.com with SMTP id x82so27821614qkb.12 for ; Tue, 24 Oct 2017 12:55:45 -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=5qeVVmHPc2K+MtvI3N0+4uxMTBLdIq9Jd1sMoP9fUyc=; b=thusA1dBvgZ8nspieDln+YYRmqxOx5nxOCZ/a5rNPH3G2ODYxIYIAxSwYBAHnQwhAh aF2sh1rCmMaJV7uDYs8X6nI5fNSoo1fcB/pLyScJiX7qQGM5OQEKx6q8spuGSNURYNWi nz+858pnpDlD95OdmuqVLLxFw/ZdEo9VrGXTsE6gLx6agimR7wqw8Jydbjqbc4xf8k59 rXkkpBzBQ6xYXO08XZzx1OvYgOqy7YUppc+KCkRn1bPxgKg2uFdtJWqbGpRz0yxBj93l tRGcYSNkQWic73q/ZvcKV4t947YbP6h92HTxfXuYUWAxEATuwpWsJOI6bNbiNvA5fZlY ZASg== 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=5qeVVmHPc2K+MtvI3N0+4uxMTBLdIq9Jd1sMoP9fUyc=; b=T5QApDrrEzhn+8mKjJoAqVbFoGOjgG0wmK88lHSRfQ/cf6crRkQynw1IH81Ld9yAef OUDpFd32i1xarbE3Q73Bzn2DcC0WyMlVnXODilsoPSDarhGBFtFSFQ0vIn/j+9mej0Q9 T3vzQQL0k9m5lI3Quxc44sBuVI9RM/BL9b6BOIZO00f4tSGBbmOTVoUMhFAtvIiZin5I D9vUgMfdR9KXt9XrKOP4bS1t5ne+7djKQfrDfb96B+v3LzhentJ/b23KAsXZGTWF8obh FhCL4aSn3eFBCEPTAbxj7HNe5rg7Pr8GHF7+N0Fl0DifXAgOuQHxxfgWNW46ez9AmBkX NQVQ== X-Gm-Message-State: AMCzsaWN3chHNCyb+xgcUSkhUEP/q/i6Mf+EQLfOxSMk3kllQ/4sIDuZ ismN1AaWEjxgaSfOnCuMJ8A= X-Google-Smtp-Source: ABhQp+ROAMZ+Ha/E2RHb1VYWhUL4arbDX1fQvw/0kjtlcAZoSL9FBm0gDeoT8rOIi6rckiKaGo2kAg== X-Received: by 10.55.31.163 with SMTP id n35mr26192366qkh.279.1508874943982; Tue, 24 Oct 2017 12:55:43 -0700 (PDT) Received: from stb-bld-02.irv.broadcom.com ([192.19.255.250]) by smtp.gmail.com with ESMTPSA id s27sm794249qtj.3.2017.10.24.12.55.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Oct 2017 12:55:43 -0700 (PDT) From: Doug Berger To: Gregory Fong Subject: [PATCH v2 4/7] gpio: brcmstb: switch to handle_level_irq flow Date: Tue, 24 Oct 2017 12:54:48 -0700 Message-Id: <20171024195451.30535-5-opendmb@gmail.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171024195451.30535-1-opendmb@gmail.com> References: <20171024195451.30535-1-opendmb@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171024_125606_121773_4855FD45 X-CRM114-Status: GOOD ( 12.76 ) 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 Reviewed-by: Florian Fainelli 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 fd8c0412f8af..513de4936a25 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,