All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] mmc: core: eMMC in Sleep mode before suspend
@ 2011-09-08 16:38 Balaji T K
  2011-09-09  6:34 ` Subhash Jadavani
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Balaji T K @ 2011-09-08 16:38 UTC (permalink / raw)
  To: linux-mmc, cjb; +Cc: subhashj, adrian.hunter, Balaji T K

Put MMC to sleep if it supports SLEEP/AWAKE (CMD5)
in the mmc suspend so that Vcc (NAND core) can be cut
to minimize power consumption.
eMMC put into SLEEP can respond to CMD0 or H/W reset or CMD5.
Current implemention on resume from suspend relies on CMD0 in
mmc_init_card to get out of SLEEP mode.

Signed-off-by: Balaji T K <balajitk@ti.com>
Acked-by: Venkatraman S <svenkatr@ti.com>
---
 drivers/mmc/core/mmc.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 5700b1c..f73fcee 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -553,6 +553,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
 	 * need to tell some cards to go back to the idle
 	 * state.  We wait 1ms to give cards time to
 	 * respond.
+	 * mmc_go_idle is needed for eMMC that are asleep
 	 */
 	mmc_go_idle(host);
 
@@ -900,16 +901,20 @@ static void mmc_detect(struct mmc_host *host)
  */
 static int mmc_suspend(struct mmc_host *host)
 {
+	int err = 0;
+
 	BUG_ON(!host);
 	BUG_ON(!host->card);
 
 	mmc_claim_host(host);
-	if (!mmc_host_is_spi(host))
+	if (mmc_card_can_sleep(host))
+		err = mmc_card_sleep(host);
+	else if (!mmc_host_is_spi(host))
 		mmc_deselect_cards(host);
 	host->card->state &= ~MMC_STATE_HIGHSPEED;
 	mmc_release_host(host);
 
-	return 0;
+	return err;
 }
 
 /*
-- 
1.7.0.4


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

* Re: [PATCH v2] mmc: core: eMMC in Sleep mode before suspend
  2011-09-08 16:38 [PATCH v2] mmc: core: eMMC in Sleep mode before suspend Balaji T K
@ 2011-09-09  6:34 ` Subhash Jadavani
  2011-09-09  6:56   ` Adrian Hunter
  2011-09-21 17:47 ` Chris Ball
  2012-04-12  4:24 ` Chris Ball
  2 siblings, 1 reply; 6+ messages in thread
From: Subhash Jadavani @ 2011-09-09  6:34 UTC (permalink / raw)
  Cc: linux-mmc, cjb, subhashj, adrian.hunter, Balaji T K

Hi Balaji,

> Put MMC to sleep if it supports SLEEP/AWAKE (CMD5)
> in the mmc suspend so that Vcc (NAND core) can be cut
> to minimize power consumption.
> eMMC put into SLEEP can respond to CMD0 or H/W reset or CMD5.
> Current implemention on resume from suspend relies on CMD0 in
> mmc_init_card to get out of SLEEP mode.
>
> Signed-off-by: Balaji T K <balajitk@ti.com>
> Acked-by: Venkatraman S <svenkatr@ti.com>
> ---
>  drivers/mmc/core/mmc.c |    9 +++++++--
>  1 files changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
> index 5700b1c..f73fcee 100644
> --- a/drivers/mmc/core/mmc.c
> +++ b/drivers/mmc/core/mmc.c
> @@ -553,6 +553,7 @@ static int mmc_init_card(struct mmc_host *host, u32
> ocr,
>  	 * need to tell some cards to go back to the idle
>  	 * state.  We wait 1ms to give cards time to
>  	 * respond.
> +	 * mmc_go_idle is needed for eMMC that are asleep
>  	 */
>  	mmc_go_idle(host);
>
> @@ -900,16 +901,20 @@ static void mmc_detect(struct mmc_host *host)
>   */
>  static int mmc_suspend(struct mmc_host *host)
>  {
> +	int err = 0;
> +
>  	BUG_ON(!host);
>  	BUG_ON(!host->card);
>
>  	mmc_claim_host(host);
> -	if (!mmc_host_is_spi(host))
> +	if (mmc_card_can_sleep(host))
> +		err = mmc_card_sleep(host);
> +	else if (!mmc_host_is_spi(host))
>  		mmc_deselect_cards(host);
>  	host->card->state &= ~MMC_STATE_HIGHSPEED;
>  	mmc_release_host(host);
>
> -	return 0;
> +	return err;
>  }

Looks good to me:
Reviewed-by: Subhash Jadavani <subhashj@codeaurora.org>

Thanks,
Subhash

>
>  /*
> --
> 1.7.0.4
>
>


-- 
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.


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

* Re: [PATCH v2] mmc: core: eMMC in Sleep mode before suspend
  2011-09-09  6:34 ` Subhash Jadavani
@ 2011-09-09  6:56   ` Adrian Hunter
  0 siblings, 0 replies; 6+ messages in thread
From: Adrian Hunter @ 2011-09-09  6:56 UTC (permalink / raw)
  To: Subhash Jadavani; +Cc: Balaji T K, linux-mmc, cjb

On 09/09/11 09:34, Subhash Jadavani wrote:
> Hi Balaji,
>
>> Put MMC to sleep if it supports SLEEP/AWAKE (CMD5)
>> in the mmc suspend so that Vcc (NAND core) can be cut
>> to minimize power consumption.
>> eMMC put into SLEEP can respond to CMD0 or H/W reset or CMD5.
>> Current implemention on resume from suspend relies on CMD0 in
>> mmc_init_card to get out of SLEEP mode.
>>
>> Signed-off-by: Balaji T K<balajitk@ti.com>
>> Acked-by: Venkatraman S<svenkatr@ti.com>
>> ---
>>   drivers/mmc/core/mmc.c |    9 +++++++--
>>   1 files changed, 7 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
>> index 5700b1c..f73fcee 100644
>> --- a/drivers/mmc/core/mmc.c
>> +++ b/drivers/mmc/core/mmc.c
>> @@ -553,6 +553,7 @@ static int mmc_init_card(struct mmc_host *host, u32
>> ocr,
>>   	 * need to tell some cards to go back to the idle
>>   	 * state.  We wait 1ms to give cards time to
>>   	 * respond.
>> +	 * mmc_go_idle is needed for eMMC that are asleep
>>   	 */
>>   	mmc_go_idle(host);
>>
>> @@ -900,16 +901,20 @@ static void mmc_detect(struct mmc_host *host)
>>    */
>>   static int mmc_suspend(struct mmc_host *host)
>>   {
>> +	int err = 0;
>> +
>>   	BUG_ON(!host);
>>   	BUG_ON(!host->card);
>>
>>   	mmc_claim_host(host);
>> -	if (!mmc_host_is_spi(host))
>> +	if (mmc_card_can_sleep(host))
>> +		err = mmc_card_sleep(host);
>> +	else if (!mmc_host_is_spi(host))
>>   		mmc_deselect_cards(host);
>>   	host->card->state&= ~MMC_STATE_HIGHSPEED;
>>   	mmc_release_host(host);
>>
>> -	return 0;
>> +	return err;
>>   }
>
> Looks good to me:
> Reviewed-by: Subhash Jadavani<subhashj@codeaurora.org>

Acked-by: Adrian Hunter <adrian.hunter@intel.com>

>
> Thanks,
> Subhash
>
>>
>>   /*
>> --
>> 1.7.0.4
>>
>>
>
>


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

* Re: [PATCH v2] mmc: core: eMMC in Sleep mode before suspend
  2011-09-08 16:38 [PATCH v2] mmc: core: eMMC in Sleep mode before suspend Balaji T K
  2011-09-09  6:34 ` Subhash Jadavani
@ 2011-09-21 17:47 ` Chris Ball
  2012-04-12  4:24 ` Chris Ball
  2 siblings, 0 replies; 6+ messages in thread
From: Chris Ball @ 2011-09-21 17:47 UTC (permalink / raw)
  To: Balaji T K; +Cc: linux-mmc, subhashj, adrian.hunter

Hi Balaji,

On Thu, Sep 08 2011, Balaji T K wrote:
> Put MMC to sleep if it supports SLEEP/AWAKE (CMD5)
> in the mmc suspend so that Vcc (NAND core) can be cut
> to minimize power consumption.
> eMMC put into SLEEP can respond to CMD0 or H/W reset or CMD5.
> Current implemention on resume from suspend relies on CMD0 in
> mmc_init_card to get out of SLEEP mode.
>
> Signed-off-by: Balaji T K <balajitk@ti.com>
> Acked-by: Venkatraman S <svenkatr@ti.com>

Thanks, pushed to mmc-next for 3.2.

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

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

* Re: [PATCH v2] mmc: core: eMMC in Sleep mode before suspend
  2011-09-08 16:38 [PATCH v2] mmc: core: eMMC in Sleep mode before suspend Balaji T K
  2011-09-09  6:34 ` Subhash Jadavani
  2011-09-21 17:47 ` Chris Ball
@ 2012-04-12  4:24 ` Chris Ball
  2012-04-12  7:22   ` T Krishnamoorthy, Balaji
  2 siblings, 1 reply; 6+ messages in thread
From: Chris Ball @ 2012-04-12  4:24 UTC (permalink / raw)
  To: Balaji T K
  Cc: linux-mmc, subhashj, adrian.hunter, Venkatraman S, Jarkko Lavinen

Hi,

On Thu, Sep 08 2011, Balaji T K wrote:
> Put MMC to sleep if it supports SLEEP/AWAKE (CMD5)
> in the mmc suspend so that Vcc (NAND core) can be cut
> to minimize power consumption.
> eMMC put into SLEEP can respond to CMD0 or H/W reset or CMD5.
> Current implemention on resume from suspend relies on CMD0 in
> mmc_init_card to get out of SLEEP mode.
>
> Signed-off-by: Balaji T K <balajitk@ti.com>
> Acked-by: Venkatraman S <svenkatr@ti.com>

I've just tried this on an eMMC 4.41 device (Sandisk SEM04G) with
sdhci-pxav3, and it resulted in a crash on the way into suspend:

[   18.379192] PM: Syncing filesystems ... done.
[   18.423866] Freezing user space processes ... (elapsed 0.01 seconds) done.
[   18.446542] Freezing remaining freezable tasks ... (elapsed 0.01 seconds) done.
[   18.549586] PM: Device sdhci-pxav3.2 failed to suspend: error -110
[   18.583808] PM: Some devices failed to suspend
[   22.141284] mmcblk0: error -110 sending status command, retrying
[   22.153150] mmcblk0: error -110 sending status command, retrying
[   22.164708] mmcblk0: error -110 sending status command, aborting
[   22.176097] end_request: I/O error, dev mmcblk0, sector 4430104
[..]

Digging down, the -110 is coming from:

int mmc_card_sleepawake(struct mmc_host *host, int sleep)
{
        struct mmc_command cmd = {0};
        struct mmc_card *card = host->card;
        int err;

        if (sleep)
                mmc_deselect_cards(host);

        cmd.opcode = MMC_SLEEP_AWAKE;
        cmd.arg = card->rca << 16;
        if (sleep)
                cmd.arg |= 1 << 15;

        cmd.flags = MMC_RSP_R1B | MMC_CMD_AC;
        err = mmc_wait_for_cmd(host, &cmd, 0);
        if (err)
                return err;
        [..]

Has anyone tried sleepawake on an SEM04G before?

It seems likely (I haven't tested yet, but will do) that the card
actually went into sleep successfully and is waiting for an AWAKE
command, even though mmc_wait_for_cmd() returned a timeout.
If so, any suggestions on how to handle that case?

Thanks,

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

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

* Re: [PATCH v2] mmc: core: eMMC in Sleep mode before suspend
  2012-04-12  4:24 ` Chris Ball
@ 2012-04-12  7:22   ` T Krishnamoorthy, Balaji
  0 siblings, 0 replies; 6+ messages in thread
From: T Krishnamoorthy, Balaji @ 2012-04-12  7:22 UTC (permalink / raw)
  To: Chris Ball
  Cc: linux-mmc, subhashj, adrian.hunter, Venkatraman S, Jarkko Lavinen

On Thu, Apr 12, 2012 at 9:54 AM, Chris Ball <cjb@laptop.org> wrote:
> Hi,
>
> On Thu, Sep 08 2011, Balaji T K wrote:
>> Put MMC to sleep if it supports SLEEP/AWAKE (CMD5)
>> in the mmc suspend so that Vcc (NAND core) can be cut
>> to minimize power consumption.
>> eMMC put into SLEEP can respond to CMD0 or H/W reset or CMD5.
>> Current implemention on resume from suspend relies on CMD0 in
>> mmc_init_card to get out of SLEEP mode.
>>
>> Signed-off-by: Balaji T K <balajitk@ti.com>
>> Acked-by: Venkatraman S <svenkatr@ti.com>
>
> I've just tried this on an eMMC 4.41 device (Sandisk SEM04G) with
> sdhci-pxav3, and it resulted in a crash on the way into suspend:
>
> [   18.379192] PM: Syncing filesystems ... done.
> [   18.423866] Freezing user space processes ... (elapsed 0.01 seconds) done.
> [   18.446542] Freezing remaining freezable tasks ... (elapsed 0.01 seconds) done.
> [   18.549586] PM: Device sdhci-pxav3.2 failed to suspend: error -110
> [   18.583808] PM: Some devices failed to suspend
> [   22.141284] mmcblk0: error -110 sending status command, retrying
> [   22.153150] mmcblk0: error -110 sending status command, retrying
> [   22.164708] mmcblk0: error -110 sending status command, aborting
> [   22.176097] end_request: I/O error, dev mmcblk0, sector 4430104
> [..]
>
> Digging down, the -110 is coming from:
>
> int mmc_card_sleepawake(struct mmc_host *host, int sleep)
> {
>        struct mmc_command cmd = {0};
>        struct mmc_card *card = host->card;
>        int err;
>
>        if (sleep)
>                mmc_deselect_cards(host);
>
>        cmd.opcode = MMC_SLEEP_AWAKE;
>        cmd.arg = card->rca << 16;
>        if (sleep)
>                cmd.arg |= 1 << 15;
>
>        cmd.flags = MMC_RSP_R1B | MMC_CMD_AC;
>        err = mmc_wait_for_cmd(host, &cmd, 0);
>        if (err)
>                return err;
>        [..]
>
> Has anyone tried sleepawake on an SEM04G before?
>
Hi Chris,

I tried eMMC 4.41 device (Sandisk SEM08G) with
omap4, both CMD5 sleep/awake is successful

mmc_card_sleepawake (host, 1)
[   20.094451] mmc0: starting CMD7 arg 00000000 flags 00000000
[   20.103576] omap_hsmmc omap_hsmmc.1: mmc0: CMD7, argument 0x00000000
[   20.103576] omap_hsmmc omap_hsmmc.1: IRQ Status is 1
[   20.110229] mmc0: req done (CMD7): 0: 00000000 00000000 00000000 00000000
[   20.122528] mmc0: starting CMD5 arg 00018000 flags 0000001d
[   20.128356] omap_hsmmc omap_hsmmc.1: mmc0: CMD5, argument 0x00018000
[   20.135040] omap_hsmmc omap_hsmmc.1: IRQ Status is 1
[   20.140228] omap_hsmmc omap_hsmmc.1: IRQ Status is 2
[   20.140228] mmc0: req done (CMD5): 0: 00000600 00000000 00000000 00000000
[   20.152526] mmc0: clock 0Hz busmode 1 powermode 0 cs 0 Vdd 0 width 0 timing 0

mmc_card_sleepawake (host, 0)
[   32.875762] mmc0: starting CMD5 arg 00010000 flags 0000001d
[   32.881591] omap_hsmmc omap_hsmmc.1: mmc0: CMD5, argument 0x00010000
[   32.888549] omap_hsmmc omap_hsmmc.1: IRQ Status is 1
[   32.893737] omap_hsmmc omap_hsmmc.1: IRQ Status is 2
[   32.898925] mmc0: req done (CMD5): 0: 00001400 00000000 00000000 00000000
[   32.906066] mmc0: starting CMD7 arg 00010000 flags 00000015
[   32.911895] omap_hsmmc omap_hsmmc.1: mmc0: CMD7, argument 0x00010000
[   32.918884] omap_hsmmc omap_hsmmc.1: IRQ Status is 1
[   32.918884] mmc0: req done (CMD7): 0: 00000700 00000000 00000000 00000000
[   32.931182] omap_hsmmc omap_hsmmc.1: disabled

> It seems likely (I haven't tested yet, but will do) that the card
> actually went into sleep successfully and is waiting for an AWAKE
> command, even though mmc_wait_for_cmd() returned a timeout.
> If so, any suggestions on how to handle that case?
>
> Thanks,
>
> - Chris.
> --
> Chris Ball   <cjb@laptop.org>   <http://printf.net/>
> One Laptop Per Child

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

end of thread, other threads:[~2012-04-12  7:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-08 16:38 [PATCH v2] mmc: core: eMMC in Sleep mode before suspend Balaji T K
2011-09-09  6:34 ` Subhash Jadavani
2011-09-09  6:56   ` Adrian Hunter
2011-09-21 17:47 ` Chris Ball
2012-04-12  4:24 ` Chris Ball
2012-04-12  7:22   ` T Krishnamoorthy, Balaji

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.