From: Gwendal Grignou <gwendal@chromium.org>
To: ulf.hansson@linaro.org
Cc: grundler@chromium.org, axboe@kernel.dk,
linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2] mmc: Set pref erase size based on size.
Date: Thu, 2 Jun 2016 17:27:18 -0700 [thread overview]
Message-ID: <1464913638-5283-1-git-send-email-gwendal@chromium.org> (raw)
In-Reply-To: <1464908184-20153-1-git-send-email-gwendal@chromium.org>
If available, eMMC stack uses HC_ERASE_GRP_SIZE as preferred erase size.
However, that size is the minimal size we must use, not the optimal size.
Calculate the optimal size based on whole device size and fall back to
HC_ERASE_GRP_SIZE if too small.
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
---
v2: fix comments
drivers/mmc/core/core.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index ef76b1c..b858907 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -1987,17 +1987,17 @@ void mmc_init_erase(struct mmc_card *card)
* to that size and alignment.
*
* For SD cards that define Allocation Unit size, limit erases to one
- * Allocation Unit at a time. For MMC cards that define High Capacity
- * Erase Size, whether it is switched on or not, limit to that size.
- * Otherwise just have a stab at a good value. For modern cards it
- * will end up being 4MiB. Note that if the value is too small, it
- * can end up taking longer to erase.
+ * Allocation Unit at a time.
+ * For MMC, have a stab at a good value. For modern cards it
+ * will end up being 4MiB.
+ * Be sure the size is at least the High Capacity Erase Size, as long
+ * as it is defined, even if not used.
+ * Note that if the value is too small, it can end up taking longer to
+ * erase.
*/
if (mmc_card_sd(card) && card->ssr.au) {
card->pref_erase = card->ssr.au;
card->erase_shift = ffs(card->ssr.au) - 1;
- } else if (card->ext_csd.hc_erase_size) {
- card->pref_erase = card->ext_csd.hc_erase_size;
} else if (card->erase_size) {
sz = (card->csd.capacity << (card->csd.read_blkbits - 9)) >> 11;
if (sz < 128)
@@ -2015,6 +2015,8 @@ void mmc_init_erase(struct mmc_card *card)
if (sz)
card->pref_erase += card->erase_size - sz;
}
+ if (card->ext_csd.hc_erase_size > card->pref_erase)
+ card->pref_erase = card->ext_csd.hc_erase_size;
} else
card->pref_erase = 0;
}
--
2.8.0.rc3.226.g39d4020
next prev parent reply other threads:[~2016-06-03 0:27 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-23 1:54 RFC: 32-bit __data_len and REQ_DISCARD+REQ_SECURE Grant Grundler
2015-09-24 17:39 ` Grant Grundler
[not found] ` <CANEJEGukOKUgRJNPVaeEXpx-REzj8ooSfWdrnRMMCQr6EVaNqQ@mail.gmail.com>
2015-09-28 21:45 ` Fwd: " Grant Grundler
2015-09-29 12:56 ` Gwendal Grignou
2015-10-20 17:53 ` Grant Grundler
2015-10-20 18:57 ` Jeff Moyer
2015-10-21 9:00 ` Ulf Hansson
2015-10-21 17:06 ` Grant Grundler
2015-10-28 22:15 ` Jeff Moyer
2016-06-02 22:56 ` [PATCH] mmc: Set pref erase size based on size Gwendal Grignou
2016-06-03 0:27 ` Gwendal Grignou [this message]
2016-06-03 16:08 ` [PATCH v3] CHROMIUM: " Gwendal Grignou
2016-06-22 15:23 ` Ulf Hansson
2016-06-10 17:02 ` [PATCH v2] " Grant Grundler
2015-10-21 17:38 ` RFC: 32-bit __data_len and REQ_DISCARD+REQ_SECURE Grant Grundler
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=1464913638-5283-1-git-send-email-gwendal@chromium.org \
--to=gwendal@chromium.org \
--cc=axboe@kernel.dk \
--cc=grundler@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--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
all inboxes | Powered by JetHome®