mmc: {tmio,renesas_sdhi}: fix tuning behavior
Subsystems (2)
cover mmc: {tmio,renesas_sdhi}: fix tuning behavior
Hi,
Tuning failed on my R-Car H3 ES2.0 board using latest mmc/next while the Renesas BSP kernel worked. After some digging I found patches in the BSP which remedied this and whit these applied tuning now works for me.
I have done small fixes, updated commit messages and rebased on latest mmc/next but Hayakawa-san did all the real work.
Masaharu Hayakawa (4):
mmc: tmio: Fix tuning flow
mmc: tmio: Fix SCC error detection
mmc: renesas_sdhi: Fix sampling clock position selecting
mmc: renesas_sdhi: Fix SCC error detection
drivers/mmc/host/renesas_sdhi_core.c | 16 ++++++++++++++++ drivers/mmc/host/tmio_mmc_core.c | 9 +++------ 2 files changed, 19 insertions(+), 6 deletions(-)
Signature · 1 line
2.17.0
PATCH 1/4 mmc: tmio: Fix tuning flow
From: Masaharu Hayakawa <[email protected]>
If the return value of mmc_send_tuning() is error other than -EILSEQ, the tuning fails and process goes out of for_loop. The correct processing is to judge their TAP as not good (NG) and continue.
--- drivers/mmc/host/tmio_mmc_core.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/mmc/host/tmio_mmc_core.c +1 -4
@@ -804,10 +804,7 @@ static int tmio_mmc_execute_tuning(struct mmc_host *mmc, u32 opcode)if (host->prepare_tuning) host->prepare_tuning (host, i % host->tap_num); - ret =mmc_send_tuning (mmc, opcode,NULL ); -if (ret && ret != -EILSEQ ) - goto out; -if (ret ==0 ) +if (!mmc_send_tuning (mmc, opcode,NULL ))set_bit (i, host->taps);usleep_range (1000 ,1200 );
Signature · 1 line
2.17.0
Re: [PATCH 1/4] mmc: tmio: Fix tuning flow
drivers/mmc/host/tmio_mmc_core.c static int tmio_mmc_execute_tuning(struct mmc_host *mmc, u32 opcode) · line 807
Quoted 3 lines
drivers/mmc/host/tmio_mmc_core.c +1
-1-if (ret ==0 ) +if (!mmc_send_tuning (mmc, opcode,NULL ))
I'd prefer '== 0' here as it makes clearer that we are checking for the good case here.
But in general, the patch makes sense to me.
PATCH 2/4 mmc: tmio: Fix SCC error detection
In reply to Niklas SöderlundFrom: Masaharu Hayakawa <[email protected]>
SDR104 and HS200 need to check for SCC error. If SCC error is detected, retuning is necessary.
--- drivers/mmc/host/tmio_mmc_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/host/tmio_mmc_core.c +2 -2
@@ -906,8 +906,8 @@ static void tmio_mmc_finish_request(struct tmio_mmc_host *host)if (mrq->cmd->error || (mrq->data && mrq->data->error))tmio_mmc_abort_dma (host); -if (host->check_scc_error) - host->check_scc_error (host); +if (host->check_scc_error && host->check_scc_error (host)) + mrq->cmd->error = -EILSEQ ;/* If SET_BLOCK_COUNT, continue with main command */ if (host->mrq && !mrq->cmd->error) {
Signature · 1 line
2.17.0
Re: [PATCH 2/4] mmc: tmio: Fix SCC error detection
Quoted 8 lines · Niklas Söderlund
From: Masaharu Hayakawa <[email protected]>
SDR104 and HS200 need to check for SCC error. If SCC error is detected, retuning is necessary.
Signed-off-by Masaharu Hayakawa <[email protected]>[Niklas: update commit message]Signed-off-by Niklas Söderlund <[email protected]>
It makes sense to me. We don't have a testcase to test this against, however :(
How do other people test stuff like this? Rare error paths?
PATCH 3/4 mmc: renesas_sdhi: Fix sampling clock position selecting
In reply to Niklas SöderlundFrom: Masaharu Hayakawa <[email protected]>
When the result of tuning was different between the first set and the second set, there was a case where the wrong sampling clock position was selected. As a countermeasure, make the two results the same.
--- drivers/mmc/host/renesas_sdhi_core.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/mmc/host/renesas_sdhi_core.c +9 -0
@@ -301,6 +301,15 @@ static int renesas_sdhi_select_tuning(struct tmio_mmc_host *host)/* Clear SCC_RVSREQ */ sd_scc_write32 (host, priv,SH_MOBILE_SDHI_SCC_RVSREQ ,0 ); +/* Merge the results */ +for (i =0 ; i < host->tap_num *2 ; i++) { +if (!test_bit (i, host->taps)) { +clear_bit (i % host->tap_num, host->taps); +clear_bit ((i % host->tap_num) + host->tap_num, + host->taps); + } + } +/* * Find the longest consecutive run of successful probes. If that * is more than SH_MOBILE_SDHI_MAX_TAP probes long then use the
Signature · 1 line
2.17.0
Re: [PATCH 3/4] mmc: renesas_sdhi: Fix sampling clock position selecting
Quoted 9 lines · Niklas Söderlund
From: Masaharu Hayakawa <[email protected]>
When the result of tuning was different between the first set and the second set, there was a case where the wrong sampling clock position was selected. As a countermeasure, make the two results the same.
Signed-off-by Masaharu Hayakawa <[email protected]>[Niklas: update commit message]Signed-off-by Niklas Söderlund <[email protected]>
As mentioned on IRC, I think this needs an updated patch description IMHO.
PATCH 4/4 mmc: renesas_sdhi: Fix SCC error detection
In reply to Niklas SöderlundFrom: Masaharu Hayakawa <[email protected]>
SDR104 and HS200 need to check SCC error. If SCC error is detected, retuning is necessary.
In addition SCC error checking during retuning is unnecessary.
--- drivers/mmc/host/renesas_sdhi_core.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/mmc/host/renesas_sdhi_core.c +7 -0
@@ -358,6 +358,13 @@ static bool renesas_sdhi_check_scc_error(struct tmio_mmc_host *host) {struct renesas_sdhi *priv =host_to_priv (host); +if (!(host->mmc->ios.timing ==MMC_TIMING_UHS_SDR104 ) && + !(host->mmc->ios.timing ==MMC_TIMING_MMC_HS200 )) +return false; + +if (host->mmc->doing_retune) +return false; +/* Check SCC error */ if (sd_scc_read32(host, priv, SH_MOBILE_SDHI_SCC_RVSCNTL) & SH_MOBILE_SDHI_SCC_RVSCNTL_RVSEN &&
Signature · 1 line
2.17.0
Re: [PATCH 4/4] mmc: renesas_sdhi: Fix SCC error detection
Quoted 10 lines · Niklas Söderlund
From: Masaharu Hayakawa <[email protected]>
SDR104 and HS200 need to check SCC error. If SCC error is detected, retuning is necessary.
In addition SCC error checking during retuning is unnecessary.
Signed-off-by Masaharu Hayakawa <[email protected]>[Niklas: fix small style issue]Signed-off-by Niklas Söderlund <[email protected]>
Same here, needs more explanation in the commit message IMO.
Thanks for working on this!