* SanDisk 4.3+ iNAND eMMC devices TRIM bug workaround.
@ 2011-04-11 22:20 Andrei Warkentin
2011-04-11 22:20 ` [PATCH 1/2] MMC: Support for block quirks Andrei Warkentin
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: Andrei Warkentin @ 2011-04-11 22:20 UTC (permalink / raw)
To: linux-mmc; +Cc: cjb
This fixes the out-of-spec erase/trim support. CMD38 argument
is passed through an EXT_CSD byte instead of as the command
argument. This has the effect that trims act as group erases,
erasing more data than necessary. Secure trims/erases were also affected.
N.B. This depends on the mmc_switch patch from the earlier boot partition
patchset (MMC: Allow setting CMD timeout for CMD6 (SWITCH)). This also
depends on the update core/quirks.c code.
ToC:
[PATCH 1/2] MMC: Support for block quirks.
[PATCH 2/2] MMC: Fix erase/trim for certain SanDisk cards.
A
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 1/2] MMC: Support for block quirks.
2011-04-11 22:20 SanDisk 4.3+ iNAND eMMC devices TRIM bug workaround Andrei Warkentin
@ 2011-04-11 22:20 ` Andrei Warkentin
2011-04-11 22:20 ` [PATCH 2/2] MMC: Fix erase/trim for certain SanDisk cards Andrei Warkentin
2011-04-12 16:57 ` SanDisk 4.3+ iNAND eMMC devices TRIM bug workaround Chris Ball
2 siblings, 0 replies; 11+ messages in thread
From: Andrei Warkentin @ 2011-04-11 22:20 UTC (permalink / raw)
To: linux-mmc; +Cc: cjb, Andrei Warkentin
Block quirks implemented using core/quirks.c support.
Change-Id: I81d9ad57a7ae95c60ee8026f090c8df7c75fd069
Signed-off-by: Andrei Warkentin <andreiw@motorola.com>
---
drivers/mmc/card/block.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index 91a6767..823f295 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -755,6 +755,11 @@ mmc_blk_set_blksize(struct mmc_blk_data *md, struct mmc_card *card)
return 0;
}
+static const struct mmc_fixup blk_fixups[] =
+{
+ END_FIXUP
+};
+
static int mmc_blk_probe(struct mmc_card *card)
{
struct mmc_blk_data *md;
@@ -782,6 +787,7 @@ static int mmc_blk_probe(struct mmc_card *card)
cap_str, md->read_only ? "(ro)" : "");
mmc_set_drvdata(card, md);
+ mmc_fixup_device(card, blk_fixups);
add_disk(md->disk);
return 0;
--
1.7.0.4
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 2/2] MMC: Fix erase/trim for certain SanDisk cards.
2011-04-11 22:20 SanDisk 4.3+ iNAND eMMC devices TRIM bug workaround Andrei Warkentin
2011-04-11 22:20 ` [PATCH 1/2] MMC: Support for block quirks Andrei Warkentin
@ 2011-04-11 22:20 ` Andrei Warkentin
2011-04-12 16:57 ` SanDisk 4.3+ iNAND eMMC devices TRIM bug workaround Chris Ball
2 siblings, 0 replies; 11+ messages in thread
From: Andrei Warkentin @ 2011-04-11 22:20 UTC (permalink / raw)
To: linux-mmc; +Cc: cjb, Andrei Warkentin
CMD38 argument is passed through EXT_CSD[113].
Change-Id: I47e9d5e2cf44d9274a65a3b1955026185cb8f2b8
Signed-off-by: Andrei Warkentin <andreiw@motorola.com>
---
drivers/mmc/card/block.c | 40 +++++++++++++++++++++++++++++++++++++++-
include/linux/mmc/card.h | 1 +
2 files changed, 40 insertions(+), 1 deletions(-)
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index 823f295..9fba4a6 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -48,6 +48,13 @@ MODULE_ALIAS("mmc:block");
#endif
#define MODULE_PARAM_PREFIX "mmcblk."
+#define INAND_CMD38_ARG_EXT_CSD 113
+#define INAND_CMD38_ARG_ERASE 0x00
+#define INAND_CMD38_ARG_TRIM 0x01
+#define INAND_CMD38_ARG_SECERASE 0x80
+#define INAND_CMD38_ARG_SECTRIM1 0x81
+#define INAND_CMD38_ARG_SECTRIM2 0x88
+
#define REL_WRITES_SUPPORTED(card) (mmc_card_mmc((card)) && \
(((card)->ext_csd.rel_param & EXT_CSD_WR_REL_PARAM_EN) || \
((card)->ext_csd.rel_sectors)))
@@ -288,6 +295,15 @@ static int mmc_blk_issue_discard_rq(struct mmc_queue *mq, struct request *req)
else
arg = MMC_ERASE_ARG;
+ if (card->quirks & MMC_QUIRK_INAND_CMD38) {
+ err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
+ INAND_CMD38_ARG_EXT_CSD,
+ arg == MMC_TRIM_ARG ?
+ INAND_CMD38_ARG_TRIM :
+ INAND_CMD38_ARG_ERASE);
+ if (err)
+ goto out;
+ }
err = mmc_erase(card, from, nr, arg);
out:
spin_lock_irq(&md->lock);
@@ -322,9 +338,26 @@ static int mmc_blk_issue_secdiscard_rq(struct mmc_queue *mq,
else
arg = MMC_SECURE_ERASE_ARG;
+ if (card->quirks & MMC_QUIRK_INAND_CMD38) {
+ err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
+ INAND_CMD38_ARG_EXT_CSD,
+ arg == MMC_SECURE_TRIM1_ARG ?
+ INAND_CMD38_ARG_SECTRIM1 :
+ INAND_CMD38_ARG_SECERASE);
+ if (err)
+ goto out;
+ }
err = mmc_erase(card, from, nr, arg);
- if (!err && arg == MMC_SECURE_TRIM1_ARG)
+ if (!err && 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);
+ if (err)
+ goto out;
+ }
err = mmc_erase(card, from, nr, MMC_SECURE_TRIM2_ARG);
+ }
out:
spin_lock_irq(&md->lock);
__blk_end_request(req, err, blk_rq_bytes(req));
@@ -757,6 +790,11 @@ mmc_blk_set_blksize(struct mmc_blk_data *md, struct mmc_card *card)
static const struct mmc_fixup blk_fixups[] =
{
+ MMC_FIXUP("SEM02G", 0x2, 0x100, add_quirk, MMC_QUIRK_INAND_CMD38),
+ MMC_FIXUP("SEM04G", 0x2, 0x100, add_quirk, MMC_QUIRK_INAND_CMD38),
+ MMC_FIXUP("SEM08G", 0x2, 0x100, add_quirk, MMC_QUIRK_INAND_CMD38),
+ MMC_FIXUP("SEM16G", 0x2, 0x100, add_quirk, MMC_QUIRK_INAND_CMD38),
+ MMC_FIXUP("SEM32G", 0x2, 0x100, add_quirk, MMC_QUIRK_INAND_CMD38),
END_FIXUP
};
diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h
index c651317..28ce230 100644
--- a/include/linux/mmc/card.h
+++ b/include/linux/mmc/card.h
@@ -131,6 +131,7 @@ struct mmc_card {
#define MMC_QUIRK_BROKEN_CLK_GATING (1<<3) /* clock gating the sdio bus will make card fail */
#define MMC_QUIRK_NONSTD_FUNC_IF (1<<4) /* SDIO card has nonstd function interfaces */
#define MMC_QUIRK_DISABLE_CD (1<<5) /* disconnect CD/DAT[3] resistor */
+#define MMC_QUIRK_INAND_CMD38 (1<<6) /* iNAND devices have broken CMD38 */
unsigned int erase_size; /* erase size in sectors */
unsigned int erase_shift; /* if erase unit is power 2 */
--
1.7.0.4
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: SanDisk 4.3+ iNAND eMMC devices TRIM bug workaround.
2011-04-11 22:20 SanDisk 4.3+ iNAND eMMC devices TRIM bug workaround Andrei Warkentin
2011-04-11 22:20 ` [PATCH 1/2] MMC: Support for block quirks Andrei Warkentin
2011-04-11 22:20 ` [PATCH 2/2] MMC: Fix erase/trim for certain SanDisk cards Andrei Warkentin
@ 2011-04-12 16:57 ` Chris Ball
2011-04-12 18:06 ` Andrei Warkentin
2 siblings, 1 reply; 11+ messages in thread
From: Chris Ball @ 2011-04-12 16:57 UTC (permalink / raw)
To: Andrei Warkentin; +Cc: linux-mmc
Hi Andrei,
On Mon, Apr 11 2011, Andrei Warkentin wrote:
> This fixes the out-of-spec erase/trim support. CMD38 argument
> is passed through an EXT_CSD byte instead of as the command
> argument. This has the effect that trims act as group erases,
> erasing more data than necessary. Secure trims/erases were also affected.
>
> N.B. This depends on the mmc_switch patch from the earlier boot partition
> patchset (MMC: Allow setting CMD timeout for CMD6 (SWITCH)). This also
> depends on the update core/quirks.c code.
>
> ToC:
> [PATCH 1/2] MMC: Support for block quirks.
> [PATCH 2/2] MMC: Fix erase/trim for certain SanDisk cards.
Looks like these are missing your new timeout arg to mmc_switch():
drivers/mmc/card/block.c: In function ‘mmc_blk_issue_discard_rq’:
drivers/mmc/card/block.c:371:6: error: too few arguments to function ‘mmc_switch’
include/linux/mmc/core.h:138:12: note: declared here
drivers/mmc/card/block.c: In function ‘mmc_blk_issue_secdiscard_rq’:
drivers/mmc/card/block.c:410:6: error: too few arguments to function ‘mmc_switch’
include/linux/mmc/core.h:138:12: note: declared here
drivers/mmc/card/block.c:419:7: error: too few arguments to function ‘mmc_switch’
Thanks,
- Chris.
--
Chris Ball <cjb@laptop.org> <http://printf.net/>
One Laptop Per Child
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: SanDisk 4.3+ iNAND eMMC devices TRIM bug workaround.
2011-04-12 16:57 ` SanDisk 4.3+ iNAND eMMC devices TRIM bug workaround Chris Ball
@ 2011-04-12 18:06 ` Andrei Warkentin
2011-04-12 20:03 ` [PATCH] MMC: Fix erase/trim for certain SanDisk cards Andrei Warkentin
2011-04-12 20:06 ` [PatchRebased] " Andrei Warkentin
0 siblings, 2 replies; 11+ messages in thread
From: Andrei Warkentin @ 2011-04-12 18:06 UTC (permalink / raw)
To: Chris Ball; +Cc: linux-mmc
On Tue, Apr 12, 2011 at 11:57 AM, Chris Ball <cjb@laptop.org> wrote:
> Hi Andrei,
>
> On Mon, Apr 11 2011, Andrei Warkentin wrote:
>> This fixes the out-of-spec erase/trim support. CMD38 argument
>> is passed through an EXT_CSD byte instead of as the command
>> argument. This has the effect that trims act as group erases,
>> erasing more data than necessary. Secure trims/erases were also affected.
>>
>> N.B. This depends on the mmc_switch patch from the earlier boot partition
>> patchset (MMC: Allow setting CMD timeout for CMD6 (SWITCH)). This also
>> depends on the update core/quirks.c code.
>>
>> ToC:
>> [PATCH 1/2] MMC: Support for block quirks.
>> [PATCH 2/2] MMC: Fix erase/trim for certain SanDisk cards.
>
> Looks like these are missing your new timeout arg to mmc_switch():
>
> drivers/mmc/card/block.c: In function ‘mmc_blk_issue_discard_rq’:
> drivers/mmc/card/block.c:371:6: error: too few arguments to function ‘mmc_switch’
> include/linux/mmc/core.h:138:12: note: declared here
> drivers/mmc/card/block.c: In function ‘mmc_blk_issue_secdiscard_rq’:
> drivers/mmc/card/block.c:410:6: error: too few arguments to function ‘mmc_switch’
> include/linux/mmc/core.h:138:12: note: declared here
> drivers/mmc/card/block.c:419:7: error: too few arguments to function ‘mmc_switch’
>
> Thanks,
>
> - Chris.
> --
> Chris Ball <cjb@laptop.org> <http://printf.net/>
> One Laptop Per Child
>
I'm sorry about that. I was sure I had rebased it appropriately, but I
had not. I will repush it.
A
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] MMC: Fix erase/trim for certain SanDisk cards.
2011-04-12 20:03 ` [PATCH] MMC: Fix erase/trim for certain SanDisk cards Andrei Warkentin
@ 2011-04-12 19:27 ` Andrei Warkentin
2011-04-12 19:33 ` Chris Ball
1 sibling, 0 replies; 11+ messages in thread
From: Andrei Warkentin @ 2011-04-12 19:27 UTC (permalink / raw)
To: linux-mmc; +Cc: cjb, Andrei Warkentin
On Tue, Apr 12, 2011 at 3:03 PM, Andrei Warkentin <andreiw@motorola.com> wrote:
> CMD38 argument is passed through EXT_CSD[113].
>
> Signed-off-by: Andrei Warkentin <andreiw@motorola.com>
> ---
Wrong version again, sorry! :(
A
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] MMC: Fix erase/trim for certain SanDisk cards.
2011-04-12 19:33 ` Chris Ball
@ 2011-04-12 19:30 ` Andrei Warkentin
0 siblings, 0 replies; 11+ messages in thread
From: Andrei Warkentin @ 2011-04-12 19:30 UTC (permalink / raw)
To: Chris Ball; +Cc: linux-mmc
On Tue, Apr 12, 2011 at 2:33 PM, Chris Ball <cjb@laptop.org> wrote:
> Hi Andrei,
>
> On Tue, Apr 12 2011, Andrei Warkentin wrote:
>> CMD38 argument is passed through EXT_CSD[113].
>>
>> Signed-off-by: Andrei Warkentin <andreiw@motorola.com>
>> ---
>
> You're still missing the final argument to mmc_switch(), no?
>
> Thanks,
>
I didn't amend before sending. Sorry. The right version has just been
resent with subject prefix [PatchRebased].
A
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] MMC: Fix erase/trim for certain SanDisk cards.
2011-04-12 20:03 ` [PATCH] MMC: Fix erase/trim for certain SanDisk cards Andrei Warkentin
2011-04-12 19:27 ` Andrei Warkentin
@ 2011-04-12 19:33 ` Chris Ball
2011-04-12 19:30 ` Andrei Warkentin
1 sibling, 1 reply; 11+ messages in thread
From: Chris Ball @ 2011-04-12 19:33 UTC (permalink / raw)
To: Andrei Warkentin; +Cc: linux-mmc
Hi Andrei,
On Tue, Apr 12 2011, Andrei Warkentin wrote:
> CMD38 argument is passed through EXT_CSD[113].
>
> Signed-off-by: Andrei Warkentin <andreiw@motorola.com>
> ---
> drivers/mmc/card/block.c | 40 +++++++++++++++++++++++++++++++++++++++-
> include/linux/mmc/card.h | 1 +
> 2 files changed, 40 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
> index 1bf1c5d..8895bb9 100644
> --- a/drivers/mmc/card/block.c
> +++ b/drivers/mmc/card/block.c
> @@ -48,6 +48,13 @@ MODULE_ALIAS("mmc:block");
> #endif
> #define MODULE_PARAM_PREFIX "mmcblk."
>
> +#define INAND_CMD38_ARG_EXT_CSD 113
> +#define INAND_CMD38_ARG_ERASE 0x00
> +#define INAND_CMD38_ARG_TRIM 0x01
> +#define INAND_CMD38_ARG_SECERASE 0x80
> +#define INAND_CMD38_ARG_SECTRIM1 0x81
> +#define INAND_CMD38_ARG_SECTRIM2 0x88
> +
> #define REL_WRITES_SUPPORTED(card) (mmc_card_mmc((card)) && \
> (((card)->ext_csd.rel_param & EXT_CSD_WR_REL_PARAM_EN) || \
> ((card)->ext_csd.rel_sectors)))
> @@ -356,6 +363,15 @@ static int mmc_blk_issue_discard_rq(struct mmc_queue *mq, struct request *req)
> else
> arg = MMC_ERASE_ARG;
>
> + if (card->quirks & MMC_QUIRK_INAND_CMD38) {
> + err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
> + INAND_CMD38_ARG_EXT_CSD,
> + arg == MMC_TRIM_ARG ?
> + INAND_CMD38_ARG_TRIM :
> + INAND_CMD38_ARG_ERASE);
You're still missing the final argument to mmc_switch(), no?
Thanks,
- Chris.
--
Chris Ball <cjb@laptop.org> <http://printf.net/>
One Laptop Per Child
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PatchRebased] MMC: Fix erase/trim for certain SanDisk cards.
2011-04-12 20:06 ` [PatchRebased] " Andrei Warkentin
@ 2011-04-12 19:37 ` Chris Ball
0 siblings, 0 replies; 11+ messages in thread
From: Chris Ball @ 2011-04-12 19:37 UTC (permalink / raw)
To: Andrei Warkentin; +Cc: linux-mmc
Hi Andrei,
On Tue, Apr 12 2011, Andrei Warkentin wrote:
> CMD38 argument is passed through EXT_CSD[113].
>
> Signed-off-by: Andrei Warkentin <andreiw@motorola.com>
> ---
> drivers/mmc/card/block.c | 43 ++++++++++++++++++++++++++++++++++++++++++-
> include/linux/mmc/card.h | 1 +
> 2 files changed, 43 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
> index 1bf1c5d..863f810 100644
> --- a/drivers/mmc/card/block.c
> +++ b/drivers/mmc/card/block.c
> @@ -48,6 +48,13 @@ MODULE_ALIAS("mmc:block");
> #endif
> #define MODULE_PARAM_PREFIX "mmcblk."
>
> +#define INAND_CMD38_ARG_EXT_CSD 113
> +#define INAND_CMD38_ARG_ERASE 0x00
> +#define INAND_CMD38_ARG_TRIM 0x01
> +#define INAND_CMD38_ARG_SECERASE 0x80
> +#define INAND_CMD38_ARG_SECTRIM1 0x81
> +#define INAND_CMD38_ARG_SECTRIM2 0x88
> +
> #define REL_WRITES_SUPPORTED(card) (mmc_card_mmc((card)) && \
> (((card)->ext_csd.rel_param & EXT_CSD_WR_REL_PARAM_EN) || \
> ((card)->ext_csd.rel_sectors)))
> @@ -356,6 +363,16 @@ static int mmc_blk_issue_discard_rq(struct mmc_queue *mq, struct request *req)
> else
> arg = MMC_ERASE_ARG;
>
> + if (card->quirks & MMC_QUIRK_INAND_CMD38) {
> + err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
> + INAND_CMD38_ARG_EXT_CSD,
> + arg == MMC_TRIM_ARG ?
> + INAND_CMD38_ARG_TRIM :
> + INAND_CMD38_ARG_ERASE,
> + 0);
> + if (err)
> + goto out;
> + }
> err = mmc_erase(card, from, nr, arg);
> out:
> spin_lock_irq(&md->lock);
> @@ -386,9 +403,28 @@ static int mmc_blk_issue_secdiscard_rq(struct mmc_queue *mq,
> else
> arg = MMC_SECURE_ERASE_ARG;
>
> + if (card->quirks & MMC_QUIRK_INAND_CMD38) {
> + err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
> + INAND_CMD38_ARG_EXT_CSD,
> + arg == MMC_SECURE_TRIM1_ARG ?
> + INAND_CMD38_ARG_SECTRIM1 :
> + INAND_CMD38_ARG_SECERASE,
> + 0);
> + if (err)
> + goto out;
> + }
> err = mmc_erase(card, from, nr, arg);
> - if (!err && arg == MMC_SECURE_TRIM1_ARG)
> + if (!err && 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;
> + }
> err = mmc_erase(card, from, nr, MMC_SECURE_TRIM2_ARG);
> + }
> out:
> spin_lock_irq(&md->lock);
> __blk_end_request(req, err, blk_rq_bytes(req));
> @@ -941,6 +977,11 @@ static int mmc_add_disk(struct mmc_blk_data *md)
>
> static const struct mmc_fixup blk_fixups[] =
> {
> + MMC_FIXUP("SEM02G", 0x2, 0x100, add_quirk, MMC_QUIRK_INAND_CMD38),
> + MMC_FIXUP("SEM04G", 0x2, 0x100, add_quirk, MMC_QUIRK_INAND_CMD38),
> + MMC_FIXUP("SEM08G", 0x2, 0x100, add_quirk, MMC_QUIRK_INAND_CMD38),
> + MMC_FIXUP("SEM16G", 0x2, 0x100, add_quirk, MMC_QUIRK_INAND_CMD38),
> + MMC_FIXUP("SEM32G", 0x2, 0x100, add_quirk, MMC_QUIRK_INAND_CMD38),
> END_FIXUP
> };
>
> diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h
> index 8ac96f7..0a2be01 100644
> --- a/include/linux/mmc/card.h
> +++ b/include/linux/mmc/card.h
> @@ -133,6 +133,7 @@ struct mmc_card {
> #define MMC_QUIRK_BROKEN_CLK_GATING (1<<3) /* clock gating the sdio bus will make card fail */
> #define MMC_QUIRK_NONSTD_FUNC_IF (1<<4) /* SDIO card has nonstd function interfaces */
> #define MMC_QUIRK_DISABLE_CD (1<<5) /* disconnect CD/DAT[3] resistor */
> +#define MMC_QUIRK_INAND_CMD38 (1<<6) /* iNAND devices have broken CMD38 */
>
> unsigned int erase_size; /* erase size in sectors */
> unsigned int erase_shift; /* if erase unit is power 2 */
Pushed to mmc-next for .40 along with the other patchsets. Thanks very much!
- Chris.
--
Chris Ball <cjb@laptop.org> <http://printf.net/>
One Laptop Per Child
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH] MMC: Fix erase/trim for certain SanDisk cards.
2011-04-12 18:06 ` Andrei Warkentin
@ 2011-04-12 20:03 ` Andrei Warkentin
2011-04-12 19:27 ` Andrei Warkentin
2011-04-12 19:33 ` Chris Ball
2011-04-12 20:06 ` [PatchRebased] " Andrei Warkentin
1 sibling, 2 replies; 11+ messages in thread
From: Andrei Warkentin @ 2011-04-12 20:03 UTC (permalink / raw)
To: linux-mmc; +Cc: cjb, Andrei Warkentin
CMD38 argument is passed through EXT_CSD[113].
Signed-off-by: Andrei Warkentin <andreiw@motorola.com>
---
drivers/mmc/card/block.c | 40 +++++++++++++++++++++++++++++++++++++++-
include/linux/mmc/card.h | 1 +
2 files changed, 40 insertions(+), 1 deletions(-)
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index 1bf1c5d..8895bb9 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -48,6 +48,13 @@ MODULE_ALIAS("mmc:block");
#endif
#define MODULE_PARAM_PREFIX "mmcblk."
+#define INAND_CMD38_ARG_EXT_CSD 113
+#define INAND_CMD38_ARG_ERASE 0x00
+#define INAND_CMD38_ARG_TRIM 0x01
+#define INAND_CMD38_ARG_SECERASE 0x80
+#define INAND_CMD38_ARG_SECTRIM1 0x81
+#define INAND_CMD38_ARG_SECTRIM2 0x88
+
#define REL_WRITES_SUPPORTED(card) (mmc_card_mmc((card)) && \
(((card)->ext_csd.rel_param & EXT_CSD_WR_REL_PARAM_EN) || \
((card)->ext_csd.rel_sectors)))
@@ -356,6 +363,15 @@ static int mmc_blk_issue_discard_rq(struct mmc_queue *mq, struct request *req)
else
arg = MMC_ERASE_ARG;
+ if (card->quirks & MMC_QUIRK_INAND_CMD38) {
+ err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
+ INAND_CMD38_ARG_EXT_CSD,
+ arg == MMC_TRIM_ARG ?
+ INAND_CMD38_ARG_TRIM :
+ INAND_CMD38_ARG_ERASE);
+ if (err)
+ goto out;
+ }
err = mmc_erase(card, from, nr, arg);
out:
spin_lock_irq(&md->lock);
@@ -386,9 +402,26 @@ static int mmc_blk_issue_secdiscard_rq(struct mmc_queue *mq,
else
arg = MMC_SECURE_ERASE_ARG;
+ if (card->quirks & MMC_QUIRK_INAND_CMD38) {
+ err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
+ INAND_CMD38_ARG_EXT_CSD,
+ arg == MMC_SECURE_TRIM1_ARG ?
+ INAND_CMD38_ARG_SECTRIM1 :
+ INAND_CMD38_ARG_SECERASE);
+ if (err)
+ goto out;
+ }
err = mmc_erase(card, from, nr, arg);
- if (!err && arg == MMC_SECURE_TRIM1_ARG)
+ if (!err && 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);
+ if (err)
+ goto out;
+ }
err = mmc_erase(card, from, nr, MMC_SECURE_TRIM2_ARG);
+ }
out:
spin_lock_irq(&md->lock);
__blk_end_request(req, err, blk_rq_bytes(req));
@@ -941,6 +974,11 @@ static int mmc_add_disk(struct mmc_blk_data *md)
static const struct mmc_fixup blk_fixups[] =
{
+ MMC_FIXUP("SEM02G", 0x2, 0x100, add_quirk, MMC_QUIRK_INAND_CMD38),
+ MMC_FIXUP("SEM04G", 0x2, 0x100, add_quirk, MMC_QUIRK_INAND_CMD38),
+ MMC_FIXUP("SEM08G", 0x2, 0x100, add_quirk, MMC_QUIRK_INAND_CMD38),
+ MMC_FIXUP("SEM16G", 0x2, 0x100, add_quirk, MMC_QUIRK_INAND_CMD38),
+ MMC_FIXUP("SEM32G", 0x2, 0x100, add_quirk, MMC_QUIRK_INAND_CMD38),
END_FIXUP
};
diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h
index 8ac96f7..0a2be01 100644
--- a/include/linux/mmc/card.h
+++ b/include/linux/mmc/card.h
@@ -133,6 +133,7 @@ struct mmc_card {
#define MMC_QUIRK_BROKEN_CLK_GATING (1<<3) /* clock gating the sdio bus will make card fail */
#define MMC_QUIRK_NONSTD_FUNC_IF (1<<4) /* SDIO card has nonstd function interfaces */
#define MMC_QUIRK_DISABLE_CD (1<<5) /* disconnect CD/DAT[3] resistor */
+#define MMC_QUIRK_INAND_CMD38 (1<<6) /* iNAND devices have broken CMD38 */
unsigned int erase_size; /* erase size in sectors */
unsigned int erase_shift; /* if erase unit is power 2 */
--
1.7.0.4
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PatchRebased] MMC: Fix erase/trim for certain SanDisk cards.
2011-04-12 18:06 ` Andrei Warkentin
2011-04-12 20:03 ` [PATCH] MMC: Fix erase/trim for certain SanDisk cards Andrei Warkentin
@ 2011-04-12 20:06 ` Andrei Warkentin
2011-04-12 19:37 ` Chris Ball
1 sibling, 1 reply; 11+ messages in thread
From: Andrei Warkentin @ 2011-04-12 20:06 UTC (permalink / raw)
To: linux-mmc; +Cc: cjb, Andrei Warkentin
CMD38 argument is passed through EXT_CSD[113].
Signed-off-by: Andrei Warkentin <andreiw@motorola.com>
---
drivers/mmc/card/block.c | 43 ++++++++++++++++++++++++++++++++++++++++++-
include/linux/mmc/card.h | 1 +
2 files changed, 43 insertions(+), 1 deletions(-)
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index 1bf1c5d..863f810 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -48,6 +48,13 @@ MODULE_ALIAS("mmc:block");
#endif
#define MODULE_PARAM_PREFIX "mmcblk."
+#define INAND_CMD38_ARG_EXT_CSD 113
+#define INAND_CMD38_ARG_ERASE 0x00
+#define INAND_CMD38_ARG_TRIM 0x01
+#define INAND_CMD38_ARG_SECERASE 0x80
+#define INAND_CMD38_ARG_SECTRIM1 0x81
+#define INAND_CMD38_ARG_SECTRIM2 0x88
+
#define REL_WRITES_SUPPORTED(card) (mmc_card_mmc((card)) && \
(((card)->ext_csd.rel_param & EXT_CSD_WR_REL_PARAM_EN) || \
((card)->ext_csd.rel_sectors)))
@@ -356,6 +363,16 @@ static int mmc_blk_issue_discard_rq(struct mmc_queue *mq, struct request *req)
else
arg = MMC_ERASE_ARG;
+ if (card->quirks & MMC_QUIRK_INAND_CMD38) {
+ err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
+ INAND_CMD38_ARG_EXT_CSD,
+ arg == MMC_TRIM_ARG ?
+ INAND_CMD38_ARG_TRIM :
+ INAND_CMD38_ARG_ERASE,
+ 0);
+ if (err)
+ goto out;
+ }
err = mmc_erase(card, from, nr, arg);
out:
spin_lock_irq(&md->lock);
@@ -386,9 +403,28 @@ static int mmc_blk_issue_secdiscard_rq(struct mmc_queue *mq,
else
arg = MMC_SECURE_ERASE_ARG;
+ if (card->quirks & MMC_QUIRK_INAND_CMD38) {
+ err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
+ INAND_CMD38_ARG_EXT_CSD,
+ arg == MMC_SECURE_TRIM1_ARG ?
+ INAND_CMD38_ARG_SECTRIM1 :
+ INAND_CMD38_ARG_SECERASE,
+ 0);
+ if (err)
+ goto out;
+ }
err = mmc_erase(card, from, nr, arg);
- if (!err && arg == MMC_SECURE_TRIM1_ARG)
+ if (!err && 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;
+ }
err = mmc_erase(card, from, nr, MMC_SECURE_TRIM2_ARG);
+ }
out:
spin_lock_irq(&md->lock);
__blk_end_request(req, err, blk_rq_bytes(req));
@@ -941,6 +977,11 @@ static int mmc_add_disk(struct mmc_blk_data *md)
static const struct mmc_fixup blk_fixups[] =
{
+ MMC_FIXUP("SEM02G", 0x2, 0x100, add_quirk, MMC_QUIRK_INAND_CMD38),
+ MMC_FIXUP("SEM04G", 0x2, 0x100, add_quirk, MMC_QUIRK_INAND_CMD38),
+ MMC_FIXUP("SEM08G", 0x2, 0x100, add_quirk, MMC_QUIRK_INAND_CMD38),
+ MMC_FIXUP("SEM16G", 0x2, 0x100, add_quirk, MMC_QUIRK_INAND_CMD38),
+ MMC_FIXUP("SEM32G", 0x2, 0x100, add_quirk, MMC_QUIRK_INAND_CMD38),
END_FIXUP
};
diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h
index 8ac96f7..0a2be01 100644
--- a/include/linux/mmc/card.h
+++ b/include/linux/mmc/card.h
@@ -133,6 +133,7 @@ struct mmc_card {
#define MMC_QUIRK_BROKEN_CLK_GATING (1<<3) /* clock gating the sdio bus will make card fail */
#define MMC_QUIRK_NONSTD_FUNC_IF (1<<4) /* SDIO card has nonstd function interfaces */
#define MMC_QUIRK_DISABLE_CD (1<<5) /* disconnect CD/DAT[3] resistor */
+#define MMC_QUIRK_INAND_CMD38 (1<<6) /* iNAND devices have broken CMD38 */
unsigned int erase_size; /* erase size in sectors */
unsigned int erase_shift; /* if erase unit is power 2 */
--
1.7.0.4
^ permalink raw reply related [flat|nested] 11+ messages in thread
end of thread, other threads:[~2011-04-12 19:32 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-11 22:20 SanDisk 4.3+ iNAND eMMC devices TRIM bug workaround Andrei Warkentin
2011-04-11 22:20 ` [PATCH 1/2] MMC: Support for block quirks Andrei Warkentin
2011-04-11 22:20 ` [PATCH 2/2] MMC: Fix erase/trim for certain SanDisk cards Andrei Warkentin
2011-04-12 16:57 ` SanDisk 4.3+ iNAND eMMC devices TRIM bug workaround Chris Ball
2011-04-12 18:06 ` Andrei Warkentin
2011-04-12 20:03 ` [PATCH] MMC: Fix erase/trim for certain SanDisk cards Andrei Warkentin
2011-04-12 19:27 ` Andrei Warkentin
2011-04-12 19:33 ` Chris Ball
2011-04-12 19:30 ` Andrei Warkentin
2011-04-12 20:06 ` [PatchRebased] " Andrei Warkentin
2011-04-12 19:37 ` 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).