Skip to contentSkip to conversation

mmc:fix: Increase the timeout value for SDHCI_send_command()

RFC Lukasz Majewski 4 participants 11 messages Jan 8, 2013 – Jan 28, 2013

lore
Share & tools
lore
#0 lore raw

I'd like to ask for your opinion about the following problem:

TRATS # saveenv
Saving Environment to MMC...
Writing to MMC(0)... Controller never released inhibit bit(s). Controller never released inhibit bit(s).
Controller never released inhibit bit(s).
...
failed

The same is for e.g. ext4.

The provided patch seems to solve the problem, but I DO NOT think that increasing delay is an acceptable solution to any problem.

#1 lore raw

Dear Lukasz Majewski,

Quoted 1 line · In message <[email protected]> you wrote:

I'd like to ask for your opinion about the following problem:

I cannot comment on the problem - only a bit about the proposed patch ;-)

Quoted 11 lines

From a brief checking I can say that it happens when we are doing consecutive MMC operations (i.e. many reads), and the 10ms timeout might be too short when eMMC firmware is forced to do some internal time consuming operations (e.g. flash blocks management, wear leveling).
In this situation, the SDHCI_CMD_INHIBIT bit is set, which means that SDHCI controller didn't received response from eMMC.

One proposition would be to define the per device/per memory chip specific timeouts, to replace those defined at ./drivers/mmc/sdhci.c file.

Is there no way to ask the device and/or controller when it is done, so we can poll for ready state instead of adding delays, which will always have to be tailored for the so far known worst case, i. e. they will be always too long on all almost all systems.

drivers/mmc/sdhci.c int sdhci_send_command(struct mmc *mmc, struct mmc_cmd *cmd, · line 141

Quoted 10 lines
drivers/mmc/sdhci.c +2 -2
@@ -137,8 +137,8 @@ int sdhci_send_command(struct mmc *mmc, struct mmc_cmd *cmd,
 	unsigned int timeout, start_addr = 0;
 	unsigned int retry = 10000;
 
-	/* Wait max 10 ms */
-	timeout = 10;
+	/* Wait max 100 ms */
+	timeout = 100;

We have cases where we struggle for sub-second boot times. Adding 100 ms delay here is clearly prohbitive. [Even the 10 ms are way too long IMHO.] There must be a better way to handle this.

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
f u cn rd ths, u cn gt a gd jb n cmptr prgrmmng.
#2 lore raw

Hi All,

I think this problem is produced when card is running write/erase operation. We used the mmc_send_status() into driver/mmc/mmc.c.
When That command is sending, i found the inhibit released log.

I think problem that SDHCI_DATA_INHIBIT is set at every command. if didn't have data and response type is not busy-wait type, SDHCI_DATA_INHIBIT didn't need to set.

How about this? It is more reasonable than increasing timeout value.

@@ -141,7 +143,10 @@ int sdhci_send_command(struct mmc *mmc, struct mmc_cmd *cmd,
timeout = 10;

sdhci_writel(host, SDHCI_INT_ALL_MASK, SDHCI_INT_STATUS);
- mask = SDHCI_CMD_INHIBIT | SDHCI_DATA_INHIBIT;
+ mask = SDHCI_CMD_INHIBIT;
+
+ if ((data != NULL) || (cmd->resp_type & MMC_RSP_BUSY))
+ mask |= SDHCI_DATA_INHIBIT;

/* We shouldn't wait for data inihibit for stop commands, even
though they might use busy signaling */

Best Regards,
Jaehoon Chung

Quoted 44 lines · Wolfgang Denk

Dear Lukasz Majewski,

Quoted 1 line · In message <[email protected]> you wrote:

I'd like to ask for your opinion about the following problem:

I cannot comment on the problem - only a bit about the proposed patch ;-)

Quoted 11 lines

From a brief checking I can say that it happens when we are doing consecutive MMC operations (i.e. many reads), and the 10ms timeout might be too short when eMMC firmware is forced to do some internal time consuming operations (e.g. flash blocks management, wear leveling).
In this situation, the SDHCI_CMD_INHIBIT bit is set, which means that SDHCI controller didn't received response from eMMC.

One proposition would be to define the per device/per memory chip specific timeouts, to replace those defined at ./drivers/mmc/sdhci.c file.

Is there no way to ask the device and/or controller when it is done, so we can poll for ready state instead of adding delays, which will always have to be tailored for the so far known worst case, i. e. they will be always too long on all almost all systems.

drivers/mmc/sdhci.c int sdhci_send_command(struct mmc *mmc, struct mmc_cmd *cmd, · line 141

Quoted 10 lines
drivers/mmc/sdhci.c +2 -2
@@ -137,8 +137,8 @@ int sdhci_send_command(struct mmc *mmc, struct mmc_cmd *cmd,
 	unsigned int timeout, start_addr = 0;
 	unsigned int retry = 10000;
 
-	/* Wait max 10 ms */
-	timeout = 10;
+	/* Wait max 100 ms */
+	timeout = 100;

We have cases where we struggle for sub-second boot times. Adding 100 ms delay here is clearly prohbitive. [Even the 10 ms are way too long IMHO.] There must be a better way to handle this.

Best regards,

Wolfgang Denk

#3 lore raw

Hi Jaehoon,

Quoted 13 lines

Hi All,

I think this problem is produced when card is running write/erase operation. We used the mmc_send_status() into driver/mmc/mmc.c. When That command is sending, i found the inhibit released log.

I think problem that SDHCI_DATA_INHIBIT is set at every command. if didn't have data and response type is not busy-wait type, SDHCI_DATA_INHIBIT didn't need to set.

How about this? It is more reasonable than increasing timeout value.

Review int sdhci_send_command(struct mmc *mmc, struct · line 150

Quoted 9 lines
(quoted diff) +4 -1
@@ -141,7 +143,10 @@ int sdhci_send_command(struct mmc *mmc, struct
 mmc_cmd *cmd, timeout = 10;
 
 	sdhci_writel(host, SDHCI_INT_ALL_MASK, SDHCI_INT_STATUS);
-	mask = SDHCI_CMD_INHIBIT | SDHCI_DATA_INHIBIT;
+	mask = SDHCI_CMD_INHIBIT;
+
+	if ((data != NULL) || (cmd->resp_type & MMC_RSP_BUSY))
+		mask |= SDHCI_DATA_INHIBIT;
 

I will test this and let you know.

Quoted 53 lines
(quoted diff) +0 -0
 	/* We shouldn't wait for data inihibit for stop commands,

even though they might use busy signaling */

Best Regards,
Jaehoon Chung

Quoted 45 lines · Wolfgang Denk

Dear Lukasz Majewski,

In message

Quoted 1 line · <[email protected]> you wrote:

I'd like to ask for your opinion about the following problem:

I cannot comment on the problem - only a bit about the proposed patch ;-)

Quoted 11 lines

From a brief checking I can say that it happens when we are doing consecutive MMC operations (i.e. many reads), and the 10ms timeout might be too short when eMMC firmware is forced to do some internal time consuming operations (e.g. flash blocks management, wear leveling).
In this situation, the SDHCI_CMD_INHIBIT bit is set, which means that SDHCI controller didn't received response from eMMC.

One proposition would be to define the per device/per memory chip specific timeouts, to replace those defined
at ./drivers/mmc/sdhci.c file.

Is there no way to ask the device and/or controller when it is done, so we can poll for ready state instead of adding delays, which will always have to be tailored for the so far known worst case, i. e. they will be always too long on all almost all systems.

drivers/mmc/sdhci.c int sdhci_send_command(struct mmc *mmc, struct · line 141

Quoted 10 lines
drivers/mmc/sdhci.c +2 -2
@@ -137,8 +137,8 @@ int sdhci_send_command(struct mmc *mmc, struct
 mmc_cmd *cmd, unsigned int timeout, start_addr = 0;
 	unsigned int retry = 10000;
 
-	/* Wait max 10 ms */
-	timeout = 10;
+	/* Wait max 100 ms */
+	timeout = 100;

We have cases where we struggle for sub-second boot times. Adding 100 ms delay here is clearly prohbitive. [Even the 10 ms are way too long IMHO.] There must be a better way to handle this.

Best regards,

Wolfgang Denk

Signature · 5 lines
Best regards,

Lukasz Majewski

Samsung R&D Poland (SRPOL) | Linux Platform Group
#4 lore raw
In reply to Jaehoon Chung

Hi Jaehoon,

Quoted 13 lines

Hi All,

I think this problem is produced when card is running write/erase operation. We used the mmc_send_status() into driver/mmc/mmc.c. When That command is sending, i found the inhibit released log.

I think problem that SDHCI_DATA_INHIBIT is set at every command. if didn't have data and response type is not busy-wait type, SDHCI_DATA_INHIBIT didn't need to set.

How about this? It is more reasonable than increasing timeout value.

Review int sdhci_send_command(struct mmc *mmc, struct · line 150

Quoted 9 lines
(quoted diff) +4 -1
@@ -141,7 +143,10 @@ int sdhci_send_command(struct mmc *mmc, struct
 mmc_cmd *cmd, timeout = 10;
 
 	sdhci_writel(host, SDHCI_INT_ALL_MASK, SDHCI_INT_STATUS);
-	mask = SDHCI_CMD_INHIBIT | SDHCI_DATA_INHIBIT;
+	mask = SDHCI_CMD_INHIBIT;
+
+	if ((data != NULL) || (cmd->resp_type & MMC_RSP_BUSY))
+		mask |= SDHCI_DATA_INHIBIT;
 

Ive tested this code and data abort appears when used with ext4.

I think, that we need to look around for another solution.

Quoted 53 lines
(quoted diff) +0 -0
 	/* We shouldn't wait for data inihibit for stop commands,

even though they might use busy signaling */

Best Regards,
Jaehoon Chung

Quoted 45 lines · Wolfgang Denk

Dear Lukasz Majewski,

In message

Quoted 1 line · <[email protected]> you wrote:

I'd like to ask for your opinion about the following problem:

I cannot comment on the problem - only a bit about the proposed patch ;-)

Quoted 11 lines

From a brief checking I can say that it happens when we are doing consecutive MMC operations (i.e. many reads), and the 10ms timeout might be too short when eMMC firmware is forced to do some internal time consuming operations (e.g. flash blocks management, wear leveling).
In this situation, the SDHCI_CMD_INHIBIT bit is set, which means that SDHCI controller didn't received response from eMMC.

One proposition would be to define the per device/per memory chip specific timeouts, to replace those defined
at ./drivers/mmc/sdhci.c file.

Is there no way to ask the device and/or controller when it is done, so we can poll for ready state instead of adding delays, which will always have to be tailored for the so far known worst case, i. e. they will be always too long on all almost all systems.

drivers/mmc/sdhci.c int sdhci_send_command(struct mmc *mmc, struct · line 141

Quoted 10 lines
drivers/mmc/sdhci.c +2 -2
@@ -137,8 +137,8 @@ int sdhci_send_command(struct mmc *mmc, struct
 mmc_cmd *cmd, unsigned int timeout, start_addr = 0;
 	unsigned int retry = 10000;
 
-	/* Wait max 10 ms */
-	timeout = 10;
+	/* Wait max 100 ms */
+	timeout = 100;

We have cases where we struggle for sub-second boot times. Adding 100 ms delay here is clearly prohbitive. [Even the 10 ms are way too long IMHO.] There must be a better way to handle this.

Best regards,

Wolfgang Denk

Signature · 5 lines
Best regards,

Lukasz Majewski

Samsung R&D Poland (SRPOL) | Linux Platform Group
#5 lore raw
In reply to Wolfgang Denk

Hi Wolfgang,

Quoted 17 lines

Dear Lukasz Majewski,

In message <[email protected]>

Quoted 1 line · you

I'd like to ask for your opinion about the following problem:

I cannot comment on the problem - only a bit about the proposed patch ;-)

Quoted 8 lines

From a brief checking I can say that it happens when we are doing consecutive MMC operations (i.e. many reads), and the 10ms timeout might be too short when eMMC firmware is forced to do some internal time consuming operations (e.g. flash blocks management, wear leveling).
In this situation, the SDHCI_CMD_INHIBIT bit is set, which means that SDHCI controller didn't received response from eMMC.

Quoted 8 lines
Quoted 3 lines

One proposition would be to define the per device/per memory chip specific timeouts, to replace those defined at ./drivers/mmc/sdhci.c file.

Is there no way to ask the device and/or controller when it is done, so we can poll for ready state instead of adding delays, which will always have to be tailored for the so far known worst case, i. e. they will be always too long on all almost all systems.

We are doing this already - the SDHCI_PRESENT_STATE register's bit 0 (SDHCI_CMD_INHIBIT) and bit 1 (DATA_INHIBIT) are for this purpose. Those indicate when host controller can send further command/data to the card.

Moreover, there are also timeouts in the case when someone pull out SD card inserted to the slot (or any other use case which I'm not aware).

Quoted 7 lines
Quoted 7 lines
drivers/mmc/sdhci.c +0 -0
@@ -137,8 +137,8 @@ int sdhci_send_command(struct mmc *mmc, struct
 mmc_cmd *cmd, unsigned int timeout, start_addr = 0;
 	unsigned int retry = 10000;
 
Quoted 8 lines

drivers/mmc/sdhci.c int sdhci_send_command(struct mmc *mmc, struct · line 141

Quoted 4 lines
drivers/mmc/sdhci.c +2 -2
-	/* Wait max 10 ms */
-	timeout = 10;
+	/* Wait max 100 ms */
+	timeout = 100;

We have cases where we struggle for sub-second boot times. Adding 100 ms delay here is clearly prohbitive. [Even the 10 ms are way too long IMHO.] There must be a better way to handle this.

That's why I'm asking.

It is strange that, when I'm increasing delay it works.

Maybe we will find some areas of optimization?

Quoted 5 lines

Best regards,

Wolfgang Denk

Signature · 5 lines
Best regards,

Lukasz Majewski

Samsung R&D Poland (SRPOL) | Linux Platform Group
#6 lore raw

Hi,

Quoted 53 lines · Lukasz Majewski

Hi Wolfgang,

Quoted 17 lines

Dear Lukasz Majewski,

In message <[email protected]>

Quoted 1 line · you

I'd like to ask for your opinion about the following problem:

I cannot comment on the problem - only a bit about the proposed patch ;-)

Quoted 8 lines

From a brief checking I can say that it happens when we are doing consecutive MMC operations (i.e. many reads), and the 10ms timeout might be too short when eMMC firmware is forced to do some internal time consuming operations (e.g. flash blocks management, wear leveling).
In this situation, the SDHCI_CMD_INHIBIT bit is set, which means that SDHCI controller didn't received response from eMMC.

Quoted 8 lines
Quoted 3 lines

One proposition would be to define the per device/per memory chip specific timeouts, to replace those defined at ./drivers/mmc/sdhci.c file.

Is there no way to ask the device and/or controller when it is done, so we can poll for ready state instead of adding delays, which will always have to be tailored for the so far known worst case, i. e. they will be always too long on all almost all systems.

We are doing this already - the SDHCI_PRESENT_STATE register's bit 0 (SDHCI_CMD_INHIBIT) and bit 1 (DATA_INHIBIT) are for this purpose. Those indicate when host controller can send further command/data to the card.

Moreover, there are also timeouts in the case when someone pull out SD card inserted to the slot (or any other use case which I'm not aware).

Quoted 7 lines
Quoted 7 lines
drivers/mmc/sdhci.c +0 -0
@@ -137,8 +137,8 @@ int sdhci_send_command(struct mmc *mmc, struct
 mmc_cmd *cmd, unsigned int timeout, start_addr = 0;
    unsigned int retry = 10000;
 
Quoted 8 lines

drivers/mmc/sdhci.c int sdhci_send_command(struct mmc *mmc, struct · line 141

Quoted 4 lines
drivers/mmc/sdhci.c +2 -2
-   /* Wait max 10 ms */
-   timeout = 10;
+   /* Wait max 100 ms */
+   timeout = 100;

We have cases where we struggle for sub-second boot times. Adding 100 ms delay here is clearly prohbitive. [Even the 10 ms are way too long IMHO.] There must be a better way to handle this.

Quoted 5 lines

That's why I'm asking.

It is strange that, when I'm increasing delay it works.

Maybe we will find some areas of optimization?

BTW: I am also finding the similar issue.

But when I enabled CONFIG_MMC_TRACE for log traces, i never see the issue..it's pretty much working fine.
As per my latest debug, the issue is fire for CMD6 (SWITCH_FUNC).

May be we need to update the logic on this while loop...

Thanks,
Jagan.

Quoted 19 lines
Quoted 6 lines

Best regards,

Wolfgang Denk

--
Best regards,

Lukasz Majewski

Samsung R&D Poland (SRPOL) | Linux Platform Group
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

#7 lore raw
Quoted 58 lines · Jagan Teki

Hi,

Quoted 55 lines · Lukasz Majewski

Hi Wolfgang,

Quoted 17 lines

Dear Lukasz Majewski,

In message <[email protected]>

Quoted 1 line · you

I'd like to ask for your opinion about the following problem:

I cannot comment on the problem - only a bit about the proposed patch ;-)

Quoted 8 lines

From a brief checking I can say that it happens when we are doing consecutive MMC operations (i.e. many reads), and the 10ms timeout might be too short when eMMC firmware is forced to do some internal time consuming operations (e.g. flash blocks management, wear leveling).
In this situation, the SDHCI_CMD_INHIBIT bit is set, which means that SDHCI controller didn't received response from eMMC.

Quoted 8 lines
Quoted 3 lines

One proposition would be to define the per device/per memory chip specific timeouts, to replace those defined at ./drivers/mmc/sdhci.c file.

Is there no way to ask the device and/or controller when it is done, so we can poll for ready state instead of adding delays, which will always have to be tailored for the so far known worst case, i. e. they will be always too long on all almost all systems.

We are doing this already - the SDHCI_PRESENT_STATE register's bit 0 (SDHCI_CMD_INHIBIT) and bit 1 (DATA_INHIBIT) are for this purpose. Those indicate when host controller can send further command/data to the card.

Moreover, there are also timeouts in the case when someone pull out SD card inserted to the slot (or any other use case which I'm not aware).

Quoted 7 lines
Quoted 7 lines
drivers/mmc/sdhci.c +0 -0
@@ -137,8 +137,8 @@ int sdhci_send_command(struct mmc *mmc, struct
 mmc_cmd *cmd, unsigned int timeout, start_addr = 0;
    unsigned int retry = 10000;
 
Quoted 8 lines

drivers/mmc/sdhci.c int sdhci_send_command(struct mmc *mmc, struct · line 141

Quoted 4 lines
drivers/mmc/sdhci.c +2 -2
-   /* Wait max 10 ms */
-   timeout = 10;
+   /* Wait max 100 ms */
+   timeout = 100;

We have cases where we struggle for sub-second boot times. Adding 100 ms delay here is clearly prohbitive. [Even the 10 ms are way too long IMHO.] There must be a better way to handle this.

That's why I'm asking.

Quoted 8 lines
Quoted 3 lines

It is strange that, when I'm increasing delay it works.

Maybe we will find some areas of optimization?

BTW: I am also finding the similar issue.

But when I enabled CONFIG_MMC_TRACE for log traces, i never see the issue..it's pretty much working fine.

It's not important to enable the MMC_TRACE. It should be increased the delay.

Quoted 1 line

As per my latest debug, the issue is fire for CMD6 (SWITCH_FUNC).

Right, i also find the error log for CMD6.
Could you test this point?

sdhci_writel(host, SDHCI_INT_ALL_MASK, SDHCI_INT_STATUS);
- mask = SDHCI_CMD_INHIBIT | SDHCI_DATA_INHIBIT;
+ mask = SDHCI_CMD_INHIBIT;
+
+ if ((data != NULL) || (cmd->resp_type & MMC_RSP_BUSY))
+ mask |= SDHCI_DATA_INHIBIT;

Best Regards,
Jaehoon Chung

Quoted 30 lines

May be we need to update the logic on this while loop...

Thanks,
Jagan.

Quoted 12 lines
Quoted 6 lines

Best regards,

Wolfgang Denk

--
Best regards,

Quoted 7 lines

Lukasz Majewski

Samsung R&D Poland (SRPOL) | Linux Platform Group
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

#8 lore raw

Hi Jaehoon Chung,

Quoted 73 lines · Jaehoon Chung
Quoted 58 lines · Jagan Teki

Hi,

Quoted 55 lines · Lukasz Majewski

Hi Wolfgang,

Quoted 17 lines

Dear Lukasz Majewski,

In message <[email protected]>

Quoted 1 line · you

I'd like to ask for your opinion about the following problem:

I cannot comment on the problem - only a bit about the proposed patch ;-)

Quoted 8 lines

From a brief checking I can say that it happens when we are doing consecutive MMC operations (i.e. many reads), and the 10ms timeout might be too short when eMMC firmware is forced to do some internal time consuming operations (e.g. flash blocks management, wear leveling).
In this situation, the SDHCI_CMD_INHIBIT bit is set, which means that SDHCI controller didn't received response from eMMC.

Quoted 8 lines
Quoted 3 lines

One proposition would be to define the per device/per memory chip specific timeouts, to replace those defined at ./drivers/mmc/sdhci.c file.

Is there no way to ask the device and/or controller when it is done, so we can poll for ready state instead of adding delays, which will always have to be tailored for the so far known worst case, i. e. they will be always too long on all almost all systems.

We are doing this already - the SDHCI_PRESENT_STATE register's bit 0 (SDHCI_CMD_INHIBIT) and bit 1 (DATA_INHIBIT) are for this purpose. Those indicate when host controller can send further command/data to the card.

Moreover, there are also timeouts in the case when someone pull out SD card inserted to the slot (or any other use case which I'm not aware).

Quoted 7 lines
Quoted 7 lines
drivers/mmc/sdhci.c +0 -0
@@ -137,8 +137,8 @@ int sdhci_send_command(struct mmc *mmc, struct
 mmc_cmd *cmd, unsigned int timeout, start_addr = 0;
    unsigned int retry = 10000;
 
Quoted 8 lines

drivers/mmc/sdhci.c int sdhci_send_command(struct mmc *mmc, struct · line 141

Quoted 4 lines
drivers/mmc/sdhci.c +2 -2
-   /* Wait max 10 ms */
-   timeout = 10;
+   /* Wait max 100 ms */
+   timeout = 100;

We have cases where we struggle for sub-second boot times. Adding 100 ms delay here is clearly prohbitive. [Even the 10 ms are way too long IMHO.] There must be a better way to handle this.

That's why I'm asking.

Quoted 8 lines
Quoted 3 lines

It is strange that, when I'm increasing delay it works.

Maybe we will find some areas of optimization?

BTW: I am also finding the similar issue.

But when I enabled CONFIG_MMC_TRACE for log traces, i never see the issue..it's pretty much working fine.

It's not important to enable the MMC_TRACE. It should be increased the delay.

Quoted 1 line

As per my latest debug, the issue is fire for CMD6 (SWITCH_FUNC).

Right, i also find the error log for CMD6.
Could you test this point?

        sdhci_writel(host, SDHCI_INT_ALL_MASK, SDHCI_INT_STATUS);

Review

Quoted 5 lines
(quoted diff) +4 -1
-       mask = SDHCI_CMD_INHIBIT | SDHCI_DATA_INHIBIT;
+       mask = SDHCI_CMD_INHIBIT;
+
+       if ((data != NULL) || (cmd->resp_type & MMC_RSP_BUSY))
+               mask |= SDHCI_DATA_INHIBIT;

I found similar issue, no changes...

for masking data, the mask is ORed in CMD51 and CMD6 cases.
mask |= SDHCI_DATA_INHIBIT;

But I have tried by putting the delay between the command transfer like..

        if (host->quirks & SDHCI_QUIRK_WAIT_SEND_CMD)
                udelay(1000);

I just enabled the above quirks on my sdhci driver, everything work fine. But again I don't now does this delay really required?, or it may causes any harm?

Thanks,
Jagan.

Quoted 34 lines

Best Regards,
Jaehoon Chung

Quoted 30 lines

May be we need to update the logic on this while loop...

Thanks,
Jagan.

Quoted 12 lines
Quoted 6 lines

Best regards,

Wolfgang Denk

--
Best regards,

Quoted 7 lines

Lukasz Majewski

Samsung R&D Poland (SRPOL) | Linux Platform Group
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

#9 lore raw
In reply to Jaehoon Chung

Hi Jaehoon,

Quoted 65 lines · Jagan Teki
Quoted 64 lines

Hi,

Quoted 60 lines · Lukasz Majewski

Hi Wolfgang,

Quoted 22 lines

Dear Lukasz Majewski,

In message <[email protected]> you

Quoted 1 line · wrote:

I'd like to ask for your opinion about the following problem:

I cannot comment on the problem - only a bit about the proposed patch ;-)

Quoted 11 lines

From a brief checking I can say that it happens when we are doing consecutive MMC operations (i.e. many reads), and the 10ms timeout might be too short when eMMC firmware is forced to do some internal time consuming operations (e.g. flash blocks management, wear leveling).
In this situation, the SDHCI_CMD_INHIBIT bit is set, which means that SDHCI controller didn't received response from eMMC.

One proposition would be to define the per device/per memory chip specific timeouts, to replace those defined
at ./drivers/mmc/sdhci.c file.

Quoted 5 lines

Is there no way to ask the device and/or controller when it is done, so we can poll for ready state instead of adding delays, which will always have to be tailored for the so far known worst case, i. e. they will be always too long on all almost all systems.

We are doing this already - the SDHCI_PRESENT_STATE register's bit 0 (SDHCI_CMD_INHIBIT) and bit 1 (DATA_INHIBIT) are for this purpose. Those indicate when host controller can send further command/data to the card.

Moreover, there are also timeouts in the case when someone pull out SD card inserted to the slot (or any other use case which I'm not aware).

Quoted 7 lines
Quoted 7 lines
drivers/mmc/sdhci.c +0 -0
@@ -137,8 +137,8 @@ int sdhci_send_command(struct mmc *mmc,
 struct mmc_cmd *cmd, unsigned int timeout, start_addr = 0;
    unsigned int retry = 10000;
 
Quoted 8 lines

drivers/mmc/sdhci.c int sdhci_send_command(struct mmc *mmc, · line 141

Quoted 4 lines
drivers/mmc/sdhci.c +2 -2
-   /* Wait max 10 ms */
-   timeout = 10;
+   /* Wait max 100 ms */
+   timeout = 100;

We have cases where we struggle for sub-second boot times. Adding 100 ms delay here is clearly prohbitive. [Even the 10 ms are way too long IMHO.] There must be a better way to handle this.

That's why I'm asking.

It is strange that, when I'm increasing delay it works.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

Maybe we will find some areas of optimization?

BTW: I am also finding the similar issue.

But when I enabled CONFIG_MMC_TRACE for log traces, i never see the issue..it's pretty much working fine.

It's not important to enable the MMC_TRACE. It should be increased the delay.

You don't see problem, since CONFIG_MMC_TRACE causes extra delays to write log information to serial console.

Review

Quoted 10 lines
Quoted 1 line

As per my latest debug, the issue is fire for CMD6 (SWITCH_FUNC).

Right, i also find the error log for CMD6.
Could you test this point?

(quoted diff) +4 -1
 	sdhci_writel(host, SDHCI_INT_ALL_MASK, SDHCI_INT_STATUS);
-	mask = SDHCI_CMD_INHIBIT | SDHCI_DATA_INHIBIT;
+	mask = SDHCI_CMD_INHIBIT;
+
+	if ((data != NULL) || (cmd->resp_type & MMC_RSP_BUSY))
+		mask |= SDHCI_DATA_INHIBIT;

I've tested it on trats, but mentioned errors also appear (with lower frequency though).

Quoted 5 lines

Best Regards,
Jaehoon Chung

Quoted 2 lines

May be we need to update the logic on this while loop...

Yep.

Quoted 29 lines
Quoted 28 lines

Thanks,
Jagan.

Quoted 12 lines
Quoted 6 lines

Best regards,

Wolfgang Denk

--
Best regards,

Quoted 7 lines

Lukasz Majewski

Samsung R&D Poland (SRPOL) | Linux Platform Group
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Signature · 5 lines
Best regards,

Lukasz Majewski

Samsung R&D Poland (SRPOL) | Linux Platform Group
#10 lore raw

Hi Lukasz,

Quoted 71 lines · Lukasz Majewski

Hi Jaehoon,

Quoted 69 lines · Jagan Teki
Quoted 68 lines

Hi,

Quoted 56 lines · Lukasz Majewski

Hi Wolfgang,

Quoted 22 lines

Dear Lukasz Majewski,

In message <[email protected]> you

Quoted 1 line · wrote:

I'd like to ask for your opinion about the following problem:

I cannot comment on the problem - only a bit about the proposed patch ;-)

Quoted 11 lines

From a brief checking I can say that it happens when we are doing consecutive MMC operations (i.e. many reads), and the 10ms timeout might be too short when eMMC firmware is forced to do some internal time consuming operations (e.g. flash blocks management, wear leveling).
In this situation, the SDHCI_CMD_INHIBIT bit is set, which means that SDHCI controller didn't received response from eMMC.

One proposition would be to define the per device/per memory chip specific timeouts, to replace those defined
at ./drivers/mmc/sdhci.c file.

Quoted 5 lines

Is there no way to ask the device and/or controller when it is done, so we can poll for ready state instead of adding delays, which will always have to be tailored for the so far known worst case, i. e. they will be always too long on all almost all systems.

We are doing this already - the SDHCI_PRESENT_STATE register's bit 0 (SDHCI_CMD_INHIBIT) and bit 1 (DATA_INHIBIT) are for this purpose. Those indicate when host controller can send further command/data to the card.

Moreover, there are also timeouts in the case when someone pull out SD card inserted to the slot (or any other use case which I'm not aware).

Quoted 7 lines
Quoted 7 lines
drivers/mmc/sdhci.c +0 -0
@@ -137,8 +137,8 @@ int sdhci_send_command(struct mmc *mmc,
 struct mmc_cmd *cmd, unsigned int timeout, start_addr = 0;
    unsigned int retry = 10000;
 
Quoted 8 lines

drivers/mmc/sdhci.c int sdhci_send_command(struct mmc *mmc, · line 141

Quoted 4 lines
drivers/mmc/sdhci.c +2 -2
-   /* Wait max 10 ms */
-   timeout = 10;
+   /* Wait max 100 ms */
+   timeout = 100;

We have cases where we struggle for sub-second boot times. Adding 100 ms delay here is clearly prohbitive. [Even the 10 ms are way too long IMHO.] There must be a better way to handle this.

Quoted 5 lines

That's why I'm asking.

It is strange that, when I'm increasing delay it works.

Maybe we will find some areas of optimization?

BTW: I am also finding the similar issue.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

But when I enabled CONFIG_MMC_TRACE for log traces, i never see the issue..it's pretty much working fine.

It's not important to enable the MMC_TRACE. It should be increased the delay.

You don't see problem, since CONFIG_MMC_TRACE causes extra delays to write log information to serial console.

Right...So i mentioned that CONFIG_MMC_TRACE isn't important.(added delay).

Quoted 5 lines
Quoted 5 lines
Quoted 2 lines

As per my latest debug, the issue is fire for CMD6 (SWITCH_FUNC).

Right, i also find the error log for CMD6.
Could you test this point?

Quoted 9 lines

Review

Quoted 6 lines
(quoted diff) +4 -1
 	sdhci_writel(host, SDHCI_INT_ALL_MASK, SDHCI_INT_STATUS);
-	mask = SDHCI_CMD_INHIBIT | SDHCI_DATA_INHIBIT;
+	mask = SDHCI_CMD_INHIBIT;
+
+	if ((data != NULL) || (cmd->resp_type & MMC_RSP_BUSY))
+		mask |= SDHCI_DATA_INHIBIT;

I've tested it on trats, but mentioned errors also appear (with lower frequency though).

Right..But I think that this patch is correct regardless of this problem. if you agree this, i will send the patch with this.

Quoted 7 lines
Quoted 7 lines

Best Regards,
Jaehoon Chung

Quoted 2 lines

May be we need to update the logic on this while loop...

how about using get_timer()?

Best Regards,
Jaehoon Chung

Quoted 35 lines

Yep.

Quoted 29 lines
Quoted 28 lines

Thanks,
Jagan.

Quoted 12 lines
Quoted 6 lines

Best regards,

Wolfgang Denk

--
Best regards,

Quoted 7 lines

Lukasz Majewski

Samsung R&D Poland (SRPOL) | Linux Platform Group
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot