From mboxrd@z Thu Jan 1 00:00:00 1970 From: Brian Norris Subject: [4.12 REGRESSION] pinctrl: rockchip: sleeping function called from atomic context Date: Wed, 17 May 2017 15:56:35 -0700 Message-ID: <20170517225634.GA11404@google.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline Sender: linux-pm-owner@vger.kernel.org To: Heiko Stuebner , Linus Walleij Cc: linux-rockchip@lists.infradead.org, Julia Cartwright , linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, John Keeping , linux-pm@vger.kernel.org List-Id: linux-gpio@vger.kernel.org Hi, Looks like we've added a mutex in the ->bus_lock() callback for Rockchip's pinctrl irqchip, which triggers a CONFIG_DEBUG_ATOMIC_SLEEP warning when entering system suspend: [ 151.406483] BUG: sleeping function called from invalid context at kernel/locking/mutex.c:238 [ 151.420321] in_atomic(): 0, irqs_disabled(): 0, pid: 2447, name: cat [ 151.427457] CPU: 2 PID: 2447 Comm: cat Tainted: G W 4.12.0-rc1+ [ 151.435922] Hardware name: Google Kevin (DT) [ 151.440687] Call trace: [ 151.443440] [] dump_backtrace+0x0/0x2b8 [ 151.449485] [] show_stack+0x20/0x28 [ 151.455137] [] dump_stack+0xa4/0xcc [ 151.460797] [] ___might_sleep+0x16c/0x188 [ 151.467036] [] __might_sleep+0xc0/0xd4 [ 151.472979] [] mutex_lock+0x2c/0x68 [ 151.478637] [] rockchip_irq_bus_lock+0x48/0x54 [ 151.485364] [] __irq_get_desc_lock+0x9c/0xc8 [ 151.491895] [] irq_set_irq_wake+0x44/0x178 [ 151.498235] [] dev_pm_arm_wake_irq+0x78/0x84 [ 151.504769] [] device_wakeup_arm_wake_irqs+0x48/0x70 [ 151.512077] [] dpm_suspend_noirq+0x180/0x51c [ 151.518608] [] suspend_devices_and_enter+0x1dc/0xde4 [ 151.525914] [] pm_suspend+0x9f8/0xa38 [...] The warning goes away if I revert commit 88bb94216f59 ("pinctrl: rockchip: avoid hardirq-unsafe functions in irq_chip"). The thing is, the documentation (and apparent design) suggest that calling sleeping functions from ->irq_bus_lock() is perfectly valid. I'm not 100% following the ___might_sleep() logic, but is this complaining because of the RCU read locking in device_wakeup_arm_wake_irqs()? I have CONFIG_PREEMPT_RCU and CONFIG_PREEMPT enabled, FWIW. Brian