From patchwork Tue Sep 9 08:32:13 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Lothar_Wa=C3=9Fmann?= X-Patchwork-Id: 387210 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 410F4140086 for ; Tue, 9 Sep 2014 18:32:21 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751575AbaIIIcU (ORCPT ); Tue, 9 Sep 2014 04:32:20 -0400 Received: from mail.karo-electronics.de ([81.173.242.67]:56973 "EHLO mail.karo-electronics.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751453AbaIIIcR (ORCPT ); Tue, 9 Sep 2014 04:32:17 -0400 From: =?UTF-8?q?Lothar=20Wa=C3=9Fmann?= To: linux-gpio@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Linus Walleij , Alexandre Courbot , =?UTF-8?q?Lothar=20Wa=C3=9Fmann?= Subject: [PATCH] gpio: pca953x: Fix warning when HW interrupts are rescheduled by the softirq tasklet Date: Tue, 9 Sep 2014 10:32:13 +0200 Message-Id: <1410251533-4990-1-git-send-email-LW@KARO-electronics.de> X-Mailer: git-send-email 1.7.10.4 MIME-Version: 1.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org When using e.g. the matrix_keymap driver with the gpio-pca953x driver, the following warning may be issued when a keypress is detected: WARNING: CPU: 0 PID: 3 at kernel/irq/manage.c:677 irq_nested_primary_handler+0x18/0x2c() Primary handler called for nested irq 245 Modules linked in: evbug ci_hdrc_imx usbmisc_imx ci_hdrc udc_core ehci_hcd phy_mxs_usb CPU: 0 PID: 3 Comm: ksoftirqd/0 Tainted: G W 3.16.0-karo+ #118 [] (unwind_backtrace) from [] (show_stack+0x10/0x14) [] (show_stack) from [] (warn_slowpath_common+0x64/0x84) [] (warn_slowpath_common) from [] (warn_slowpath_fmt+0x30/0x40) [] (warn_slowpath_fmt) from [] (irq_nested_primary_handler+0x18/0x2c) [] (irq_nested_primary_handler) from [] (handle_irq_event_percpu+0x50/0x168) [] (handle_irq_event_percpu) from [] (handle_irq_event+0x60/0x7c) [] (handle_irq_event) from [] (handle_simple_irq+0x78/0xdc) [] (handle_simple_irq) from [] (resend_irqs+0x4c/0x78) [] (resend_irqs) from [] (tasklet_action+0x74/0xd8) [] (tasklet_action) from [] (__do_softirq+0xd0/0x1f4) [] (__do_softirq) from [] (run_ksoftirqd+0x40/0x64) [] (run_ksoftirqd) from [] (smpboot_thread_fn+0x174/0x234) [] (smpboot_thread_fn) from [] (kthread+0xb4/0xd0) [] (kthread) from [] (ret_from_fork+0x14/0x24) ---[ end trace a68cf7bc5348c4f7 ]--- This happens when an IRQ is detected by the GPIO driver while the GPIO client driver (matrix_keypad in this case) has disabled the irq for the GPIO it has acquired. When the HW IRQ is being rescheduled by the softirq thread, the primary IRQ handler is called for the nested IRQ registered by the client driver rather than for the parent IRQ from the GPIO driver. This patch makes sure, that the parent_irq (gpio-pca953x) is rescheduled rather than the nested irq registered by the matrix_keypad driver. Similar patches are most probably required for a bunch of other drivers too. Signed-off-by: Lothar Waßmann --- drivers/gpio/gpio-pca953x.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c index e2da64a..770ef6b 100644 --- a/drivers/gpio/gpio-pca953x.c +++ b/drivers/gpio/gpio-pca953x.c @@ -518,6 +518,7 @@ static int pca953x_irq_setup(struct pca953x_chip *chip, int irq_base) { struct i2c_client *client = chip->client; + struct gpio_chip *gpio_chip = &chip->gpio_chip; int ret, i, offset = 0; if (client->irq && irq_base != -1 @@ -567,6 +568,17 @@ static int pca953x_irq_setup(struct pca953x_chip *chip, "could not connect irqchip to gpiochip\n"); return ret; } + + for (i = 0; i < NBANK(chip); i++) { + int j; + + for (j = 0; j < BANK_SZ; j++) { + int gpio = gpio_chip->base + i * BANK_SZ + j; + int irq = gpio_to_irq(gpio); + + irq_set_parent(irq, client->irq); + } + } } return 0;