* [PATCH 0/2] mmc: fixes for eMMC v4.5 discard / sanitize operations
@ 2012-04-05 11:45 Adrian Hunter
2012-04-05 11:45 ` [PATCH 1/2] mmc: fixes for eMMC v4.5 discard operation Adrian Hunter
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Adrian Hunter @ 2012-04-05 11:45 UTC (permalink / raw)
To: Chris Ball
Cc: linux-mmc, Linus Walleij, Luca Porzio (lporzio), Kyungmin Park,
Kyungmin Park, Jaehoon Chung, Adrian Hunter
Hi
Here are patches in response to the thread
"mmc: card: move variable initialization earlier"
The patches have not been tested on eMMC v4.5
because I do not have one. Consequently, these
patches need an ack or tested-by someone who has
one that supports discard and sanitize.
Adrian Hunter (2):
mmc: fixes for eMMC v4.5 discard operation
mmc: fixes for eMMC v4.5 sanitize operation
drivers/mmc/card/block.c | 54 ++++++++++++++++++++++++++++++++-------------
drivers/mmc/card/queue.c | 2 +-
drivers/mmc/core/core.c | 9 +++++--
3 files changed, 45 insertions(+), 20 deletions(-)
Regards
Adrian
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] mmc: fixes for eMMC v4.5 discard operation
2012-04-05 11:45 [PATCH 0/2] mmc: fixes for eMMC v4.5 discard / sanitize operations Adrian Hunter
@ 2012-04-05 11:45 ` Adrian Hunter
2012-04-05 11:45 ` [PATCH 2/2] mmc: fixes for eMMC v4.5 sanitize operation Adrian Hunter
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Adrian Hunter @ 2012-04-05 11:45 UTC (permalink / raw)
To: Chris Ball
Cc: linux-mmc, Linus Walleij, Luca Porzio (lporzio), Kyungmin Park,
Kyungmin Park, Jaehoon Chung, Adrian Hunter, stable
eMMC v4.5 discard operation is significantly different from the
existing trim operation because it is not guaranteed to work with
the new sanitize operation. Consequently mmc_can_trim() is
separated from mmc_can_discard().
Also the new discard operation does not result in the sectors being
set to all-zeros, so discard_zeroes_data must not be set.
In addition, the new discard has the same timeout as trim, but from
v4.5 trim is defined to use the hc timeout. The timeout calculation
is adjusted accordingly.
Fixes apply to linux 3.2 on.
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: <stable@vger.kernel.org>
---
drivers/mmc/card/queue.c | 2 +-
drivers/mmc/core/core.c | 7 ++++---
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/mmc/card/queue.c b/drivers/mmc/card/queue.c
index 2517547..996f8e3 100644
--- a/drivers/mmc/card/queue.c
+++ b/drivers/mmc/card/queue.c
@@ -139,7 +139,7 @@ static void mmc_queue_setup_discard(struct request_queue *q,
queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, q);
q->limits.max_discard_sectors = max_discard;
- if (card->erased_byte == 0)
+ if (card->erased_byte == 0 && !mmc_can_discard(card))
q->limits.discard_zeroes_data = 1;
q->limits.discard_granularity = card->pref_erase << 9;
/* granularity must not be greater than max. discard */
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 14f262e..8a9f286 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -1405,7 +1405,10 @@ static unsigned int mmc_mmc_erase_timeout(struct mmc_card *card,
{
unsigned int erase_timeout;
- if (card->ext_csd.erase_group_def & 1) {
+ if (arg == MMC_DISCARD_ARG ||
+ (arg == MMC_TRIM_ARG && card->ext_csd.rev >= 6)) {
+ erase_timeout = card->ext_csd.trim_timeout;
+ } else 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;
@@ -1677,8 +1680,6 @@ int mmc_can_trim(struct mmc_card *card)
{
if (card->ext_csd.sec_feature_support & EXT_CSD_SEC_GB_CL_EN)
return 1;
- if (mmc_can_discard(card))
- return 1;
return 0;
}
EXPORT_SYMBOL(mmc_can_trim);
--
1.7.6.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] mmc: fixes for eMMC v4.5 sanitize operation
2012-04-05 11:45 [PATCH 0/2] mmc: fixes for eMMC v4.5 discard / sanitize operations Adrian Hunter
2012-04-05 11:45 ` [PATCH 1/2] mmc: fixes for eMMC v4.5 discard operation Adrian Hunter
@ 2012-04-05 11:45 ` Adrian Hunter
2012-04-09 5:08 ` [PATCH 0/2] mmc: fixes for eMMC v4.5 discard / sanitize operations Jaehoon Chung
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Adrian Hunter @ 2012-04-05 11:45 UTC (permalink / raw)
To: Chris Ball
Cc: linux-mmc, Linus Walleij, Luca Porzio (lporzio), Kyungmin Park,
Kyungmin Park, Jaehoon Chung, Adrian Hunter, stable
eMMC v4.5 sanitize operation erases all copies of unmapped
data. However trim or erase operations must be used first
to unmap the required sectors. That was not being done.
Fixes apply to linux 3.2 on.
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: <stable@vger.kernel.org>
---
drivers/mmc/card/block.c | 54 ++++++++++++++++++++++++++++++++-------------
drivers/mmc/core/core.c | 2 +
2 files changed, 40 insertions(+), 16 deletions(-)
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index b180965..4232bc4 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -873,7 +873,7 @@ static int mmc_blk_issue_secdiscard_rq(struct mmc_queue *mq,
{
struct mmc_blk_data *md = mq->data;
struct mmc_card *card = md->queue.card;
- unsigned int from, nr, arg;
+ unsigned int from, nr, arg, trim_arg, erase_arg;
int err = 0, type = MMC_BLK_SECDISCARD;
if (!(mmc_can_secure_erase_trim(card) || mmc_can_sanitize(card))) {
@@ -881,20 +881,26 @@ static int mmc_blk_issue_secdiscard_rq(struct mmc_queue *mq,
goto out;
}
+ from = blk_rq_pos(req);
+ nr = blk_rq_sectors(req);
+
/* The sanitize operation is supported at v4.5 only */
if (mmc_can_sanitize(card)) {
- err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
- EXT_CSD_SANITIZE_START, 1, 0);
- goto out;
+ erase_arg = MMC_ERASE_ARG;
+ trim_arg = MMC_TRIM_ARG;
+ } else {
+ erase_arg = MMC_SECURE_ERASE_ARG;
+ trim_arg = MMC_SECURE_TRIM1_ARG;
}
- from = blk_rq_pos(req);
- nr = blk_rq_sectors(req);
-
- if (mmc_can_trim(card) && !mmc_erase_group_aligned(card, from, nr))
- arg = MMC_SECURE_TRIM1_ARG;
- else
- arg = MMC_SECURE_ERASE_ARG;
+ if (mmc_erase_group_aligned(card, from, nr))
+ arg = erase_arg;
+ else if (mmc_can_trim(card))
+ arg = trim_arg;
+ else {
+ err = -EINVAL;
+ goto out;
+ }
retry:
if (card->quirks & MMC_QUIRK_INAND_CMD38) {
err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
@@ -904,25 +910,41 @@ retry:
INAND_CMD38_ARG_SECERASE,
0);
if (err)
- goto out;
+ goto out_retry;
}
+
err = mmc_erase(card, from, nr, arg);
- if (!err && arg == MMC_SECURE_TRIM1_ARG) {
+ if (err == -EIO)
+ goto out_retry;
+ if (err)
+ goto out;
+
+ if (arg == MMC_SECURE_TRIM1_ARG) {
if (card->quirks & MMC_QUIRK_INAND_CMD38) {
err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
INAND_CMD38_ARG_EXT_CSD,
INAND_CMD38_ARG_SECTRIM2,
0);
if (err)
- goto out;
+ goto out_retry;
}
+
err = mmc_erase(card, from, nr, MMC_SECURE_TRIM2_ARG);
+ if (err == -EIO)
+ goto out_retry;
+ if (err)
+ goto out;
}
-out:
- if (err == -EIO && !mmc_blk_reset(md, card->host, type))
+
+ if (mmc_can_sanitize(card))
+ err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
+ EXT_CSD_SANITIZE_START, 1, 0);
+out_retry:
+ if (err && !mmc_blk_reset(md, card->host, type))
goto retry;
if (!err)
mmc_blk_reset_success(md, type);
+out:
spin_lock_irq(&md->lock);
__blk_end_request(req, err, blk_rq_bytes(req));
spin_unlock_irq(&md->lock);
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 8a9f286..50eb323 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -1698,6 +1698,8 @@ EXPORT_SYMBOL(mmc_can_discard);
int mmc_can_sanitize(struct mmc_card *card)
{
+ if (!mmc_can_trim(card) && !mmc_can_erase(card))
+ return 0;
if (card->ext_csd.sec_feature_support & EXT_CSD_SEC_SANITIZE)
return 1;
return 0;
--
1.7.6.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 0/2] mmc: fixes for eMMC v4.5 discard / sanitize operations
2012-04-05 11:45 [PATCH 0/2] mmc: fixes for eMMC v4.5 discard / sanitize operations Adrian Hunter
2012-04-05 11:45 ` [PATCH 1/2] mmc: fixes for eMMC v4.5 discard operation Adrian Hunter
2012-04-05 11:45 ` [PATCH 2/2] mmc: fixes for eMMC v4.5 sanitize operation Adrian Hunter
@ 2012-04-09 5:08 ` Jaehoon Chung
2012-04-09 17:44 ` Linus Walleij
2012-04-09 17:49 ` Chris Ball
4 siblings, 0 replies; 6+ messages in thread
From: Jaehoon Chung @ 2012-04-09 5:08 UTC (permalink / raw)
To: Adrian Hunter
Cc: Chris Ball, linux-mmc, Linus Walleij, Luca Porzio (lporzio),
Kyungmin Park, Kyungmin Park, Jaehoon Chung
Hi Adrian.
This patch is make sense.
It looks fine to me.
I tested with eMMC4.5 and triggered the secdiscard/discard with ioctl.
(But i didn't have the iNAND.)
Acked-by: Jaehoon Chung <jh80.chung@samsung.com>
Best Regards,
Jaehoon Chung
On 04/05/2012 08:45 PM, Adrian Hunter wrote:
> Hi
>
> Here are patches in response to the thread
> "mmc: card: move variable initialization earlier"
>
> The patches have not been tested on eMMC v4.5
> because I do not have one. Consequently, these
> patches need an ack or tested-by someone who has
> one that supports discard and sanitize.
>
>
> Adrian Hunter (2):
> mmc: fixes for eMMC v4.5 discard operation
> mmc: fixes for eMMC v4.5 sanitize operation
>
> drivers/mmc/card/block.c | 54 ++++++++++++++++++++++++++++++++-------------
> drivers/mmc/card/queue.c | 2 +-
> drivers/mmc/core/core.c | 9 +++++--
> 3 files changed, 45 insertions(+), 20 deletions(-)
>
>
> Regards
> Adrian
> --
> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 0/2] mmc: fixes for eMMC v4.5 discard / sanitize operations
2012-04-05 11:45 [PATCH 0/2] mmc: fixes for eMMC v4.5 discard / sanitize operations Adrian Hunter
` (2 preceding siblings ...)
2012-04-09 5:08 ` [PATCH 0/2] mmc: fixes for eMMC v4.5 discard / sanitize operations Jaehoon Chung
@ 2012-04-09 17:44 ` Linus Walleij
2012-04-09 17:49 ` Chris Ball
4 siblings, 0 replies; 6+ messages in thread
From: Linus Walleij @ 2012-04-09 17:44 UTC (permalink / raw)
To: Adrian Hunter
Cc: Chris Ball, linux-mmc, Luca Porzio (lporzio), Kyungmin Park,
Kyungmin Park, Jaehoon Chung
On Thu, Apr 5, 2012 at 1:45 PM, Adrian Hunter <adrian.hunter@intel.com> wrote:
> Here are patches in response to the thread
> "mmc: card: move variable initialization earlier"
Sweet, thanks for looking into this Adrian!
I have no MMC 4.5 device either but FWIW:
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Thanks,
Linus Walleij
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 0/2] mmc: fixes for eMMC v4.5 discard / sanitize operations
2012-04-05 11:45 [PATCH 0/2] mmc: fixes for eMMC v4.5 discard / sanitize operations Adrian Hunter
` (3 preceding siblings ...)
2012-04-09 17:44 ` Linus Walleij
@ 2012-04-09 17:49 ` Chris Ball
4 siblings, 0 replies; 6+ messages in thread
From: Chris Ball @ 2012-04-09 17:49 UTC (permalink / raw)
To: Adrian Hunter
Cc: linux-mmc, Linus Walleij, Luca Porzio (lporzio), Kyungmin Park,
Kyungmin Park, Jaehoon Chung
Hi,
On Thu, Apr 05 2012, Adrian Hunter wrote:
> Here are patches in response to the thread
> "mmc: card: move variable initialization earlier"
>
> The patches have not been tested on eMMC v4.5
> because I do not have one. Consequently, these
> patches need an ack or tested-by someone who has
> one that supports discard and sanitize.
>
>
> Adrian Hunter (2):
> mmc: fixes for eMMC v4.5 discard operation
> mmc: fixes for eMMC v4.5 sanitize operation
>
> drivers/mmc/card/block.c | 54 ++++++++++++++++++++++++++++++++-------------
> drivers/mmc/card/queue.c | 2 +-
> drivers/mmc/core/core.c | 9 +++++--
> 3 files changed, 45 insertions(+), 20 deletions(-)
Thanks very much, Adrian, pushed to mmc-next with ACKs from Jaehoon
and Linus W.
I'm not sure whether to merge these for 3.4, or let them soak until
the 3.5 window opens given how scarce the 4.5 devices are. Opinions
welcome; I'm thinking about waiting until 3.5 if no-one feels strongly.
- Chris.
--
Chris Ball <cjb@laptop.org> <http://printf.net/>
One Laptop Per Child
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-04-09 17:50 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-05 11:45 [PATCH 0/2] mmc: fixes for eMMC v4.5 discard / sanitize operations Adrian Hunter
2012-04-05 11:45 ` [PATCH 1/2] mmc: fixes for eMMC v4.5 discard operation Adrian Hunter
2012-04-05 11:45 ` [PATCH 2/2] mmc: fixes for eMMC v4.5 sanitize operation Adrian Hunter
2012-04-09 5:08 ` [PATCH 0/2] mmc: fixes for eMMC v4.5 discard / sanitize operations Jaehoon Chung
2012-04-09 17:44 ` Linus Walleij
2012-04-09 17:49 ` Chris Ball
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).