From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754742Ab3KTTKM (ORCPT ); Wed, 20 Nov 2013 14:10:12 -0500 Received: from arroyo.ext.ti.com ([192.94.94.40]:43061 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754444Ab3KTTKJ (ORCPT ); Wed, 20 Nov 2013 14:10:09 -0500 Message-ID: <528D082C.3040405@ti.com> Date: Wed, 20 Nov 2013 21:06:20 +0200 From: Grygorii Strashko User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0 MIME-Version: 1.0 To: Stephen Boyd , Len Brown , Pavel Machek , "Rafael J. Wysocki" , Greg Kroah-Hartman CC: , , , Subject: Re: [PATCH] PM / Clocks: fix pm_clk_resume/suspend if CONFIG_PM_RUNTIME is set References: <1384954307-27094-1-git-send-email-grygorii.strashko@ti.com> <528D0296.1070001@codeaurora.org> In-Reply-To: <528D0296.1070001@codeaurora.org> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.167.145.75] X-EXCLAIMER-MD-CONFIG: f9c360f5-3d1e-4c3c-8703-f45bf52eff6b Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Stephen, On 11/20/2013 08:42 PM, Stephen Boyd wrote: > On 11/20/13 05:31, Grygorii Strashko wrote: >> The following warning is shown and clk_enable() failed on Keystone platform >> if CONFIG_PM_RUNTIME is set and Runtime PM is enabled for Davinci gpio driver: >> [ 0.564486] ------------[ cut here ]------------ >> [ 0.569221] WARNING: CPU: 0 PID: 1 at drivers/clk/clk.c:883__clk_enable+0x8c/0x98() >> [ 0.577070] Modules linked in: >> [ 0.580231] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 3.12.0-10116-g11d59938-dirty #259 >> [ 0.588368] [] (unwind_backtrace+0x0/0xf8) from [] (show_stack+0x10/0x14) >> [ 0.597018] [] (show_stack+0x10/0x14) from [] (dump_stack+0x64/0xa4) >> [ 0.605235] [] (dump_stack+0x64/0xa4) from [] (warn_slowpath_common+0x68/0x88) >> [ 0.614315] [] (warn_slowpath_common+0x68/0x88) from [] (warn_slowpath_null+0x1c/0x24) >> [ 0.624092] [] (warn_slowpath_null+0x1c/0x24) from [] (__clk_enable+0x8c/0x98) >> [ 0.633173] [] (__clk_enable+0x8c/0x98) from [] (clk_enable+0x18/0x2c) >> [ 0.641556] [] (clk_enable+0x18/0x2c) from [] (pm_clk_resume+0x5c/0x80) >> [ 0.650025] [] (pm_clk_resume+0x5c/0x80) from [] (keystone_pm_runtime_resume+0xc/0x18) >> [ 0.659800] [] (keystone_pm_runtime_resume+0xc/0x18) from [] (__rpm_callback+0x34/0x70) >> [ 0.669662] [] (__rpm_callback+0x34/0x70) from [] (rpm_callback+0x28/0x88) >> [ 0.678390] [] (rpm_callback+0x28/0x88) from [] (rpm_resume+0x3c8/0x684) >> [ 0.686942] [] (rpm_resume+0x3c8/0x684) from [] (__pm_runtime_resume+0x4c/0x64) >> [ 0.696111] [] (__pm_runtime_resume+0x4c/0x64) from [] (davinci_gpio_probe+0x20c/0x5ac) >> [ 0.705983] [] (davinci_gpio_probe+0x20c/0x5ac) from [] (platform_drv_probe+0x18/0x48) >> [ 0.715758] [] (platform_drv_probe+0x18/0x48) from [] (driver_probe_device+0x80/0x21c) >> [ 0.725532] [] (driver_probe_device+0x80/0x21c) from [] (__driver_attach+0x8c/0x90) >> [ 0.735044] [] (__driver_attach+0x8c/0x90) from [] (bus_for_each_dev+0x60/0x94) >> [ 0.744207] [] (bus_for_each_dev+0x60/0x94) from [] (bus_add_driver+0xdc/0x1d0) >> [ 0.753371] [] (bus_add_driver+0xdc/0x1d0) from [] (driver_register+0x78/0xf4) >> [ 0.762449] [] (driver_register+0x78/0xf4) from [] (do_one_initcall+0xec/0x148) >> [ 0.771616] [] (do_one_initcall+0xec/0x148) from [] (kernel_init_freeable+0xfc/0x1c8) >> [ 0.781303] [] (kernel_init_freeable+0xfc/0x1c8) from [] (kernel_init+0x8/0x110) >> [ 0.790553] [] (kernel_init+0x8/0x110) from [] (ret_from_fork+0x14/0x3c) >> [ 0.799117] ---[ end trace 6588a0ec7fbc847a ]--- > > Please omit the timestamps here. ok. > >> >> This happens because the clk_enable() is called without clk_prepare() >> from pm_clk_resume(). >> >> Hence, switch to use clk_prepare_enable()/clk_disable_unprepare() >> instead of clk_enable()/clk_disable() in case if CONFIG_PM_RUNTIME is >> set. >> Actually, This is remainder fix of the earlier commit c122f27e1c >> "base: power - use clk_prepare_enable and clk_prepare_disable". >> >> Signed-off-by: Grygorii Strashko >> --- >> drivers/base/power/clock_ops.c | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/base/power/clock_ops.c b/drivers/base/power/clock_ops.c >> index 9d8fde7..60d389a 100644 >> --- a/drivers/base/power/clock_ops.c >> +++ b/drivers/base/power/clock_ops.c >> @@ -230,7 +230,7 @@ int pm_clk_suspend(struct device *dev) >> list_for_each_entry_reverse(ce, &psd->clock_list, node) { >> if (ce->status < PCE_STATUS_ERROR) { >> if (ce->status == PCE_STATUS_ENABLED) >> - clk_disable(ce->clk); >> + clk_disable_unprepare(ce->clk); >> ce->status = PCE_STATUS_ACQUIRED; >> } >> } >> @@ -259,7 +259,7 @@ int pm_clk_resume(struct device *dev) >> >> list_for_each_entry(ce, &psd->clock_list, node) { >> if (ce->status < PCE_STATUS_ERROR) { >> - clk_enable(ce->clk); >> + clk_prepare_enable(ce->clk); >> ce->status = PCE_STATUS_ENABLED; >> } >> } > > This is inside a spin_lock_irqsave(). You should be getting scheduling > while atomic warnings with this change. Are you testing with > DEBUG_ATOMIC_SLEEP=y? Ops, thanks. No, It's not tested with DEBUG_ATOMIC_SLEEP and I agree with you. So, I see two option here: 1) split above loops on two 2) add calls of clk_prepare()/clk_unprepare() in pm_clk_notify() In my opinion option [2] is better. Regards, -grygorii