mmc: Do not poll using CMD13 when changing timing
PATCH 1/1 mmc: Do not poll using CMD13 when changing timing
When using CMD6 to switch eMMC card timing from HS200/HS400 to HS/legacy, do not poll for the completion status using CMD13, but rather wait 50mS.
Once the card receives the CMD6 and starts executing it, the bus is in undefined state until both the card finishes executing the command and until the controller switches the bus to matching timing configuration. During this time, it is not possible to transport any commands or data across the bus, which includes the CMD13.
---
NOTE: Linux does the same thing.
--- drivers/mmc/mmc.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-)
drivers/mmc/mmc.c +20 -8
@@ -720,7 +720,8 @@ static int mmc_send_ext_csd(struct mmc *mmc, u8 *ext_csd)return err; } -int mmc_switch (struct mmc *mmc,u8 set,u8 index,u8 value) +static int __mmc_switch (struct mmc *mmc,u8 set,u8 index,u8 value, +bool send_status) {struct mmc_cmd cmd;int timeout =1000 ;
@@ -736,19 +737,29 @@ int mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value)while (retries >0 ) { ret =mmc_send_cmd (mmc, &cmd,NULL ); -/* Waiting for the ready status */ -if (!ret) { - ret =mmc_send_status (mmc, timeout); -return ret; +if (ret) { + retries--; +continue ; + } + +if (!send_status) { +mdelay (50 ); +return 0 ; } - retries--; +/* Waiting for the ready status */ +return mmc_send_status (mmc, timeout); }return ret; } +int mmc_switch (struct mmc *mmc,u8 set,u8 index,u8 value) +{ +return __mmc_switch (mmc, set, index, value, true); +} +#if !CONFIG_IS_ENABLED (MMC_TINY )static int mmc_set_card_speed (struct mmc *mmc,enum bus_mode mode,bool hsdowngrade)
@@ -780,8 +791,9 @@ static int mmc_set_card_speed(struct mmc *mmc, enum bus_mode mode,default :return -EINVAL ; } - err =mmc_switch (mmc,EXT_CSD_CMD_SET_NORMAL ,EXT_CSD_HS_TIMING , - speed_bits); + + err =__mmc_switch (mmc,EXT_CSD_CMD_SET_NORMAL ,EXT_CSD_HS_TIMING , + speed_bits, !hsdowngrade);if (err)return err;
Signature · 1 line
2.19.2
PATCH 1/1 mmc: Do not poll using CMD13 when changing timing
Quoted 68 lines · Marek Vasut
When using CMD6 to switch eMMC card timing from HS200/HS400 to HS/legacy, do not poll for the completion status using CMD13, but rather wait 50mS.
Once the card receives the CMD6 and starts executing it, the bus is in undefined state until both the card finishes executing the command and until the controller switches the bus to matching timing configuration. During this time, it is not possible to transport any commands or data across the bus, which includes the CMD13.
Signed-off-by Marek Vasut <[email protected]>Cc Jaehoon Chung <[email protected]>---
NOTE: Linux does the same thing.--- drivers/mmc/mmc.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-)drivers/mmc/mmc.c +17
-6@@ -720,7 +720,8 @@ static int mmc_send_ext_csd(struct mmc *mmc, u8 *ext_csd)return err; } -int mmc_switch (struct mmc *mmc,u8 set,u8 index,u8 value) +static int __mmc_switch (struct mmc *mmc,u8 set,u8 index,u8 value, +bool send_status) {struct mmc_cmd cmd;int timeout =1000 ;@@ -736,19 +737,29 @@ int mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value)while (retries >0 ) { ret =mmc_send_cmd (mmc, &cmd,NULL ); -/* Waiting for the ready status */ -if (!ret) { - ret =mmc_send_status (mmc, timeout); -return ret; +if (ret) { + retries--; +continue ; + } + +if (!send_status) { +mdelay (50 ); +return 0 ; } - retries--; +/* Waiting for the ready status */ +return mmc_send_status (mmc, timeout); }return ret; } +int mmc_switch (struct mmc *mmc,u8 set,u8 index,u8 value) +{ +return __mmc_switch (mmc, set, index, value, true); +} +#if !CONFIG_IS_ENABLED (MMC_TINY )static int mmc_set_card_speed (struct mmc *mmc,enum bus_mode mode,bool hsdowngrade)@@ -780,8 +791,9 @@ static int mmc_set_card_speed(struct mmc *mmc, enum bus_mode mode,default :
drivers/mmc/mmc.c static int mmc_set_card_speed(struct mmc *mmc, enum bus_mode mode, · line 799
Quoted 10 lines
drivers/mmc/mmc.c +3
-2return -EINVAL ; } - err =mmc_switch (mmc,EXT_CSD_CMD_SET_NORMAL ,EXT_CSD_HS_TIMING , - speed_bits); + + err =__mmc_switch (mmc,EXT_CSD_CMD_SET_NORMAL ,EXT_CSD_HS_TIMING , + speed_bits, !hsdowngrade);if (err)return err;
PATCH 1/1 mmc: Do not poll using CMD13 when changing timing
In reply to Marek VasutHi Marek,
Quoted 3 lines
When using CMD6 to switch eMMC card timing from HS200/HS400 to HS/legacy, do not poll for the completion status using CMD13, but rather wait 50mS.
Nit: mS -> ms
Quoted 6 lines
Once the card receives the CMD6 and starts executing it, the bus is in undefined state until both the card finishes executing the command and until the controller switches the bus to matching timing configuration. During this time, it is not possible to transport any commands or data across the bus, which includes the CMD13.
Just out of curiosity - is this 50ms time written in some spec? Or is it only specific to Renesas HS200/HS400 ?
Quoted 69 lines
Signed-off-by Marek Vasut <[email protected]>Cc Jaehoon Chung <[email protected]>---
NOTE: Linux does the same thing.--- drivers/mmc/mmc.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-)drivers/mmc/mmc.c +17
-6@@ -720,7 +720,8 @@ static int mmc_send_ext_csd(struct mmc *mmc, u8 *ext_csd) return err; } -int mmc_switch (struct mmc *mmc,u8 set,u8 index,u8 value) +static int __mmc_switch (struct mmc *mmc,u8 set,u8 index,u8 value, +bool send_status) {struct mmc_cmd cmd;int timeout =1000 ;@@ -736,19 +737,29 @@ int mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value) while (retries > 0) { ret =mmc_send_cmd (mmc, &cmd,NULL ); -/* Waiting for the ready status */ -if (!ret) { - ret =mmc_send_status (mmc, timeout); -return ret; +if (ret) { + retries--; +continue ; + } + +if (!send_status) { +mdelay (50 ); +return 0 ; } - retries--; +/* Waiting for the ready status */ +return mmc_send_status (mmc, timeout); }return ret; } +int mmc_switch (struct mmc *mmc,u8 set,u8 index,u8 value) +{ +return __mmc_switch (mmc, set, index, value, true); +} +#if !CONFIG_IS_ENABLED (MMC_TINY )static int mmc_set_card_speed (struct mmc *mmc,enum bus_mode mode,bool hsdowngrade)@@ -780,8 +791,9 @@ static int mmc_set_card_speed(struct mmc *mmc,enum
bus_modemode, default:drivers/mmc/mmc.c +0
-1return -EINVAL ; } - err = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL,
EXT_CSD_HS_TIMING,drivers/mmc/mmc.c +2
-1- speed_bits); + + err = __mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL,
EXT_CSD_HS_TIMING,
drivers/mmc/mmc.c static int mmc_set_card_speed(struct mmc *mmc, enum bus_mode mode, · line 798
Quoted 3 lines
drivers/mmc/mmc.c +1
-0+ speed_bits, !hsdowngrade);if (err)return err;
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de -------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190211/46c2b9f6/attachment.sig>
PATCH 1/1 mmc: Do not poll using CMD13 when changing timing
In reply to Marek VasutHi Marek,
Quoted 8 lines · Marek Vasut
When using CMD6 to switch eMMC card timing from HS200/HS400 to HS/legacy, do not poll for the completion status using CMD13, but rather wait 50mS.
Once the card receives the CMD6 and starts executing it, the bus is in undefined state until both the card finishes executing the command and until the controller switches the bus to matching timing configuration. During this time, it is not possible to transport any commands or data across the bus, which includes the CMD13.
Is it something that affects all platforms ?
I've been working on this on TI platforms lately and although I've seen the same kind of problems. But they mostly go away If the code handling the switch handles the SWITCH_ERROR bit.
JJ
Quoted 70 lines
Signed-off-by Marek Vasut <[email protected]>Cc Jaehoon Chung <[email protected]>---
NOTE: Linux does the same thing.--- drivers/mmc/mmc.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-)drivers/mmc/mmc.c +20
-8@@ -720,7 +720,8 @@ static int mmc_send_ext_csd(struct mmc *mmc, u8 *ext_csd)return err; } -int mmc_switch (struct mmc *mmc,u8 set,u8 index,u8 value) +static int __mmc_switch (struct mmc *mmc,u8 set,u8 index,u8 value, +bool send_status) {struct mmc_cmd cmd;int timeout =1000 ;@@ -736,19 +737,29 @@ int mmc_switch(struct mmc *mmc, u8 set, u8 index, u8 value)while (retries >0 ) { ret =mmc_send_cmd (mmc, &cmd,NULL ); -/* Waiting for the ready status */ -if (!ret) { - ret =mmc_send_status (mmc, timeout); -return ret; +if (ret) { + retries--; +continue ; + } + +if (!send_status) { +mdelay (50 ); +return 0 ; } - retries--; +/* Waiting for the ready status */ +return mmc_send_status (mmc, timeout); }return ret; } +int mmc_switch (struct mmc *mmc,u8 set,u8 index,u8 value) +{ +return __mmc_switch (mmc, set, index, value, true); +} +#if !CONFIG_IS_ENABLED (MMC_TINY )static int mmc_set_card_speed (struct mmc *mmc,enum bus_mode mode,bool hsdowngrade)@@ -780,8 +791,9 @@ static int mmc_set_card_speed(struct mmc *mmc, enum bus_mode mode,default :return -EINVAL ; } - err =mmc_switch (mmc,EXT_CSD_CMD_SET_NORMAL ,EXT_CSD_HS_TIMING , - speed_bits); + + err =__mmc_switch (mmc,EXT_CSD_CMD_SET_NORMAL ,EXT_CSD_HS_TIMING , + speed_bits, !hsdowngrade);if (err)return err;
PATCH 1/1 mmc: Do not poll using CMD13 when changing timing
Quoted 12 lines · Jean-Jacques Hiblot
Hi Marek,
Quoted 8 lines · Marek Vasut
When using CMD6 to switch eMMC card timing from HS200/HS400 to HS/legacy, do not poll for the completion status using CMD13, but rather wait 50mS.
Once the card receives the CMD6 and starts executing it, the bus is in undefined state until both the card finishes executing the command and until the controller switches the bus to matching timing configuration. During this time, it is not possible to transport any commands or data across the bus, which includes the CMD13.
Quoted 5 lines
Is it something that affects all platforms ?
I've been working on this on TI platforms lately and although I've seen the same kind of problems. But they mostly go away If the code handling the switch handles the
SWITCH_ERRORbit.
The error probably happens because you send the card a command, but the command hits the bus that's in some weird intermediate state. Either the card didn't finish switching the bus properties yet, or it did, or it's in the middle of it, but you cannot tell.
[...]
Signature · 2 lines
Best regards, Marek Vasut
PATCH 1/1 mmc: Do not poll using CMD13 when changing timing
Quoted 14 lines · Marek Vasut
Quoted 13 lines · Jean-Jacques Hiblot
Hi Marek,
Quoted 8 lines · Marek Vasut
When using CMD6 to switch eMMC card timing from HS200/HS400 to HS/legacy, do not poll for the completion status using CMD13, but rather wait 50mS.
Once the card receives the CMD6 and starts executing it, the bus is in undefined state until both the card finishes executing the command and until the controller switches the bus to matching timing configuration. During this time, it is not possible to transport any commands or data across the bus, which includes the CMD13.
Is it something that affects all platforms ?
Quoted 7 lines
Quoted 3 lines
I've been working on this on TI platforms lately and although I've seen the same kind of problems. But they mostly go away If the code handling the switch handles the
SWITCH_ERRORbit.The error probably happens because you send the card a command, but the command hits the bus that's in some weird intermediate state. Either the card didn't finish switching the bus properties yet, or it did, or it's in the middle of it, but you cannot tell.
OK thanks for the response.
If CMD13 can't be used because the bus is in an undefined state, shouldn't send_cmd(CMD13) just fail ?
I'm asking because this is a 50ms delay in the hot path of the boot process.
JJ
Quoted 3 lines
[...]
PATCH 1/1 mmc: Do not poll using CMD13 when changing timing
Quoted 26 lines · Jean-Jacques Hiblot
Quoted 16 lines · Marek Vasut
Quoted 15 lines · Jean-Jacques Hiblot
Hi Marek,
Quoted 10 lines · Marek Vasut
When using CMD6 to switch eMMC card timing from HS200/HS400 to HS/legacy,
do not poll for the completion status using CMD13, but rather wait 50mS.Once the card receives the CMD6 and starts executing it, the bus is in undefined state until both the card finishes executing the command and until the controller switches the bus to matching timing configuration. During this time, it is not possible to transport any commands or data across the bus, which includes the CMD13.
Is it something that affects all platforms ?
Quoted 7 lines
Quoted 3 lines
I've been working on this on TI platforms lately and although I've seen the same kind of problems. But they mostly go away If the code handling the switch handles the
SWITCH_ERRORbit.The error probably happens because you send the card a command, but the command hits the bus that's in some weird intermediate state. Either the card didn't finish switching the bus properties yet, or it did, or it's in the middle of it, but you cannot tell.
Quoted 4 lines
OK thanks for the response.
If CMD13 can't be used because the bus is in an undefined state, shouldn't
send_cmd(CMD13)just fail ?
So it would fail, but how do you guarantee the bus/card switched to the new state and is reliably ready ? You can't, because you cannot communicate with the card -- which is the entire problem here, you have no way to communicate with the card while the bus is switching. However, you can wait the maximum allowed time according to the spec, and then the bus/card must be ready. If not, all bets are off.
Quoted 2 lines
I'm asking because this is a 50ms delay in the hot path of the boot process.
I totally understand that, I have the same issue with HS200/HS400 on R-Car Gen3, all the calibration shenanigans and this indeed add quite a bit to the boot time. But I don't have a good answer here.
Signature · 2 lines
Best regards, Marek Vasut
PATCH 1/1 mmc: Do not poll using CMD13 when changing timing
Quoted 36 lines · Marek Vasut
Quoted 20 lines · Jean-Jacques Hiblot
Quoted 19 lines · Marek Vasut
Quoted 18 lines · Jean-Jacques Hiblot
Hi Marek,
Quoted 10 lines · Marek Vasut
When using CMD6 to switch eMMC card timing from HS200/HS400 to HS/legacy,
do not poll for the completion status using CMD13, but rather wait 50mS.Once the card receives the CMD6 and starts executing it, the bus is in undefined state until both the card finishes executing the command and until the controller switches the bus to matching timing configuration. During this time, it is not possible to transport any commands or data across the bus, which includes the CMD13.
Is it something that affects all platforms ?
I've been working on this on TI platforms lately and although I've seen the same kind of problems. But they mostly go away If the code handling the switch handles the
SWITCH_ERRORbit.Quoted 8 lines
Quoted 4 lines
The error probably happens because you send the card a command, but the command hits the bus that's in some weird intermediate state. Either the card didn't finish switching the bus properties yet, or it did, or it's in the middle of it, but you cannot tell.
OK thanks for the response.
If CMD13 can't be used because the bus is in an undefined state, shouldn't
send_cmd(CMD13)just fail ?So it would fail, but how do you guarantee the bus/card switched to the new state and is reliably ready ? You can't, because you cannot communicate with the card -- which is the entire problem here, you have no way to communicate with the card while the bus is switching. However, you can wait the maximum allowed time according to the spec, and then the bus/card must be ready. If not, all bets are off.
Quoted 5 lines
Quoted 2 lines
I'm asking because this is a 50ms delay in the hot path of the boot process.
I totally understand that, I have the same issue with HS200/HS400 on R-Car Gen3, all the calibration shenanigans and this indeed add quite a* bit to the boot time. But I don't have a good answer here.
I'll post something using the existing wait_dat0() callback. If the callback is implemented, we can forgo the 50ms delay and poll the dat0 line.
Quoted 1 line
PATCH 1/1 mmc: Do not poll using CMD13 when changing timing
Quoted 47 lines · Jean-Jacques Hiblot
Quoted 45 lines · Marek Vasut
Quoted 31 lines · Jean-Jacques Hiblot
Quoted 25 lines · Marek Vasut
Quoted 17 lines · Jean-Jacques Hiblot
Hi Marek,
Quoted 5 lines · Marek Vasut
When using CMD6 to switch eMMC card timing from HS200/HS400 to HS/legacy,
do not poll for the completion status using CMD13, but rather wait 50mS.Quoted 9 lines
Once the card receives the CMD6 and starts executing it, the bus is in
undefined state until both the card finishes executing the command and
until the controller switches the bus to matching timing configuration.
During this time, it is not possible to transport any commands or data
across the bus, which includes the CMD13.Quoted 7 lines
Is it something that affects all platforms ?
I've been working on this on TI platforms lately and although I've seen
the same kind of problems. But they mostly go away If the code handling
the switch handles theSWITCH_ERRORbit.Quoted 5 lines
The error probably happens because you send the card a command, but the command hits the bus that's in some weird intermediate state. Either the
card didn't finish switching the bus properties yet, or it did, or it's in the middle of it, but you cannot tell.Quoted 4 lines
OK thanks for the response.
If CMD13 can't be used because the bus is in an undefined state, shouldn't
send_cmd(CMD13)just fail ?So it would fail, but how do you guarantee the bus/card switched to the new state and is reliably ready ? You can't, because you cannot communicate with the card -- which is the entire problem here, you have no way to communicate with the card while the bus is switching. However, you can wait the maximum allowed time according to the spec, and then the bus/card must be ready. If not, all bets are off.
Quoted 2 lines
I'm asking because this is a 50ms delay in the hot path of the boot process.
Quoted 7 lines
Quoted 3 lines
I totally understand that, I have the same issue with HS200/HS400 on R-Car Gen3, all the calibration shenanigans and this indeed add quite a* bit to the boot time. But I don't have a good answer here.
I'll post something using the existing
wait_dat0()callback. If the callback is implemented, we can forgo the 50ms delay and poll the dat0 line.
We can ? Do you have some more details ?
Signature · 2 lines
Best regards, Marek Vasut
PATCH 1/1 mmc: Do not poll using CMD13 when changing timing
Quoted 47 lines · Marek Vasut
Quoted 46 lines · Jean-Jacques Hiblot
Quoted 45 lines · Marek Vasut
Quoted 31 lines · Jean-Jacques Hiblot
Quoted 25 lines · Marek Vasut
Quoted 17 lines · Jean-Jacques Hiblot
Hi Marek,
Quoted 5 lines · Marek Vasut
When using CMD6 to switch eMMC card timing from HS200/HS400 to HS/legacy,
do not poll for the completion status using CMD13, but rather wait 50mS.Quoted 9 lines
Once the card receives the CMD6 and starts executing it, the bus is in
undefined state until both the card finishes executing the command and
until the controller switches the bus to matching timing configuration.
During this time, it is not possible to transport any commands or data
across the bus, which includes the CMD13.Quoted 7 lines
Is it something that affects all platforms ?
I've been working on this on TI platforms lately and although I've seen
the same kind of problems. But they mostly go away If the code handling
the switch handles theSWITCH_ERRORbit.Quoted 5 lines
The error probably happens because you send the card a command, but the command hits the bus that's in some weird intermediate state. Either the
card didn't finish switching the bus properties yet, or it did, or it's in the middle of it, but you cannot tell.Quoted 4 lines
OK thanks for the response.
If CMD13 can't be used because the bus is in an undefined state, shouldn't
send_cmd(CMD13)just fail ?So it would fail, but how do you guarantee the bus/card switched to the new state and is reliably ready ? You can't, because you cannot communicate with the card -- which is the entire problem here, you have no way to communicate with the card while the bus is switching. However, you can wait the maximum allowed time according to the spec, and then the bus/card must be ready. If not, all bets are off.
Quoted 2 lines
I'm asking because this is a 50ms delay in the hot path of the boot process.
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
I totally understand that, I have the same issue with HS200/HS400 on R-Car Gen3, all the calibration shenanigans and this indeed add quite a* bit to the boot time. But I don't have a good answer here.
I'll post something using the existing
wait_dat0()callback. If the callback is implemented, we can forgo the 50ms delay and poll the dat0 line.We can ? Do you have some more details ?
dat0 is a rdy/busy indicator. In the linux driver it is used in the card_busy() callback (look at sdhci_card_busy() for an example).
In u-boot we have a wait_dat0() that polls on dat0. It is used during the UHS initialization.
Quoted 1 line
PATCH 1/1 mmc: Do not poll using CMD13 when changing timing
Quoted 59 lines · Jean-Jacques Hiblot
Quoted 57 lines · Marek Vasut
Quoted 56 lines · Jean-Jacques Hiblot
Quoted 46 lines · Marek Vasut
Quoted 33 lines · Jean-Jacques Hiblot
Quoted 25 lines · Marek Vasut
Quoted 17 lines · Jean-Jacques Hiblot
Hi Marek,
Quoted 5 lines · Marek Vasut
When using CMD6 to switch eMMC card timing from HS200/HS400 to HS/legacy,
do not poll for the completion status using CMD13, but rather wait 50mS.Quoted 9 lines
Once the card receives the CMD6 and starts executing it, the bus is in
undefined state until both the card finishes executing the command and
until the controller switches the bus to matching timing configuration.
During this time, it is not possible to transport any commands or data
across the bus, which includes the CMD13.Quoted 7 lines
Is it something that affects all platforms ?
I've been working on this on TI platforms lately and although I've seen
the same kind of problems. But they mostly go away If the code handling
the switch handles theSWITCH_ERRORbit.Quoted 7 lines
The error probably happens because you send the card a command, but the
command hits the bus that's in some weird intermediate state. Either the
card didn't finish switching the bus properties yet, or it did, or it's
in the middle of it, but you cannot tell.Quoted 4 lines
OK thanks for the response.
If CMD13 can't be used because the bus is in an undefined state, shouldn't
send_cmd(CMD13)just fail ?So it would fail, but how do you guarantee the bus/card switched to the new state and is reliably ready ? You can't, because you cannot communicate with the card -- which is the entire problem here, you have no way to communicate with the card while the bus is switching. However,
you can wait the maximum allowed time according to the spec, and then the bus/card must be ready. If not, all bets are off.Quoted 6 lines
Quoted 2 lines
I'm asking because this is a 50ms delay in the hot path of the boot process.
I totally understand that, I have the same issue with HS200/HS400 on R-Car Gen3, all the calibration shenanigans and this indeed add quite a*
bit to the boot time. But I don't have a good answer here.I'll post something using the existing
wait_dat0()callback. If the callback is implemented, we can forgo the 50ms delay and poll the dat0 line.
Quoted 7 lines
Quoted 1 line
We can ? Do you have some more details ?
dat0 is a rdy/busy indicator. In the linux driver it is used in the
card_busy()callback (look atsdhci_card_busy()for an example).In u-boot we have a
wait_dat0()that polls on dat0. It is used during the UHS initialization.
All right, let's try this.
Signature · 2 lines
Best regards, Marek Vasut