linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ulf Hansson <ulf.hansson@linaro.org>
To: Adrian Hunter <adrian.hunter@intel.com>
Cc: linux-mmc <linux-mmc@vger.kernel.org>,
	Jaehoon Chung <jh80.chung@samsung.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Chaotian Jing <chaotian.jing@mediatek.com>,
	Stephen Boyd <sboyd@codeaurora.org>,
	Michael Walle <michael@walle.cc>,
	Yong Mao <yong.mao@mediatek.com>,
	Shawn Lin <shawn.lin@rock-chips.com>
Subject: Re: [PATCH 7/9] mmc: core: Allow CMD13 polling when switch to HS200 mode
Date: Thu, 17 Nov 2016 16:02:43 +0100	[thread overview]
Message-ID: <CAPDyKFrDP_K_muRArcNrMGBeTLB_XWawcMc9yb82k4cdd8z0eQ@mail.gmail.com> (raw)
In-Reply-To: <e003f72a-6084-eb1a-6b44-c6a11d93b3ae@intel.com>

On 17 November 2016 at 11:23, Adrian Hunter <adrian.hunter@intel.com> wrote:
> On 16/11/16 12:51, Ulf Hansson wrote:
>> In cases when the mmc host doesn't support HW busy detection, polling for
>> busy by using CMD13 is beneficial. The reasons have already been explained
>> in earlier change logs.
>>
>> To allow polling with CMD13, let's provide MMC_TIMING_MMC_HS200 as the
>> timing parameter to __mmc_switch(), which makes sure the mmc host and the
>> mmc card operates at the same bus timing during the polling.
>
> I have reports of cases where CMD13 always gives CRC errors after switch
> to HS200.  Currently we are assuming the low frequency should mean that
> won't happen, but it does in some cases.  That is not entirely surprising
> since HS200 needs tuning at the final operating frequency.

>From a logical point of view and if tuning is needed also for the CMD
line, this somehow make sense.

However, this is *not* how the JEDEC spec describes the HS200 switch
sequence. It is clearly stated that the host should validate the CM6
status via sending a CMD13 command, *before* performing tuning.

Could it be that the observations about the CRC errors, is related to
a controller/driver issue and not a card issue?

>
> What I would like to do for hosts that support busy waiting or DAT0 polling
> (i.e. MMC_CAP_WAIT_WHILE_BUSY or host->ops->card_busy), is to ignore CRC
> errors from the CMD13 that checks the switch status.  The main reason for
> doing that is that we really expect the switch to succeed and, given HS200
> tuning requirement, the CRC error is not a reliable means of determining
> that it hasn't.

Hmm. So what you are saying is that CMD13 polling for HS200 doesn't
work, as tuning is needed.

So, to me that means we need to fall-back to use the generic CMD6
timeout instead (when HW busy detection isn't supported).

>
> With the existing code I would just change the err check:
>
>
> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
> index 3268fcd3378d..c8862c58b60b 100644
> --- a/drivers/mmc/core/mmc.c
> +++ b/drivers/mmc/core/mmc.c
> @@ -1387,6 +1387,13 @@ static int mmc_select_hs200(struct mmc_card *card)
>
>                 err = mmc_switch_status(card);
>                 /*
> +                * For HS200, CRC errors are not a reliable way to know the
> +                * switch failed. If there really is a problem, we would expect
> +                * tuning will fail and the result ends up the same.
> +                */
> +               if (err == -EILSEQ)
> +                       err = 0;
> +               /*

I don't think ignoring CRC errors is reliable when verifying the CMD6
status. My point is that we must not parse the status, in case of CRC
errors as it can't be trusted.

So, then we might as well just ignore validating the CMD6 status
altogether, but instead always move on to the tuning and hope that it
succeeds.

I think the CMD21 (tuning) should set the ILLEGAL COMMAND if HS200
mode isn't enabled, so we could check that. Anyway, we should fail
with the tuning if the earlier HS200 switch also failed. Don't you
think?

>                  * mmc_select_timing() assumes timing has not changed if
>                  * it is a switch error.
>                  */
>
>
> Then to support polling:
>
>
> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
> index c8862c58b60b..66d8d57ae2fb 100644
> --- a/drivers/mmc/core/mmc.c
> +++ b/drivers/mmc/core/mmc.c
> @@ -1352,6 +1352,7 @@ static int mmc_select_hs200(struct mmc_card *card)
>  {
>         struct mmc_host *host = card->host;
>         unsigned int old_timing, old_signal_voltage;
> +       bool send_status;
>         int err = -EINVAL;
>         u8 val;
>
> @@ -1373,18 +1374,20 @@ static int mmc_select_hs200(struct mmc_card *card)
>          * switch to HS200 mode if bus width is set successfully.
>          */
>         err = mmc_select_bus_width(card);
> -       if (err > 0) {
> -               val = EXT_CSD_TIMING_HS200 |
> -                     card->drive_strength << EXT_CSD_DRV_STR_SHIFT;
> -               err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
> -                                  EXT_CSD_HS_TIMING, val,
> -                                  card->ext_csd.generic_cmd6_time, 0,
> -                                  true, false, true);
> -               if (err)
> -                       goto err;
> -               old_timing = host->ios.timing;
> -               mmc_set_timing(host, MMC_TIMING_MMC_HS200);
> +       if (err <= 0)
> +               goto err;
> +
> +       send_status = !(host->caps & MMC_CAP_WAIT_WHILE_BUSY) &&
> +                     !host->ops->card_busy;
> +       old_timing = host->ios.timing;
> +
> +       val = EXT_CSD_TIMING_HS200 |
> +             card->drive_strength << EXT_CSD_DRV_STR_SHIFT;
> +       err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_HS_TIMING, val,
> +                          card->ext_csd.generic_cmd6_time,
> +                          MMC_TIMING_MMC_HS200, true, send_status, true);
>
> +       if (!err && !send_status) {
>                 err = mmc_switch_status(card);
>                 /*
>                  * For HS200, CRC errors are not a reliable way to know the
>
>
>
> Thoughts?

Well, I think the main problem is that if we have cards that returns
CRC errors even after the HS200 switch, then we can't use polling, as
we can't trust to parse the CMD6 status.

Kind regards
Uffe

  reply	other threads:[~2016-11-17 17:46 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-16 10:51 [PATCH 0/9] mmc: core: Re-work CMD13 polling method for CMD6 for mmc Ulf Hansson
2016-11-16 10:51 ` [PATCH 1/9] mmc: core: Retry instead of ignore at CRC errors when polling for busy Ulf Hansson
2016-11-16 10:51 ` [PATCH 2/9] mmc: core: Remove redundant __mmc_send_status() Ulf Hansson
2016-11-16 10:51 ` [PATCH 3/9] mmc: core: Rename ignore_crc to retry_crc_err to reflect its purpose Ulf Hansson
2016-11-16 10:51 ` [PATCH 4/9] mmc: core: Enable __mmc_switch() to change bus speed timing for the host Ulf Hansson
2016-11-16 10:51 ` [PATCH 5/9] mmc: core: Allow CMD13 polling when switching to HS mode for mmc Ulf Hansson
2016-11-16 10:51 ` [PATCH 6/9] mmc: core: Update CMD13 polling policy when switch to HS DDR mode Ulf Hansson
2016-11-16 10:51 ` [PATCH 7/9] mmc: core: Allow CMD13 polling when switch to HS200 mode Ulf Hansson
2016-11-17 10:23   ` Adrian Hunter
2016-11-17 15:02     ` Ulf Hansson [this message]
2016-11-18  9:30       ` Adrian Hunter
2016-11-18 12:20         ` Ulf Hansson
2016-11-18 12:32           ` Adrian Hunter
2016-11-18 13:16             ` Ulf Hansson
2016-11-18  8:05   ` Shawn Lin
2016-11-18 11:45     ` Ulf Hansson
2016-11-23  1:24       ` Shawn Lin
2016-11-16 10:51 ` [PATCH 8/9] mmc: core: Allow CMD13 polling when switch to HS400 mode Ulf Hansson
2016-11-18 12:02   ` Adrian Hunter
2016-11-18 12:59     ` Ulf Hansson
2016-11-16 10:51 ` [PATCH 9/9] mmc: core: Allow CMD13 polling when switch to HS400ES mode Ulf Hansson
2016-11-18 13:35   ` Adrian Hunter
2016-11-18 14:37     ` Ulf Hansson
2016-11-18 14:43       ` Adrian Hunter
2016-11-17  9:06 ` [PATCH 0/9] mmc: core: Re-work CMD13 polling method for CMD6 for mmc Linus Walleij

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAPDyKFrDP_K_muRArcNrMGBeTLB_XWawcMc9yb82k4cdd8z0eQ@mail.gmail.com \
    --to=ulf.hansson@linaro.org \
    --cc=adrian.hunter@intel.com \
    --cc=chaotian.jing@mediatek.com \
    --cc=jh80.chung@samsung.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=michael@walle.cc \
    --cc=sboyd@codeaurora.org \
    --cc=shawn.lin@rock-chips.com \
    --cc=yong.mao@mediatek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).