All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chuanxiao Dong <chuanxiao.dong@intel.com>
To: linux-mmc@vger.kernel.org
Cc: adrian.hunter@intel.com, cjb@laptop.org
Subject: [PATCH]mmc: core: not to --qty when calculate timeout for SECURE_ERASE
Date: Fri, 13 Apr 2012 12:19:34 +0800	[thread overview]
Message-ID: <20120413041934.GA30513@intel.com> (raw)

--qty when calculating erase timeout for trim/erase & secure trim/erase
can prevent the erase range crossing qty+1 erase groups, which made
the final timeout value is too large for the host.

When operate SECURE_ERASE, driver needs the erase range is aligned with
erase size, otherwise do nothing and return an error. That is to say
it is not necessary for SECURE_ERASE to --qty since it will never cross
an erase group.

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

diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index e541efb..b5a393a 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -1761,7 +1761,7 @@ static unsigned int mmc_do_calc_max_discard(struct mmc_card *card,
 	if (!qty)
 		return 0;
 
-	if (qty == 1)
+	if (qty == 1 && arg != MMC_SECURE_ERASE_ARG)
 		return 1;
 
 	/* Convert qty to sectors */
@@ -1772,6 +1772,13 @@ static unsigned int mmc_do_calc_max_discard(struct mmc_card *card,
 	else
 		max_discard = --qty * card->erase_size;
 
+	/*
+	 * since SECURE_ERASE is erase group aligned, otherwise
+	 * it cannot be erased in secure purpose, needn't --qty
+	 */
+	if (arg == MMC_SECURE_ERASE_ARG)
+		max_discard += card->erase_size;
+
 	return max_discard;
 }
 
-- 
1.7.1


             reply	other threads:[~2012-04-13  4:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-13  4:19 Chuanxiao Dong [this message]
2012-05-21 11:05 ` [PATCH]mmc: core: not to --qty when calculate timeout for SECURE_ERASE Adrian Hunter
2012-05-21 11:19   ` Dong, Chuanxiao
2012-05-21 11:27     ` Adrian Hunter

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=20120413041934.GA30513@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.