All of lore.kernel.org
 help / color / mirror / Atom feed
From: Shawn Lin <shawn.lin@rock-chips.com>
To: "Christian Löhle" <CLoehle@hyperstone.com>,
	"Ulf Hansson" <ulf.hansson@linaro.org>
Cc: shawn.lin@rock-chips.com,
	"linux-mmc@vger.kernel.org" <linux-mmc@vger.kernel.org>
Subject: Re: [PATCH] mmc: block: Use .card_busy() to detect busy state in card_busy_detect
Date: Tue, 8 Jun 2021 14:58:52 +0800	[thread overview]
Message-ID: <73d27461-ba9f-1a90-0401-4ce0cf59ac30@rock-chips.com> (raw)
In-Reply-To: <CWXP265MB2680A140D951939931D1729BC4379@CWXP265MB2680.GBRP265.PROD.OUTLOOK.COM>

Hi Christian

On 2021/6/8 14:28, Christian Löhle wrote:
> Hey Shawn,
> You're assuming a card not signalling busy indicates TRAN state, and set the state manually,
> but a card might not be pulling DAT lines in PROG state.

Refer to JESD84-B51 for emmc spec, section 6.5.13 clearly says that. And
SD spec V4 also has a similar statement in section 4.3.4.

So I guess if that was the case you point out, most of all operations in
mmc_ops.c would suffer from this.


> I will send a patch later that reworks card_busy_detect, as there are some issues
> with some command sequences in practice. I'd ask to wait with the patch until then.
> 
> Regards,
> Christian
> 
> 
> From: Shawn Lin <shawn.lin@rock-chips.com>
> Sent: Monday, June 7, 2021 11:18 AM
> To: Ulf Hansson <ulf.hansson@linaro.org>
> Cc: linux-mmc@vger.kernel.org <linux-mmc@vger.kernel.org>; Shawn Lin <shawn.lin@rock-chips.com>
> Subject: [PATCH] mmc: block: Use .card_busy() to detect busy state in card_busy_detect
>   
> No need to send CMD13 if host driver supports .card_busy().
> 
> Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
> ---
> 
>   drivers/mmc/core/block.c | 8 ++++++++
>   1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
> index 88f4c215..23623a9 100644
> --- a/drivers/mmc/core/block.c
> +++ b/drivers/mmc/core/block.c
> @@ -417,10 +417,17 @@ static int card_busy_detect(struct mmc_card *card, unsigned int timeout_ms,
>           unsigned long timeout = jiffies + msecs_to_jiffies(timeout_ms);
>           int err = 0;
>           u32 status;
> +       bool busy;
>   
>           do {
>                   bool done = time_after(jiffies, timeout);
>   
> +               if (card->host->ops->card_busy) {
> +                       busy = card->host->ops->card_busy(card->host);
> +                       status = busy ? 0 : R1_READY_FOR_DATA | R1_STATE_TRAN << 9;
> +                       goto cb;
> +               }
> +
>                   err = __mmc_send_status(card, &status, 5);
>                   if (err) {
>                           dev_err(mmc_dev(card->host),
> @@ -442,6 +449,7 @@ static int card_busy_detect(struct mmc_card *card, unsigned int timeout_ms,
>                                    __func__, status);
>                           return -ETIMEDOUT;
>                   }
> +cb:
>           } while (!mmc_ready_for_data(status));
>   
>           return err;
> 



  reply	other threads:[~2021-06-08  6:58 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-07  9:18 [PATCH] mmc: block: Use .card_busy() to detect busy state in card_busy_detect Shawn Lin
2021-06-07 13:28 ` kernel test robot
2021-06-07 13:28   ` kernel test robot
2021-06-07 14:03 ` kernel test robot
2021-06-07 14:03   ` kernel test robot
2021-06-07 14:28 ` kernel test robot
2021-06-07 14:28   ` kernel test robot
2021-06-08  6:28 ` Christian Löhle
2021-06-08  6:58   ` Shawn Lin [this message]
2021-06-08  7:51     ` Christian Löhle

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=73d27461-ba9f-1a90-0401-4ce0cf59ac30@rock-chips.com \
    --to=shawn.lin@rock-chips.com \
    --cc=CLoehle@hyperstone.com \
    --cc=linux-mmc@vger.kernel.org \
    --cc=ulf.hansson@linaro.org \
    /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 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.