All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] mmc: {tmio,renesas_sdhi}: fix tuning behavior
@ 2018-06-06 20:47 Niklas Söderlund
  2018-06-06 20:47 ` [PATCH 1/4] mmc: tmio: Fix tuning flow Niklas Söderlund
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Niklas Söderlund @ 2018-06-06 20:47 UTC (permalink / raw)
  To: Wolfram Sang, Ulf Hansson, linux-mmc
  Cc: linux-renesas-soc, Niklas Söderlund

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(-)

-- 
2.17.0

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/4] mmc: tmio: Fix tuning flow
  2018-06-06 20:47 [PATCH 0/4] mmc: {tmio,renesas_sdhi}: fix tuning behavior Niklas Söderlund
@ 2018-06-06 20:47 ` Niklas Söderlund
  2018-06-07  8:46   ` Wolfram Sang
  2018-06-06 20:47 ` [PATCH 2/4] mmc: tmio: Fix SCC error detection Niklas Söderlund
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: Niklas Söderlund @ 2018-06-06 20:47 UTC (permalink / raw)
  To: Wolfram Sang, Ulf Hansson, linux-mmc
  Cc: linux-renesas-soc, Masaharu Hayakawa, Niklas Söderlund

From: Masaharu Hayakawa <masaharu.hayakawa.ry@renesas.com>

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.

Signed-off-by: Masaharu Hayakawa <masaharu.hayakawa.ry@renesas.com>
[Niklas: update commit message]
Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
---
 drivers/mmc/host/tmio_mmc_core.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/mmc/host/tmio_mmc_core.c b/drivers/mmc/host/tmio_mmc_core.c
index 3080299303045adc..e805f84b24a2def8 100644
--- a/drivers/mmc/host/tmio_mmc_core.c
+++ b/drivers/mmc/host/tmio_mmc_core.c
@@ -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);
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/4] mmc: tmio: Fix SCC error detection
  2018-06-06 20:47 [PATCH 0/4] mmc: {tmio,renesas_sdhi}: fix tuning behavior Niklas Söderlund
  2018-06-06 20:47 ` [PATCH 1/4] mmc: tmio: Fix tuning flow Niklas Söderlund
@ 2018-06-06 20:47 ` Niklas Söderlund
  2018-06-07  8:50   ` Wolfram Sang
  2018-06-06 20:47 ` [PATCH 3/4] mmc: renesas_sdhi: Fix sampling clock position selecting Niklas Söderlund
  2018-06-06 20:47 ` [PATCH 4/4] mmc: renesas_sdhi: Fix SCC error detection Niklas Söderlund
  3 siblings, 1 reply; 9+ messages in thread
From: Niklas Söderlund @ 2018-06-06 20:47 UTC (permalink / raw)
  To: Wolfram Sang, Ulf Hansson, linux-mmc
  Cc: linux-renesas-soc, Masaharu Hayakawa, Niklas Söderlund

From: Masaharu Hayakawa <masaharu.hayakawa.ry@renesas.com>

SDR104 and HS200 need to check for SCC error. If SCC error is detected,
retuning is necessary.

Signed-off-by: Masaharu Hayakawa <masaharu.hayakawa.ry@renesas.com>
[Niklas: update commit message]
Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
---
 drivers/mmc/host/tmio_mmc_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/tmio_mmc_core.c b/drivers/mmc/host/tmio_mmc_core.c
index e805f84b24a2def8..c1366df08e59a89b 100644
--- a/drivers/mmc/host/tmio_mmc_core.c
+++ b/drivers/mmc/host/tmio_mmc_core.c
@@ -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) {
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 3/4] mmc: renesas_sdhi: Fix sampling clock position selecting
  2018-06-06 20:47 [PATCH 0/4] mmc: {tmio,renesas_sdhi}: fix tuning behavior Niklas Söderlund
  2018-06-06 20:47 ` [PATCH 1/4] mmc: tmio: Fix tuning flow Niklas Söderlund
  2018-06-06 20:47 ` [PATCH 2/4] mmc: tmio: Fix SCC error detection Niklas Söderlund
@ 2018-06-06 20:47 ` Niklas Söderlund
  2018-06-07  8:58   ` Wolfram Sang
  2018-06-06 20:47 ` [PATCH 4/4] mmc: renesas_sdhi: Fix SCC error detection Niklas Söderlund
  3 siblings, 1 reply; 9+ messages in thread
From: Niklas Söderlund @ 2018-06-06 20:47 UTC (permalink / raw)
  To: Wolfram Sang, Ulf Hansson, linux-mmc
  Cc: linux-renesas-soc, Masaharu Hayakawa, Niklas Söderlund

From: Masaharu Hayakawa <masaharu.hayakawa.ry@renesas.com>

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 <masaharu.hayakawa.ry@renesas.com>
[Niklas: update commit message]
Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
---
 drivers/mmc/host/renesas_sdhi_core.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/mmc/host/renesas_sdhi_core.c b/drivers/mmc/host/renesas_sdhi_core.c
index 45c015da2e757c90..85152e73e6386f1c 100644
--- a/drivers/mmc/host/renesas_sdhi_core.c
+++ b/drivers/mmc/host/renesas_sdhi_core.c
@@ -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
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 4/4] mmc: renesas_sdhi: Fix SCC error detection
  2018-06-06 20:47 [PATCH 0/4] mmc: {tmio,renesas_sdhi}: fix tuning behavior Niklas Söderlund
                   ` (2 preceding siblings ...)
  2018-06-06 20:47 ` [PATCH 3/4] mmc: renesas_sdhi: Fix sampling clock position selecting Niklas Söderlund
@ 2018-06-06 20:47 ` Niklas Söderlund
  2018-06-07  9:19   ` Wolfram Sang
  3 siblings, 1 reply; 9+ messages in thread
From: Niklas Söderlund @ 2018-06-06 20:47 UTC (permalink / raw)
  To: Wolfram Sang, Ulf Hansson, linux-mmc
  Cc: linux-renesas-soc, Masaharu Hayakawa, Niklas Söderlund

From: Masaharu Hayakawa <masaharu.hayakawa.ry@renesas.com>

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 <masaharu.hayakawa.ry@renesas.com>
[Niklas: fix small style issue]
Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
---
 drivers/mmc/host/renesas_sdhi_core.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/mmc/host/renesas_sdhi_core.c b/drivers/mmc/host/renesas_sdhi_core.c
index 85152e73e6386f1c..c5af7a8645f9eea2 100644
--- a/drivers/mmc/host/renesas_sdhi_core.c
+++ b/drivers/mmc/host/renesas_sdhi_core.c
@@ -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 &&
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/4] mmc: tmio: Fix tuning flow
  2018-06-06 20:47 ` [PATCH 1/4] mmc: tmio: Fix tuning flow Niklas Söderlund
@ 2018-06-07  8:46   ` Wolfram Sang
  0 siblings, 0 replies; 9+ messages in thread
From: Wolfram Sang @ 2018-06-07  8:46 UTC (permalink / raw)
  To: Niklas Söderlund
  Cc: Wolfram Sang, Ulf Hansson, linux-mmc, linux-renesas-soc,
	Masaharu Hayakawa

[-- Attachment #1: Type: text/plain, Size: 202 bytes --]


> -		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.


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/4] mmc: tmio: Fix SCC error detection
  2018-06-06 20:47 ` [PATCH 2/4] mmc: tmio: Fix SCC error detection Niklas Söderlund
@ 2018-06-07  8:50   ` Wolfram Sang
  0 siblings, 0 replies; 9+ messages in thread
From: Wolfram Sang @ 2018-06-07  8:50 UTC (permalink / raw)
  To: Niklas Söderlund
  Cc: Wolfram Sang, Ulf Hansson, linux-mmc, linux-renesas-soc,
	Masaharu Hayakawa

[-- Attachment #1: Type: text/plain, Size: 570 bytes --]

On Wed, Jun 06, 2018 at 10:47:22PM +0200, Niklas Söderlund wrote:
> From: Masaharu Hayakawa <masaharu.hayakawa.ry@renesas.com>
> 
> SDR104 and HS200 need to check for SCC error. If SCC error is detected,
> retuning is necessary.
> 
> Signed-off-by: Masaharu Hayakawa <masaharu.hayakawa.ry@renesas.com>
> [Niklas: update commit message]
> Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

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?


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 3/4] mmc: renesas_sdhi: Fix sampling clock position selecting
  2018-06-06 20:47 ` [PATCH 3/4] mmc: renesas_sdhi: Fix sampling clock position selecting Niklas Söderlund
@ 2018-06-07  8:58   ` Wolfram Sang
  0 siblings, 0 replies; 9+ messages in thread
From: Wolfram Sang @ 2018-06-07  8:58 UTC (permalink / raw)
  To: Niklas Söderlund
  Cc: Wolfram Sang, Ulf Hansson, linux-mmc, linux-renesas-soc,
	Masaharu Hayakawa

[-- Attachment #1: Type: text/plain, Size: 615 bytes --]

On Wed, Jun 06, 2018 at 10:47:23PM +0200, Niklas Söderlund wrote:
> From: Masaharu Hayakawa <masaharu.hayakawa.ry@renesas.com>
> 
> 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 <masaharu.hayakawa.ry@renesas.com>
> [Niklas: update commit message]
> Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

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


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 4/4] mmc: renesas_sdhi: Fix SCC error detection
  2018-06-06 20:47 ` [PATCH 4/4] mmc: renesas_sdhi: Fix SCC error detection Niklas Söderlund
@ 2018-06-07  9:19   ` Wolfram Sang
  0 siblings, 0 replies; 9+ messages in thread
From: Wolfram Sang @ 2018-06-07  9:19 UTC (permalink / raw)
  To: Niklas Söderlund
  Cc: Wolfram Sang, Ulf Hansson, linux-mmc, linux-renesas-soc,
	Masaharu Hayakawa

[-- Attachment #1: Type: text/plain, Size: 584 bytes --]

On Wed, Jun 06, 2018 at 10:47:24PM +0200, Niklas Söderlund wrote:
> From: Masaharu Hayakawa <masaharu.hayakawa.ry@renesas.com>
> 
> 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 <masaharu.hayakawa.ry@renesas.com>
> [Niklas: fix small style issue]
> Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

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

Thanks for working on this!


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2018-06-07  9:19 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-06 20:47 [PATCH 0/4] mmc: {tmio,renesas_sdhi}: fix tuning behavior Niklas Söderlund
2018-06-06 20:47 ` [PATCH 1/4] mmc: tmio: Fix tuning flow Niklas Söderlund
2018-06-07  8:46   ` Wolfram Sang
2018-06-06 20:47 ` [PATCH 2/4] mmc: tmio: Fix SCC error detection Niklas Söderlund
2018-06-07  8:50   ` Wolfram Sang
2018-06-06 20:47 ` [PATCH 3/4] mmc: renesas_sdhi: Fix sampling clock position selecting Niklas Söderlund
2018-06-07  8:58   ` Wolfram Sang
2018-06-06 20:47 ` [PATCH 4/4] mmc: renesas_sdhi: Fix SCC error detection Niklas Söderlund
2018-06-07  9:19   ` Wolfram Sang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.