| From foo@baz Thu May 19 04:19:13 PM CEST 2022 |
| From: Florian Fainelli <f.fainelli@gmail.com> |
| Date: Tue, 17 May 2022 11:22:11 -0700 |
| Subject: mmc: core: Default to generic_cmd6_time as timeout in __mmc_switch() |
| To: stable@vger.kernel.org |
| Cc: "Ulf Hansson" <ulf.hansson@linaro.org>, "Florian Fainelli" <f.fainelli@gmail.com>, "Adrian Hunter" <adrian.hunter@intel.com>, "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>, "Avri Altman" <avri.altman@wdc.com>, "Bean Huo" <beanhuo@micron.com>, "Nishad Kamdar" <nishadkamdar@gmail.com>, "Christian Löhle" <CLoehle@hyperstone.com>, linux-mmc@vger.kernel.org (open list:MULTIMEDIA CARD (MMC), SECURE DIGITAL (SD) AND...), linux-kernel@vger.kernel.org (open list), alcooperx@gmail.com, kdasu.kdev@gmail.com |
| Message-ID: <20220517182211.249775-4-f.fainelli@gmail.com> |
| |
| From: Ulf Hansson <ulf.hansson@linaro.org> |
| |
| commit 533a6cfe08f96a7b5c65e06d20916d552c11b256 upstream |
| |
| 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 <ulf.hansson@linaro.org> |
| Link: https://lore.kernel.org/r/20200122142747.5690-4-ulf.hansson@linaro.org |
| Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> |
| Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
| --- |
| drivers/mmc/core/mmc_ops.c | 16 +++++++--------- |
| 1 file changed, 7 insertions(+), 9 deletions(-) |
| |
| --- a/drivers/mmc/core/mmc_ops.c |
| +++ b/drivers/mmc/core/mmc_ops.c |
| @@ -458,10 +458,6 @@ static int mmc_poll_for_busy(struct mmc_ |
| bool expired = false; |
| bool busy = false; |
| |
| - /* We have an unspecified cmd timeout, use the fallback value. */ |
| - if (!timeout_ms) |
| - timeout_ms = MMC_OPS_TIMEOUT_MS; |
| - |
| /* |
| * In cases when not allowed to poll by using CMD13 or because we aren't |
| * capable of polling by using ->card_busy(), then rely on waiting the |
| @@ -534,6 +530,12 @@ int __mmc_switch(struct mmc_card *card, |
| |
| mmc_retune_hold(host); |
| |
| + if (!timeout_ms) { |
| + pr_warn("%s: unspecified timeout for CMD6 - use generic\n", |
| + mmc_hostname(host)); |
| + timeout_ms = card->ext_csd.generic_cmd6_time; |
| + } |
| + |
| /* |
| * If the cmd timeout and the max_busy_timeout of the host are both |
| * specified, let's validate them. A failure means we need to prevent |
| @@ -542,7 +544,7 @@ int __mmc_switch(struct mmc_card *card, |
| * which also means they are on their own when it comes to deal with the |
| * busy timeout. |
| */ |
| - if (!(host->caps & MMC_CAP_NEED_RSP_BUSY) && timeout_ms && |
| + if (!(host->caps & MMC_CAP_NEED_RSP_BUSY) && |
| host->max_busy_timeout && (timeout_ms > host->max_busy_timeout)) |
| use_r1b_resp = false; |
| |
| @@ -554,10 +556,6 @@ int __mmc_switch(struct mmc_card *card, |
| cmd.flags = MMC_CMD_AC; |
| if (use_r1b_resp) { |
| cmd.flags |= MMC_RSP_SPI_R1B | MMC_RSP_R1B; |
| - /* |
| - * A busy_timeout of zero means the host can decide to use |
| - * whatever value it finds suitable. |
| - */ |
| cmd.busy_timeout = timeout_ms; |
| } else { |
| cmd.flags |= MMC_RSP_SPI_R1 | MMC_RSP_R1; |