From patchwork Sat Jan 11 16:08:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Johnson X-Patchwork-Id: 239467 List-Id: U-Boot discussion From: mrjoel at lixil.net (Joel Johnson) Date: Sat, 11 Jan 2020 09:08:14 -0700 Subject: [PATCH 1/2] mmc: add additional quirk for APP_CMD retry Message-ID: <20200111160815.2152-1-mrjoel@lixil.net> It was observed (on ClearFog Base) that sending MMC APP_CMD returned an error on the first attempt. The issue appears to be timing related since even inserting a puts() short debug entry before the execution added sufficient delay to receive success on first attempt. Follow the existing quirks pattern to retry if initial issuance failed so as to not introduce any delay unless needed. Signed-off-by: Joel Johnson --- drivers/mmc/mmc.c | 17 ++++++++++++++++- include/mmc.h | 1 + 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index f683b52ead..d43983d4a6 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -1444,6 +1444,20 @@ static int sd_read_ssr(struct mmc *mmc) cmd.cmdarg = mmc->rca << 16; err = mmc_send_cmd(mmc, &cmd, NULL); +#ifdef CONFIG_MMC_QUIRKS + if (err && (mmc->quirks & MMC_QUIRK_RETRY_APP_CMD)) { + int retries = 4; + /* + * It has been seen that APP_CMD may fail on the first + * attempt, let's try a few more times + */ + do { + err = mmc_send_cmd(mmc, &cmd, NULL); + if (!err) + break; + } while (retries--); + } +#endif if (err) return err; @@ -2755,7 +2769,8 @@ int mmc_get_op_cond(struct mmc *mmc) #ifdef CONFIG_MMC_QUIRKS mmc->quirks = MMC_QUIRK_RETRY_SET_BLOCKLEN | - MMC_QUIRK_RETRY_SEND_CID; + MMC_QUIRK_RETRY_SEND_CID | + MMC_QUIRK_RETRY_APP_CMD; #endif err = mmc_power_cycle(mmc); diff --git a/include/mmc.h b/include/mmc.h index 1a9efe4c38..b5cb514f57 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -331,6 +331,7 @@ static inline bool mmc_is_tuning_cmd(uint cmdidx) #define MMC_QUIRK_RETRY_SEND_CID BIT(0) #define MMC_QUIRK_RETRY_SET_BLOCKLEN BIT(1) +#define MMC_QUIRK_RETRY_APP_CMD BIT(2) enum mmc_voltage { MMC_SIGNAL_VOLTAGE_000 = 0, From patchwork Sat Jan 11 16:08:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Johnson X-Patchwork-Id: 239466 List-Id: U-Boot discussion From: mrjoel at lixil.net (Joel Johnson) Date: Sat, 11 Jan 2020 09:08:15 -0700 Subject: [PATCH 2/2] mmc: config help typo fix In-Reply-To: <20200111160815.2152-1-mrjoel@lixil.net> References: <20200111160815.2152-1-mrjoel@lixil.net> Message-ID: <20200111160815.2152-2-mrjoel@lixil.net> Fix typo in description of MMC_QUIRKS config option. Signed-off-by: Joel Johnson --- drivers/mmc/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig index 85fd1906bd..5696ef0339 100644 --- a/drivers/mmc/Kconfig +++ b/drivers/mmc/Kconfig @@ -79,7 +79,7 @@ config MMC_QUIRKS help Some cards and hosts may sometimes behave unexpectedly (quirks). This option enable workarounds to handle those quirks. Some of them - are enabled by default, other may require additionnal flags or are + are enabled by default, other may require additional flags or are enabled by the host driver. config MMC_HW_PARTITIONING