Skip to content

Commit 39c9af3

Browse files
committed
mmc: Speed up reboot with an absent card
On devices with no card detect mechanism, the host ends up polling for the insertion of a card. This polling happens at multiple frequencies and with many steps (SDIO, SD, MMC), some of which involve timeouts. If a reboot is requested during one of those scans, it will stall, pointlessly, for up to a minute while it completes. Attempt to short circuit the rescan if the MMC interface is being removed. Signed-off-by: Phil Elwell <phil@raspberrypi.com>
1 parent 18a5b4e commit 39c9af3

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

drivers/mmc/core/core.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,10 +399,16 @@ void mmc_wait_for_req_done(struct mmc_host *host, struct mmc_request *mrq)
399399
struct mmc_command *cmd;
400400

401401
while (1) {
402-
wait_for_completion(&mrq->completion);
402+
if (!host->rescan_disable)
403+
wait_for_completion(&mrq->completion);
403404

404405
cmd = mrq->cmd;
405406

407+
if (host->rescan_disable) {
408+
cmd->error = -ENOENT;
409+
break;
410+
}
411+
406412
if (!cmd->error || !cmd->retries ||
407413
mmc_card_removed(host->card))
408414
break;
@@ -619,6 +625,11 @@ EXPORT_SYMBOL(mmc_is_req_done);
619625
*/
620626
void mmc_wait_for_req(struct mmc_host *host, struct mmc_request *mrq)
621627
{
628+
if (host->rescan_disable) {
629+
mrq->cmd->error = -ENOENT;
630+
return;
631+
}
632+
622633
__mmc_start_req(host, mrq);
623634

624635
if (!mrq->cap_cmd_during_tfr)
@@ -2265,6 +2276,8 @@ void mmc_rescan(struct work_struct *work)
22652276

22662277
for (i = 0; i < ARRAY_SIZE(freqs); i++) {
22672278
unsigned int freq = freqs[i];
2279+
if (host->rescan_disable)
2280+
return;
22682281
if (freq > host->f_max) {
22692282
if (i + 1 < ARRAY_SIZE(freqs))
22702283
continue;

drivers/mmc/core/mmc_ops.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,9 @@ int __mmc_poll_for_busy(struct mmc_host *host, unsigned int period_us,
512512

513513
timeout = jiffies + msecs_to_jiffies(timeout_ms) + 1;
514514
do {
515+
if (host->rescan_disable)
516+
return -ENOENT;
517+
515518
/*
516519
* Due to the possibility of being preempted while polling,
517520
* check the expiration time first.

drivers/mmc/core/sdio.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,10 @@ static int mmc_sdio_init_card(struct mmc_host *host, u32 ocr,
673673
ocr |= R4_18V_PRESENT;
674674

675675
try_again:
676+
if (host->rescan_disable) {
677+
err = -ENOENT;
678+
goto remove;
679+
}
676680
if (!retries) {
677681
pr_warn("%s: Skipping voltage switch\n", mmc_hostname(host));
678682
ocr &= ~R4_18V_PRESENT;

0 commit comments

Comments
 (0)