Skip to contentSkip to conversation

mmc: core: apply SD quirks earlier during probe

PATCH In review Keita Aihara 4 participants 5 messages Aug 20, 2024 – Aug 26, 2024 MMC, SD and SDIO

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 mmc: core: apply SD quirks earlier during probe

From: Jonathan Bell <[email protected]>

Applying MMC_QUIRK_BROKEN_SD_CACHE is broken, as the card's SD quirks are referenced in sd_parse_ext_reg_perf() prior to the quirks being initialized in mmc_blk_probe().

Split this out into a SD-specific list of quirks and apply in mmc_sd_init_card() instead.

Fixes c467c8f08185 ("mmc: Add MMC_QUIRK_BROKEN_SD_CACHE for Kingston Canvas Go Plus from 11/2019")
---
 drivers/mmc/core/quirks.h | 22 +++++++++++++---------
 drivers/mmc/core/sd.c     |  4 ++++
 2 files changed, 17 insertions(+), 9 deletions(-)
drivers/mmc/core/quirks.h +13 -9
index cca71867bc4a..92905fc46436 100644
@@ -15,6 +15,19 @@
 
 #include "card.h"
 
+static const struct mmc_fixup __maybe_unused mmc_sd_fixups[] = {
+	/*
+	 * Kingston Canvas Go! Plus microSD cards never finish SD cache flush.
+	 * This has so far only been observed on cards from 11/2019, while new
+	 * cards from 2023/05 do not exhibit this behavior.
+	 */
+	_FIXUP_EXT("SD64G", CID_MANFID_KINGSTON_SD, 0x5449, 2019, 11,
+		   0, -1ull, SDIO_ANY_ID, SDIO_ANY_ID, add_quirk_sd,
+		   MMC_QUIRK_BROKEN_SD_CACHE, EXT_CSD_REV_ANY),
+
+	END_FIXUP
+};
+
 static const struct mmc_fixup __maybe_unused mmc_blk_fixups[] = {
 #define INAND_CMD38_ARG_EXT_CSD  113
 #define INAND_CMD38_ARG_ERASE    0x00
@@ -53,15 +66,6 @@ static const struct mmc_fixup __maybe_unused mmc_blk_fixups[] = {
 	MMC_FIXUP("MMC32G", CID_MANFID_TOSHIBA, CID_OEMID_ANY, add_quirk_mmc,
 		  MMC_QUIRK_BLK_NO_CMD23),
 
-	/*
-	 * Kingston Canvas Go! Plus microSD cards never finish SD cache flush.
-	 * This has so far only been observed on cards from 11/2019, while new
-	 * cards from 2023/05 do not exhibit this behavior.
-	 */
-	_FIXUP_EXT("SD64G", CID_MANFID_KINGSTON_SD, 0x5449, 2019, 11,
-		   0, -1ull, SDIO_ANY_ID, SDIO_ANY_ID, add_quirk_sd,
-		   MMC_QUIRK_BROKEN_SD_CACHE, EXT_CSD_REV_ANY),
-
 	/*
 	 * Some SD cards lockup while using CMD23 multiblock transfers.
 	 */
drivers/mmc/core/sd.c +4 -0
index 1c8148cdda50..ee37ad14e79e 100644
@@ -26,6 +26,7 @@
 #include "host.h"
 #include "bus.h"
 #include "mmc_ops.h"
+#include "quirks.h"
 #include "sd.h"
 #include "sd_ops.h"
 
@@ -1475,6 +1476,9 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr,
 			goto free_card;
 	}
 
+	/* Apply quirks prior to card setup */
+	mmc_fixup_device(card, mmc_sd_fixups);
+
 	err = mmc_sd_setup_card(host, card, oldcard != NULL);
 	if (err)
 		goto free_card;

--
2.43.2

Reviewed-by on v2 1/1
#1 lore raw

Hello Keita,

Quoted 6 lines · Keita Aihara

From: Jonathan Bell <[email protected]>

Applying MMC_QUIRK_BROKEN_SD_CACHE is broken, as the card's SD quirks are referenced in sd_parse_ext_reg_perf() prior to the quirks being initialized in mmc_blk_probe().

Quoted 8 lines

Split this out into a SD-specific list of quirks and apply in mmc_sd_init_card() instead.

Fixes c467c8f08185 ("mmc: Add MMC_QUIRK_BROKEN_SD_CACHE for Kingston

Canvas Go Plus from 11/2019")

Looking good to me. This fix allows sd_read_ext_regs() to have the available information for not assigning the SD_EXT_PERF_CACHE as one of the (un)supported features, which in turn allows mmc_sd_init_card() to properly skip execution of sd_enable_cache().

Quoted 75 lines
---
 drivers/mmc/core/quirks.h | 22 +++++++++++++---------
 drivers/mmc/core/sd.c     |  4 ++++
 2 files changed, 17 insertions(+), 9 deletions(-)
drivers/mmc/core/quirks.h +3 -0
index cca71867bc4a..92905fc46436 100644
@@ -15,6 +15,19 @@
 
 #include "card.h"
 
+static const struct mmc_fixup __maybe_unused mmc_sd_fixups[] = {
+	/*
+	 * Kingston Canvas Go! Plus microSD cards never finish SD cache 

flush.

drivers/mmc/core/quirks.h +1 -0
+	 * This has so far only been observed on cards from 11/2019, while 

new

drivers/mmc/core/quirks.h +9 -2
+	 * cards from 2023/05 do not exhibit this behavior.
+	 */
+	_FIXUP_EXT("SD64G", CID_MANFID_KINGSTON_SD, 0x5449, 2019, 11,
+		   0, -1ull, SDIO_ANY_ID, SDIO_ANY_ID, add_quirk_sd,
+		   MMC_QUIRK_BROKEN_SD_CACHE, EXT_CSD_REV_ANY),
+
+	END_FIXUP
+};
+
 static const struct mmc_fixup __maybe_unused mmc_blk_fixups[] = {
 #define INAND_CMD38_ARG_EXT_CSD  113
 #define INAND_CMD38_ARG_ERASE    0x00
@@ -53,15 +66,6 @@ static const struct mmc_fixup __maybe_unused
 mmc_blk_fixups[] = {
 	MMC_FIXUP("MMC32G", CID_MANFID_TOSHIBA, CID_OEMID_ANY, add_quirk_mmc,
 		  MMC_QUIRK_BLK_NO_CMD23),
 
-	/*
-	 * Kingston Canvas Go! Plus microSD cards never finish SD cache 

flush.

drivers/mmc/core/quirks.h +0 -1
-	 * This has so far only been observed on cards from 11/2019, while 

new

drivers/mmc/core/quirks.h +0 -6
-	 * cards from 2023/05 do not exhibit this behavior.
-	 */
-	_FIXUP_EXT("SD64G", CID_MANFID_KINGSTON_SD, 0x5449, 2019, 11,
-		   0, -1ull, SDIO_ANY_ID, SDIO_ANY_ID, add_quirk_sd,
-		   MMC_QUIRK_BROKEN_SD_CACHE, EXT_CSD_REV_ANY),
-
 	/*
 	 * Some SD cards lockup while using CMD23 multiblock transfers.
 	 */
drivers/mmc/core/sd.c +4 -0
index 1c8148cdda50..ee37ad14e79e 100644
@@ -26,6 +26,7 @@
 #include "host.h"
 #include "bus.h"
 #include "mmc_ops.h"
+#include "quirks.h"
 #include "sd.h"
 #include "sd_ops.h"
 
@@ -1475,6 +1476,9 @@ static int mmc_sd_init_card(struct mmc_host
 *host, u32 ocr,
 			goto free_card;
 	}
 
+	/* Apply quirks prior to card setup */
+	mmc_fixup_device(card, mmc_sd_fixups);
+
 	err = mmc_sd_setup_card(host, card, oldcard != NULL);
 	if (err)

goto free_card;
--
2.43.2

#2 lore raw
Quoted 18 lines · Dragan Simic

Hello Keita,

Quoted 6 lines · Keita Aihara

From: Jonathan Bell <[email protected]>

Applying MMC_QUIRK_BROKEN_SD_CACHE is broken, as the card's SD quirks are referenced in sd_parse_ext_reg_perf() prior to the quirks being initialized in mmc_blk_probe().

Quoted 8 lines

Split this out into a SD-specific list of quirks and apply in mmc_sd_init_card() instead.

Fixes c467c8f08185 ("mmc: Add MMC_QUIRK_BROKEN_SD_CACHE for Kingston

Canvas Go Plus from 11/2019")

Quoted 6 lines

Looking good to me. This fix allows sd_read_ext_regs() to have the available information for not assigning the SD_EXT_PERF_CACHE as one of the (un)supported features, which in turn allows mmc_sd_init_card() to properly skip execution of sd_enable_cache().

Sorry, forgot to mention that this patch should, in my opinion, be also submitted for inclusion into stable kernels.

Quoted 76 lines
Quoted 76 lines
---
 drivers/mmc/core/quirks.h | 22 +++++++++++++---------
 drivers/mmc/core/sd.c     |  4 ++++
 2 files changed, 17 insertions(+), 9 deletions(-)
drivers/mmc/core/quirks.h +3 -0
index cca71867bc4a..92905fc46436 100644
@@ -15,6 +15,19 @@
 
 #include "card.h"
 
+static const struct mmc_fixup __maybe_unused mmc_sd_fixups[] = {
+	/*
+	 * Kingston Canvas Go! Plus microSD cards never finish SD cache 

flush.

drivers/mmc/core/quirks.h +1 -0
+	 * This has so far only been observed on cards from 11/2019, while 

new

drivers/mmc/core/quirks.h +9 -2
+	 * cards from 2023/05 do not exhibit this behavior.
+	 */
+	_FIXUP_EXT("SD64G", CID_MANFID_KINGSTON_SD, 0x5449, 2019, 11,
+		   0, -1ull, SDIO_ANY_ID, SDIO_ANY_ID, add_quirk_sd,
+		   MMC_QUIRK_BROKEN_SD_CACHE, EXT_CSD_REV_ANY),
+
+	END_FIXUP
+};
+
 static const struct mmc_fixup __maybe_unused mmc_blk_fixups[] = {
 #define INAND_CMD38_ARG_EXT_CSD  113
 #define INAND_CMD38_ARG_ERASE    0x00
@@ -53,15 +66,6 @@ static const struct mmc_fixup __maybe_unused
 mmc_blk_fixups[] = {
 	MMC_FIXUP("MMC32G", CID_MANFID_TOSHIBA, CID_OEMID_ANY, 
 add_quirk_mmc,
 		  MMC_QUIRK_BLK_NO_CMD23),
 
-	/*
-	 * Kingston Canvas Go! Plus microSD cards never finish SD cache 

flush.

drivers/mmc/core/quirks.h +0 -1
-	 * This has so far only been observed on cards from 11/2019, while 

new

drivers/mmc/core/quirks.h +0 -6
-	 * cards from 2023/05 do not exhibit this behavior.
-	 */
-	_FIXUP_EXT("SD64G", CID_MANFID_KINGSTON_SD, 0x5449, 2019, 11,
-		   0, -1ull, SDIO_ANY_ID, SDIO_ANY_ID, add_quirk_sd,
-		   MMC_QUIRK_BROKEN_SD_CACHE, EXT_CSD_REV_ANY),
-
 	/*
 	 * Some SD cards lockup while using CMD23 multiblock transfers.
 	 */
drivers/mmc/core/sd.c +4 -0
index 1c8148cdda50..ee37ad14e79e 100644
@@ -26,6 +26,7 @@
 #include "host.h"
 #include "bus.h"
 #include "mmc_ops.h"
+#include "quirks.h"
 #include "sd.h"
 #include "sd_ops.h"
 
@@ -1475,6 +1476,9 @@ static int mmc_sd_init_card(struct mmc_host
 *host, u32 ocr,
 			goto free_card;
 	}
 
+	/* Apply quirks prior to card setup */
+	mmc_fixup_device(card, mmc_sd_fixups);
+
 	err = mmc_sd_setup_card(host, card, oldcard != NULL);
 	if (err)

goto free_card;
--
2.43.2

Reviewed-by on v2 1/1
#3 lore raw
In reply to Keita Aihara
Quoted 8 lines

From: Jonathan Bell <[email protected]>

Applying MMC_QUIRK_BROKEN_SD_CACHE is broken, as the card's SD quirks are referenced in sd_parse_ext_reg_perf() prior to the quirks being initialized in mmc_blk_probe().

Quoted 8 lines

Split this out into a SD-specific list of quirks and apply in mmc_sd_init_card() instead.

Fixes c467c8f08185 ("mmc: Add MMC_QUIRK_BROKEN_SD_CACHE for Kingston

Canvas Go Plus from 11/2019")

#4 lore raw
In reply to Keita Aihara
Quoted 7 lines · Keita Aihara

From: Jonathan Bell <[email protected]>

Applying MMC_QUIRK_BROKEN_SD_CACHE is broken, as the card's SD quirks are referenced in sd_parse_ext_reg_perf() prior to the quirks being initialized in mmc_blk_probe().

Quoted 7 lines

Split this out into a SD-specific list of quirks and apply in mmc_sd_init_card() instead.

Fixes c467c8f08185 ("mmc: Add MMC_QUIRK_BROKEN_SD_CACHE for Kingston Canvas Go Plus from 11/2019")

Applied for fixes and by adding a stable-tag, thanks!

Kind regards
Uffe

Quoted 70 lines
---
 drivers/mmc/core/quirks.h | 22 +++++++++++++---------
 drivers/mmc/core/sd.c     |  4 ++++
 2 files changed, 17 insertions(+), 9 deletions(-)
drivers/mmc/core/quirks.h +13 -9
index cca71867bc4a..92905fc46436 100644
@@ -15,6 +15,19 @@
 
 #include "card.h"
 
+static const struct mmc_fixup __maybe_unused mmc_sd_fixups[] = {
+       /*
+        * Kingston Canvas Go! Plus microSD cards never finish SD cache flush.
+        * This has so far only been observed on cards from 11/2019, while new
+        * cards from 2023/05 do not exhibit this behavior.
+        */
+       _FIXUP_EXT("SD64G", CID_MANFID_KINGSTON_SD, 0x5449, 2019, 11,
+                  0, -1ull, SDIO_ANY_ID, SDIO_ANY_ID, add_quirk_sd,
+                  MMC_QUIRK_BROKEN_SD_CACHE, EXT_CSD_REV_ANY),
+
+       END_FIXUP
+};
+
 static const struct mmc_fixup __maybe_unused mmc_blk_fixups[] = {
 #define INAND_CMD38_ARG_EXT_CSD  113
 #define INAND_CMD38_ARG_ERASE    0x00
@@ -53,15 +66,6 @@ static const struct mmc_fixup __maybe_unused mmc_blk_fixups[] = {
        MMC_FIXUP("MMC32G", CID_MANFID_TOSHIBA, CID_OEMID_ANY, add_quirk_mmc,
                  MMC_QUIRK_BLK_NO_CMD23),
 
-       /*
-        * Kingston Canvas Go! Plus microSD cards never finish SD cache flush.
-        * This has so far only been observed on cards from 11/2019, while new
-        * cards from 2023/05 do not exhibit this behavior.
-        */
-       _FIXUP_EXT("SD64G", CID_MANFID_KINGSTON_SD, 0x5449, 2019, 11,
-                  0, -1ull, SDIO_ANY_ID, SDIO_ANY_ID, add_quirk_sd,
-                  MMC_QUIRK_BROKEN_SD_CACHE, EXT_CSD_REV_ANY),
-
        /*
         * Some SD cards lockup while using CMD23 multiblock transfers.
         */
drivers/mmc/core/sd.c +4 -1
index 1c8148cdda50..ee37ad14e79e 100644
@@ -26,6 +26,7 @@
 #include "host.h"
 #include "bus.h"
 #include "mmc_ops.h"
+#include "quirks.h"
 #include "sd.h"
 #include "sd_ops.h"
 
@@ -1475,6 +1476,9 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr,
                        goto free_card;
        }
 
+       /* Apply quirks prior to card setup */
+       mmc_fixup_device(card, mmc_sd_fixups);
+
        err = mmc_sd_setup_card(host, card, oldcard != NULL);
        if (err)
                goto free_card;
--

2.43.2