All of lore.kernel.org
 help / color / mirror / Atom feed
From: Grygorii Strashko <grygorii.strashko@ti.com>
To: Stephen Boyd <sboyd@codeaurora.org>,
	Len Brown <len.brown@intel.com>, Pavel Machek <pavel@ucw.cz>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: santosh.shilimkar@ti.com, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org,
	Mike Turquette <mturquette@linaro.org>
Subject: Re: [PATCH] PM / Clocks: fix pm_clk_resume/suspend if CONFIG_PM_RUNTIME is set
Date: Wed, 20 Nov 2013 22:11:48 +0200	[thread overview]
Message-ID: <528D1784.8080704@ti.com> (raw)
In-Reply-To: <528D1327.7080205@codeaurora.org>

On 11/20/2013 09:53 PM, Stephen Boyd wrote:
> On 11/20/13 11:06, Grygorii Strashko wrote:
>> On 11/20/2013 08:42 PM, Stephen Boyd wrote:
>>> On 11/20/13 05:31, Grygorii Strashko wrote:
>>>> @@ -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.
>>
> 
> Doesn't that mean the clock will always be prepared as long as the
> device is present? That doesn't sound good. I would like the clocks to
> be disabled and unprepared as long as the device is suspended.

Yep (

> 
> What is the lock protecting? The linked list or something more? Can we
> remove the locks?

Looks like it's protecting linked list pm_clock_entry'es.

> 
> It looks like even if you just remove the locks here, the PM core is
> free to call this function with irqs disabled if pm_runtime_irq_safe()
> has been called on the device. Perhaps runtime PM can only do the
> clk_enable()/clk_disable() part and the clk_unprepare()/clk_prepare()
> calls should happen in the system suspend callbacks?

Even don't know what to say :( On Keystone clk_unprepare()/clk_prepare() are NOPs.
But clk_prepare() has to be called at least once before clk_enable() :((
So, solution with suspend/resume will not fix current problem :( unfortunately.

FYI, Now pm_clk_suspend/pm_clk_resume are called from arch/arm/mach-keystone/pm_domain.c
(also similar solution is used by Davinci, but issue has not been detected because
PM runtime hasn't been used by Davinci IP drivers before)

Regards,
- grygorii



WARNING: multiple messages have this Message-ID (diff)
From: grygorii.strashko@ti.com (Grygorii Strashko)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] PM / Clocks: fix pm_clk_resume/suspend if CONFIG_PM_RUNTIME is set
Date: Wed, 20 Nov 2013 22:11:48 +0200	[thread overview]
Message-ID: <528D1784.8080704@ti.com> (raw)
In-Reply-To: <528D1327.7080205@codeaurora.org>

On 11/20/2013 09:53 PM, Stephen Boyd wrote:
> On 11/20/13 11:06, Grygorii Strashko wrote:
>> On 11/20/2013 08:42 PM, Stephen Boyd wrote:
>>> On 11/20/13 05:31, Grygorii Strashko wrote:
>>>> @@ -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.
>>
> 
> Doesn't that mean the clock will always be prepared as long as the
> device is present? That doesn't sound good. I would like the clocks to
> be disabled and unprepared as long as the device is suspended.

Yep (

> 
> What is the lock protecting? The linked list or something more? Can we
> remove the locks?

Looks like it's protecting linked list pm_clock_entry'es.

> 
> It looks like even if you just remove the locks here, the PM core is
> free to call this function with irqs disabled if pm_runtime_irq_safe()
> has been called on the device. Perhaps runtime PM can only do the
> clk_enable()/clk_disable() part and the clk_unprepare()/clk_prepare()
> calls should happen in the system suspend callbacks?

Even don't know what to say :( On Keystone clk_unprepare()/clk_prepare() are NOPs.
But clk_prepare() has to be called at least once before clk_enable() :((
So, solution with suspend/resume will not fix current problem :( unfortunately.

FYI, Now pm_clk_suspend/pm_clk_resume are called from arch/arm/mach-keystone/pm_domain.c
(also similar solution is used by Davinci, but issue has not been detected because
PM runtime hasn't been used by Davinci IP drivers before)

Regards,
- grygorii

WARNING: multiple messages have this Message-ID (diff)
From: Grygorii Strashko <grygorii.strashko@ti.com>
To: Stephen Boyd <sboyd@codeaurora.org>,
	Len Brown <len.brown@intel.com>, Pavel Machek <pavel@ucw.cz>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: <santosh.shilimkar@ti.com>, <linux-kernel@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-pm@vger.kernel.org>,
	Mike Turquette <mturquette@linaro.org>
Subject: Re: [PATCH] PM / Clocks: fix pm_clk_resume/suspend if CONFIG_PM_RUNTIME is set
Date: Wed, 20 Nov 2013 22:11:48 +0200	[thread overview]
Message-ID: <528D1784.8080704@ti.com> (raw)
In-Reply-To: <528D1327.7080205@codeaurora.org>

On 11/20/2013 09:53 PM, Stephen Boyd wrote:
> On 11/20/13 11:06, Grygorii Strashko wrote:
>> On 11/20/2013 08:42 PM, Stephen Boyd wrote:
>>> On 11/20/13 05:31, Grygorii Strashko wrote:
>>>> @@ -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.
>>
> 
> Doesn't that mean the clock will always be prepared as long as the
> device is present? That doesn't sound good. I would like the clocks to
> be disabled and unprepared as long as the device is suspended.

Yep (

> 
> What is the lock protecting? The linked list or something more? Can we
> remove the locks?

Looks like it's protecting linked list pm_clock_entry'es.

> 
> It looks like even if you just remove the locks here, the PM core is
> free to call this function with irqs disabled if pm_runtime_irq_safe()
> has been called on the device. Perhaps runtime PM can only do the
> clk_enable()/clk_disable() part and the clk_unprepare()/clk_prepare()
> calls should happen in the system suspend callbacks?

Even don't know what to say :( On Keystone clk_unprepare()/clk_prepare() are NOPs.
But clk_prepare() has to be called at least once before clk_enable() :((
So, solution with suspend/resume will not fix current problem :( unfortunately.

FYI, Now pm_clk_suspend/pm_clk_resume are called from arch/arm/mach-keystone/pm_domain.c
(also similar solution is used by Davinci, but issue has not been detected because
PM runtime hasn't been used by Davinci IP drivers before)

Regards,
- grygorii



  reply	other threads:[~2013-11-20 20:15 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-20 13:31 [PATCH] PM / Clocks: fix pm_clk_resume/suspend if CONFIG_PM_RUNTIME is set Grygorii Strashko
2013-11-20 13:31 ` Grygorii Strashko
2013-11-20 13:31 ` Grygorii Strashko
2013-11-20 18:42 ` Stephen Boyd
2013-11-20 18:42   ` Stephen Boyd
2013-11-20 19:06   ` Grygorii Strashko
2013-11-20 19:06     ` Grygorii Strashko
2013-11-20 19:06     ` Grygorii Strashko
2013-11-20 19:53     ` Stephen Boyd
2013-11-20 19:53       ` Stephen Boyd
2013-11-20 20:11       ` Grygorii Strashko [this message]
2013-11-20 20:11         ` Grygorii Strashko
2013-11-20 20:11         ` Grygorii Strashko
2013-11-20 20:32         ` Santosh Shilimkar
2013-11-20 20:32           ` Santosh Shilimkar
2013-11-20 20:32           ` Santosh Shilimkar
2013-11-22 18:43           ` Kevin Hilman
2013-11-22 18:43             ` Kevin Hilman
2013-11-22 18:43             ` Kevin Hilman
2013-11-22 19:01             ` Santosh Shilimkar
2013-11-22 19:01               ` Santosh Shilimkar
2013-11-22 19:01               ` Santosh Shilimkar
2013-11-25 10:05               ` Grygorii Strashko
2013-11-25 10:05                 ` Grygorii Strashko
2013-11-25 10:05                 ` Grygorii Strashko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=528D1784.8080704@ti.com \
    --to=grygorii.strashko@ti.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=len.brown@intel.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mturquette@linaro.org \
    --cc=pavel@ucw.cz \
    --cc=rjw@rjwysocki.net \
    --cc=santosh.shilimkar@ti.com \
    --cc=sboyd@codeaurora.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.