All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Drake <dsd@laptop.org>
To: Ohad Ben-Cohen <ohad@wizery.com>
Cc: linux-mmc@vger.kernel.org
Subject: Re: MMC runtime PM patches break libertas probe
Date: Sun, 29 May 2011 17:21:01 +0100	[thread overview]
Message-ID: <BANLkTikpciJnTudOeSLM_O7AAD4GGkbbOw@mail.gmail.com> (raw)
In-Reply-To: <AANLkTi=cPURFAitedD=mjkNiD_=ZCjakkMN6z7ecqv6k@mail.gmail.com>

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

Hi Ohad,

On 31 October 2010 19:06, Ohad Ben-Cohen <ohad@wizery.com> wrote:
> OK, as expected.
>
> So to summarize:
> 1. Card is powered up at boot, and successfully initialized
> 2. After mmc + sdio devices are added to the device tree, power is
> (seemingly) taken down by runtime PM
> 3. When the driver is loaded, card is powered up again, but doesn't
> respond to CMD3
>
> The only explanation I can think of why the card doesn't respond to
> CMD3, after its power is brought up again, is that we didn't have a
> full reset here (i.e. mmc_power_off() didn't completely power off
> everything).

I have investigated this again, as we'd like runtime PM to work.

It's certainly possible that there's something weird about the
hardware in question, but we *are* able to successfully power down and
up the card with a hacky rfkill driver that calls mmc_stop_host /
mmc_start_host. So I went around finding out what the difference was
between these functions and the runtime PM implementation.

Through this comparison I think mmc_power_save_host() does almost
exactly the same as mmc_stop_host() (good), but
mmc_power_restore_host() lacks some steps which would otherwise be
taken by mmc_start_host(). These are:

in mmc_rescan_try_freq():

	/*
	 * sdio_reset sends CMD52 to reset card.  Since we do not know
	 * if the card is being re-initialized, just send it.  CMD52
	 * should be ignored by SD/eMMC cards.
	 */
	sdio_reset(host);
	mmc_go_idle(host);

	mmc_send_if_cond(host, host->ocr_avail);


In mmc_attach_sdio():

	err = mmc_send_io_op_cond(host, 0, &ocr);
	if (err)
		return err;

	mmc_attach_bus(host, &mmc_sdio_ops);
	if (host->ocr_avail_sdio)
		host->ocr_avail = host->ocr_avail_sdio;

	/*
	 * Sanity check the voltages that the card claims to
	 * support.
	 */
	if (ocr & 0x7F) {
		printk(KERN_WARNING "%s: card claims to support voltages "
		       "below the defined range. These will be ignored.\n",
		       mmc_hostname(host));
		ocr &= ~0x7F;
	}

	host->ocr = mmc_select_voltage(host, ocr);

	/*
	 * Can we support the voltage(s) of the card(s)?
	 */
	if (!host->ocr) {
		err = -EINVAL;
		goto err;
	}


Should anything in those code snippets be running during runtime PM resume?

I went ahead and ran the obvious test by putting those bits of code in
the runtime PM resume path... the first snippet doesn't seem to
improve or hurt anything, but the second snippet fixes the problem. At
least it means I can boot, the card gets powered down during boot,
then I load the module and it powers up and initialises correctly.
Patch attached for clarity.

Any thoughts?

Thanks,
Daniel

[-- Attachment #2: fix-sdio-power-restore.txt --]
[-- Type: text/plain, Size: 1166 bytes --]

diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c
index 4d0c15b..3b06379 100644
--- a/drivers/mmc/core/sdio.c
+++ b/drivers/mmc/core/sdio.c
@@ -691,15 +691,47 @@ static int mmc_sdio_resume(struct mmc_host *host)
 static int mmc_sdio_power_restore(struct mmc_host *host)
 {
 	int ret;
+	u32 ocr;
 
 	BUG_ON(!host);
 	BUG_ON(!host->card);
 
 	mmc_claim_host(host);
+
+	ret = mmc_send_io_op_cond(host, 0, &ocr);
+	if (ret)
+		goto out;
+
+	if (host->ocr_avail_sdio)
+		host->ocr_avail = host->ocr_avail_sdio;
+
+	/*
+	 * Sanity check the voltages that the card claims to
+	 * support.
+	 */
+	if (ocr & 0x7F) {
+		printk(KERN_WARNING "%s: card claims to support voltages "
+		       "below the defined range. These will be ignored.\n",
+		       mmc_hostname(host));
+		ocr &= ~0x7F;
+	}
+
+	host->ocr = mmc_select_voltage(host, ocr);
+
+	/*
+	 * Can we support the voltage(s) of the card(s)?
+	 */
+	if (!host->ocr) {
+		ret = -EINVAL;
+		goto out;
+	}
+
 	ret = mmc_sdio_init_card(host, host->ocr, host->card,
 				mmc_card_keep_power(host));
 	if (!ret && host->sdio_irqs)
 		mmc_signal_sdio_irq(host);
+
+out:
 	mmc_release_host(host);
 
 	return ret;

  parent reply	other threads:[~2011-05-29 16:21 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-31 14:29 MMC runtime PM patches break libertas probe Daniel Drake
2010-10-31 14:42 ` Ohad Ben-Cohen
2010-10-31 14:55   ` Daniel Drake
2010-10-31 15:08     ` Ohad Ben-Cohen
2010-10-31 15:10       ` Daniel Drake
2010-10-31 15:16         ` Ohad Ben-Cohen
2010-10-31 15:21           ` Daniel Drake
2010-10-31 15:21           ` Daniel Drake
2010-10-31 15:27             ` Ohad Ben-Cohen
2010-10-31 15:57               ` Daniel Drake
2010-10-31 16:16                 ` Ohad Ben-Cohen
2010-10-31 16:24                   ` Daniel Drake
2010-10-31 19:06                     ` Ohad Ben-Cohen
2010-11-01  8:27                       ` Ohad Ben-Cohen
2010-11-06 21:19                         ` Daniel Drake
2010-11-07  1:48                           ` Nicolas Pitre
2010-11-07 10:19                             ` Daniel Drake
2010-11-07 15:12                               ` Nicolas Pitre
2010-11-07 10:42                           ` Ohad Ben-Cohen
2010-11-07 10:51                             ` Daniel Drake
2010-11-07 13:17                               ` Ohad Ben-Cohen
2010-11-16 13:22                         ` Ohad Ben-Cohen
2010-11-16 14:29                           ` Daniel Drake
2010-11-16 14:49                             ` Ohad Ben-Cohen
2010-11-17  6:46                               ` Mike Rapoport
2010-11-17  7:29                                 ` Ohad Ben-Cohen
2010-11-17 14:54                                   ` Nicolas Pitre
2010-11-16 17:17                           ` Arnd Hannemann
2010-11-16 20:58                             ` Ohad Ben-Cohen
2010-11-16 21:16                               ` Arnd Hannemann
2010-11-16 22:26                                 ` Ohad Ben-Cohen
2011-05-29 16:21                       ` Daniel Drake [this message]
2011-05-30  6:52                         ` Ohad Ben-Cohen
2011-05-30  7:01                           ` Daniel Drake
2011-05-30  7:32                             ` Ohad Ben-Cohen
2011-05-30 11:04                               ` zhangfei gao
2011-05-30 11:16                                 ` Ohad Ben-Cohen
2011-06-02  8:39                                   ` Bing Zhao
2011-06-02 18:25                                     ` Ohad Ben-Cohen
2011-06-03 22:28                                       ` Bing Zhao
2011-06-03 22:52                                         ` Ohad Ben-Cohen
2011-06-07 14:34                                           ` Arnd Hannemann
2011-06-07 14:45                                             ` Ohad Ben-Cohen
2011-06-08 14:34                                           ` Ohad Ben-Cohen
2011-06-10  2:02                                             ` zhangfei gao
2011-06-10  4:28                                               ` Ohad Ben-Cohen
2011-06-11  2:33                                                 ` zhangfei gao
2011-06-11  9:03                                                   ` Ohad Ben-Cohen

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=BANLkTikpciJnTudOeSLM_O7AAD4GGkbbOw@mail.gmail.com \
    --to=dsd@laptop.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 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.