All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alan Stern <stern@rowland.harvard.edu>
To: Ohad Ben-Cohen <ohad@wizery.com>
Cc: "Rafael J. Wysocki" <rjw@sisk.pl>,
	<linux-pm@lists.linux-foundation.org>,
	Johannes Berg <johannes@sipsolutions.net>,
	<linux-wireless@vger.kernel.org>, <linux-mmc@vger.kernel.org>,
	Ido Yariv <ido@wizery.com>,
	Kevin Hilman <khilman@deeprootsystems.com>
Subject: Re: [linux-pm] subtle pm_runtime_put_sync race and sdio functions
Date: Sun, 26 Dec 2010 12:00:25 -0500 (EST)	[thread overview]
Message-ID: <Pine.LNX.4.44L0.1012261050050.18773-100000@netrider.rowland.org> (raw)
In-Reply-To: <AANLkTinyKfwcZLD5D4rdF6OpQqr79F==GRjAMBjjbupW@mail.gmail.com>

On Sun, 26 Dec 2010, Ohad Ben-Cohen wrote:

> On Sun, Dec 26, 2010 at 4:48 AM, Alan Stern <stern@rowland.harvard.edu> wrote:
> > Is there a separate handler responsible for powering the device back
> > on?  What are the names of these handlers?
> 
> wl1271_sdio_power_on() and wl1271_sdio_power_off().
> 
> If you're taking a look, please do so using the latest code as seen on mmc-next:
> 
> git://git.kernel.org/pub/scm/linux/kernel/git/cjb/mmc.git mmc-next

Hmm.  It's a little difficult to untangle the web of dev_pm_ops
pointers and other stuff.  There's wl1271_suspend() and wl1271_resume()
(which don't do anything) plus wl1271_sdio_set_power(), which calls
either wl1271_sdio_power_on() or wl1271_sdio_power_off(), and these
routines in turn call pm_runtime_get_sync() and pm_runtime_put_sync().

Under what circumstances does the MMC/SDIO core call 
wl1271_sdio_set_power(), and where are those function calls?

> > That's not a race
> 
> It is.
> 
> If system suspend will continue uninterruptedly, and the driver will
> be suspended (by the SDIO subsystem), then the device will be powered
> down, and everything will work.
> 
> But if something will interrupt the suspend transition _before_ our
> driver is suspended (e.g. some other suspend() handler will fail),
> then we have a problem, because the device will not be reset as the
> driver needs it to be.

The normal case is that system suspend succeeds.  Then there is no 
race.  If system suspend fails then the failure may occur either before 
or after the wl1271 device is powered down; _that_ is the race 
(assuming you are using asynchronous PM).  But normally it doesn't 
occur.

> > What is the name of the driver's runtime_suspend routine?
> 
> The driver itself doesn't have one; power is being controlled by the
> MMC/SDIO subsystem, so the actual runtime_suspend handler is
> mmc_runtime_suspend().

You mean, the wl1271 device has no PM methods of its own; its power is 
managed entirely by the parent MMC/SDIO controller?  If that's right 
then you should call pm_runtime_no_callbacks() for the wl1271 device.

Is it possible for there to be more than one device connected to the 
same MMC/SDIO controller?  If it is, how do you reset one without 
resetting all the others?

> > And while we're at it, what is the name of the routine that _actually_ changes the
> > device's power level?
> 
> mmc_power_save_host(), which is called by mmc_runtime_suspend().
> 
> (well, more accurately it is actually fixed_voltage_disable(), but
> that's a few levels deeper than I think you'll be interested in)

That's for runtime PM.  What about system sleep?  It looks like
sdio_bus_type has no callbacks for suspend or resume, so the driver's
callbacks get used instead -- that would be wl1271_suspend() and
wl1271_resume().  But they don't do anything, so there's no power
change until the parent MMC/SDIO controller is suspended.  That would
be in mmc_sdio_suspend() and mmc_sdio_resume()?  But I can't tell what
pmops->suspend and pmops->resume methods they end up calling.  Are
these the entries in wl1271_sdio_pm_ops?  Does that mean
wl1271_suspend() and wl1271_resume() get called twice?

I think I already understand how the runtime suspend/resume paths work:
There are no runtime PM methods for the wl1271 device, so the PM core
simply propagates changes up to the parent MMC/SDIO device and ends up
calling mmc_runtime_suspend() or mmc_runtime_resume().  Right?

What is the pathway for reset (or other similar activities that 
require the device to be powered-down while it is in use)?  
wl1271_sdio_reset() doesn't do anything.

Alan Stern


WARNING: multiple messages have this Message-ID (diff)
From: Alan Stern <stern-nwvwT67g6+6dFdvTe/nMLpVzexx5G7lz@public.gmane.org>
To: Ohad Ben-Cohen <ohad-Ix1uc/W3ht7QT0dZR+AlfA@public.gmane.org>
Cc: "Rafael J. Wysocki" <rjw-KKrjLPT3xs0@public.gmane.org>,
	linux-pm-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org,
	Johannes Berg <johannes-cdvu00un1VgdHxzADdlk8Q@public.gmane.org>,
	linux-wireless-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-mmc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Ido Yariv <ido-Ix1uc/W3ht7QT0dZR+AlfA@public.gmane.org>,
	Kevin Hilman
	<khilman-1D3HCaltpLuhEniVeURVKkEOCMrvLtNR@public.gmane.org>
Subject: Re: [linux-pm] subtle pm_runtime_put_sync race and sdio functions
Date: Sun, 26 Dec 2010 12:00:25 -0500 (EST)	[thread overview]
Message-ID: <Pine.LNX.4.44L0.1012261050050.18773-100000@netrider.rowland.org> (raw)
In-Reply-To: <AANLkTinyKfwcZLD5D4rdF6OpQqr79F==GRjAMBjjbupW-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

On Sun, 26 Dec 2010, Ohad Ben-Cohen wrote:

> On Sun, Dec 26, 2010 at 4:48 AM, Alan Stern <stern-nwvwT67g6+6dFdvTe/nMLsd9G2dDO2Ms@public.gmane.orgu> wrote:
> > Is there a separate handler responsible for powering the device back
> > on?  What are the names of these handlers?
> 
> wl1271_sdio_power_on() and wl1271_sdio_power_off().
> 
> If you're taking a look, please do so using the latest code as seen on mmc-next:
> 
> git://git.kernel.org/pub/scm/linux/kernel/git/cjb/mmc.git mmc-next

Hmm.  It's a little difficult to untangle the web of dev_pm_ops
pointers and other stuff.  There's wl1271_suspend() and wl1271_resume()
(which don't do anything) plus wl1271_sdio_set_power(), which calls
either wl1271_sdio_power_on() or wl1271_sdio_power_off(), and these
routines in turn call pm_runtime_get_sync() and pm_runtime_put_sync().

Under what circumstances does the MMC/SDIO core call 
wl1271_sdio_set_power(), and where are those function calls?

> > That's not a race
> 
> It is.
> 
> If system suspend will continue uninterruptedly, and the driver will
> be suspended (by the SDIO subsystem), then the device will be powered
> down, and everything will work.
> 
> But if something will interrupt the suspend transition _before_ our
> driver is suspended (e.g. some other suspend() handler will fail),
> then we have a problem, because the device will not be reset as the
> driver needs it to be.

The normal case is that system suspend succeeds.  Then there is no 
race.  If system suspend fails then the failure may occur either before 
or after the wl1271 device is powered down; _that_ is the race 
(assuming you are using asynchronous PM).  But normally it doesn't 
occur.

> > What is the name of the driver's runtime_suspend routine?
> 
> The driver itself doesn't have one; power is being controlled by the
> MMC/SDIO subsystem, so the actual runtime_suspend handler is
> mmc_runtime_suspend().

You mean, the wl1271 device has no PM methods of its own; its power is 
managed entirely by the parent MMC/SDIO controller?  If that's right 
then you should call pm_runtime_no_callbacks() for the wl1271 device.

Is it possible for there to be more than one device connected to the 
same MMC/SDIO controller?  If it is, how do you reset one without 
resetting all the others?

> > And while we're at it, what is the name of the routine that _actually_ changes the
> > device's power level?
> 
> mmc_power_save_host(), which is called by mmc_runtime_suspend().
> 
> (well, more accurately it is actually fixed_voltage_disable(), but
> that's a few levels deeper than I think you'll be interested in)

That's for runtime PM.  What about system sleep?  It looks like
sdio_bus_type has no callbacks for suspend or resume, so the driver's
callbacks get used instead -- that would be wl1271_suspend() and
wl1271_resume().  But they don't do anything, so there's no power
change until the parent MMC/SDIO controller is suspended.  That would
be in mmc_sdio_suspend() and mmc_sdio_resume()?  But I can't tell what
pmops->suspend and pmops->resume methods they end up calling.  Are
these the entries in wl1271_sdio_pm_ops?  Does that mean
wl1271_suspend() and wl1271_resume() get called twice?

I think I already understand how the runtime suspend/resume paths work:
There are no runtime PM methods for the wl1271 device, so the PM core
simply propagates changes up to the parent MMC/SDIO device and ends up
calling mmc_runtime_suspend() or mmc_runtime_resume().  Right?

What is the pathway for reset (or other similar activities that 
require the device to be powered-down while it is in use)?  
wl1271_sdio_reset() doesn't do anything.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2010-12-26 17:00 UTC|newest]

Thread overview: 179+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-09 23:37 subtle pm_runtime_put_sync race and sdio functions Ohad Ben-Cohen
2010-12-10  0:00 ` Rafael J. Wysocki
2010-12-10  0:00 ` [linux-pm] " Rafael J. Wysocki
2010-12-10 17:24   ` Alan Stern
2010-12-10 17:24   ` [linux-pm] " Alan Stern
2010-12-10 22:01     ` Rafael J. Wysocki
2010-12-10 22:01     ` [linux-pm] " Rafael J. Wysocki
2010-12-10 23:02       ` Ohad Ben-Cohen
2010-12-10 23:02       ` [linux-pm] " Ohad Ben-Cohen
2010-12-10 22:59     ` Ohad Ben-Cohen
2010-12-10 22:59     ` [linux-pm] " Ohad Ben-Cohen
2010-12-11  1:17       ` Ohad Ben-Cohen
2010-12-11 14:53         ` Alan Stern
2010-12-11  1:17       ` Ohad Ben-Cohen
2010-12-11 14:50       ` Alan Stern
2010-12-18 13:29         ` Ohad Ben-Cohen
2010-12-18 13:29         ` [linux-pm] " Ohad Ben-Cohen
2010-12-18 14:16           ` David Vrabel
2010-12-18 15:12             ` Ohad Ben-Cohen
2010-12-18 15:12             ` Ohad Ben-Cohen
2010-12-18 14:16           ` David Vrabel
2010-12-18 15:07           ` [linux-pm] " Rafael J. Wysocki
2010-12-18 16:00             ` Ohad Ben-Cohen
2010-12-18 16:00             ` [linux-pm] " Ohad Ben-Cohen
2010-12-18 16:40               ` Johannes Berg
2010-12-18 19:08                 ` Ohad Ben-Cohen
2010-12-18 19:08                   ` Ohad Ben-Cohen
2010-12-18 21:30                   ` Alan Stern
2010-12-18 21:30                     ` Alan Stern
2010-12-18 22:57                     ` Rafael J. Wysocki
2010-12-18 22:57                     ` [linux-pm] " Rafael J. Wysocki
2010-12-18 21:30                   ` Alan Stern
2010-12-18 22:52                   ` Rafael J. Wysocki
2010-12-18 22:52                   ` [linux-pm] " Rafael J. Wysocki
2010-12-18 19:08                 ` Ohad Ben-Cohen
2010-12-18 21:29                 ` [linux-pm] " Alan Stern
2010-12-18 21:29                   ` Alan Stern
2010-12-18 21:29                 ` Alan Stern
2010-12-18 22:50                 ` Rafael J. Wysocki
2010-12-18 22:50                 ` [linux-pm] " Rafael J. Wysocki
2010-12-18 16:40               ` Johannes Berg
2010-12-18 22:47               ` [linux-pm] " Rafael J. Wysocki
2010-12-18 22:47                 ` Rafael J. Wysocki
2010-12-19  7:48                 ` Ohad Ben-Cohen
2010-12-19  7:48                   ` Ohad Ben-Cohen
2010-12-19  7:48                 ` Ohad Ben-Cohen
2010-12-19 10:22                 ` Rafael J. Wysocki
2010-12-19 10:22                 ` [linux-pm] " Rafael J. Wysocki
2010-12-20  3:37                   ` Alan Stern
2010-12-20  3:37                     ` Alan Stern
2010-12-20 21:17                     ` Rafael J. Wysocki
2010-12-21  0:57                       ` Alan Stern
2010-12-21  0:57                         ` Alan Stern
2010-12-21 21:31                         ` Rafael J. Wysocki
2010-12-22  1:42                           ` Alan Stern
2010-12-22  1:42                             ` Alan Stern
2010-12-22 12:29                             ` Rafael J. Wysocki
2010-12-22 12:29                               ` Rafael J. Wysocki
2011-01-26 23:28                               ` Kevin Hilman
2011-01-26 23:28                                 ` Kevin Hilman
2011-01-27 18:13                                 ` Alan Stern
2011-01-27 18:13                                 ` [linux-pm] " Alan Stern
2011-01-27 18:13                                   ` Alan Stern
2011-01-27 19:22                                   ` Kevin Hilman
2011-01-27 19:22                                   ` [linux-pm] " Kevin Hilman
2011-01-27 19:22                                     ` Kevin Hilman
2011-01-27 19:49                                     ` Alan Stern
2011-01-27 19:49                                     ` [linux-pm] " Alan Stern
2011-01-27 19:49                                       ` Alan Stern
2011-01-27 20:15                                       ` Kevin Hilman
2011-01-27 20:15                                       ` [linux-pm] " Kevin Hilman
2011-01-27 20:15                                         ` Kevin Hilman
2011-01-27 22:18                                         ` Vitaly Wool
2011-01-27 22:18                                           ` Vitaly Wool
2011-01-27 22:18                                         ` Vitaly Wool
2011-01-27 23:21                                         ` Rafael J. Wysocki
2011-01-27 23:21                                         ` [linux-pm] " Rafael J. Wysocki
2011-01-27 23:49                                           ` Kevin Hilman
2011-01-27 23:49                                           ` [linux-pm] " Kevin Hilman
2011-01-27 23:11                                   ` Rafael J. Wysocki
2011-01-27 23:11                                   ` [linux-pm] " Rafael J. Wysocki
2011-01-27 18:20                                 ` Vitaly Wool
2011-01-27 18:20                                 ` [linux-pm] " Vitaly Wool
2011-01-27 18:20                                   ` Vitaly Wool
2011-01-27 18:54                                   ` Kevin Hilman
2011-01-27 18:54                                   ` [linux-pm] " Kevin Hilman
2010-12-22 12:29                             ` Rafael J. Wysocki
2010-12-22  1:42                           ` Alan Stern
2010-12-21 21:31                         ` Rafael J. Wysocki
2010-12-21  0:57                       ` Alan Stern
2010-12-20 21:17                     ` Rafael J. Wysocki
2010-12-20  3:37                   ` Alan Stern
2010-12-21 22:23                   ` Kevin Hilman
2010-12-21 22:23                   ` [linux-pm] " Kevin Hilman
2010-12-22  1:48                     ` Alan Stern
2010-12-22  1:48                       ` Alan Stern
2010-12-22  1:48                     ` Alan Stern
2010-12-23  7:51                   ` Ohad Ben-Cohen
2010-12-23  7:51                   ` [linux-pm] " Ohad Ben-Cohen
2010-12-23 16:03                     ` Alan Stern
2010-12-23 16:03                     ` [linux-pm] " Alan Stern
2010-12-23 16:03                       ` Alan Stern
2010-12-25  7:34                       ` Ohad Ben-Cohen
2010-12-25  7:34                         ` Ohad Ben-Cohen
2010-12-25 16:21                         ` Alan Stern
2010-12-25 16:21                           ` Alan Stern
2010-12-25 20:58                           ` Ohad Ben-Cohen
2010-12-25 20:58                           ` [linux-pm] " Ohad Ben-Cohen
2010-12-25 20:58                             ` Ohad Ben-Cohen
2010-12-25 21:50                             ` Vitaly Wool
2010-12-25 21:50                             ` [linux-pm] " Vitaly Wool
2010-12-26  5:27                               ` Ohad Ben-Cohen
2010-12-26  5:27                               ` [linux-pm] " Ohad Ben-Cohen
2010-12-25 21:54                             ` Vitaly Wool
2010-12-25 21:54                               ` Vitaly Wool
2010-12-25 21:54                             ` Vitaly Wool
2010-12-26  2:48                             ` [linux-pm] " Alan Stern
2010-12-26  2:48                               ` Alan Stern
2010-12-26  5:55                               ` Ohad Ben-Cohen
2010-12-26  5:55                               ` [linux-pm] " Ohad Ben-Cohen
2010-12-26  5:55                                 ` Ohad Ben-Cohen
2010-12-26 11:45                                 ` Rafael J. Wysocki
2010-12-26 12:43                                   ` Ohad Ben-Cohen
2010-12-26 12:43                                   ` [linux-pm] " Ohad Ben-Cohen
2010-12-26 12:43                                     ` Ohad Ben-Cohen
2010-12-26 18:35                                     ` Rafael J. Wysocki
2010-12-28 19:11                                       ` Ohad Ben-Cohen
2010-12-28 19:11                                       ` [linux-pm] " Ohad Ben-Cohen
2010-12-28 19:21                                         ` Rafael J. Wysocki
2010-12-28 19:21                                         ` [linux-pm] " Rafael J. Wysocki
2010-12-28 19:21                                           ` Rafael J. Wysocki
2010-12-28 19:34                                           ` Ohad Ben-Cohen
2010-12-28 20:36                                             ` Rafael J. Wysocki
2010-12-28 20:36                                             ` [linux-pm] " Rafael J. Wysocki
2010-12-28 19:34                                           ` Ohad Ben-Cohen
2010-12-26 18:35                                     ` Rafael J. Wysocki
2010-12-26 14:53                                   ` [linux-pm] " Ohad Ben-Cohen
2010-12-26 18:37                                     ` Rafael J. Wysocki
2010-12-26 18:37                                     ` [linux-pm] " Rafael J. Wysocki
2010-12-28 19:15                                       ` Ohad Ben-Cohen
2010-12-28 20:04                                         ` Rafael J. Wysocki
2010-12-28 20:04                                         ` [linux-pm] " Rafael J. Wysocki
2010-12-28 20:04                                           ` Rafael J. Wysocki
2010-12-28 20:41                                           ` Ohad Ben-Cohen
2010-12-28 20:41                                           ` [linux-pm] " Ohad Ben-Cohen
2010-12-28 20:41                                             ` Ohad Ben-Cohen
2010-12-28 19:15                                       ` Ohad Ben-Cohen
2010-12-26 14:53                                   ` Ohad Ben-Cohen
2010-12-26 11:45                                 ` Rafael J. Wysocki
2010-12-26 17:00                                 ` Alan Stern [this message]
2010-12-26 17:00                                   ` [linux-pm] " Alan Stern
2010-12-28 19:04                                   ` Ohad Ben-Cohen
2010-12-28 19:04                                   ` [linux-pm] " Ohad Ben-Cohen
2010-12-28 19:04                                     ` Ohad Ben-Cohen
2010-12-28 21:46                                     ` Alan Stern
2010-12-28 21:46                                     ` [linux-pm] " Alan Stern
2010-12-28 21:46                                       ` Alan Stern
2010-12-29  6:34                                       ` Ohad Ben-Cohen
2010-12-30  4:25                                         ` Alan Stern
2010-12-30  4:25                                           ` Alan Stern
2010-12-30  4:25                                         ` Alan Stern
2010-12-29  6:34                                       ` Ohad Ben-Cohen
2010-12-29  8:01                                       ` Ohad Ben-Cohen
2010-12-29  8:01                                       ` [linux-pm] " Ohad Ben-Cohen
2010-12-30  4:30                                         ` Alan Stern
2010-12-30  4:30                                         ` [linux-pm] " Alan Stern
2010-12-30  4:30                                           ` Alan Stern
2010-12-26 17:00                                 ` Alan Stern
2010-12-26  2:48                             ` Alan Stern
2010-12-25 16:21                         ` Alan Stern
2010-12-25  7:34                       ` Ohad Ben-Cohen
2010-12-18 22:47               ` Rafael J. Wysocki
2010-12-18 15:07           ` Rafael J. Wysocki
2010-12-18 21:20           ` [linux-pm] " Alan Stern
2010-12-18 23:03             ` Rafael J. Wysocki
2010-12-18 23:03             ` Rafael J. Wysocki
2010-12-19 10:00             ` [linux-pm] " Ohad Ben-Cohen
2010-12-19 10:00             ` Ohad Ben-Cohen
2010-12-18 21:20           ` Alan Stern

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.1012261050050.18773-100000@netrider.rowland.org \
    --to=stern@rowland.harvard.edu \
    --cc=ido@wizery.com \
    --cc=johannes@sipsolutions.net \
    --cc=khilman@deeprootsystems.com \
    --cc=linux-mmc@vger.kernel.org \
    --cc=linux-pm@lists.linux-foundation.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=ohad@wizery.com \
    --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.