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: ACPI Devel Maling List <linux-acpi@vger.kernel.org>,
	Linux-pm mailing list <linux-pm@lists.linux-foundation.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [patch update] Re: Run-time PM idea (was: Re: [RFC][PATCH 0/2] PM: Rearrange core suspend code)
Date: Wed, 10 Jun 2009 17:14:07 -0400 (EDT)	[thread overview]
Message-ID: <Pine.LNX.4.44L0.0906101656100.2589-100000__46070.9744169891$1244668502$gmane$org@iolanthe.rowland.org> (raw)
In-Reply-To: <200906101029.27529.rjw@sisk.pl>

On Wed, 10 Jun 2009, Rafael J. Wysocki wrote:

> > The idea is that if ->autosuspend() or ->autoresume() returns an error code,
> > this is a situation the PM core cannot recover from by itself, so it shouldn't
> > pretend it knows what's happened.  Instead, it marks the device as "I don't
> > know if it is safe to touch this" and won't handle it until the device driver
> > or bus type clears the status.

I'm still not sure this is a good idea.  When would the device driver 
clear the status?  The autosuspend and autoresume methods run 
asynchronously, so after they're done the driver doesn't get a chance 
to do anything.

It might be best just to set the status to RPM_ACTIVE if a runtime 
suspend fails and RPM_SUSPENDED if a runtime resume fails.

> Finally, I decided to follow the Oliver's suggestion that some error codes returned
> by ->autosuspend() and ->autoresume() may be regarded as "go back to the
> previous state" information.  I chose to use -EAGAIN and -EBUSY for this
> purpose.

Maybe...


>  struct dev_pm_info {
>  	pm_message_t		power_state;
> -	unsigned		can_wakeup:1;
> -	unsigned		should_wakeup:1;
> +	unsigned int		can_wakeup:1;
> +	unsigned int		should_wakeup:1;
>  	enum dpm_state		status;		/* Owned by the PM core */
>  #ifdef	CONFIG_PM_SLEEP
>  	struct list_head	entry;
>  #endif
> +#ifdef	CONFIG_PM_RUNTIME
> +	struct delayed_work	suspend_work;
> +	unsigned int		suspend_aborted:1;
> +	struct work_struct	resume_work;
> +	struct completion	work_done;
> +	enum rpm_state		runtime_status;
> +	spinlock_t		lock;
> +#endif
>  };

You know, it doesn't make any sense to have a suspend and a resume 
both pending at the same time.  So you could add only a delayed_work 
structure and use its embedded work_struct for resume requests.

Also, you might borrow a trick from Dave Brownell.  Define the RPM_*
values so that the individual bits have meanings.  Then instead of
testing for multiple possible values of runtime_status, you could do a
simple bit test.

> +/**
> + * pm_device_suspended - Check if given device has been suspended at run time.
> + * @dev: Device to check.
> + * @data: Ignored.
> + *
> + * Returns 0 if the device has been suspended or -EBUSY otherwise.
> + */
> +static int pm_device_suspended(struct device *dev, void *data)
> +{
> +	int ret;
> +
> +	spin_lock(&dev->power.lock);
> +
> +	ret = dev->power.runtime_status == RPM_SUSPENDED ? 0 : -EBUSY;
> +
> +	spin_unlock(&dev->power.lock);

How does acquiring the lock help here?

> +/**
> + * pm_check_children - Check if all children of a device have been suspended.
> + * @dev: Device to check.
> + *
> + * Returns 0 if all children of the device have been suspended or -EBUSY
> + * otherwise.
> + */

We might want to do a runtime suspend even if the device's children
aren't already suspended.  For example, you could suspend a link while
leaving the device on the other end of the link at full power --
especially if powering down the device is slow but changing the link's
power level is fast.

> +/**
> + * pm_autosuspend - Run autosuspend callback of given device object's bus type.
> + * @work: Work structure used for scheduling the execution of this function.
> + *
> + * Use @work to get the device object the suspend has been scheduled for,
> + * check if the suspend request hasn't been cancelled and run the
> + * ->autosuspend() callback from the device's bus type driver.  Update the
> + * run-time PM flags in the device object to reflect the current status of the
> + * device.
> + */
> +static void pm_autosuspend(struct work_struct *work)

Can we call this something else?  "Autosuspend" implies that the 
suspend originated from within the kernel.  How about "pm_suspend_work" 
or "pm_runtime_suspend"?  Likewise for the resume routines.

I haven't checked the details of the code yet.  More later...

Alan Stern

  parent reply	other threads:[~2009-06-10 21:14 UTC|newest]

Thread overview: 199+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-06 22:54 [RFC][PATCH 0/2] PM: Rearrange core suspend code Rafael J. Wysocki
2009-06-06 22:55 ` [RFC][PATCH 1/2] PM: Separate suspend to RAM functionality from core Rafael J. Wysocki
2009-06-06 22:55 ` Rafael J. Wysocki
2009-06-08  6:36   ` Pavel Machek
2009-06-08  6:36   ` Pavel Machek
2009-06-06 22:56 ` [RFC][PATCH 2/2] PM/Hibernate: Rename disk.c to hibernate.c Rafael J. Wysocki
2009-06-06 22:56 ` Rafael J. Wysocki
2009-06-08  6:37   ` Pavel Machek
2009-06-08  6:37   ` Pavel Machek
2009-06-07 20:51 ` [RFC][PATCH 0/2] PM: Rearrange core suspend code Alan Stern
2009-06-07 20:51 ` [linux-pm] " Alan Stern
2009-06-07 21:46   ` Run-time PM idea (was: Re: [RFC][PATCH 0/2] PM: Rearrange core suspend code) Rafael J. Wysocki
2009-06-07 21:46   ` Run-time PM idea (was: Re: [linux-pm] " Rafael J. Wysocki
2009-06-07 22:02     ` Run-time PM idea (was: " Oliver Neukum
2009-06-07 22:02     ` Run-time PM idea (was: Re: [linux-pm] " Oliver Neukum
2009-06-07 22:02       ` Oliver Neukum
2009-06-07 22:05     ` Run-time PM idea (was: " Oliver Neukum
2009-06-07 22:05     ` [linux-pm] " Oliver Neukum
2009-06-08 11:29       ` Rafael J. Wysocki
2009-06-08 11:29       ` [linux-pm] " Rafael J. Wysocki
2009-06-08 12:04         ` Oliver Neukum
2009-06-08 18:34           ` Rafael J. Wysocki
2009-06-09  7:25             ` Oliver Neukum
2009-06-09  7:25             ` [linux-pm] " Oliver Neukum
2009-06-09 14:33               ` Alan Stern
2009-06-09 14:33               ` [linux-pm] " Alan Stern
2009-06-09 14:33                 ` Alan Stern
2009-06-09 14:48                 ` Oliver Neukum
2009-06-09 14:48                   ` Oliver Neukum
2009-06-09 14:48                 ` Oliver Neukum
2009-06-09 22:44               ` [linux-pm] " Rafael J. Wysocki
2009-06-09 22:44               ` Rafael J. Wysocki
2009-06-08 18:34           ` Rafael J. Wysocki
2009-06-08 12:04         ` Oliver Neukum
2009-06-08 20:35         ` Alan Stern
2009-06-08 20:35         ` [linux-pm] " Alan Stern
2009-06-08 20:35           ` Alan Stern
2009-06-08 21:31           ` Rafael J. Wysocki
2009-06-09  2:49             ` Alan Stern
2009-06-09  2:49               ` Alan Stern
2009-06-09 22:57               ` Rafael J. Wysocki
2009-06-10  8:29                 ` [patch update] " Rafael J. Wysocki
2009-06-10  8:29                 ` [patch update] Re: [linux-pm] " Rafael J. Wysocki
2009-06-10 14:20                   ` [patch update] " Oliver Neukum
2009-06-10 14:20                   ` [patch update] Re: [linux-pm] " Oliver Neukum
2009-06-10 19:27                     ` Rafael J. Wysocki
2009-06-10 21:38                       ` Oliver Neukum
2009-06-10 21:38                         ` Oliver Neukum
2009-06-10 22:01                         ` [patch update] " Rafael J. Wysocki
2009-06-10 22:01                         ` [patch update] Re: [linux-pm] " Rafael J. Wysocki
2009-06-10 23:07                           ` Oliver Neukum
2009-06-10 23:07                             ` Oliver Neukum
2009-06-10 23:42                             ` [patch update] " Alan Stern
2009-06-10 23:42                             ` [patch update] Re: [linux-pm] " Alan Stern
2009-06-10 23:42                               ` Alan Stern
2009-06-11 13:48                               ` Rafael J. Wysocki
2009-06-11 13:57                                 ` [patch update] " Oliver Neukum
2009-06-11 13:57                                 ` [patch update] Re: [linux-pm] " Oliver Neukum
2009-06-11 14:16                                   ` [patch update] " Alan Stern
2009-06-11 14:16                                   ` [patch update] Re: [linux-pm] " Alan Stern
2009-06-11 14:16                                     ` Alan Stern
2009-06-11 19:38                                     ` [patch update] " Rafael J. Wysocki
2009-06-11 19:38                                     ` [patch update] Re: [linux-pm] " Rafael J. Wysocki
2009-06-11 13:48                               ` [patch update] " Rafael J. Wysocki
2009-06-11 13:46                             ` Rafael J. Wysocki
2009-06-11 13:46                             ` [patch update] Re: [linux-pm] " Rafael J. Wysocki
2009-06-10 23:07                           ` [patch update] " Oliver Neukum
2009-06-10 21:38                       ` Oliver Neukum
2009-06-10 19:27                     ` Rafael J. Wysocki
2009-06-10 21:14                   ` Alan Stern [this message]
2009-06-10 21:14                   ` [patch update] Re: [linux-pm] " Alan Stern
2009-06-10 21:31                     ` [patch update] " Rafael J. Wysocki
2009-06-10 21:31                     ` [patch update] Re: [linux-pm] " Rafael J. Wysocki
2009-06-10 23:15                       ` [patch update] " Oliver Neukum
2009-06-10 23:15                       ` [patch update] Re: [linux-pm] " Oliver Neukum
2009-06-10 23:15                         ` Oliver Neukum
2009-06-11  5:27                         ` [patch update] " Magnus Damm
2009-06-11  5:27                         ` [patch update] Re: [linux-pm] " Magnus Damm
2009-06-11  5:27                           ` Magnus Damm
2009-06-10 23:42                       ` Alan Stern
2009-06-11 14:17                         ` [patch update] " Rafael J. Wysocki
2009-06-11 14:17                           ` [patch update] Re: [linux-pm] " Rafael J. Wysocki
2009-06-11 14:52                           ` [patch update] " Alan Stern
2009-06-11 14:52                           ` [patch update] Re: [linux-pm] " Alan Stern
2009-06-11 15:06                             ` Oliver Neukum
2009-06-11 15:06                               ` Oliver Neukum
2009-06-11 15:22                               ` Alan Stern
2009-06-11 15:22                                 ` Alan Stern
2009-06-11 16:05                                 ` Oliver Neukum
2009-06-11 16:05                                   ` Oliver Neukum
2009-06-11 18:36                                   ` [patch update] " Alan Stern
2009-06-11 18:36                                   ` [patch update] Re: [linux-pm] " Alan Stern
2009-06-11 18:36                                     ` Alan Stern
2009-06-11 21:05                                     ` [patch update] " Oliver Neukum
2009-06-11 21:05                                     ` [patch update] Re: [linux-pm] " Oliver Neukum
2009-06-11 21:05                                       ` Oliver Neukum
2009-06-12  2:16                                       ` Alan Stern
2009-06-12  2:16                                         ` Alan Stern
2009-06-12  8:15                                         ` Oliver Neukum
2009-06-12 14:32                                           ` [patch update] " Alan Stern
2009-06-12 14:32                                           ` [patch update] Re: [linux-pm] " Alan Stern
2009-06-12 14:32                                             ` Alan Stern
2009-06-12 19:09                                             ` [patch update] " Rafael J. Wysocki
2009-06-12 19:09                                             ` [patch update] Re: [linux-pm] " Rafael J. Wysocki
2009-06-12 19:48                                               ` Alan Stern
2009-06-12 19:56                                                 ` [patch update] " Rafael J. Wysocki
2009-06-12 19:56                                                 ` [patch update] Re: [linux-pm] " Rafael J. Wysocki
2009-06-12 21:23                                                   ` Alan Stern
2009-06-12 23:06                                                     ` [patch update] " Rafael J. Wysocki
2009-06-12 23:06                                                     ` [patch update] Re: [linux-pm] " Rafael J. Wysocki
2009-06-13 18:08                                                       ` [patch update] " Alan Stern
2009-06-13 18:08                                                       ` [patch update] Re: [linux-pm] " Alan Stern
2009-06-13 22:04                                                         ` [patch update] " Rafael J. Wysocki
2009-06-13 22:04                                                         ` [patch update] Re: [linux-pm] " Rafael J. Wysocki
2009-06-12 21:23                                                   ` [patch update] " Alan Stern
2009-06-12 19:48                                               ` Alan Stern
2009-06-12  8:15                                         ` Oliver Neukum
2009-06-12  2:16                                       ` Alan Stern
2009-06-11 16:05                                 ` Oliver Neukum
2009-06-11 15:22                               ` Alan Stern
2009-06-11 15:06                             ` Oliver Neukum
2009-06-11 19:43                             ` Rafael J. Wysocki
2009-06-11 19:43                             ` [patch update] Re: [linux-pm] " Rafael J. Wysocki
2009-06-12 14:25                               ` [patch update] " Alan Stern
2009-06-12 14:25                               ` [patch update] Re: [linux-pm] " Alan Stern
2009-06-10 23:42                       ` [patch update] " Alan Stern
2009-06-11  5:18                   ` [patch update] Re: [linux-pm] " Magnus Damm
2009-06-11  5:18                     ` Magnus Damm
2009-06-11  9:08                     ` Oliver Neukum
2009-06-12  3:13                       ` [patch update] " Magnus Damm
2009-06-12  3:13                         ` [patch update] Re: [linux-pm] " Magnus Damm
2009-06-12  8:11                         ` Oliver Neukum
2009-06-12 10:54                           ` [patch update] " Magnus Damm
2009-06-12 10:54                           ` [patch update] Re: [linux-pm] " Magnus Damm
2009-06-12 10:54                             ` Magnus Damm
2009-06-12  8:11                         ` [patch update] " Oliver Neukum
2009-06-11  9:08                     ` Oliver Neukum
2009-06-11  5:18                   ` Magnus Damm
2009-06-10 20:48                 ` [linux-pm] " Alan Stern
2009-06-10 20:48                   ` Alan Stern
2009-06-10 21:15                   ` Rafael J. Wysocki
2009-06-10 21:15                   ` [linux-pm] " Rafael J. Wysocki
2009-06-10 20:48                 ` Alan Stern
2009-06-09 22:57               ` Rafael J. Wysocki
2009-06-09  2:49             ` Alan Stern
2009-06-09  7:31             ` [linux-pm] " Oliver Neukum
2009-06-09  7:31               ` Oliver Neukum
2009-06-09 23:02               ` Rafael J. Wysocki
2009-06-09 23:02               ` [linux-pm] " Rafael J. Wysocki
2009-06-09  7:31             ` Oliver Neukum
2009-06-08 21:31           ` Rafael J. Wysocki
2009-06-08  6:54     ` Ingo Molnar
2009-06-08  6:54     ` Run-time PM idea (was: Re: [linux-pm] " Ingo Molnar
2009-06-08 11:30       ` Rafael J. Wysocki
2009-06-08 13:05         ` Ingo Molnar
2009-06-08 13:11           ` Matthew Garrett
2009-06-08 13:22             ` Run-time PM idea (was: " Ingo Molnar
2009-06-08 13:22             ` Run-time PM idea (was: Re: [linux-pm] " Ingo Molnar
2009-06-08 13:32               ` Matthew Garrett
2009-06-08 13:46                 ` Run-time PM idea (was: " Ingo Molnar
2009-06-08 13:46                 ` Run-time PM idea (was: Re: [linux-pm] " Ingo Molnar
2009-06-08 13:54                   ` Run-time PM idea (was: " Matthew Garrett
2009-06-08 13:54                   ` Run-time PM idea (was: Re: [linux-pm] " Matthew Garrett
2009-06-08 14:24                     ` Run-time PM idea (was: " Ingo Molnar
2009-06-08 14:24                     ` Run-time PM idea (was: Re: [linux-pm] " Ingo Molnar
2009-06-08 14:35                       ` Run-time PM idea (was: " Matthew Garrett
2009-06-08 14:35                         ` Run-time PM idea (was: Re: [linux-pm] " Matthew Garrett
2009-06-08 14:44                         ` Run-time PM idea (was: " Ingo Molnar
2009-06-08 14:44                         ` Run-time PM idea (was: Re: [linux-pm] " Ingo Molnar
2009-06-08 14:51                           ` Matthew Garrett
2009-06-24 15:03                             ` Run-time PM idea (was: " Pavel Machek
2009-06-24 15:03                               ` Run-time PM idea (was: Re: [linux-pm] " Pavel Machek
2009-06-08 14:51                           ` Run-time PM idea (was: " Matthew Garrett
2009-06-19  1:50                         ` Robert Hancock
2009-06-19  1:50                         ` Robert Hancock
2009-06-08 13:58                   ` Oliver Neukum
2009-06-08 13:58                   ` Run-time PM idea (was: Re: [linux-pm] " Oliver Neukum
2009-06-08 13:58                     ` Oliver Neukum
2009-06-08 13:32               ` Run-time PM idea (was: " Matthew Garrett
2009-06-08 13:39               ` Oliver Neukum
2009-06-08 13:39               ` Run-time PM idea (was: Re: [linux-pm] " Oliver Neukum
2009-06-08 13:44                 ` Run-time PM idea (was: " Matthew Garrett
2009-06-08 13:44                 ` Run-time PM idea (was: Re: [linux-pm] " Matthew Garrett
2009-06-08 14:21                 ` Ingo Molnar
2009-06-08 14:30                   ` Matthew Garrett
2009-06-08 15:06                     ` Run-time PM idea (was: " Ingo Molnar
2009-06-08 15:06                     ` Run-time PM idea (was: Re: [linux-pm] " Ingo Molnar
2009-06-08 15:11                       ` Matthew Garrett
2009-06-08 15:11                       ` Run-time PM idea (was: " Matthew Garrett
2009-06-08 16:29                       ` Ray Lee
2009-06-08 16:29                       ` Run-time PM idea (was: Re: [linux-pm] " Ray Lee
2009-06-08 16:29                         ` Ray Lee
2009-06-08 14:30                   ` Run-time PM idea (was: " Matthew Garrett
2009-06-09 22:44                   ` Jiri Kosina
2009-06-09 22:44                   ` Run-time PM idea (was: Re: [linux-pm] " Jiri Kosina
2009-06-08 14:21                 ` Run-time PM idea (was: " Ingo Molnar
2009-06-08 13:11           ` Matthew Garrett
2009-06-08 13:05         ` Ingo Molnar
2009-06-08 11:30       ` 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.0906101656100.2589-100000__46070.9744169891$1244668502$gmane$org@iolanthe.rowland.org' \
    --to=stern@rowland.harvard.edu \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@lists.linux-foundation.org \
    --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.