public inbox for linux-mmc@vger.kernel.org
 help / color / mirror / Atom feed
From: Adrian Hunter <adrian.hunter@intel.com>
To: Uri Yanai <uri.yanai@sandisk.com>, ulf.hansson@linaro.org
Cc: linux-mmc@vger.kernel.org, chris@printf.net, alex.lemberg@sandisk.com
Subject: Re: [PATCH 3/3] mmc: Checking BKOPS status prior to Suspend
Date: Fri, 20 Jan 2017 13:56:03 +0200	[thread overview]
Message-ID: <7a21bfe1-9eef-0f6f-56ce-4fc34d628ac0@intel.com> (raw)
In-Reply-To: <1484655337-32562-4-git-send-email-uri.yanai@sandisk.com>

On 17/01/17 14:15, Uri Yanai wrote:
> If asked to do device Runtime Suspend while
> in BKOPS and auto BKOPS is enabled return –EBUSY

The spec also says

"Before moving to Sleep state hosts may set the POWER_OFF_NOTIFICATION byte
to SLEEP_NOTIFICATION (0x04) if aware that the device is capable of
autonomously initiating background operations for possible performance
improvements."

Have you considered that?

But I wonder if we shouldn't always use SLEEP_NOTIFICATION before sleep?

> 
> Change-Id: Ie4b38a32fe98179f0bca5b57edaaa47a02d0a389
> Signed-off-by: Uri Yanai <uri.yanai@sandisk.com>
> Signed-off-by: Alex Lemberg <alex.lemberg@sandisk.com>
> ---
>  drivers/mmc/core/mmc.c  | 35 ++++++++++++++++++++++++++++-------
>  include/linux/mmc/mmc.h |  2 ++
>  2 files changed, 30 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
> index f70f6a1..21f5851 100644
> --- a/drivers/mmc/core/mmc.c
> +++ b/drivers/mmc/core/mmc.c
> @@ -1942,7 +1942,8 @@ static void mmc_detect(struct mmc_host *host)
>  	}
>  }
>  
> -static int _mmc_suspend(struct mmc_host *host, bool is_suspend)
> +static int _mmc_suspend(struct mmc_host *host, bool is_suspend,
> +	bool is_runtime_pm)
>  {
>  	int err = 0;
>  	unsigned int notify_type = is_suspend ? EXT_CSD_POWER_OFF_SHORT :
> @@ -1953,10 +1954,30 @@ static int _mmc_suspend(struct mmc_host *host, bool is_suspend)
>  	if (mmc_card_suspended(host->card))
>  		goto out;
>  
> -	if (mmc_card_doing_bkops(host->card)) {
> -		err = mmc_stop_bkops(host->card);
> -		if (err)
> +	if (mmc_card_doing_bkops(host->card) ||
> +		host->card->ext_csd.auto_bkops_en) {
> +		err = mmc_read_bkops_status(host->card);
> +		if (err) {
> +			pr_err("%s: error %d reading BKOPS Status\n",
> +				mmc_hostname(host), err);
>  			goto out;
> +		}
> +		if (is_runtime_pm && host->card->ext_csd.raw_bkops_status >=
> +				EXT_CSD_BKOPS_LEVEL_PM_SUSPEND) {
> +			/*
> +			 * We don’t allow Runtime Suspend while device still
> +			 * needs time to complete internal BKOPS, returning
> +			 * -EBUSY while BKOPS level is above
> +			 *  EXT_CSD_BKOPS_LEVEL_PM_SUSPEND
> +			 */
> +			err = -EBUSY;
> +			goto out;
> +		}
> +		if (mmc_card_doing_bkops(host->card)) {
> +			err = mmc_stop_bkops(host->card);
> +			if (err)
> +				goto out;
> +		}
>  	}
>  
>  	err = mmc_flush_cache(host->card);
> @@ -1987,7 +2008,7 @@ static int mmc_suspend(struct mmc_host *host)
>  {
>  	int err;
>  
> -	err = _mmc_suspend(host, true);
> +	err = _mmc_suspend(host, true, false);
>  	if (!err) {
>  		pm_runtime_disable(&host->card->dev);
>  		pm_runtime_set_suspended(&host->card->dev);
> @@ -2034,7 +2055,7 @@ static int mmc_shutdown(struct mmc_host *host)
>  		err = _mmc_resume(host);
>  
>  	if (!err)
> -		err = _mmc_suspend(host, false);
> +		err = _mmc_suspend(host, false, false);
>  
>  	return err;
>  }
> @@ -2058,7 +2079,7 @@ static int mmc_runtime_suspend(struct mmc_host *host)
>  	if (!(host->caps & MMC_CAP_AGGRESSIVE_PM))
>  		return 0;
>  
> -	err = _mmc_suspend(host, true);
> +	err = _mmc_suspend(host, true, true);
>  	if (err)
>  		pr_err("%s: error %d doing aggressive suspend\n",
>  			mmc_hostname(host), err);
> diff --git a/include/linux/mmc/mmc.h b/include/linux/mmc/mmc.h
> index 126b8d5..2633274 100644
> --- a/include/linux/mmc/mmc.h
> +++ b/include/linux/mmc/mmc.h
> @@ -445,6 +445,8 @@ struct _mmc_csd {
>   */
>  #define EXT_CSD_BKOPS_LEVEL_2		0x2
>  
> +#define EXT_CSD_BKOPS_LEVEL_PM_SUSPEND	EXT_CSD_BKOPS_LEVEL_2
> +
>  /*
>   * BKOPS modes
>   */
> 


  parent reply	other threads:[~2017-01-20 12:01 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-17 12:15 [PATCH 0/3] Auto BKOPS PM suspend Uri Yanai
2017-01-17 12:15 ` [PATCH 1/3] mmc: replacing hardcoded value for runtime " Uri Yanai
2017-01-17 12:15 ` [PATCH 2/3] mmc: Adding AUTO_BKOPS_EN bit set for Auto BKOPS support Uri Yanai
2017-01-17 12:15 ` [PATCH 3/3] mmc: Checking BKOPS status prior to Suspend Uri Yanai
2017-01-18  1:59   ` Shawn Lin
2017-01-18 15:01     ` Uri Yanai
2017-01-20 11:56   ` Adrian Hunter [this message]
2017-01-22 15:55     ` Uri Yanai
2017-01-23 17:07       ` Alex Lemberg
2017-01-24 14:36         ` Adrian Hunter
2017-01-25  9:48           ` Alex Lemberg
2017-01-25 10:30             ` Adrian Hunter
2017-01-25 12:40               ` Alex Lemberg
2017-01-25 12:45                 ` Adrian Hunter
2017-01-25 13:42                   ` Alex Lemberg
2017-01-18  1:53 ` [PATCH 0/3] Auto BKOPS PM suspend Shawn Lin
2017-01-18 14:12   ` Uri Yanai
  -- strict thread matches above, loose matches on Subject: below --
2016-09-01 14:24 [PATCH 0/3] mmc: Check BKOPS Level On Runtime Suspend alex lemberg
2016-09-01 14:24 ` [PATCH 3/3] mmc: Checking BKOPS status prior to Suspend alex lemberg
2016-10-13  7:36   ` Ulf Hansson
2016-10-31  9:53     ` Alex Lemberg

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=7a21bfe1-9eef-0f6f-56ce-4fc34d628ac0@intel.com \
    --to=adrian.hunter@intel.com \
    --cc=alex.lemberg@sandisk.com \
    --cc=chris@printf.net \
    --cc=linux-mmc@vger.kernel.org \
    --cc=ulf.hansson@linaro.org \
    --cc=uri.yanai@sandisk.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