public inbox for linux-mmc@vger.kernel.org
 help / color / mirror / Atom feed
From: NeilBrown <neilb@suse.de>
To: Chris Ball <cjb@laptop.org>
Cc: linux-mmc@vger.kernel.org, lkml <linux-kernel@vger.kernel.org>,
	Daniel Drake <dsd@laptop.org>, Ohad Ben-Cohen <ohad@wizery.com>
Subject: [PATCH] mmc/sdio: don't allow interface to runtime-suspend until probe is finished.
Date: Mon, 5 Dec 2011 12:54:16 +1100	[thread overview]
Message-ID: <20111205125416.6093ecd8@notabene.brown> (raw)

[-- Attachment #1: Type: text/plain, Size: 2749 bytes --]


Greetings.

 I've been chasing down a problem with the SDIO-attached wifi card in the
 GTA04 (www.gta04.org).
 The problem seems very similar to that described in 

    http://www.mail-archive.com/linux-mmc@vger.kernel.org/msg04289.html

 as referenced in:

commit 08da834a24312157f512224691ad1fddd11c1073
Author: Daniel Drake <dsd@laptop.org>
Date:   Wed Jul 20 17:39:22 2011 +0100

    mmc: enable runtime PM by default


and if I revert that commit so that runtime PM is not enabled the problem
goes away.

(The wifi chip is a libertas_sdio supported chip connected to an mmc
interface on an omap3, and has a separate regulator for power supply, plus a
GPIO pin for reset, just like in the email thread.  The problem is
exemplified by:
[   64.643981] libertas_sdio: probe of mmc1:0001:1 failed with error -16
).

I finally managed to track down exactly what was happening - runtime PM was
putting the interface to sleep before the SDIO functions were probed so
initialising them failed.

This patch fixes it and seem to be 'correct'.

Please consider applying.

Thanks,
NeilBrown

From: NeilBrown <neilb@suse.de>
Date: Mon, 5 Dec 2011 11:34:47 +1100
Subject: [PATCH] mmc/sdio: don't allow interface to runtime-suspend until
 probe is finished.

mmc_attach_sdio currently enables runtime power management on
the mmc interface before it completes the probe of functions.
This means that it might be asleep during the probe and the probe
will fail.

In particular, if 'drivers_autoprobe' is enabled on the mmc bus, then
device_attach() will be called by bus_probe_device() from device_add()
and it will pm_runtime_get_noresume()/pm_runtime_put_sync().

As runtime power management this the device is running
(pm_runtime_set_active() in mmc_attach_sdio()) and rtpm is enabled
(pm_runtime_enable()), the pm_runtime_put_sync() call puts the mmc
interface to sleep, so function probing fails.

So this patch moves the call to pm_runtime_enable to after all the
calls to sdio_add_func.

Signed-off-by: NeilBrown <neilb@suse.de>

diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c
index 3ab565e..c0c83f6 100644
--- a/drivers/mmc/core/sdio.c
+++ b/drivers/mmc/core/sdio.c
@@ -811,11 +811,6 @@ int mmc_attach_sdio(struct mmc_host *host)
 		err = pm_runtime_set_active(&card->dev);
 		if (err)
 			goto remove;
-
-		/*
-		 * Enable runtime PM for this card
-		 */
-		pm_runtime_enable(&card->dev);
 	}
 
 	/*
@@ -858,6 +853,12 @@ int mmc_attach_sdio(struct mmc_host *host)
 	}
 
 	mmc_claim_host(host);
+	if (host->caps & MMC_CAP_POWER_OFF_CARD) {
+		/*
+		 * Enable runtime PM for this card
+		 */
+		pm_runtime_enable(&card->dev);
+	}
 	return 0;
 
 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

             reply	other threads:[~2011-12-05  1:54 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-05  1:54 NeilBrown [this message]
2011-12-05 10:25 ` [PATCH] mmc/sdio: don't allow interface to runtime-suspend until probe is finished Ohad Ben-Cohen
2011-12-05 19:06   ` NeilBrown
2011-12-05 19:17     ` Daniel Drake
2011-12-05 19:37     ` Ohad Ben-Cohen
2011-12-10  7:15       ` NeilBrown
2011-12-11  7:30         ` Ohad Ben-Cohen
2011-12-15  7:35           ` Bing Zhao
2011-12-19  9:12             ` Ohad Ben-Cohen
2011-12-16  4:08           ` NeilBrown
2011-12-16  4:39             ` Bing Zhao
2011-12-16  5:21               ` NeilBrown

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=20111205125416.6093ecd8@notabene.brown \
    --to=neilb@suse.de \
    --cc=cjb@laptop.org \
    --cc=dsd@laptop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=ohad@wizery.com \
    /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