All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jyri Sarha <jsarha@ti.com>
To: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: linux-pm@vger.kernel.org, pavel@ucw.cz, t-kristo@ti.com,
	tomi.valkeinen@ti.com
Subject: Re: [PATCH RFC] PM / Runtime: Better support for nested irq_safe drivers
Date: Tue, 2 Dec 2014 23:46:21 +0200	[thread overview]
Message-ID: <547E332D.3060405@ti.com> (raw)
In-Reply-To: <2710424.RMSWoOIU7o@vostro.rjw.lan>

On 12/02/2014 11:54 PM, Rafael J. Wysocki wrote:
> On Tuesday, December 02, 2014 10:19:03 PM Jyri Sarha wrote:
>> Do not lock parent of irq safe device to enabled state if the parent
>> is also irq safe.
>>
>> Before this patch the pm_runtime_irq_safe() always called
>> pm_runtime_get_sync() for the parent, locking the parent to enabled
>> state and for sure making any parent irq_safe. This is hardly optimal
>> if the parent device PM code is also irq_safe.
>>
>> After this patch the PM runtime core synchronously enables any
>> irq_safe parents of an irq_safe device when pm_runtime_get_sync() is
>> called. The parents are checked asyncronously after pm_runtime_put()
>> call.
>>
>> Signed-off-by: Jyri Sarha <jsarha@ti.com>
>> ---
>>   drivers/base/power/runtime.c |   11 ++++++-----
>>   1 file changed, 6 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
>> index 67c7938..800ca1e 100644
>> --- a/drivers/base/power/runtime.c
>> +++ b/drivers/base/power/runtime.c
>> @@ -541,7 +541,8 @@ static int rpm_suspend(struct device *dev, int rpmflags)
>>   	}
>>
>>   	/* Maybe the parent is now able to suspend. */
>> -	if (parent && !parent->power.ignore_children && !dev->power.irq_safe) {
>> +	if (parent && !parent->power.ignore_children &&
>> +	    (!dev->power.irq_safe || parent->power.irq_safe)) {
>>   		spin_unlock(&dev->power.lock);
>>
>>   		spin_lock(&parent->power.lock);
>> @@ -706,7 +707,7 @@ static int rpm_resume(struct device *dev, int rpmflags)
>>   		 * parent is permanently resumed.
>>   		 */
>>   		parent = dev->parent;
>> -		if (dev->power.irq_safe)
>> +		if (dev->power.irq_safe && !parent->power.irq_safe)
>
> Of course, you haven't read the comment above these two lines, because
> otherwise you wouldn't have submitted this patch at all.
>
> I'm not applying it.

Is there something seriously wrong with the code part too? Or is this 
just a matter of updating the comment (sorry that I missed that)?

If the thing I am doing somehow fundamentally flawed, I 	apologize. 
However, this was an RFC patch after all and the problem I am trying to 
solve is real.

>
>>   			goto skip_parent;
>>   		spin_unlock(&dev->power.lock);
>>
>> @@ -755,7 +756,7 @@ static int rpm_resume(struct device *dev, int rpmflags)
>>   		rpm_idle(dev, RPM_ASYNC);
>>
>>    out:
>> -	if (parent && !dev->power.irq_safe) {
>> +	if (parent && (!dev->power.irq_safe || parent->power.irq_safe)) {
>>   		spin_unlock_irq(&dev->power.lock);
>>
>>   		pm_runtime_put(parent);
>> @@ -1269,7 +1270,7 @@ EXPORT_SYMBOL_GPL(pm_runtime_no_callbacks);
>>    */
>>   void pm_runtime_irq_safe(struct device *dev)
>>   {
>> -	if (dev->parent)
>> +	if (dev->parent && !dev->parent->power.irq_safe)
>>   		pm_runtime_get_sync(dev->parent);
>>   	spin_lock_irq(&dev->power.lock);
>>   	dev->power.irq_safe = 1;
>> @@ -1399,7 +1400,7 @@ void pm_runtime_remove(struct device *dev)
>>   	/* Change the status back to 'suspended' to match the initial status. */
>>   	if (dev->power.runtime_status == RPM_ACTIVE)
>>   		pm_runtime_set_suspended(dev);
>> -	if (dev->power.irq_safe && dev->parent)
>> +	if (dev->power.irq_safe && dev->parent && !dev->parent->power.irq_safe)
>>   		pm_runtime_put(dev->parent);
>>   }
>>   #endif
>>
>


  reply	other threads:[~2014-12-02 21:46 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-02 20:19 [PATCH RFC] PM / Runtime: Better support for nested irq_safe drivers Jyri Sarha
2014-12-02 21:54 ` Rafael J. Wysocki
2014-12-02 21:46   ` Jyri Sarha [this message]
2014-12-02 23:11     ` Rafael J. Wysocki
2014-12-03  7:45       ` Tomi Valkeinen
2014-12-03 23:27         ` Rafael J. Wysocki
2014-12-03 15:22     ` Alan Stern
2014-12-03 15:53       ` Tomi Valkeinen
2014-12-03 18:12         ` Alan Stern
2014-12-03 23:11         ` Rafael J. Wysocki
2014-12-04 11:58           ` Jyri Sarha
2014-12-04 11:59 ` [PATCH RFC v2] " Jyri Sarha

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=547E332D.3060405@ti.com \
    --to=jsarha@ti.com \
    --cc=linux-pm@vger.kernel.org \
    --cc=pavel@ucw.cz \
    --cc=rjw@rjwysocki.net \
    --cc=t-kristo@ti.com \
    --cc=tomi.valkeinen@ti.com \
    /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.