mmc: dw_mmc: reset controller after data error
PATCH RESEND v2 1/1 mmc: dw_mmc: reset controller after data error
From: Ziyuan Xu <[email protected]>
Per dw_mmc databook, it's recommended to reset the host controller if some data-related error occurred.
Implement a reset mechanism.
--- drivers/mmc/dw_mmc.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/mmc/dw_mmc.c +19 -1
@@ -138,7 +138,7 @@ static int dwmci_data_transfer(struct dwmci_host *host, struct mmc_data *data) {struct mmc *mmc = host->mmc;int ret =0 ; -u32 timeout, mask, size, i, len =0 ; +u32 timeout, reset_timeout =100 , status, ctrl, mask, size, i, len =0 ;u32 *buf =NULL ;ulong start =get_timer (0 ); u32 fifo_depth = (((host->fifoth_val & RX_WMARK_MASK) >>
@@ -159,6 +159,24 @@ static int dwmci_data_transfer(struct dwmci_host *host, struct mmc_data *data)/* Error during data transfer. */ if (mask & (DWMCI_DATA_ERR |DWMCI_DATA_TOUT )) {debug ("%s: DATA ERROR!\n" , __func__); + +dwmci_wait_reset (host,DWMCI_RESET_ALL ); +dwmci_writel (host,DWMCI_CMD ,DWMCI_CMD_PRV_DAT_WAIT | +DWMCI_CMD_UPD_CLK |DWMCI_CMD_START ); + +do { + status =dwmci_readl (host,DWMCI_CMD ); +if (!reset_timeout--) +break ; +udelay (100 ); + }while (status &DWMCI_CMD_START ); + +if (!host->fifo_mode) { + ctrl =dwmci_readl (host,DWMCI_BMOD ); + ctrl |=DWMCI_BMOD_IDMAC_RESET ; +dwmci_writel (host,DWMCI_BMOD , ctrl); + } + ret = -EINVAL ;break ; }
Signature · 1 line
2.34.1
Quoted 6 lines · Eugen Hristev
From: Ziyuan Xu <[email protected]>
Per
dw_mmcdatabook, it's recommended to reset the host controller if some data-related error occurred.
Implement a reset mechanism.
Quoted 6 lines
Signed-off-by Ziyuan Xu <[email protected]>Co-developed-by Jason Zhu <[email protected]>Signed-off-by Jason Zhu <[email protected]>[[email protected]: modified a bit the variables initialization]Signed-off-by Eugen Hristev <[email protected]>---
Hi,
Gentle ping.
This patch require any more changes?
Thanks,
Eugen
Quoted 41 lines
drivers/mmc/dw_mmc.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)drivers/mmc/dw_mmc.c +19
-1@@ -138,7 +138,7 @@ static int dwmci_data_transfer(struct dwmci_host *host, struct mmc_data *data) {struct mmc *mmc = host->mmc;int ret =0 ; -u32 timeout, mask, size, i, len =0 ; +u32 timeout, reset_timeout =100 , status, ctrl, mask, size, i, len =0 ;u32 *buf =NULL ;ulong start =get_timer (0 ); u32 fifo_depth = (((host->fifoth_val & RX_WMARK_MASK) >>@@ -159,6 +159,24 @@ static int dwmci_data_transfer(struct dwmci_host *host, struct mmc_data *data)/* Error during data transfer. */ if (mask & (DWMCI_DATA_ERR |DWMCI_DATA_TOUT )) {debug ("%s: DATA ERROR!\n" , __func__); + +dwmci_wait_reset (host,DWMCI_RESET_ALL ); +dwmci_writel (host,DWMCI_CMD ,DWMCI_CMD_PRV_DAT_WAIT | +DWMCI_CMD_UPD_CLK |DWMCI_CMD_START ); + +do { + status =dwmci_readl (host,DWMCI_CMD ); +if (!reset_timeout--) +break ; +udelay (100 ); + }while (status &DWMCI_CMD_START ); + +if (!host->fifo_mode) { + ctrl =dwmci_readl (host,DWMCI_BMOD ); + ctrl |=DWMCI_BMOD_IDMAC_RESET ; +dwmci_writel (host,DWMCI_BMOD , ctrl); + } + ret = -EINVAL ;break ; }
I am able to reproduce this on RK3588 QuartzPro64.
I thought "[PATCH v2 RESEND] mmc: dw_mmc: reset controller after data error"[0] might fix this, but after applying that, I am still able to reproduce the issue.
Hi Tom,
Could you have a try with rockchip vendor U-Boot, maybe still some other fixes are missing in mainline U-Boot mmc driver.
Thanks,
- Kever
Quoted 7 lines · Tom Fitzhenry
I am able to reproduce this on RK3588 QuartzPro64.
I thought "[PATCH v2 RESEND] mmc:
dw_mmc: reset controller after data error"[0] might fix this, but after applying that, I am still able to reproduce the issue.
Quoted 2 lines · Kever Yang
Could you have a try with rockchip vendor U-Boot, maybe still some other fixes are missing in mainline U-Boot mmc driver.
Sorry, I just realised I sent this message as a reply to the patch, rather than against the bug report[0].
I have tested the vendor u-boot, and found it to be working. I have replied against the bug thread[1].
0. https://lore.kernel.org/u-boot/[email protected]/
1. https://lore.kernel.org/u-boot/[email protected]/
Quoted 11 lines · Eugen Hristev
From: Ziyuan Xu <[email protected]>
Per
dw_mmcdatabook, it's recommended to reset the host controller if some data-related error occurred.
Implement a reset mechanism.Signed-off-by Ziyuan Xu <[email protected]>Co-developed-by Jason Zhu <[email protected]>Signed-off-by Jason Zhu <[email protected]>[[email protected]: modified a bit the variables initialization]Signed-off-by Eugen Hristev <[email protected]>
Thanks,
- Kever
Quoted 42 lines
--- drivers/mmc/dw_mmc.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)drivers/mmc/dw_mmc.c +19
-1@@ -138,7 +138,7 @@ static int dwmci_data_transfer(struct dwmci_host *host, struct mmc_data *data) {struct mmc *mmc = host->mmc;int ret =0 ; -u32 timeout, mask, size, i, len =0 ; +u32 timeout, reset_timeout =100 , status, ctrl, mask, size, i, len =0 ;u32 *buf =NULL ;ulong start =get_timer (0 ); u32 fifo_depth = (((host->fifoth_val & RX_WMARK_MASK) >>@@ -159,6 +159,24 @@ static int dwmci_data_transfer(struct dwmci_host *host, struct mmc_data *data)/* Error during data transfer. */ if (mask & (DWMCI_DATA_ERR |DWMCI_DATA_TOUT )) {debug ("%s: DATA ERROR!\n" , __func__); + +dwmci_wait_reset (host,DWMCI_RESET_ALL ); +dwmci_writel (host,DWMCI_CMD ,DWMCI_CMD_PRV_DAT_WAIT | +DWMCI_CMD_UPD_CLK |DWMCI_CMD_START ); + +do { + status =dwmci_readl (host,DWMCI_CMD ); +if (!reset_timeout--) +break ; +udelay (100 ); + }while (status &DWMCI_CMD_START ); + +if (!host->fifo_mode) { + ctrl =dwmci_readl (host,DWMCI_BMOD ); + ctrl |=DWMCI_BMOD_IDMAC_RESET ; +dwmci_writel (host,DWMCI_BMOD , ctrl); + } + ret = -EINVAL ;break ; }
Quoted 6 lines · Eugen Hristev
From: Ziyuan Xu <[email protected]>
Per
dw_mmcdatabook, it's recommended to reset the host controller if some data-related error occurred.
Implement a reset mechanism.
Quoted 6 lines
Signed-off-by Ziyuan Xu <[email protected]>Co-developed-by Jason Zhu <[email protected]>Signed-off-by Jason Zhu <[email protected]>[[email protected]: modified a bit the variables initialization]Signed-off-by Eugen Hristev <[email protected]>Reviewed-by Kever Yang <[email protected]>
Best Regards,
Jaehoon Chung
Quoted 42 lines
--- drivers/mmc/dw_mmc.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)drivers/mmc/dw_mmc.c +19
-1@@ -138,7 +138,7 @@ static int dwmci_data_transfer(struct dwmci_host *host, struct mmc_data *data) {struct mmc *mmc = host->mmc;int ret =0 ; -u32 timeout, mask, size, i, len =0 ; +u32 timeout, reset_timeout =100 , status, ctrl, mask, size, i, len =0 ;u32 *buf =NULL ;ulong start =get_timer (0 ); u32 fifo_depth = (((host->fifoth_val & RX_WMARK_MASK) >>@@ -159,6 +159,24 @@ static int dwmci_data_transfer(struct dwmci_host *host, struct mmc_data *data)/* Error during data transfer. */ if (mask & (DWMCI_DATA_ERR |DWMCI_DATA_TOUT )) {debug ("%s: DATA ERROR!\n" , __func__); + +dwmci_wait_reset (host,DWMCI_RESET_ALL ); +dwmci_writel (host,DWMCI_CMD ,DWMCI_CMD_PRV_DAT_WAIT | +DWMCI_CMD_UPD_CLK |DWMCI_CMD_START ); + +do { + status =dwmci_readl (host,DWMCI_CMD ); +if (!reset_timeout--) +break ; +udelay (100 ); + }while (status &DWMCI_CMD_START ); + +if (!host->fifo_mode) { + ctrl =dwmci_readl (host,DWMCI_BMOD ); + ctrl |=DWMCI_BMOD_IDMAC_RESET ; +dwmci_writel (host,DWMCI_BMOD , ctrl); + } + ret = -EINVAL ;break ; }