From: Alan Stern <stern@rowland.harvard.edu>
To: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Cc: Ohad Ben-Cohen <ohad@wizery.com>,
linux-mmc@vger.kernel.org, Magnus Damm <damm@opensource.se>,
Simon Horman <horms@verge.net.au>,
"Rafael J. Wysocki" <rjw@sisk.pl>
Subject: Re: [PATCH/RFC] MMC: remove unbalanced pm_runtime_suspend()
Date: Wed, 20 Apr 2011 11:12:54 -0400 (EDT) [thread overview]
Message-ID: <Pine.LNX.4.44L0.1104201104230.2159-100000@iolanthe.rowland.org> (raw)
In-Reply-To: <Pine.LNX.4.64.1104201629030.18555@axis700.grange>
On Wed, 20 Apr 2011, Guennadi Liakhovetski wrote:
> As I said above - I did mean probe() and remove(). Now, I have now traced
> down the cause of my problem. In dd.c::driver_probe_device():
>
> pm_runtime_get_noresume(dev);
> pm_runtime_barrier(dev);
> ret = really_probe(dev, drv);
> pm_runtime_put_sync(dev);
>
> Which means, if originally
>
> usage_count = 0
> disable_depth = 1
>
> the first get_noresume() increments
>
> usage_count = 1
>
> In probe() we do enable(), which decrements
>
> disable_depth = 0
>
> and resume(), which poweres everything up. If we now return from probe(),
> put_sync() will power down and decrement
>
> usage_count = 0
>
> which is ok for sh_mmcif.c. If there is no card in the slot, we keep
> interface powered down, card polling works also in powered down mode if
> there's a GPIO, or the MMC core will wake us up every time to check for a
> new card. Next, let's say, a card has been inserted, and we rmmod the
> driver. dd.c::__device_release_driver() does
>
> pm_runtime_get_noresume(dev);
> pm_runtime_barrier(dev);
> .remove();
> pm_runtime_put_sync(dev);
>
> the first get_noresume() increments
>
> usage_count = 1
>
> Then if we go the "exact inverse" route, we do suspend(), which does
> nothing, because usage_count > 0, then we do disable(), which increments
>
> disable_depth = 1
>
> After returning from .remove() pm_runtime_put_sync() is executed, but also
> it does nothing, because disable_depth > 0. The interface stays powered
> on. So, as you see, the problem is on the .remove() path. I work around it
> by doing
>
> pm_runtime_put_sync(&pdev->dev);
> pm_runtime_disable(&pdev->dev);
> pm_runtime_get_noresume(&pdev->dev);
>
> in the driver. This way the first call decrements
>
> usage_count = 0
>
> and powers down, the second one increments
>
> disable_depth = 1
>
> the third one
>
> usage_count = 1
>
> Then, back in dd.c again
>
> usage_count = 0
>
> and all is happy:-) But the above triplet looks kinda ugly to me. Is this
> really how it is supposed to work?...
Ah, now I see the problem. It looks like we did not give sufficient
thought to the case where a device starts off (and therefore should
finish up) in a powered-down state. Calling pm_runtime_put_sync()
after unbinding the device driver seems a little futile -- with no
driver, the subsystem may not be able to power-down the device!
Rafael, how do you think we should handle this? Get rid of the
pm_runtime_get_no_resume() and pm_runtime_put_sync() calls in
dd.c:__device_release_driver()?
Alan Stern
next prev parent reply other threads:[~2011-04-20 15:12 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-19 10:46 [PATCH/RFC] MMC: remove unbalanced pm_runtime_suspend() Guennadi Liakhovetski
2011-04-19 12:44 ` Ohad Ben-Cohen
2011-04-19 13:23 ` Guennadi Liakhovetski
2011-04-19 14:16 ` Ohad Ben-Cohen
2011-04-19 14:26 ` Alan Stern
2011-04-19 22:59 ` Guennadi Liakhovetski
2011-04-20 14:22 ` Alan Stern
2011-04-20 14:50 ` Guennadi Liakhovetski
2011-04-20 15:12 ` Alan Stern [this message]
2011-04-20 20:06 ` Rafael J. Wysocki
2011-04-20 21:16 ` Alan Stern
2011-04-20 21:44 ` Rafael J. Wysocki
2011-04-21 13:58 ` Alan Stern
2011-04-21 18:00 ` Rafael J. Wysocki
2011-04-21 18:36 ` Alan Stern
2011-04-21 20:05 ` Rafael J. Wysocki
2011-04-21 21:48 ` Alan Stern
2011-04-21 22:06 ` Rafael J. Wysocki
2011-04-22 15:20 ` Alan Stern
2011-04-22 20:22 ` Rafael J. Wysocki
2011-04-22 20:25 ` Rafael J. Wysocki
2011-04-22 21:20 ` Alan Stern
2011-04-22 22:11 ` Rafael J. Wysocki
2011-04-25 10:29 ` [linux-pm] " Rafael J. Wysocki
2011-04-26 10:44 ` Guennadi Liakhovetski
2011-04-26 11:51 ` Rafael J. Wysocki
2011-04-28 22:12 ` 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.1104201104230.2159-100000@iolanthe.rowland.org \
--to=stern@rowland.harvard.edu \
--cc=damm@opensource.se \
--cc=g.liakhovetski@gmx.de \
--cc=horms@verge.net.au \
--cc=linux-mmc@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).