Skip to content

Commit 533a6cf

Browse files
committed
mmc: core: Default to generic_cmd6_time as timeout in __mmc_switch()
All callers of __mmc_switch() should now be specifying a valid timeout for the CMD6 command. However, just to be sure, let's print a warning and default to use the generic_cmd6_time in case the provided timeout_ms argument is zero. In this context, let's also simplify some of the corresponding code and clarify some related comments. Signed-off-by: Ulf Hansson <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent ad91619 commit 533a6cf

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

drivers/mmc/core/mmc_ops.c

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -460,10 +460,6 @@ static int mmc_poll_for_busy(struct mmc_card *card, unsigned int timeout_ms,
460460
bool expired = false;
461461
bool busy = false;
462462

463-
/* We have an unspecified cmd timeout, use the fallback value. */
464-
if (!timeout_ms)
465-
timeout_ms = MMC_OPS_TIMEOUT_MS;
466-
467463
/*
468464
* In cases when not allowed to poll by using CMD13 or because we aren't
469465
* capable of polling by using ->card_busy(), then rely on waiting the
@@ -536,14 +532,19 @@ int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value,
536532

537533
mmc_retune_hold(host);
538534

535+
if (!timeout_ms) {
536+
pr_warn("%s: unspecified timeout for CMD6 - use generic\n",
537+
mmc_hostname(host));
538+
timeout_ms = card->ext_csd.generic_cmd6_time;
539+
}
540+
539541
/*
540-
* If the cmd timeout and the max_busy_timeout of the host are both
541-
* specified, let's validate them. A failure means we need to prevent
542-
* the host from doing hw busy detection, which is done by converting
543-
* to a R1 response instead of a R1B.
542+
* If the max_busy_timeout of the host is specified, make sure it's
543+
* enough to fit the used timeout_ms. In case it's not, let's instruct
544+
* the host to avoid HW busy detection, by converting to a R1 response
545+
* instead of a R1B.
544546
*/
545-
if (timeout_ms && host->max_busy_timeout &&
546-
(timeout_ms > host->max_busy_timeout))
547+
if (host->max_busy_timeout && (timeout_ms > host->max_busy_timeout))
547548
use_r1b_resp = false;
548549

549550
cmd.opcode = MMC_SWITCH;
@@ -554,10 +555,6 @@ int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value,
554555
cmd.flags = MMC_CMD_AC;
555556
if (use_r1b_resp) {
556557
cmd.flags |= MMC_RSP_SPI_R1B | MMC_RSP_R1B;
557-
/*
558-
* A busy_timeout of zero means the host can decide to use
559-
* whatever value it finds suitable.
560-
*/
561558
cmd.busy_timeout = timeout_ms;
562559
} else {
563560
cmd.flags |= MMC_RSP_SPI_R1 | MMC_RSP_R1;

0 commit comments

Comments
 (0)