All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alan Stern <stern@rowland.harvard.edu>
To: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: Greg KH <gregkh@suse.de>, LKML <linux-kernel@vger.kernel.org>,
	ACPI Devel Maling List <linux-acpi@vger.kernel.org>,
	linux-pm@lists.linux-foundation.org, Ingo Molnar <mingo@elte.hu>
Subject: Re: [patch update 3] PM: Introduce core framework for run-time PM of I/O devices
Date: Sat, 20 Jun 2009 22:23:00 -0400 (EDT)	[thread overview]
Message-ID: <Pine.LNX.4.44L0.0906202142110.20502-100000__48473.308972507$1245551044$gmane$org@netrider.rowland.org> (raw)
In-Reply-To: <200906210138.53682.rjw@sisk.pl>

On Sun, 21 Jun 2009, Rafael J. Wysocki wrote:

> > 	pm_request_suspend should run very quickly, since it will be
> > 	called after every I/O operation.  Likewise, pm_request_resume
> > 	should run very quickly if the status is RPM_ACTIVE or 
> > 	RPM_IDLE.
> 
> Hmm.  pm_request_suspend() is really short, so it should be fast.
> pm_request_resume() is a bit more complicated, though (it takes two spinlocks,
> increases an atomic counter, possibly twice, and queues up a work item, also
> in the RPM_IDLE case).

Hmm, maybe that's a good reason for not trying to handle the parent
from within pm_request_resume().  :-)

Or maybe the routine should be optimized for the RPM_ACTIVE and 
RPM_IDLE cases, where it doesn't have to do much anyway.


> > 	In order to prevent autosuspends from occurring while I/O is
> > 	in progress, the pm_request_resume call should increment the
> > 	usage counter (if it had to queue the request) and the 
> > 	pm_request_suspend call should decrement it (maybe after
> > 	waiting for the delay).
> 
> I don't want like pm_request_suspend() to do that, because it's valid to
> call it many times in a row. (only the first request will be queued in such a
> case).

Sorry, what I meant was that in each case the counter should be
{inc,dec}remented if a new request had to be queued.  If one was
already queued then the counter should be left alone.

The reason behind this is that a bunch of pm_request_suspend calls
which all end up referring to the same workqueue item will result in a
single async call to the runtime_suspend method.  Therefore they should
cause a single decrement of the counter.  Likewise for
pm_request_resume.

> I'd prefer the caller to do pm_request_resume_get() (please see the patch
> below) to put a resume request into the queue and then pm_runtime_put_notify()
> when it's done with the I/O.  That will result in ->runtime_idle() being called
> automatically if the device may be suspended.

If anyone does pm_request_resume or pm_runtime_resume, what is there to 
prevent the device from being suspended again as soon as the resume is 
finished (and before anything useful can be accomplished)?

     1. The driver's runtime_suspend method might be smart enough to 
	return -EBUSY until the driver has completed whatever it's 
	doing.

     2. The usage counter might be > 0.

     3. The number of children might be > 0.

In case 1 there's no reason not to also increment the counter, since
the driver can decrement it again when it is finished.  In cases 2 and
3, we can assume the counter or the number of children was previously
equal to 0, since otherwise the resume call would have been vacuous.  
This implies that the resume call itself should be responsible for
incrementing either the counter or the number of children.

What I'm getting at is this: There's no real point to having separate 
pm_request_resume and pm_request_resume_get calls.  All such calls 
should increment either the usage counter or the number of children.

(In the USB stack, a single counter is used for both purposes.  It 
doesn't look like that will work here.)


> > All bus types will want to implement _some_ delay; it doesn't make
> > sense to power down a device immediately after every operation and then
> > power it back up for the next operation.
> 
> Sure.  But you can use the pm_request_resume()'s delay to achieve that
> without storing the delay in 'struct device'.  It seems.

If you do it that way then the delay has to be hard-coded or stored in
some non-standardized location.  Which will be more common: devices
where the delay is fixed by the bus type (or driver), or devices where
the user should be able to adjust the delay?  If user-adjustable is 
more common then the delay should be stored in dev_pm_info, so that it 
can be controlled by a centralized sysfs attribute defined in the 
driver core.  If not then you are right, the delay doesn't need to be 
stored in struct device.

Alan Stern

  reply	other threads:[~2009-06-21  2:23 UTC|newest]

Thread overview: 117+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-13 22:23 [PATCH] PM: Introduce core framework for run-time PM of I/O devices Rafael J. Wysocki
2009-06-14  9:41 ` Magnus Damm
2009-06-14  9:41 ` Magnus Damm
2009-06-14  9:41   ` Magnus Damm
2009-06-14 10:29   ` Rafael J. Wysocki
2009-06-14 10:29   ` Rafael J. Wysocki
2009-06-14  9:58 ` [linux-pm] " Rafael J. Wysocki
2009-06-14 22:57   ` [patch update] " Rafael J. Wysocki
2009-06-14 23:18     ` Arjan van de Ven
2009-06-15 20:02       ` Rafael J. Wysocki
2009-06-15 20:02       ` Rafael J. Wysocki
2009-06-14 23:18     ` Arjan van de Ven
2009-06-15 21:08     ` Alan Stern
2009-06-15 21:08     ` Alan Stern
2009-06-15 21:08       ` Alan Stern
2009-06-15 23:21       ` Rafael J. Wysocki
2009-06-16 14:30         ` Alan Stern
2009-06-16 14:30         ` Alan Stern
2009-06-16 14:30           ` Alan Stern
2009-06-16 21:30           ` [patch update 2] " Rafael J. Wysocki
2009-06-16 21:30           ` Rafael J. Wysocki
2009-06-16 22:33             ` [patch update 2 fix] " Rafael J. Wysocki
2009-06-17 20:08               ` Alan Stern
2009-06-17 20:08                 ` Alan Stern
2009-06-17 23:07                 ` Rafael J. Wysocki
2009-06-18 18:17                   ` Alan Stern
2009-06-18 18:17                   ` Alan Stern
2009-06-18 18:17                     ` Alan Stern
2009-06-19  0:38                     ` Rafael J. Wysocki
2009-06-19  0:38                     ` Rafael J. Wysocki
2009-06-19 16:25                       ` Alan Stern
2009-06-19 16:25                       ` Alan Stern
2009-06-19 16:25                         ` Alan Stern
2009-06-19 22:42                         ` Rafael J. Wysocki
2009-06-20  2:34                           ` Alan Stern
2009-06-20  2:34                           ` Alan Stern
2009-06-20  2:34                             ` Alan Stern
2009-06-20 14:30                             ` Alan Stern
2009-06-20 14:30                             ` [linux-pm] " Alan Stern
2009-06-20 23:48                               ` Rafael J. Wysocki
2009-06-20 23:48                               ` [linux-pm] " Rafael J. Wysocki
2009-06-21  2:30                                 ` Alan Stern
2009-06-21  2:30                                 ` [linux-pm] " Alan Stern
2009-06-21 11:32                                   ` Rafael J. Wysocki
2009-06-21 11:32                                   ` [linux-pm] " Rafael J. Wysocki
2009-06-22 14:16                                     ` Alan Stern
2009-06-22 15:27                                       ` Rafael J. Wysocki
2009-06-22 15:27                                       ` [linux-pm] " Rafael J. Wysocki
2009-06-22 15:39                                         ` Alan Stern
2009-06-22 15:53                                           ` Rafael J. Wysocki
2009-06-22 15:53                                           ` [linux-pm] " Rafael J. Wysocki
2009-06-22 15:39                                         ` Alan Stern
2009-06-22 14:16                                     ` Alan Stern
2009-06-22  6:20                               ` [linux-pm] " Magnus Damm
2009-06-22  6:20                                 ` Magnus Damm
2009-06-22  6:43                                 ` Arjan van de Ven
2009-06-22  6:43                                   ` Arjan van de Ven
2009-06-22  7:27                                   ` Magnus Damm
2009-06-22  7:27                                     ` [linux-pm] " Magnus Damm
2009-06-22 13:49                                     ` Arjan van de Ven
2009-06-22 13:49                                     ` [linux-pm] " Arjan van de Ven
2009-06-22 13:49                                       ` Arjan van de Ven
2009-06-22 15:39                                       ` Rafael J. Wysocki
2009-06-22 15:39                                       ` [linux-pm] " Rafael J. Wysocki
2009-06-22 15:33                                   ` Rafael J. Wysocki
2009-06-22 15:33                                   ` Rafael J. Wysocki
2009-06-22  6:43                                 ` Arjan van de Ven
2009-06-22  8:15                                 ` [linux-pm] " Oliver Neukum
2009-06-22  8:15                                 ` Oliver Neukum
2009-06-22  6:20                               ` Magnus Damm
2009-06-20 23:38                             ` [patch update 3] " Rafael J. Wysocki
2009-06-21  2:23                               ` Alan Stern [this message]
2009-06-21  2:23                               ` Alan Stern
2009-06-21  2:23                                 ` Alan Stern
2009-06-21 12:46                                 ` Rafael J. Wysocki
2009-06-21 12:46                                 ` Rafael J. Wysocki
2009-06-22 15:01                                   ` Alan Stern
2009-06-22 15:01                                     ` Alan Stern
2009-06-22 15:49                                     ` Rafael J. Wysocki
2009-06-22 15:49                                     ` Rafael J. Wysocki
2009-06-22 16:28                                       ` Alan Stern
2009-06-22 16:28                                       ` Alan Stern
2009-06-22 16:28                                         ` Alan Stern
2009-06-22 23:02                                         ` Rafael J. Wysocki
2009-06-22 23:02                                         ` Rafael J. Wysocki
2009-06-23 17:02                                       ` Alan Stern
2009-06-23 17:02                                       ` Alan Stern
2009-06-23 17:02                                         ` Alan Stern
2009-06-23 17:45                                         ` Rafael J. Wysocki
2009-06-23 18:26                                           ` Alan Stern
2009-06-23 18:26                                           ` Alan Stern
2009-06-23 18:26                                             ` Alan Stern
2009-06-24  0:17                                             ` Rafael J. Wysocki
2009-06-24  0:17                                             ` Rafael J. Wysocki
2009-06-24 14:51                                               ` Alan Stern
2009-06-24 14:51                                               ` Alan Stern
2009-06-24 19:14                                                 ` Rafael J. Wysocki
2009-06-24 19:14                                                 ` Rafael J. Wysocki
2009-06-24 20:19                                                   ` Alan Stern
2009-06-24 20:19                                                   ` Alan Stern
2009-06-24 21:23                                                     ` Rafael J. Wysocki
2009-06-24 21:23                                                     ` Rafael J. Wysocki
2009-06-23 17:45                                         ` Rafael J. Wysocki
2009-06-20 23:38                             ` Rafael J. Wysocki
2009-06-19 22:42                         ` [patch update 2 fix] " Rafael J. Wysocki
2009-06-17 23:07                 ` Rafael J. Wysocki
2009-06-17 20:08               ` Alan Stern
2009-06-16 22:33             ` Rafael J. Wysocki
2009-06-15 23:21       ` [patch update] " Rafael J. Wysocki
2009-06-24 15:04     ` Pavel Machek
2009-06-27 21:52       ` Rafael J. Wysocki
2009-07-06  8:28         ` Pavel Machek
2009-07-06  8:28         ` Pavel Machek
2009-06-27 21:52       ` Rafael J. Wysocki
2009-06-24 15:04     ` Pavel Machek
2009-06-14 22:57   ` Rafael J. Wysocki
2009-06-14  9:58 ` [PATCH] " Rafael J. Wysocki

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='Pine.LNX.4.44L0.0906202142110.20502-100000__48473.308972507$1245551044$gmane$org@netrider.rowland.org' \
    --to=stern@rowland.harvard.edu \
    --cc=gregkh@suse.de \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@lists.linux-foundation.org \
    --cc=mingo@elte.hu \
    --cc=rjw@sisk.pl \
    /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.