From patchwork Sat Aug 27 13:21:12 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Arnaud Patard (Rtp)" X-Patchwork-Id: 1103772 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p7RDQOrw030602 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sat, 27 Aug 2011 13:26:45 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QxIto-0004yr-57; Sat, 27 Aug 2011 13:26:12 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QxItn-0003uR-Ii; Sat, 27 Aug 2011 13:26:11 +0000 Received: from lebrac.rtp-net.org ([88.191.135.105]) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QxItj-0003u7-RA for linux-arm-kernel@lists.infradead.org; Sat, 27 Aug 2011 13:26:08 +0000 Received: by lebrac.rtp-net.org (Postfix, from userid 1000) id 5DACC29264; Sat, 27 Aug 2011 15:25:31 +0200 (CEST) Message-Id: <20110827132126.761444279@rtp-net.org> User-Agent: quilt/0.48-1 Date: Sat, 27 Aug 2011 15:21:12 +0200 From: Arnaud Patard (Rtp) To: linux-arm-kernel@lists.infradead.org Subject: [patch 1/1] MX5: fix clock usage Content-Disposition: inline; filename=suspend_atomic_clk.patch X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110827_092608_125462_C96E53D9 X-CRM114-Status: GOOD ( 10.78 ) X-Spam-Score: -0.5 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-0.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.5 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain Cc: kernel@pengutronix.de X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Sat, 27 Aug 2011 13:26:45 +0000 (UTC) While suspending, we're enabling a clock in ->suspend() but we're in atomic context, leading to this : [30803.667305] PM: late suspend of devices complete after 1.237 msecs [30803.667449] BUG: sleeping function called from invalid context at kernel/mutex.c:271 [30803.667464] in_atomic(): 0, irqs_disabled(): 128, pid: 4941, name: pm-suspend [30803.667474] INFO: lockdep is turned off. [30803.667483] irq event stamp: 0 [30803.667489] hardirqs last enabled at (0): [< (null)>] (null) [30803.667503] hardirqs last disabled at (0): [] copy_process.part.48+0x1e0/0xa7c [30803.667543] softirqs last enabled at (0): [] copy_process.part.48+0x1e0/0xa7c [30803.667562] softirqs last disabled at (0): [< (null)>] (null) [30803.667574] Backtrace: [30803.667611] [] (dump_backtrace+0x0/0x110) from [] (dump_stack+0x18/0x1c) [30803.667624] r6:00000000 r5:00000000 r4:d9648000 r3:d9648000 [30803.667652] [] (dump_stack+0x0/0x1c) from [] (__might_sleep.part.101+0x90/0xa8) [30803.667673] [] (__might_sleep.part.101+0x0/0xa8) from [] (__might_sleep+0x80/0x94) [30803.667686] r4:c05d58c0 [30803.667705] [] (__might_sleep+0x0/0x94) from [] (mutex_lock_nested+0x2c/0x30c) [30803.667735] [] (mutex_lock_nested+0x0/0x30c) from [] (clk_enable+0x28/0x50) [30803.667747] r8:c0438464 r7:00000003 r6:00000000 r5:00000000 r4:c05d2e98 [30803.667780] [] (clk_enable+0x0/0x50) from [] (mx5_suspend_enter+0x1c/0x98) [30803.667792] r4:00000003 r3:c060dfe0 [30803.667821] [] (mx5_suspend_enter+0x0/0x98) from [] (suspend_enter+0xec/0x15c) [30803.667833] r4:00000003 r3:c0017244 [30803.667856] [] (suspend_enter+0x0/0x15c) from [] (suspend_devices_and_enter+0x94/0x130) [30803.667868] r6:00000000 r5:00000003 r4:c0c0af00 r3:00002710 [30803.667897] [] (suspend_devices_and_enter+0x0/0x130) from [] (enter_state+0xc8/0x130) [30803.667909] r6:00000000 r5:00000003 r4:c05286e4 [30803.667934] [] (enter_state+0x0/0x130) from [] (state_store+0xac/0xc0) [30803.667945] r6:00000003 r5:00000003 r4:df39d000 r3:00000003 [30803.667978] [] (state_store+0x0/0xc0) from [] (kobj_attr_store+0x1c/0x28) [30803.668009] [] (kobj_attr_store+0x0/0x28) from [] (sysfs_write_file+0x88/0xbc) [30803.668032] [] (sysfs_write_file+0x0/0xbc) from [] (vfs_write+0xbc/0x138) [30803.668051] [] (vfs_write+0x0/0x138) from [] (sys_write+0x44/0x70) [30803.668062] r8:00000000 r7:00000004 r6:00000003 r5:002694d0 r4:d966acc0 [30803.668094] [] (sys_write+0x0/0x70) from [] (ret_fast_syscall+0x0/0x3c) [30803.668106] r9:d9648000 r8:c000dcc4 r6:00000001 r5:002694d0 r4:00000003 [30803.669927] PM: early resume of devices complete after 0.972 msecs Just move the clk_enable/disable in ->prepare() and ->finish() Signed-off-by: Arnaud Patard Index: linux-2.6-submit/arch/arm/mach-mx5/pm-imx5.c =================================================================== --- linux-2.6-submit.orig/arch/arm/mach-mx5/pm-imx5.c 2011-08-27 11:57:28.000000000 +0200 +++ linux-2.6-submit/arch/arm/mach-mx5/pm-imx5.c 2011-08-27 12:01:43.000000000 +0200 @@ -19,9 +19,13 @@ static struct clk *gpc_dvfs_clk; +static int mx5_suspend_prepare(void) +{ + return clk_enable(gpc_dvfs_clk); +} + static int mx5_suspend_enter(suspend_state_t state) { - clk_enable(gpc_dvfs_clk); switch (state) { case PM_SUSPEND_MEM: mx5_cpu_lp_set(STOP_POWER_OFF); @@ -42,11 +46,14 @@ static int mx5_suspend_enter(suspend_sta __raw_writel(0, MXC_SRPG_EMPGC1_SRPGCR); } cpu_do_idle(); - clk_disable(gpc_dvfs_clk); - return 0; } +static void mx5_suspend_finish(void) +{ + clk_disable(gpc_dvfs_clk); +} + static int mx5_pm_valid(suspend_state_t state) { return (state > PM_SUSPEND_ON && state <= PM_SUSPEND_MAX); @@ -54,7 +61,9 @@ static int mx5_pm_valid(suspend_state_t static const struct platform_suspend_ops mx5_suspend_ops = { .valid = mx5_pm_valid, + .prepare = mx5_suspend_prepare, .enter = mx5_suspend_enter, + .finish = mx5_suspend_finish, }; static int __init mx5_pm_init(void)