public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH] mmc: allow forward compatibility for EXT_CSD_REV
@ 2026-03-26  5:55 박민우 (MW Park)
  2026-04-08 16:21 ` Peng Fan
  0 siblings, 1 reply; 3+ messages in thread
From: 박민우 (MW Park) @ 2026-03-26  5:55 UTC (permalink / raw)
  To: u-boot@lists.denx.de; +Cc: peng.fan@nxp.com, jh80.chung@samsung.com

[-- Attachment #1: Type: text/plain, Size: 2740 bytes --]

According to the JEDEC Standard, the EXT_CSD format is meant to be
forward compatible. As long as CSD_STRUCTURE does not change, all
values for EXT_CSD_REV are authorized.

Currently, if an eMMC device with a newer EXT_CSD_REV (e.g., eMMC 5.1B
with EXT_CSD_REV=9) is used, U-Boot fails to initialize it and returns
-EINVAL because the revision is larger than the mmc_versions array size.

Fix this by falling back to the latest supported version if the
EXT_CSD_REV exceeds the known versions. This ensures forward
compatibility with future eMMC specifications.

Signed-off-by: MW Park <mw.park@telechips.com>
---
 drivers/mmc/mmc.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index c5705f4f215..dbec728a474 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -2334,6 +2334,7 @@ static int mmc_startup_v4(struct mmc *mmc)
        u64 capacity;
        bool has_parts = false;
        bool part_completed;
+       u8 rev;
        static const u32 mmc_versions[] = {
                MMC_VERSION_4,
                MMC_VERSION_4_1,
@@ -2380,12 +2381,19 @@ static int mmc_startup_v4(struct mmc *mmc)
                return -ENOMEM;
        memcpy(mmc->ext_csd, ext_csd, MMC_MAX_BLOCK_LEN);
 #endif
-       if (ext_csd[EXT_CSD_REV] >= ARRAY_SIZE(mmc_versions)) {
-               err = -EINVAL;
-               goto error;
-       }
+       rev = ext_csd[EXT_CSD_REV];
+
+       /*
+        * According to the JEDEC Standard, the EXT_CSD format is meant to be
+        * forward compatible. As long as CSD_STRUCTURE does not change, all
+        * values for EXT_CSD_REV are authorized.
+        * If the EXT_CSD_REV exceeds the known versions, fallback to the
+        * latest supported version instead of returning an error.
+        */
+       if (rev >= ARRAY_SIZE(mmc_versions))
+               rev = ARRAY_SIZE(mmc_versions) - 1;

-       mmc->version = mmc_versions[ext_csd[EXT_CSD_REV]];
+       mmc->version = mmc_versions[rev];

        if (mmc->version >= MMC_VERSION_4_2) {
                /*
--
2.34.1
This email and any attachments to it may be confidential and are intended solely for the use of the individual to whom it is addressed. Any views or opinions expressed are solely those of the author and do not necessarily represent those of Telechips Inc. If you are not the intended recipient of this email, you must neither take any action based upon its contents nor copy or show it to anyone. Please notify the sender immediately by email if you have received this email by mistake and delete this email from your system. Please consider the environment before printing this email.

[-- Attachment #2: 0001-mmc-allow-forward-compatibility-for-EXT_CSD_REV.patch --]
[-- Type: application/octet-stream, Size: 2104 bytes --]

From f783ea55ce5fb80a8c2a67cce151ea217b835f2a Mon Sep 17 00:00:00 2001
From: MW Park <mw.park@telechips.com>
Date: Thu, 26 Mar 2026 14:41:16 +0900
Subject: [PATCH] mmc: allow forward compatibility for EXT_CSD_REV

According to the JEDEC Standard, the EXT_CSD format is meant to be
forward compatible. As long as CSD_STRUCTURE does not change, all
values for EXT_CSD_REV are authorized.

Currently, if an eMMC device with a newer EXT_CSD_REV (e.g., eMMC 5.1B
with EXT_CSD_REV=9) is used, U-Boot fails to initialize it and returns
-EINVAL because the revision is larger than the mmc_versions array size.

Fix this by falling back to the latest supported version if the
EXT_CSD_REV exceeds the known versions. This ensures forward
compatibility with future eMMC specifications.

Signed-off-by: MW Park <mw.park@telechips.com>
---
 drivers/mmc/mmc.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index c5705f4f215..497ad172a3a 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -2334,6 +2334,7 @@ static int mmc_startup_v4(struct mmc *mmc)
 	u64 capacity;
 	bool has_parts = false;
 	bool part_completed;
+	u8 rev;
 	static const u32 mmc_versions[] = {
 		MMC_VERSION_4,
 		MMC_VERSION_4_1,
@@ -2380,12 +2381,19 @@ static int mmc_startup_v4(struct mmc *mmc)
 		return -ENOMEM;
 	memcpy(mmc->ext_csd, ext_csd, MMC_MAX_BLOCK_LEN);
 #endif
-	if (ext_csd[EXT_CSD_REV] >= ARRAY_SIZE(mmc_versions)) {
-		err = -EINVAL;
-		goto error;
-	}
+	rev = ext_csd[EXT_CSD_REV];
+
+	/*
+	 * According to the JEDEC Standard, the EXT_CSD format is meant to be
+	 * forward compatible. As long as CSD_STRUCTURE does not change, all
+	 * values for EXT_CSD_REV are authorized.
+	 * If the EXT_CSD_REV exceeds the known versions, fallback to the
+	 * latest supported version instead of returning an error.
+	 */
+	if (rev >= ARRAY_SIZE(mmc_versions))
+		rev = ARRAY_SIZE(mmc_versions) - 1;
 
-	mmc->version = mmc_versions[ext_csd[EXT_CSD_REV]];
+	mmc->version = mmc_versions[rev];
 
 	if (mmc->version >= MMC_VERSION_4_2) {
 		/*
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] mmc: allow forward compatibility for EXT_CSD_REV
  2026-03-26  5:55 [PATCH] mmc: allow forward compatibility for EXT_CSD_REV 박민우 (MW Park)
@ 2026-04-08 16:21 ` Peng Fan
  2026-04-09  1:23   ` 박민우 (MW Park)
  0 siblings, 1 reply; 3+ messages in thread
From: Peng Fan @ 2026-04-08 16:21 UTC (permalink / raw)
  To: ?????? (MW Park)
  Cc: u-boot@lists.denx.de, peng.fan@nxp.com, jh80.chung@samsung.com

On Thu, Mar 26, 2026 at 05:55:32AM +0000, ?????? (MW Park) wrote:
>According to the JEDEC Standard, the EXT_CSD format is meant to be
>forward compatible. As long as CSD_STRUCTURE does not change, all
>values for EXT_CSD_REV are authorized.
>
>Currently, if an eMMC device with a newer EXT_CSD_REV (e.g., eMMC 5.1B
>with EXT_CSD_REV=9) is used, U-Boot fails to initialize it and returns
>-EINVAL because the revision is larger than the mmc_versions array size.
>
>Fix this by falling back to the latest supported version if the
>EXT_CSD_REV exceeds the known versions. This ensures forward
>compatibility with future eMMC specifications.
>
>Signed-off-by: MW Park <mw.park@telechips.com>

Would this patch works for you?
https://lore.kernel.org/u-boot/20260225211332.1896252-1-han.xu@nxp.com/

Regards,
Peng

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mmc: allow forward compatibility for EXT_CSD_REV
  2026-04-08 16:21 ` Peng Fan
@ 2026-04-09  1:23   ` 박민우 (MW Park)
  0 siblings, 0 replies; 3+ messages in thread
From: 박민우 (MW Park) @ 2026-04-09  1:23 UTC (permalink / raw)
  To: Peng Fan; +Cc: u-boot@lists.denx.de, peng.fan@nxp.com, jh80.chung@samsung.com


>Would this patch works for you?
>https://lore.kernel.org/u-boot/20260225211332.1896252-1-han.xu@nxp.com/

>Regards,
>Peng

Thank you for your feedback.

I would like to clarify that I independently developed and verified a similar approach to the one in the linked patch. However, my analysis shows that the linked patch is primarily focused on v5.1B, which may lead to compatibility issues with future eMMC versions.

I believe my proposed patch provides a more generalized and future-proof solution, ensuring long-term maintenance and stability regardless of version updates.

Please let me know your thoughts on this approach.

Thanks,
Best Regards,
MW Park.

________________________________________
보낸 사람: Peng Fan <peng.fan@oss.nxp.com>
보낸 날짜: 2026년 4월 9일 목요일 오전 1:21
받는 사람: 박민우 (MW Park)
참조: u-boot@lists.denx.de; peng.fan@nxp.com; jh80.chung@samsung.com
제목: Re: [PATCH] mmc: allow forward compatibility for EXT_CSD_REV

CAUTION: This email was sent from outside of TELECHIPS. Please do not click links or open attachments unless you recognize the source of this email and know the content is safe.

On Thu, Mar 26, 2026 at 05:55:32AM +0000, ?????? (MW Park) wrote:
>According to the JEDEC Standard, the EXT_CSD format is meant to be
>forward compatible. As long as CSD_STRUCTURE does not change, all
>values for EXT_CSD_REV are authorized.
>
>Currently, if an eMMC device with a newer EXT_CSD_REV (e.g., eMMC 5.1B
>with EXT_CSD_REV=9) is used, U-Boot fails to initialize it and returns
>-EINVAL because the revision is larger than the mmc_versions array size.
>
>Fix this by falling back to the latest supported version if the
>EXT_CSD_REV exceeds the known versions. This ensures forward
>compatibility with future eMMC specifications.
>
>Signed-off-by: MW Park <mw.park@telechips.com>

Would this patch works for you?
https://lore.kernel.org/u-boot/20260225211332.1896252-1-han.xu@nxp.com/

Regards,
Peng
This email and any attachments to it may be confidential and are intended solely for the use of the individual to whom it is addressed. Any views or opinions expressed are solely those of the author and do not necessarily represent those of Telechips Inc. If you are not the intended recipient of this email, you must neither take any action based upon its contents nor copy or show it to anyone. Please notify the sender immediately by email if you have received this email by mistake and delete this email from your system. Please consider the environment before printing this email.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-04-09  1:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-26  5:55 [PATCH] mmc: allow forward compatibility for EXT_CSD_REV 박민우 (MW Park)
2026-04-08 16:21 ` Peng Fan
2026-04-09  1:23   ` 박민우 (MW Park)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox