All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chuanxiao Dong <chuanxiao.dong@intel.com>
To: linux-mmc@vger.kernel.org
Cc: cjb@laptop.org, adrian.hunter@intel.com
Subject: [Patch v1]mmc:core: correct mmc_erase_timeout calculation
Date: Wed, 28 Mar 2012 16:29:33 +0800	[thread overview]
Message-ID: <20120328082933.GA27568@intel.com> (raw)

According to JEDEC 7.8.2, mmc_erase_timeout calculation should be follow:
1. Secure erase timeout = 300ms * ERASE_TIMEOUT_MULT * SEC_ERASE_MULT
2. Secure trim timeout = 300ms * ERASE_TIMEOUT_MULT * SEC_TRIM_MULT
3. Trim timeout = 300ms * TRIM_MULT
4. Erase timeout:
   a. if ERASE_GROUP_DEF is true: Erase timeout = 300ms * ERASE_TIMEOUT_MULT
   b. if ERASE_GROUP_DEF is false: Erase timeout = write block delay

Signed-off-by: Chuanxiao Dong <chuanxiao.dong@intel.com>
---
 drivers/mmc/core/core.c |   42 +++++++++++++++++++++++++++++-------------
 1 files changed, 29 insertions(+), 13 deletions(-)

diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 14f262e..d9d6d1c 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -1405,12 +1405,36 @@ static unsigned int mmc_mmc_erase_timeout(struct mmc_card *card,
 {
 	unsigned int erase_timeout;
 
-	if (card->ext_csd.erase_group_def & 1) {
-		/* High Capacity Erase Group Size uses HC timeouts */
-		if (arg == MMC_TRIM_ARG)
-			erase_timeout = card->ext_csd.trim_timeout;
+	/*
+	 * JEDEC 7.8.2
+	 *
+	 * 1. Secure erase/trim timeout is calculated absed on Erase Timeout
+	 * and additional SEC_ERASE_MULT/SEC_TRIM_MULT.
+	 * So secure erase/trim timeout = ERASE Timeout * SEC_ERASE_MULT/
+	 * SEC_TRIM_MULT.
+	 * ERASE Timeout = 300ms * ERASE_TIMEOUT_MULT
+	 *
+	 * 2. trim timeout is calculated based on the TRIM_MULT factor.
+	 * So trim timeout = 300ms * TRIM_MULT
+	 *
+	 * 3. erase timeout calculation:
+	 *	a. if ERASE_GROUP_DEF is enabled, ERASE_TIMEOUT_MULT should be
+	 *	used to calculate erase timeout, so:
+	 *	erase timeout = 300 * ERASE_TIMEOUT_MULT
+	 *	b. if ERASE_GROUP_DEF is diabled, the duration of an erase
+	 *	command will be the number of Erase blocks to be erased
+	 *	multiplied by the block write delay.
+	 */
+	if (arg & MMC_SECURE_ARGS) {
+		erase_timeout = card->ext_csd.hc_erase_timeout;
+		if (arg == MMC_SECURE_ERASE_ARG)
+			erase_timeout *= card->ext_csd.sec_erase_mult;
 		else
-			erase_timeout = card->ext_csd.hc_erase_timeout;
+			erase_timeout *= card->ext_csd.sec_trim_mult;
+	} else if (arg & MMC_TRIM_ARGS) {
+		erase_timeout = card->ext_csd.trim_timeout;
+	} else if (card->ext_csd.erase_group_def & 1) {
+		erase_timeout = card->ext_csd.hc_erase_timeout;
 	} else {
 		/* CSD Erase Group Size uses write timeout */
 		unsigned int mult = (10 << card->csd.r2w_factor);
@@ -1441,14 +1465,6 @@ static unsigned int mmc_mmc_erase_timeout(struct mmc_card *card,
 			erase_timeout = 1;
 	}
 
-	/* Multiplier for secure operations */
-	if (arg & MMC_SECURE_ARGS) {
-		if (arg == MMC_SECURE_ERASE_ARG)
-			erase_timeout *= card->ext_csd.sec_erase_mult;
-		else
-			erase_timeout *= card->ext_csd.sec_trim_mult;
-	}
-
 	erase_timeout *= qty;
 
 	/*
-- 
1.7.1


             reply	other threads:[~2012-03-28  8:34 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-28  8:29 Chuanxiao Dong [this message]
2012-03-28  9:17 ` [Patch v1]mmc:core: correct mmc_erase_timeout calculation Namjae Jeon
2012-03-28  9:22   ` Dong, Chuanxiao
2012-03-28 12:35     ` Namjae Jeon
2012-03-29  2:50       ` Dong, Chuanxiao
2012-03-29  3:29         ` Namjae Jeon
2012-03-29  3:36           ` Dong, Chuanxiao
2012-03-29  3:51             ` Namjae Jeon
2012-03-29  4:46         ` Philip Rakity

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=20120328082933.GA27568@intel.com \
    --to=chuanxiao.dong@intel.com \
    --cc=adrian.hunter@intel.com \
    --cc=cjb@laptop.org \
    --cc=linux-mmc@vger.kernel.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 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.