linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ulf Hansson <ulf.hansson@linaro.org>
To: linux-mmc@vger.kernel.org, Ulf Hansson <ulf.hansson@linaro.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>,
	Wolfram Sang <wsa+renesas@sang-engineering.com>,
	Ludovic Barre <ludovic.barre@st.com>,
	Baolin Wang <baolin.wang7@gmail.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Chaotian Jing <chaotian.jing@mediatek.com>,
	Shawn Lin <shawn.lin@rock-chips.com>,
	mirq-linux@rere.qmqm.pl
Subject: [PATCH 07/12] mmc: core: Update CMD13 busy check for CMD6 commands
Date: Tue,  4 Feb 2020 09:54:44 +0100	[thread overview]
Message-ID: <20200204085449.32585-8-ulf.hansson@linaro.org> (raw)
In-Reply-To: <20200204085449.32585-1-ulf.hansson@linaro.org>

Through mmc_poll_for_busy() a CMD13 may be sent to get the status of the
(e)MMC card. If the state of the card is R1_STATE_PRG, the card is
considered as being busy, which means we continue to poll with CMD13. This
seems to be sufficient, but it's also unnecessary fragile, as it means a
new command/request could potentially be sent to the card when it's in an
unknown state.

To try to improve the situation, but also to move towards a more consistent
CMD13 polling behaviour in the mmc core, let's deploy the same policy we
use for regular I/O write requests. In other words, let's check that card
returns to the R1_STATE_TRAN and that the R1_READY_FOR_DATA bit is set in
the CMD13 response, before exiting the polling loop.

Note that, potentially this changed behaviour could lead to unnecessary
waiting for the timeout to expire, if the card for some reason, moves to an
unexpected error state. However, as we bail out from the polling loop when
R1_SWITCH_ERROR bit is set or when the CMD13 fails, this shouldn't be an
issue.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
 drivers/mmc/core/mmc_ops.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
index c17b13aacc6e..c14e24570b4e 100644
--- a/drivers/mmc/core/mmc_ops.c
+++ b/drivers/mmc/core/mmc_ops.c
@@ -468,7 +468,7 @@ static int mmc_busy_status(struct mmc_card *card, bool retry_crc_err,
 	if (err)
 		return err;
 
-	*busy = R1_CURRENT_STATE(status) == R1_STATE_PRG;
+	*busy = !mmc_ready_for_data(status);
 	return 0;
 }
 
-- 
2.17.1


  parent reply	other threads:[~2020-02-04  8:55 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-04  8:54 [PATCH 00/12] mmc: core: Improve code for polling and HW busy detect Ulf Hansson
2020-02-04  8:54 ` [PATCH 01/12] mmc: core: Throttle polling rate for CMD6 Ulf Hansson
2020-02-12 13:51   ` Ludovic BARRE
2020-02-12 14:18     ` Ulf Hansson
2020-02-12 14:24       ` Ludovic BARRE
2020-02-04  8:54 ` [PATCH 02/12] mmc: core: Drop unused define Ulf Hansson
2020-02-04  8:54 ` [PATCH 03/12] mmc: core: Extend mmc_switch_status() to rid of __mmc_switch_status() Ulf Hansson
2020-02-04  8:54 ` [PATCH 04/12] mmc: core: Drop redundant in-parameter to __mmc_switch() Ulf Hansson
2020-02-04  8:54 ` [PATCH 05/12] mmc: core: Split up mmc_poll_for_busy() Ulf Hansson
2020-02-04  8:54 ` [PATCH 06/12] mmc: core: Enable re-use of mmc_blk_in_tran_state() Ulf Hansson
2020-02-04  8:54 ` Ulf Hansson [this message]
2020-02-04  8:54 ` [PATCH 08/12] mmc: core: Convert to mmc_poll_for_busy() for erase/trim/discard Ulf Hansson
2020-02-04  8:54 ` [PATCH 09/12] mmc: core: Drop redundant out-parameter to mmc_send_hpi_cmd() Ulf Hansson
2020-02-04  8:54 ` [PATCH 10/12] mmc: core: Convert to mmc_poll_for_busy() for HPI commands Ulf Hansson
2020-02-04  8:54 ` [PATCH 11/12] mmc: core: Fixup support for HW busy detection " Ulf Hansson
2020-02-04  8:54 ` [PATCH 12/12] mmc: core: Re-work the error path for the eMMC sanitize command Ulf Hansson
2020-02-11 22:29   ` kbuild test robot
2020-02-11 13:17 ` [PATCH 00/12] mmc: core: Improve code for polling and HW busy detect Baolin Wang
2020-02-13  6:23   ` Baolin Wang
2020-02-13 11:08     ` Ulf Hansson
2020-02-13 14:42     ` Ludovic BARRE
2020-02-14 14:21       ` Ulf Hansson
2020-02-18 23:38 ` Ulf Hansson

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=20200204085449.32585-8-ulf.hansson@linaro.org \
    --to=ulf.hansson@linaro.org \
    --cc=adrian.hunter@intel.com \
    --cc=baolin.wang7@gmail.com \
    --cc=chaotian.jing@mediatek.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=ludovic.barre@st.com \
    --cc=mirq-linux@rere.qmqm.pl \
    --cc=shawn.lin@rock-chips.com \
    --cc=wsa+renesas@sang-engineering.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).