Skip to contentSkip to conversation

mmc: correct the HS400 initialization process

PATCH New BOUGH CHEN 3 participants 6 messages Mar 18, 2019 – Mar 25, 2019 MMC, SD and SDIO

lore
Share & tools
lore

BOUGH CHEN

author
#0 lore raw

PATCH 1/1 mmc: correct the HS400 initialization process

After the commit b9a2a0e2e9c0 ("mmc: Add support for downgrading HS200/HS400 to HS mode"), it add a parameter in mmc_set_card_speed() which indicates that the HS200/HS400 to HS downgrade is happening.

During the HS400 initialization, first select to HS200, and config the related clock rate, then downgrade to HS mode. So here also need to config the downgrade value to be true, make sure in the function mmc_set_card_speed(), after switch to HS mode, first config the clock rate, then read the EXT_CSD. Otherwise read EXT_CSD in HS mode at wrong clock rate, e.g. 200MHz, may lead to uncertain result.

Test on i.MX8QM MEK board, some Micron eMMC will stuck in transfer mode in this case, and USDHC will never get data transfer complete status, cause the uboot hang.

---
 drivers/mmc/mmc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/mmc/mmc.c +1 -2
index 1c1527cc74..55d3560b30 100644
@@ -1892,8 +1892,7 @@ static int mmc_select_hs400(struct mmc *mmc)
 	}
 
 	/* Set back to HS */
-	mmc_set_card_speed(mmc, MMC_HS, false);
-	mmc_set_clock(mmc, mmc_mode2freq(mmc, MMC_HS), false);
+	mmc_set_card_speed(mmc, MMC_HS, true);
 
 	err = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_BUS_WIDTH,
 			 EXT_CSD_BUS_WIDTH_8 | EXT_CSD_DDR_FLAG);
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/1 mmc: correct the HS400 initialization process

Quoted 10 lines · BOUGH CHEN

After the commit b9a2a0e2e9c0 ("mmc: Add support for downgrading HS200/HS400 to HS mode"), it add a parameter in mmc_set_card_speed() which indicates that the HS200/HS400 to HS downgrade is happening.

During the HS400 initialization, first select to HS200, and config the related clock rate, then downgrade to HS mode. So here also need to config the downgrade value to be true, make sure in the function mmc_set_card_speed(), after switch to HS mode, first config the clock rate, then read the EXT_CSD. Otherwise read EXT_CSD in HS mode at wrong clock rate, e.g. 200MHz, may lead to uncertain result.

I think the fix is right, but the reasoning for it is not.

If you call mmc_set_card_speed() with hsdowngrade=true, it will result in calling __mmc_switch() with send_status=false , which in turn means that after issuing the MMC_CMD_SWITCH command, the code won't poll the card using MMC_CMD_SEND_STATUS, but just wait a bit and then switch the bus properties. This is indeed required when switching bus properties. And that's what I think was making your card unstable.

Is that the case ?

Quoted 24 lines

Test on i.MX8QM MEK board, some Micron eMMC will stuck in transfer mode in this case, and USDHC will never get data transfer complete status, cause the uboot hang.

---
 drivers/mmc/mmc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/mmc/mmc.c +1 -2
index 1c1527cc74..55d3560b30 100644
@@ -1892,8 +1892,7 @@ static int mmc_select_hs400(struct mmc *mmc)
 	}
 
 	/* Set back to HS */
-	mmc_set_card_speed(mmc, MMC_HS, false);
-	mmc_set_clock(mmc, mmc_mode2freq(mmc, MMC_HS), false);
+	mmc_set_card_speed(mmc, MMC_HS, true);
 
 	err = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_BUS_WIDTH,
 			 EXT_CSD_BUS_WIDTH_8 | EXT_CSD_DDR_FLAG);
Signature · 2 lines
Best regards,
Marek Vasut
author
#2 lore raw

PATCH 1/1 mmc: correct the HS400 initialization process

Quoted 24 lines

-----Original Message-----
From: Marek Vasut [mailto:marek.vasut at gmail.com]
Sent: 2019年3月18日 19:53
To: BOUGH CHEN <[email protected]>; jh80.chung at samsung.com; trini at konsulko.com
Cc: marek.vasut+renesas at gmail.com; Ye Li <[email protected]>; dl-uboot-imx <[email protected]>; u-boot at lists.denx.de
Subject: Re: [PATCH] mmc: correct the HS400 initialization process

Quoted 10 lines · BOUGH CHEN

After the commit b9a2a0e2e9c0 ("mmc: Add support for downgrading HS200/HS400 to HS mode"), it add a parameter in mmc_set_card_speed() which indicates that the HS200/HS400 to HS downgrade is happening.

During the HS400 initialization, first select to HS200, and config the related clock rate, then downgrade to HS mode. So here also need to config the downgrade value to be true, make sure in the function mmc_set_card_speed(), after switch to HS mode, first config the clock rate, then read the EXT_CSD. Otherwise read EXT_CSD in HS mode at wrong clock rate, e.g. 200MHz, may lead to uncertain result.

I think the fix is right, but the reasoning for it is not.

Quoted 8 lines

If you call mmc_set_card_speed() with hsdowngrade=true, it will result in calling __mmc_switch() with send_status=false , which in turn means that after issuing the MMC_CMD_SWITCH command, the code won't poll the card using MMC_CMD_SEND_STATUS, but just wait a bit and then switch the bus properties. This is indeed required when switching bus properties. And that's what I think was making your card unstable.

Is that the case ?

Sorry for the tardy reply, I miss the email last week.
No, if without this patch, even I add the dealy after the switch command, eMMC still stuck after the CMD8.
The main issue is that, in mmc_set_card_speed, if the bus mode the HS mode, it will send CMD8 to get the EXT_CSD, but the clock is still 200MHz at that time. It is wrong that EMMC output data in HS mode at 200MHz.

Best Regards
Haibo Chen

Quoted 31 lines
Quoted 15 lines

Test on i.MX8QM MEK board, some Micron eMMC will stuck in transfer mode in this case, and USDHC will never get data transfer complete status, cause the uboot hang.

---
 drivers/mmc/mmc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/mmc/mmc.c index renamed from drivers/mmc/mmc.c +0 -0

1c1527cc74..55d3560b30 100644

drivers/mmc/mmc.c static int mmc_select_hs400(struct mmc *mmc) · line 1897

Quoted 8 lines
drivers/mmc/mmc.c +1 -2
@@ -1892,8 +1892,7 @@ static int mmc_select_hs400(struct mmc *mmc)
 	}
 
 	/* Set back to HS */
-	mmc_set_card_speed(mmc, MMC_HS, false);
-	mmc_set_clock(mmc, mmc_mode2freq(mmc, MMC_HS), false);
+	mmc_set_card_speed(mmc, MMC_HS, true);
 
 	err = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL,

EXT_CSD_BUS_WIDTH,

drivers/mmc/mmc.c static int mmc_select_hs400(struct mmc *mmc) · line 1898

Quoted 2 lines
drivers/mmc/mmc.c +0 -0
 			 EXT_CSD_BUS_WIDTH_8 | EXT_CSD_DDR_FLAG);

--
Best regards,
Marek Vasut

#3 lore raw

PATCH 1/1 mmc: correct the HS400 initialization process

Quoted 31 lines · BOUGH CHEN
Quoted 31 lines

-----Original Message-----
From: Marek Vasut [mailto:marek.vasut at gmail.com]
Sent: 2019年3月18日 19:53
To: BOUGH CHEN <[email protected]>; jh80.chung at samsung.com; trini at konsulko.com
Cc: marek.vasut+renesas at gmail.com; Ye Li <[email protected]>; dl-uboot-imx <[email protected]>; u-boot at lists.denx.de
Subject: Re: [PATCH] mmc: correct the HS400 initialization process

Quoted 10 lines · BOUGH CHEN

After the commit b9a2a0e2e9c0 ("mmc: Add support for downgrading HS200/HS400 to HS mode"), it add a parameter in mmc_set_card_speed() which indicates that the HS200/HS400 to HS downgrade is happening.

During the HS400 initialization, first select to HS200, and config the related clock rate, then downgrade to HS mode. So here also need to config the downgrade value to be true, make sure in the function mmc_set_card_speed(), after switch to HS mode, first config the clock rate, then read the EXT_CSD. Otherwise read EXT_CSD in HS mode at wrong clock rate, e.g. 200MHz, may lead to uncertain result.

I think the fix is right, but the reasoning for it is not.

If you call mmc_set_card_speed() with hsdowngrade=true, it will result in calling __mmc_switch() with send_status=false , which in turn means that after issuing the MMC_CMD_SWITCH command, the code won't poll the card using MMC_CMD_SEND_STATUS, but just wait a bit and then switch the bus properties. This is indeed required when switching bus properties. And that's what I think was making your card unstable.

Quoted 6 lines
Quoted 1 line

Is that the case ?

Sorry for the tardy reply, I miss the email last week.
No, if without this patch, even I add the dealy after the switch command, eMMC still stuck after the CMD8.
The main issue is that, in mmc_set_card_speed, if the bus mode the HS mode, it will send CMD8 to get the EXT_CSD, but the clock is still 200MHz at that time. It is wrong that EMMC output data in HS mode at 200MHz.

OK, that makes sense.

Signature · 2 lines
Best regards,
Marek Vasut
#4 lore raw

PATCH 1/1 mmc: correct the HS400 initialization process

Quoted 32 lines · Marek Vasut
Quoted 31 lines · BOUGH CHEN
Quoted 31 lines

-----Original Message-----
From: Marek Vasut [mailto:marek.vasut at gmail.com]
Sent: 2019年3月18日 19:53
To: BOUGH CHEN <[email protected]>; jh80.chung at samsung.com; trini at konsulko.com
Cc: marek.vasut+renesas at gmail.com; Ye Li <[email protected]>; dl-uboot-imx <[email protected]>; u-boot at lists.denx.de
Subject: Re: [PATCH] mmc: correct the HS400 initialization process

Quoted 10 lines · BOUGH CHEN

After the commit b9a2a0e2e9c0 ("mmc: Add support for downgrading HS200/HS400 to HS mode"), it add a parameter in mmc_set_card_speed() which indicates that the HS200/HS400 to HS downgrade is happening.

During the HS400 initialization, first select to HS200, and config the related clock rate, then downgrade to HS mode. So here also need to config the downgrade value to be true, make sure in the function mmc_set_card_speed(), after switch to HS mode, first config the clock rate, then read the EXT_CSD. Otherwise read EXT_CSD in HS mode at wrong clock rate, e.g. 200MHz, may lead to uncertain result.

I think the fix is right, but the reasoning for it is not.

If you call mmc_set_card_speed() with hsdowngrade=true, it will result in calling __mmc_switch() with send_status=false , which in turn means that after issuing the MMC_CMD_SWITCH command, the code won't poll the card using MMC_CMD_SEND_STATUS, but just wait a bit and then switch the bus properties. This is indeed required when switching bus properties. And that's what I think was making your card unstable.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

Is that the case ?

Sorry for the tardy reply, I miss the email last week.
No, if without this patch, even I add the dealy after the switch command, eMMC still stuck after the CMD8.
The main issue is that, in mmc_set_card_speed, if the bus mode the HS mode, it will send CMD8 to get the EXT_CSD, but the clock is still 200MHz at that time. It is wrong that EMMC output data in HS mode at 200MHz.

OK, that makes sense.

Do we need a re-worded commit message then or no? Thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190325/4dc32caa/attachment.sig>
#5 lore raw

PATCH 1/1 mmc: correct the HS400 initialization process

Quoted 35 lines · Tom Rini
Quoted 34 lines · Marek Vasut
Quoted 33 lines · BOUGH CHEN
Quoted 32 lines

-----Original Message-----
From: Marek Vasut [mailto:marek.vasut at gmail.com]
Sent: 2019年3月18日 19:53
To: BOUGH CHEN <[email protected]>; jh80.chung at samsung.com; trini at konsulko.com
Cc: marek.vasut+renesas at gmail.com; Ye Li <[email protected]>; dl-uboot-imx <[email protected]>; u-boot at lists.denx.de
Subject: Re: [PATCH] mmc: correct the HS400 initialization process

Quoted 10 lines · BOUGH CHEN

After the commit b9a2a0e2e9c0 ("mmc: Add support for downgrading HS200/HS400 to HS mode"), it add a parameter in mmc_set_card_speed() which indicates that the HS200/HS400 to HS downgrade is happening.

During the HS400 initialization, first select to HS200, and config the related clock rate, then downgrade to HS mode. So here also need to config the downgrade value to be true, make sure in the function mmc_set_card_speed(), after switch to HS mode, first config the clock rate, then read the EXT_CSD. Otherwise read EXT_CSD in HS mode at wrong clock rate, e.g. 200MHz, may lead to uncertain result.

I think the fix is right, but the reasoning for it is not.

If you call mmc_set_card_speed() with hsdowngrade=true, it will result in calling __mmc_switch() with send_status=false , which in turn means that after issuing the MMC_CMD_SWITCH command, the code won't poll the card using MMC_CMD_SEND_STATUS, but just wait a bit and then switch the bus properties. This is indeed required when switching bus properties. And that's what I think was making your card unstable.

Is that the case ?

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

Sorry for the tardy reply, I miss the email last week.
No, if without this patch, even I add the dealy after the switch command, eMMC still stuck after the CMD8.
The main issue is that, in mmc_set_card_speed, if the bus mode the HS mode, it will send CMD8 to get the EXT_CSD, but the clock is still 200MHz at that time. It is wrong that EMMC output data in HS mode at 200MHz.

OK, that makes sense.

Do we need a re-worded commit message then or no? Thanks!

A bit wouldn't hurt, to clarify things.

Signature · 2 lines
Best regards,
Marek Vasut