From feb6da4129a65bdcee141dd8c557cf6bd0f35b75 Mon Sep 17 00:00:00 2001 From: Ziyuan Xu Date: Sat, 15 May 2021 16:31:49 +0800 Subject: [PATCH] mmc: block: prefer the host's capability(card_busy) than send_status According to the specification, the controller should check the device status before data transport. Generally, it can get the status of device via CMD13. It's upset that command communication will produce a little interrupt inside the controller. To avoid interrupt storm whilst heavily I/O request, use card_busy instead of send_status(CMD13). Signed-off-by: Ziyuan Xu Change-Id: I3ba79ba2f563006112b0157b78aab5b31911b61a --- drivers/mmc/core/block.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index 52c98d655979..1d7138059136 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -458,16 +458,22 @@ static int card_busy_detect(struct mmc_card *card, unsigned int timeout_ms, do { bool done = time_after(jiffies, timeout); - err = __mmc_send_status(card, &status, 5); - if (err) { - dev_err(mmc_dev(card->host), - "error %d requesting status\n", err); - return err; - } + if (card->host->ops->card_busy) { + status = card->host->ops->card_busy(card->host) ? + 0 : R1_READY_FOR_DATA | R1_STATE_TRAN << 9; + usleep_range(100, 150); + } else { + err = __mmc_send_status(card, &status, 5); + if (err) { + dev_err(mmc_dev(card->host), + "error %d requesting status\n", err); + return err; + } - /* Accumulate any response error bits seen */ - if (resp_errs) - *resp_errs |= status; + /* Accumulate any response error bits seen */ + if (resp_errs) + *resp_errs |= status; + } /* * Timeout if the device never becomes ready for data and never