All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sdio: fix nasty oops in mmc_sdio_detect
@ 2010-11-14 10:40 Ohad Ben-Cohen
  2010-11-19 22:06 ` Chris Ball
  0 siblings, 1 reply; 2+ messages in thread
From: Ohad Ben-Cohen @ 2010-11-14 10:40 UTC (permalink / raw)
  To: linux-mmc; +Cc: Chris Ball, Daniel Drake, Ohad Ben-Cohen

Power off the card in mmc_sdio_detect __before__ a potential error
handler, which completely removes the card, executes, and only if the
card was successfully powered on beforehand.

While we're at it, use the _sync variant of the runtime PM put API, in
order to ensure that the card is left powered off in case an error
occurred, and the card is going to be removed.

Reproduced and tested on the XO-1.5.

Reported-by: Daniel Drake <dsd@laptop.org>
Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
---
 drivers/mmc/core/sdio.c |   16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c
index c3ad105..42a949b 100644
--- a/drivers/mmc/core/sdio.c
+++ b/drivers/mmc/core/sdio.c
@@ -560,6 +560,19 @@ static void mmc_sdio_detect(struct mmc_host *host)
 
 	mmc_release_host(host);
 
+	/*
+	 * Tell PM core it's OK to power off the card now.
+	 *
+	 * The _sync variant is used in order to ensure that the card
+	 * is left powered off in case an error occurred, and the card
+	 * is going to be removed.
+	 *
+	 * Since there is no specific reason to believe a new user
+	 * is about to show up at this point, the _sync variant is
+	 * desirable anyway.
+	 */
+	pm_runtime_put_sync(&host->card->dev);
+
 out:
 	if (err) {
 		mmc_sdio_remove(host);
@@ -568,9 +581,6 @@ out:
 		mmc_detach_bus(host);
 		mmc_release_host(host);
 	}
-
-	/* Tell PM core that we're done */
-	pm_runtime_put(&host->card->dev);
 }
 
 /*
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] sdio: fix nasty oops in mmc_sdio_detect
  2010-11-14 10:40 [PATCH] sdio: fix nasty oops in mmc_sdio_detect Ohad Ben-Cohen
@ 2010-11-19 22:06 ` Chris Ball
  0 siblings, 0 replies; 2+ messages in thread
From: Chris Ball @ 2010-11-19 22:06 UTC (permalink / raw)
  To: Ohad Ben-Cohen; +Cc: linux-mmc, Daniel Drake

Hi Ohad,

On Sun, Nov 14, 2010 at 12:40:33PM +0200, Ohad Ben-Cohen wrote:
> Power off the card in mmc_sdio_detect __before__ a potential error
> handler, which completely removes the card, executes, and only if the
> card was successfully powered on beforehand.
> 
> While we're at it, use the _sync variant of the runtime PM put API, in
> order to ensure that the card is left powered off in case an error
> occurred, and the card is going to be removed.
> 
> Reproduced and tested on the XO-1.5.
> 
> Reported-by: Daniel Drake <dsd@laptop.org>
> Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>

Thanks, pushed to for-linus/mmc-next for 2.6.37.

-- 
Chris Ball   <cjb@laptop.org>   <http://printf.net/>
One Laptop Per Child

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-11-19 22:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-14 10:40 [PATCH] sdio: fix nasty oops in mmc_sdio_detect Ohad Ben-Cohen
2010-11-19 22:06 ` Chris Ball

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.