Skip to contentSkip to conversation

mmc: {tmio,renesas_sdhi}: fix tuning behavior

PATCH Superseded Niklas Söderlund 2 participants 9 messages Jun 6, 2018 – Jun 7, 2018

Subsystems (2)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

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
#1 lore raw

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.

[Niklas: update commit message]
---
 drivers/mmc/host/tmio_mmc_core.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/mmc/host/tmio_mmc_core.c +1 -4
index 3080299303045adc..e805f84b24a2def8 100644
@@ -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
#2 lore raw

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.

#3 lore raw

PATCH 2/4 mmc: tmio: Fix SCC error detection

In reply to 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.

[Niklas: update commit message]
---
 drivers/mmc/host/tmio_mmc_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/host/tmio_mmc_core.c +2 -2
index e805f84b24a2def8..c1366df08e59a89b 100644
@@ -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
#4 lore raw

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.

[Niklas: update commit message]

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?

#5 lore raw

PATCH 3/4 mmc: renesas_sdhi: Fix sampling clock position selecting

In reply to 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.

[Niklas: update commit message]
---
 drivers/mmc/host/renesas_sdhi_core.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/mmc/host/renesas_sdhi_core.c +9 -0
index 45c015da2e757c90..85152e73e6386f1c 100644
@@ -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
#6 lore raw

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.

[Niklas: update commit message]

As mentioned on IRC, I think this needs an updated patch description IMHO.

#7 lore raw

PATCH 4/4 mmc: renesas_sdhi: Fix SCC error detection

In reply to 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.

[Niklas: fix small style issue]
---
 drivers/mmc/host/renesas_sdhi_core.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/mmc/host/renesas_sdhi_core.c +7 -0
index 85152e73e6386f1c..c5af7a8645f9eea2 100644
@@ -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
#8 lore raw

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.

[Niklas: fix small style issue]

Same here, needs more explanation in the commit message IMO.

Thanks for working on this!