]> git.baikalelectronics.ru Git - kernel.git/commitdiff
mmc: core: Update CMD13 busy check for CMD6 commands
authorUlf Hansson <ulf.hansson@linaro.org>
Tue, 4 Feb 2020 08:54:44 +0000 (09:54 +0100)
committerUlf Hansson <ulf.hansson@linaro.org>
Tue, 24 Mar 2020 13:35:39 +0000 (14:35 +0100)
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>
Tested-by: Baolin Wang <baolin.wang7@gmail.com>
Tested-by: Ludovic Barre <ludovic.barre@st.com>
Reviewed-by: Ludovic Barre <ludovic.barre@st.com>
Link: https://lore.kernel.org/r/20200204085449.32585-8-ulf.hansson@linaro.org
drivers/mmc/core/mmc_ops.c

index 3bb337a399f955aa581e83e8d39bb0d297eac408..4566f43305d565763456981080ee9c656ec12b8d 100644 (file)
@@ -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;
 }