From: alex lemberg <alex.lemberg@sandisk.com>
To: ulf.hansson@linaro.org, linux-mmc@vger.kernel.org
Cc: avi.shchislowski@sandisk.com, alex lemberg <alex.lemberg@sandisk.com>
Subject: [PATCH 3/3] mmc: Checking BKOPS status prior to Suspend
Date: Thu, 1 Sep 2016 17:24:50 +0300 [thread overview]
Message-ID: <1472739890-3384-4-git-send-email-alex.lemberg@sandisk.com> (raw)
In-Reply-To: <1472739890-3384-1-git-send-email-alex.lemberg@sandisk.com>
Rescheduling Suspend in case of BKOPS Level >= 1
in order to let eMMC device to complete its internal GC.
Applicable for Runtime Suspend Only.
Signed-off-by: alex lemberg <alex.lemberg@sandisk.com>
---
drivers/mmc/core/mmc.c | 30 +++++++++++++++++++++++-------
include/linux/mmc/mmc.h | 1 +
2 files changed, 24 insertions(+), 7 deletions(-)
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index e2e987f..c4c6326 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -1904,7 +1904,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 :
@@ -1918,10 +1919,25 @@ 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_1) {
+ pm_schedule_suspend(&host->card->dev,
+ MMC_RUNTIME_SUSPEND_DELAY_MS);
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);
@@ -1952,7 +1968,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);
@@ -2002,7 +2018,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;
}
@@ -2026,7 +2042,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 0fe3908..0f08d5c 100644
--- a/include/linux/mmc/mmc.h
+++ b/include/linux/mmc/mmc.h
@@ -430,6 +430,7 @@ struct _mmc_csd {
/*
* BKOPS status level
*/
+#define EXT_CSD_BKOPS_LEVEL_1 0x1
#define EXT_CSD_BKOPS_LEVEL_2 0x2
/*
--
1.9.1
next prev parent reply other threads:[~2016-09-01 15:02 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-01 14:24 [PATCH 0/3] mmc: Check BKOPS Level On Runtime Suspend alex lemberg
2016-09-01 14:24 ` [PATCH 1/3] mmc: replacing hardcoded value for runtime PM suspend alex lemberg
2016-09-02 7:39 ` Shawn Lin
2016-09-04 13:30 ` Alex Lemberg
2016-10-13 7:36 ` Ulf Hansson
2016-10-13 8:30 ` Shawn Lin
2016-10-31 9:53 ` Alex Lemberg
2016-09-01 14:24 ` [PATCH 2/3] mmc: Adding AUTO_BKOPS_EN bit set for Auto BKOPS support alex lemberg
2016-09-02 7:50 ` Shawn Lin
2016-09-04 13:22 ` Alex Lemberg
2016-10-13 7:36 ` Ulf Hansson
2016-10-31 9:53 ` Alex Lemberg
2016-09-01 14:24 ` alex lemberg [this message]
2016-10-13 7:36 ` [PATCH 3/3] mmc: Checking BKOPS status prior to Suspend Ulf Hansson
2016-10-31 9:53 ` Alex Lemberg
2016-09-26 15:10 ` [PATCH 0/3] mmc: Check BKOPS Level On Runtime Suspend Alex Lemberg
-- strict thread matches above, loose matches on Subject: below --
2017-01-17 12:15 [PATCH 0/3] Auto BKOPS PM suspend 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
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
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=1472739890-3384-4-git-send-email-alex.lemberg@sandisk.com \
--to=alex.lemberg@sandisk.com \
--cc=avi.shchislowski@sandisk.com \
--cc=linux-mmc@vger.kernel.org \
--cc=ulf.hansson@linaro.org \
/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