From patchwork Tue Jan 10 20:00:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grygorii Strashko X-Patchwork-Id: 9508471 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 F2B7260231 for ; Tue, 10 Jan 2017 20:02:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E449E28446 for ; Tue, 10 Jan 2017 20:02:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D8ED528573; Tue, 10 Jan 2017 20:02:04 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5219D28446 for ; Tue, 10 Jan 2017 20:02:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1031685AbdAJUBr (ORCPT ); Tue, 10 Jan 2017 15:01:47 -0500 Received: from fllnx209.ext.ti.com ([198.47.19.16]:22085 "EHLO fllnx209.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760505AbdAJUBb (ORCPT ); Tue, 10 Jan 2017 15:01:31 -0500 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by fllnx209.ext.ti.com (8.15.1/8.15.1) with ESMTP id v0AK0vdJ029136; Tue, 10 Jan 2017 14:00:57 -0600 Received: from DLEE70.ent.ti.com (dlemailx.itg.ti.com [157.170.170.113]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id v0AK0qKl009989; Tue, 10 Jan 2017 14:00:52 -0600 Received: from [128.247.83.96] (128.247.83.96) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.3.294.0; Tue, 10 Jan 2017 14:00:52 -0600 Subject: Re: gpio: pcf857x: lockdep warning on v4.10-rc3 To: Roger Quadros , Linus Walleij References: <48bef841-5267-fcdb-2398-095f6f7ae51e@ti.com> CC: Tony Lindgren , linux-omap , "linux-gpio@vger.kernel.org" , "linux-kernel@vger.kernel.org" From: Grygorii Strashko Message-ID: <6939c67f-f414-c022-85e3-4e8d8912fb34@ti.com> Date: Tue, 10 Jan 2017 14:00:52 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <48bef841-5267-fcdb-2398-095f6f7ae51e@ti.com> X-Originating-IP: [128.247.83.96] Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi On 01/10/2017 06:18 AM, Roger Quadros wrote: > Hi Linus, > > I see the following lockdep warning on v4.10-rc3 on TI's dra7-evm. > > reverting (d245b3f9bd3 "gpio: simplify adding threaded interrupts") seems to fix it. > > > [ 2.358337] ------------[ cut here ]------------ > [ 2.363194] WARNING: CPU: 1 PID: 76 at kernel/locking/lockdep.c:3124 gpiochip_irq_map+0x40/0xa4 > [ 2.372350] DEBUG_LOCKS_WARN_ON(!key) > [ 2.372354] Modules linked in: > [ 2.379407] CPU: 1 PID: 76 Comm: kworker/1:1 Not tainted 4.10.0-rc3 #1075 > [ 2.386527] Hardware name: Generic DRA74X (Flattened Device Tree) > [ 2.392920] Workqueue: events deferred_probe_work_func > [ 2.398323] [] (unwind_backtrace) from [] (show_stack+0x10/0x14) > [ 2.406445] [] (show_stack) from [] (dump_stack+0xac/0xe0) > [ 2.414030] [] (dump_stack) from [] (__warn+0xd8/0x104) > [ 2.421344] [] (__warn) from [] (warn_slowpath_fmt+0x34/0x44) > [ 2.429203] [] (warn_slowpath_fmt) from [] (gpiochip_irq_map+0x40/0xa4) > [ 2.437969] [] (gpiochip_irq_map) from [] (irq_domain_associate+0x70/0x1c0) > [ 2.447102] [] (irq_domain_associate) from [] (irq_create_mapping+0x64/0xcc) > [ 2.456313] [] (irq_create_mapping) from [] (_gpiochip_irqchip_add+0xd8/0x1a8) > [ 2.465725] [] (_gpiochip_irqchip_add) from [] (pcf857x_probe+0x260/0x38c) > [ 2.474754] [] (pcf857x_probe) from [] (i2c_device_probe+0x200/0x25c) > [ 2.483332] [] (i2c_device_probe) from [] (driver_probe_device+0x200/0x2d4) > [ 2.492456] [] (driver_probe_device) from [] (bus_for_each_drv+0x64/0x98) > [ 2.501396] [] (bus_for_each_drv) from [] (__device_attach+0xb0/0x118) > [ 2.510062] [] (__device_attach) from [] (bus_probe_device+0x88/0x90) > [ 2.518639] [] (bus_probe_device) from [] (device_add+0x3e4/0x59c) > [ 2.526938] [] (device_add) from [] (i2c_new_device+0x144/0x1a4) > [ 2.535064] [] (i2c_new_device) from [] (i2c_register_adapter+0x278/0x5a4) > [ 2.544101] [] (i2c_register_adapter) from [] (omap_i2c_probe+0x4bc/0x6a0) > [ 2.553141] [] (omap_i2c_probe) from [] (platform_drv_probe+0x4c/0xb0) > [ 2.561808] [] (platform_drv_probe) from [] (driver_probe_device+0x200/0x2d4) > [ 2.571120] [] (driver_probe_device) from [] (bus_for_each_drv+0x64/0x98) > [ 2.580065] [] (bus_for_each_drv) from [] (__device_attach+0xb0/0x118) > [ 2.588732] [] (__device_attach) from [] (bus_probe_device+0x88/0x90) > [ 2.597320] [] (bus_probe_device) from [] (deferred_probe_work_func+0x6c/0x9c) > [ 2.606719] [] (deferred_probe_work_func) from [] (process_one_work+0x1fc/0x76c) > [ 2.616298] [] (process_one_work) from [] (worker_thread+0x22c/0x540) > [ 2.624885] [] (worker_thread) from [] (kthread+0xf8/0x138) > [ 2.632547] [] (kthread) from [] (ret_from_fork+0x14/0x24) > [ 2.640162] ---[ end trace a0ca4c6c0c9a9ee8 ]--- > [ 2.646111] pcf857x 0-0020: probed > [ 2.650052] gpiochip_find_base: found new base at 478 > [ 2.655386] gpio gpiochip10: (pcf8575): added GPIO chardev (254:10) > [ 2.662262] gpiochip_setup_dev: registered GPIOs 478 to 493 on device: gpiochip10 (pcf8575) > [ 2.672058] pcf857x 0-0021: probed > I expect below patch will fix an issue. Could you try it? ----- From 4aa569ec1ac3433af1398fe62aa8c0cad1b6c5d6 Mon Sep 17 00:00:00 2001 From: Grygorii Strashko Date: Tue, 10 Jan 2017 13:41:39 -0600 Subject: [PATCH] gpiolib: irqchip: fix lockdep warning from gpiochip_irqchip_add_nested Each GPIO IRQ chip should register separate lockdep class otherwise lockdep will complain every time when GPIO chips organized in chain whare all of them are IRQ controllers and one GPIO pin is used as interrupt input from another. This issue was originally fixed by commit a0a8bcf4670c ("gpiolib: irqchip: use different lockdep class for each gpio irqchip") and then re-introduced for GPIO chips which are using nested IRQ handlers by commit d245b3f9bd3 ("gpio: simplify adding threaded interrupts"). Hence, fix it the same way as it was done for gpiochip_irqchip_add() by wrapping gpiochip_irqchip_add_nested calls into macros. Fixes: d245b3f9bd3 ("gpio: simplify adding threaded interrupts") Signed-off-by: Grygorii Strashko --- include/linux/gpio/driver.h | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index c2748ac..eae438b 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -283,15 +283,20 @@ int _gpiochip_irqchip_add(struct gpio_chip *gpiochip, struct lock_class_key *lock_key); /* FIXME: I assume threaded IRQchips do not have the lockdep problem */ -static inline int gpiochip_irqchip_add_nested(struct gpio_chip *gpiochip, - struct irq_chip *irqchip, - unsigned int first_irq, - irq_flow_handler_t handler, - unsigned int type) -{ - return _gpiochip_irqchip_add(gpiochip, irqchip, first_irq, - handler, type, true, NULL); -} +#ifdef CONFIG_LOCKDEP +#define gpiochip_irqchip_add_nested(gpiochip, irqchip, \ + first_irq, handler, type) \ +( \ + ({ \ + static struct lock_class_key _key; \ + _gpiochip_irqchip_add(gpiochip, irqchip, first_irq, \ + handler, type, true, &_key); \ + }) \ +) +#else +#define gpiochip_irqchip_add_nested(...) \ + _gpiochip_irqchip_add(__VA_ARGS__, true, NULL) +#endif #ifdef CONFIG_LOCKDEP #define gpiochip_irqchip_add(...) \