public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mmc: core: fix dead loop of mmc_retune
@ 2015-09-30  9:37 Chaotian Jing
  2015-09-30 12:01 ` Adrian Hunter
  2015-09-30 13:03 ` Ulf Hansson
  0 siblings, 2 replies; 4+ messages in thread
From: Chaotian Jing @ 2015-09-30  9:37 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Matthias Brugger, Adrian Hunter, Johan Rudholm,
	Javier Martinez Canillas, Shawn Lin, Andrew Gabbasov,
	David Jander, Sascha Hauer, linux-mmc, linux-kernel,
	linux-arm-kernel, linux-mediatek, srv_heupstream, Sascha Hauer,
	Chaotian Jing

When get a CRC error, start the mmc_retune, it will issue CMD19/CMD21
to do tune, assume there were 10 clock phase need to try, phase 0 to
phase 6 is ok, phase 7 to phase 9 is NG, we try it from 0 to 9, so
the last CMD19/CMD21 will get CRC error, host->need_retune was set and
cause mmc_retune was called, then dead loop of mmc_retune

Signed-off-by: Chaotian Jing <chaotian.jing@mediatek.com>
---
 drivers/mmc/core/core.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 0520064..a3eb20b 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -134,9 +134,11 @@ void mmc_request_done(struct mmc_host *host, struct mmc_request *mrq)
 	int err = cmd->error;
 
 	/* Flag re-tuning needed on CRC errors */
-	if (err == -EILSEQ || (mrq->sbc && mrq->sbc->error == -EILSEQ) ||
+	if ((cmd->opcode != MMC_SEND_TUNING_BLOCK &&
+	    cmd->opcode != MMC_SEND_TUNING_BLOCK_HS200) &&
+	    (err == -EILSEQ || (mrq->sbc && mrq->sbc->error == -EILSEQ) ||
 	    (mrq->data && mrq->data->error == -EILSEQ) ||
-	    (mrq->stop && mrq->stop->error == -EILSEQ))
+	    (mrq->stop && mrq->stop->error == -EILSEQ)))
 		mmc_retune_needed(host);
 
 	if (err && cmd->retries && mmc_host_is_spi(host)) {
-- 
1.8.1.1.dirty


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

* Re: [PATCH] mmc: core: fix dead loop of mmc_retune
  2015-09-30  9:37 [PATCH] mmc: core: fix dead loop of mmc_retune Chaotian Jing
@ 2015-09-30 12:01 ` Adrian Hunter
  2015-09-30 12:47   ` Ulf Hansson
  2015-09-30 13:03 ` Ulf Hansson
  1 sibling, 1 reply; 4+ messages in thread
From: Adrian Hunter @ 2015-09-30 12:01 UTC (permalink / raw)
  To: Chaotian Jing, Ulf Hansson
  Cc: Matthias Brugger, Johan Rudholm, Javier Martinez Canillas,
	Shawn Lin, Andrew Gabbasov, David Jander, Sascha Hauer, linux-mmc,
	linux-kernel, linux-arm-kernel, linux-mediatek, srv_heupstream,
	Sascha Hauer

On 30/09/15 12:37, Chaotian Jing wrote:
> When get a CRC error, start the mmc_retune, it will issue CMD19/CMD21
> to do tune, assume there were 10 clock phase need to try, phase 0 to
> phase 6 is ok, phase 7 to phase 9 is NG, we try it from 0 to 9, so
> the last CMD19/CMD21 will get CRC error, host->need_retune was set and
> cause mmc_retune was called, then dead loop of mmc_retune
> 
> Signed-off-by: Chaotian Jing <chaotian.jing@mediatek.com>

Wasn't my idea to have this CRC checking in the core ;-) and sdhci
doesn't put it's tuning commands through a mmc request so it doesn't
see this issue.

But definitely the CRC logic is not meant for the tuning commands, so

Acked-by: Adrian Hunter <adrian.hunter@intel.com>

> ---
>  drivers/mmc/core/core.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
> index 0520064..a3eb20b 100644
> --- a/drivers/mmc/core/core.c
> +++ b/drivers/mmc/core/core.c
> @@ -134,9 +134,11 @@ void mmc_request_done(struct mmc_host *host, struct mmc_request *mrq)
>  	int err = cmd->error;
>  
>  	/* Flag re-tuning needed on CRC errors */
> -	if (err == -EILSEQ || (mrq->sbc && mrq->sbc->error == -EILSEQ) ||
> +	if ((cmd->opcode != MMC_SEND_TUNING_BLOCK &&
> +	    cmd->opcode != MMC_SEND_TUNING_BLOCK_HS200) &&
> +	    (err == -EILSEQ || (mrq->sbc && mrq->sbc->error == -EILSEQ) ||
>  	    (mrq->data && mrq->data->error == -EILSEQ) ||
> -	    (mrq->stop && mrq->stop->error == -EILSEQ))
> +	    (mrq->stop && mrq->stop->error == -EILSEQ)))
>  		mmc_retune_needed(host);
>  
>  	if (err && cmd->retries && mmc_host_is_spi(host)) {
> 


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

* Re: [PATCH] mmc: core: fix dead loop of mmc_retune
  2015-09-30 12:01 ` Adrian Hunter
@ 2015-09-30 12:47   ` Ulf Hansson
  0 siblings, 0 replies; 4+ messages in thread
From: Ulf Hansson @ 2015-09-30 12:47 UTC (permalink / raw)
  To: Adrian Hunter
  Cc: Chaotian Jing, Matthias Brugger, Johan Rudholm,
	Javier Martinez Canillas, Shawn Lin, Andrew Gabbasov,
	David Jander, Sascha Hauer, linux-mmc,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, linux-mediatek,
	srv_heupstream, Sascha Hauer

On 30 September 2015 at 14:01, Adrian Hunter <adrian.hunter@intel.com> wrote:
> On 30/09/15 12:37, Chaotian Jing wrote:
>> When get a CRC error, start the mmc_retune, it will issue CMD19/CMD21
>> to do tune, assume there were 10 clock phase need to try, phase 0 to
>> phase 6 is ok, phase 7 to phase 9 is NG, we try it from 0 to 9, so
>> the last CMD19/CMD21 will get CRC error, host->need_retune was set and
>> cause mmc_retune was called, then dead loop of mmc_retune
>>
>> Signed-off-by: Chaotian Jing <chaotian.jing@mediatek.com>
>
> Wasn't my idea to have this CRC checking in the core ;-) and sdhci
> doesn't put it's tuning commands through a mmc request so it doesn't
> see this issue.

That's not true for all sdhci variants. For those that uses sdhci's
->platform_execute_tuning() callback, all uses mmc_send_tuning().

I think for sdhci's default tuning path, we should change to use
mmc_send_tuning() and thus we would potentially hit this problem as
well.

>
> But definitely the CRC logic is not meant for the tuning commands, so
>
> Acked-by: Adrian Hunter <adrian.hunter@intel.com>

Thanks for reviewing Adrian and for keeping an eye on "tuning" related patches.

Kind regards
Uffe

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

* Re: [PATCH] mmc: core: fix dead loop of mmc_retune
  2015-09-30  9:37 [PATCH] mmc: core: fix dead loop of mmc_retune Chaotian Jing
  2015-09-30 12:01 ` Adrian Hunter
@ 2015-09-30 13:03 ` Ulf Hansson
  1 sibling, 0 replies; 4+ messages in thread
From: Ulf Hansson @ 2015-09-30 13:03 UTC (permalink / raw)
  To: Chaotian Jing
  Cc: Matthias Brugger, Adrian Hunter, Johan Rudholm,
	Javier Martinez Canillas, Shawn Lin, Andrew Gabbasov,
	David Jander, Sascha Hauer, linux-mmc,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, linux-mediatek,
	srv_heupstream, Sascha Hauer

On 30 September 2015 at 11:37, Chaotian Jing <chaotian.jing@mediatek.com> wrote:
> When get a CRC error, start the mmc_retune, it will issue CMD19/CMD21
> to do tune, assume there were 10 clock phase need to try, phase 0 to
> phase 6 is ok, phase 7 to phase 9 is NG, we try it from 0 to 9, so
> the last CMD19/CMD21 will get CRC error, host->need_retune was set and
> cause mmc_retune was called, then dead loop of mmc_retune
>
> Signed-off-by: Chaotian Jing <chaotian.jing@mediatek.com>

Thanks Chaotian!

I have applied this for fixes and added the following tag:

Fixes: bd11e8bd03ca ("mmc: core: Flag re-tuning is needed on CRC errors")

Kind regards
Uffe

> ---
>  drivers/mmc/core/core.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
> index 0520064..a3eb20b 100644
> --- a/drivers/mmc/core/core.c
> +++ b/drivers/mmc/core/core.c
> @@ -134,9 +134,11 @@ void mmc_request_done(struct mmc_host *host, struct mmc_request *mrq)
>         int err = cmd->error;
>
>         /* Flag re-tuning needed on CRC errors */
> -       if (err == -EILSEQ || (mrq->sbc && mrq->sbc->error == -EILSEQ) ||
> +       if ((cmd->opcode != MMC_SEND_TUNING_BLOCK &&
> +           cmd->opcode != MMC_SEND_TUNING_BLOCK_HS200) &&
> +           (err == -EILSEQ || (mrq->sbc && mrq->sbc->error == -EILSEQ) ||
>             (mrq->data && mrq->data->error == -EILSEQ) ||
> -           (mrq->stop && mrq->stop->error == -EILSEQ))
> +           (mrq->stop && mrq->stop->error == -EILSEQ)))
>                 mmc_retune_needed(host);
>
>         if (err && cmd->retries && mmc_host_is_spi(host)) {
> --
> 1.8.1.1.dirty
>

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

end of thread, other threads:[~2015-09-30 13:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-30  9:37 [PATCH] mmc: core: fix dead loop of mmc_retune Chaotian Jing
2015-09-30 12:01 ` Adrian Hunter
2015-09-30 12:47   ` Ulf Hansson
2015-09-30 13:03 ` Ulf Hansson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox