linux-stable/drivers/mmc/core
Brian Norris 4bc31edebd mmc: core: Set HS clock speed before sending HS CMD13
Way back in commit 4f25580fb8 ("mmc: core: changes frequency to
hs_max_dtr when selecting hs400es"), Rockchip engineers noticed that
some eMMC don't respond to SEND_STATUS commands very reliably if they're
still running at a low initial frequency. As mentioned in that commit,
JESD84-B51 P49 suggests a sequence in which the host:
1. sets HS_TIMING
2. bumps the clock ("<= 52 MHz")
3. sends further commands

It doesn't exactly require that we don't use a lower-than-52MHz
frequency, but in practice, these eMMC don't like it.

The aforementioned commit tried to get that right for HS400ES, although
it's unclear whether this ever truly worked as committed into mainline,
as other changes/refactoring adjusted the sequence in conflicting ways:

08573eaf1a ("mmc: mmc: do not use CMD13 to get status after speed mode
switch")

53e60650f7 ("mmc: core: Allow CMD13 polling when switching to HS mode
for mmc")

In any case, today we do step 3 before step 2. Let's fix that, and also
apply the same logic to HS200/400, where this eMMC has problems too.

Resolves errors like this seen when booting some RK3399 Gru/Scarlet
systems:

[    2.058881] mmc1: CQHCI version 5.10
[    2.097545] mmc1: SDHCI controller on fe330000.mmc [fe330000.mmc] using ADMA
[    2.209804] mmc1: mmc_select_hs400es failed, error -84
[    2.215597] mmc1: error -84 whilst initialising MMC card
[    2.417514] mmc1: mmc_select_hs400es failed, error -110
[    2.423373] mmc1: error -110 whilst initialising MMC card
[    2.605052] mmc1: mmc_select_hs400es failed, error -110
[    2.617944] mmc1: error -110 whilst initialising MMC card
[    2.835884] mmc1: mmc_select_hs400es failed, error -110
[    2.841751] mmc1: error -110 whilst initialising MMC card

Ealier versions of this patch bumped to 200MHz/HS200 speeds too early,
which caused issues on, e.g., qcom-msm8974-fairphone-fp2. (Thanks for
the report Luca!) After a second look, it appears that aligns with
JESD84 / page 45 / table 28, so we need to keep to lower (HS / 52 MHz)
rates first.

Fixes: 08573eaf1a ("mmc: mmc: do not use CMD13 to get status after speed mode switch")
Fixes: 53e60650f7 ("mmc: core: Allow CMD13 polling when switching to HS mode for mmc")
Fixes: 4f25580fb8 ("mmc: core: changes frequency to hs_max_dtr when selecting hs400es")
Cc: Shawn Lin <shawn.lin@rock-chips.com>
Link: https://lore.kernel.org/linux-mmc/11962455.O9o76ZdvQC@g550jk/
Reported-by: Luca Weiss <luca@z3ntu.xyz>
Signed-off-by: Brian Norris <briannorris@chromium.org>
Tested-by: Luca Weiss <luca@z3ntu.xyz>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20220422100824.v4.1.I484f4ee35609f78b932bd50feed639c29e64997e@changeid
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2022-04-26 13:55:50 +02:00
..
block.c mmc: core: improve API to make clear mmc_hw_reset is for cards 2022-04-08 11:00:08 +02:00
block.h
bus.c mmc: core: use sysfs_emit() instead of sprintf() 2022-02-28 13:06:23 +01:00
bus.h mmc: core: use sysfs_emit() instead of sprintf() 2022-02-28 13:06:23 +01:00
card.h mmc: core: transplant ti,wl1251 quirks from to be retired omap_hsmmc 2021-12-14 21:35:24 +01:00
core.c mmc: core: improve API to make clear mmc_hw_reset is for cards 2022-04-08 11:00:08 +02:00
core.h mmc: core: Disable card detect during shutdown 2021-12-20 11:09:15 +01:00
crypto.c blk-crypto: rename blk_keyslot_manager to blk_crypto_profile 2021-10-21 10:49:32 -06:00
crypto.h mmc: core: Add basic support for inline encryption 2021-02-01 12:02:33 +01:00
debugfs.c mmc: debugfs: add description for module parameter 2021-06-14 13:57:43 +02:00
host.c mmc: core: Drop HS400 caps unless 8-bit bus is supported too 2022-03-15 10:25:21 +01:00
host.h mmc: host: factor out clearing the retune state 2021-08-24 10:15:28 +02:00
Kconfig mmc: pwrseq: add wilc1000_sdio dependency for pwrseq_sd8787 2021-08-24 16:59:38 +02:00
Makefile mmc: core: Add basic support for inline encryption 2021-02-01 12:02:33 +01:00
mmc.c mmc: core: Set HS clock speed before sending HS CMD13 2022-04-26 13:55:50 +02:00
mmc_ops.c mmc: core: Restore (almost) the busy polling for MMC_SEND_OP_COND 2022-03-07 11:47:39 +01:00
mmc_ops.h mmc: core: Restore (almost) the busy polling for MMC_SEND_OP_COND 2022-03-07 11:47:39 +01:00
mmc_test.c mmc: core: improve API to make clear mmc_hw_reset is for cards 2022-04-08 11:00:08 +02:00
pwrseq.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 194 2019-05-30 11:29:22 -07:00
pwrseq.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 194 2019-05-30 11:29:22 -07:00
pwrseq_emmc.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 194 2019-05-30 11:29:22 -07:00
pwrseq_sd8787.c mmc: pwrseq: sd8787: fix compilation warning 2021-08-25 11:11:16 +02:00
pwrseq_simple.c mmc: pwrseq: Use bitmap_free() to free bitmap 2021-12-28 17:53:42 +01:00
queue.c mmc: core: Fix blk_status_t handling 2021-12-21 13:07:25 +01:00
queue.h mmc: switch to blk_mq_alloc_disk 2021-06-30 15:34:04 -06:00
quirks.h staging: wfx: apply the necessary SDIO quirks for the Silabs WF200 2022-02-17 15:58:48 +01:00
regulator.c mmc: core: Add missing documetation for 'mmc' and 'ios' 2020-07-13 12:18:25 +02:00
sd.c Merge branch 'fixes' into next 2022-03-07 12:53:29 +01:00
sd.h mmc: core: remove unused host parameter of mmc_sd_get_csd() 2021-02-01 11:54:48 +01:00
sd_ops.c mmc: core: Drop open coding in mmc_sd_switch() 2021-06-14 13:57:36 +02:00
sd_ops.h mmc: core: Initial support for SD express card/host 2020-11-16 11:59:28 +01:00
sdio.c mmc: core: use sysfs_emit() instead of sprintf() 2022-02-28 13:06:23 +01:00
sdio_bus.c mmc: core: use sysfs_emit() instead of sprintf() 2022-02-28 13:06:23 +01:00
sdio_bus.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
sdio_cis.c mmc: sdio: Print contents of unknown CIS tuples 2021-08-24 10:15:33 +02:00
sdio_cis.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
sdio_io.c mmc: core: Provide description for sdio_set_host_pm_flags()'s 'flag' arg 2020-07-13 12:18:25 +02:00
sdio_irq.c sched,mmc: Convert to sched_set_fifo*() 2020-06-15 14:10:22 +02:00
sdio_ops.c mmc: sdio: Use mmc_pre_req() / mmc_post_req() 2020-09-07 08:57:44 +02:00
sdio_ops.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
sdio_uart.c sdio_uart: make use of UART_LCR_WLEN() + tty_get_char_size() 2022-02-28 22:17:21 +01:00
slot-gpio.c mmc: slot-gpio: Update default label when no con_id provided 2021-10-12 10:21:20 +02:00
slot-gpio.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 194 2019-05-30 11:29:22 -07:00