u-boot/drivers/mmc
Bin Meng 2f22cb40e5 mmc: mmc_spi: Fix potential spec violation in receiving card response
After command is sent and before card response shows up on the line,
there is a variable number of clock cycles in between called Ncr.
The spec [1] says the minimum is 1 byte and the maximum is 8 bytes.

Current logic in mmc_spi_sendcmd() has a flaw that it could only work
with certain SD cards with their Ncr being just 1 byte.

When resp_match is false, the codes try to receive only 1 byte from
the SD card. On the other hand when resp_match is true, the logic
happens to be no problem as it loops until timeout to receive as many
bytes as possible to see a match of the expected resp_match_value.
However not every call to mmc_spi_sendcmd() is made with resp_match
being true hence this exposes a potential issue with SD cards that
have a larger Ncr value.

Given no issue was reported as of today, we can reasonably conclude
that all cards being used on the supported boards happen to have a 1
byte Ncr timing requirement. But a broken case can be triggered by
utilizing QEMU to emulate a larger value of Ncr (by default 1 byte
Ncr is used on QEMU). This commit fixes such potential spec violation
to improve the card compatibility.

[1] "Physical Layer Specification Version 8.00"
     chapter 7.5.1: Command / Response
     chapter 7.5.4: Timing Values

Signed-off-by: Bin Meng <bin.meng@windriver.com>
Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>
2021-02-19 15:07:53 +08:00
..
am654_sdhci.c mmc: am654_sdhci: Use sdhci_set_control_reg() 2021-02-04 20:37:57 +05:30
arm_pl180_mmci.c dm: Use access methods for dev/uclass private data 2021-01-05 12:24:40 -07:00
arm_pl180_mmci.h mmc: arm_pl180_mmci: Sync compatible with kernel 2019-04-23 15:31:30 +02:00
aspeed_sdhci.c dm: treewide: Rename dev_get_platdata() to dev_get_plat() 2020-12-13 16:51:09 -07:00
atmel_sdhci.c common: Drop asm/global_data.h from common header 2021-02-02 15:33:42 -05:00
bcm2835_sdhci.c dm: treewide: Rename dev_get_platdata() to dev_get_plat() 2020-12-13 16:51:09 -07:00
bcm2835_sdhost.c dm: treewide: Rename dev_get_platdata() to dev_get_plat() 2020-12-13 16:51:09 -07:00
bcmstb_sdhci.c dm: treewide: Rename dev_get_platdata() to dev_get_plat() 2020-12-13 16:51:09 -07:00
ca_dw_mmc.c common: Drop asm/global_data.h from common header 2021-02-02 15:33:42 -05:00
davinci_mmc.c dm: treewide: Rename ofdata_to_platdata() to of_to_plat() 2020-12-13 16:51:09 -07:00
dw_mmc.c mmc: dwmmc: Change designware MMC 'clksel' callback function to return status 2021-01-15 17:48:36 +08:00
exynos_dw_mmc.c common: Drop asm/global_data.h from common header 2021-02-02 15:33:42 -05:00
fsl_esdhc.c common: Drop asm/global_data.h from common header 2021-02-02 15:33:42 -05:00
fsl_esdhc_imx.c common: Drop asm/global_data.h from common header 2021-02-02 15:33:42 -05:00
fsl_esdhc_spl.c mmc: fsl_esdhc_spl: remove superfluous free() 2021-01-18 15:23:06 -05:00
ftsdc010_mci.c common: Drop asm/global_data.h from common header 2021-02-02 15:33:42 -05:00
ftsdc010_mci.h SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
gen_atmel_mci.c dm: treewide: Rename dev_get_platdata() to dev_get_plat() 2020-12-13 16:51:09 -07:00
hi6220_dw_mmc.c common: Drop asm/global_data.h from common header 2021-02-02 15:33:42 -05:00
iproc_sdhci.c common: Drop asm/global_data.h from common header 2021-02-02 15:33:42 -05:00
jz_mmc.c common: Drop asm/global_data.h from common header 2021-02-02 15:33:42 -05:00
Kconfig mmc: am654_sdhci: Fix HISPD bit configuration in some lower speed modes 2021-02-04 20:37:57 +05:30
kona_sdhci.c common: Drop linux/delay.h from common header 2020-05-18 21:19:23 -04:00
Makefile mmc: sdhci: move the ADMA2 table handling into own module 2020-10-12 15:50:19 +08:00
meson_gx_mmc.c dm: treewide: Rename ..._platdata variables to just ..._plat 2020-12-13 16:51:09 -07:00
meson_gx_mmc.h dm: treewide: Rename ..._platdata variables to just ..._plat 2020-12-13 16:51:09 -07:00
mmc-uclass.c dm: treewide: Rename 'platdata' variables to just 'plat' 2020-12-13 16:51:08 -07:00
mmc.c mmc: fix response timeout after switch command 2021-02-19 15:04:15 +08:00
mmc_boot.c common: Drop log.h from common header 2020-05-18 21:19:18 -04:00
mmc_legacy.c Move eSDHC adapter card identification to board files 2020-07-27 14:16:28 +05:30
mmc_private.h Move eSDHC adapter card identification to board files 2020-07-27 14:16:28 +05:30
mmc_spi.c mmc: mmc_spi: Fix potential spec violation in receiving card response 2021-02-19 15:07:53 +08:00
mmc_write.c dm: treewide: Rename 'platdata' variables to just 'plat' 2020-12-13 16:51:08 -07:00
msm_sdhci.c common: Drop asm/global_data.h from common header 2021-02-02 15:33:42 -05:00
mtk-sd.c mmc: mtk-sd: assign plat->cfg.f_max with a correct value 2021-01-24 21:39:27 +01:00
mv_sdhci.c Merge branch '2021-02-02-drop-asm_global_data-when-unused' 2021-02-15 10:16:45 -05:00
mvebu_mmc.c common: Drop asm/global_data.h from common header 2021-02-02 15:33:42 -05:00
mxcmmc.c treewide: convert bd_t to struct bd_info by coccinelle 2020-07-17 09:30:13 -04:00
mxsmmc.c dm: Rename U_BOOT_DRIVER_ALIAS to DM_DRIVER_ALIAS 2021-01-05 12:26:35 -07:00
nexell_dw_mmc.c mmc: dwmmc: Change designware MMC 'clksel' callback function to return status 2021-01-15 17:48:36 +08:00
octeontx_hsmmc.c dm: core: Access device ofnode through functions 2021-01-05 12:24:41 -07:00
octeontx_hsmmc.h mmc: Add MMC controller driver for OcteonTX / TX2 2020-08-25 08:01:16 +02:00
omap_hsmmc.c common: Drop asm/global_data.h from common header 2021-02-02 15:33:42 -05:00
pci_mmc.c mmc: pci_mmc: Set the removable flag 2021-01-27 17:03:16 -05:00
pic32_sdhci.c common: Drop asm/global_data.h from common header 2021-02-02 15:33:42 -05:00
pxa_mmc_gen.c dm: treewide: Rename dev_get_platdata() to dev_get_plat() 2020-12-13 16:51:09 -07:00
renesas-sdhi.c common: Drop asm/global_data.h from common header 2021-02-02 15:33:42 -05:00
rockchip_dw_mmc.c dm: Rename U_BOOT_DRIVER_ALIAS to DM_DRIVER_ALIAS 2021-01-05 12:26:35 -07:00
rockchip_sdhci.c dm: treewide: Rename ofdata_to_platdata() to of_to_plat() 2020-12-13 16:51:09 -07:00
rpmb.c common: Drop log.h from common header 2020-05-18 21:19:18 -04:00
s5p_sdhci.c common: Drop asm/global_data.h from common header 2021-02-02 15:33:42 -05:00
sandbox_mmc.c dm: treewide: Rename dev_get_platdata() to dev_get_plat() 2020-12-13 16:51:09 -07:00
sdhci-adma.c mmc: sdhci: move the ADMA2 table handling into own module 2020-10-12 15:50:19 +08:00
sdhci-cadence.c common: Drop asm/global_data.h from common header 2021-02-02 15:33:42 -05:00
sdhci.c mmc: sdhci: skip cache invalidation if DMA is not used 2021-02-19 15:03:25 +08:00
sh_mmcif.c common: Drop asm/global_data.h from common header 2021-02-02 15:33:42 -05:00
sh_mmcif.h SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
sh_sdhi.c common: Drop asm/global_data.h from common header 2021-02-02 15:33:42 -05:00
snps_dw_mmc.c dm: treewide: Rename ofdata_to_platdata() to of_to_plat() 2020-12-13 16:51:09 -07:00
socfpga_dw_mmc.c common: Drop asm/global_data.h from common header 2021-02-02 15:33:42 -05:00
sti_sdhci.c common: Drop asm/global_data.h from common header 2021-02-02 15:33:42 -05:00
stm32_sdmmc2.c mmc: stm32_sdmmc2: migrate trace to dev and log macro 2021-01-13 09:52:58 +01:00
sunxi_mmc.c mmc: sunxi: Refactor mod clock register offset 2021-01-25 21:52:01 +00:00
tangier_sdhci.c dm: treewide: Rename dev_get_platdata() to dev_get_plat() 2020-12-13 16:51:09 -07:00
tegra_mmc.c dm: treewide: Rename dev_get_platdata() to dev_get_plat() 2020-12-13 16:51:09 -07:00
tmio-common.c common: Drop asm/global_data.h from common header 2021-02-02 15:33:42 -05:00
tmio-common.h mmc: tmio: sdhi: Configure internal DMA bus width 2021-01-31 14:08:45 +01:00
uniphier-sd.c dm: treewide: Rename 'platdata' variables to just 'plat' 2020-12-13 16:51:08 -07:00
xenon_sdhci.c common: Drop asm/global_data.h from common header 2021-02-02 15:33:42 -05:00
zynq_sdhci.c dm: treewide: Rename ofdata_to_platdata() to of_to_plat() 2020-12-13 16:51:09 -07:00