kernel_samsung_a53x/drivers/mmc/host
Sam Protsenko f3d55fe104 mmc: dw_mmc: Fix IDMAC operation with pages bigger than 4K
commit 8396c793ffdf28bb8aee7cfe0891080f8cab7890 upstream.

Commit 616f87661792 ("mmc: pass queue_limits to blk_mq_alloc_disk") [1]
revealed the long living issue in dw_mmc.c driver, existing since the
time when it was first introduced in commit f95f3850f7a9 ("mmc: dw_mmc:
Add Synopsys DesignWare mmc host driver."), also making kernel boot
broken on platforms using dw_mmc driver with 16K or 64K pages enabled,
with this message in dmesg:

    mmcblk: probe of mmc0:0001 failed with error -22

That's happening because mmc_blk_probe() fails when it calls
blk_validate_limits() consequently, which returns the error due to
failed max_segment_size check in this code:

    /*
     * The maximum segment size has an odd historic 64k default that
     * drivers probably should override.  Just like the I/O size we
     * require drivers to at least handle a full page per segment.
     */
    ...
    if (WARN_ON_ONCE(lim->max_segment_size < PAGE_SIZE))
        return -EINVAL;

In case when IDMAC (Internal DMA Controller) is used, dw_mmc.c always
sets .max_seg_size to 4 KiB:

    mmc->max_seg_size = 0x1000;

The comment in the code above explains why it's incorrect. Arnd
suggested setting .max_seg_size to .max_req_size to fix it, which is
also what some other drivers are doing:

   $ grep -rl 'max_seg_size.*=.*max_req_size' drivers/mmc/host/ | \
     wc -l
   18

This change is not only fixing the boot with 16K/64K pages, but also
leads to a better MMC performance. The linear write performance was
tested on E850-96 board (eMMC only), before commit [1] (where it's
possible to boot with 16K/64K pages without this fix, to be able to do
a comparison). It was tested with this command:

    # dd if=/dev/zero of=somefile bs=1M count=500 oflag=sync

Test results are as follows:

  - 4K pages,  .max_seg_size = 4 KiB:                   94.2 MB/s
  - 4K pages,  .max_seg_size = .max_req_size = 512 KiB: 96.9 MB/s
  - 16K pages, .max_seg_size = 4 KiB:                   126 MB/s
  - 16K pages, .max_seg_size = .max_req_size = 2 MiB:   128 MB/s
  - 64K pages, .max_seg_size = 4 KiB:                   138 MB/s
  - 64K pages, .max_seg_size = .max_req_size = 8 MiB:   138 MB/s

Unfortunately, SD card controller is not enabled in E850-96 yet, so it
wasn't possible for me to run the test on some cheap SD cards to check
this patch's impact on those. But it's possible that this change might
also reduce the writes count, thus improving SD/eMMC longevity.

All credit for the analysis and the suggested solution goes to Arnd.

[1] https://lore.kernel.org/all/20240215070300.2200308-18-hch@lst.de/

Fixes: f95f3850f7a9 ("mmc: dw_mmc: Add Synopsys DesignWare mmc host driver.")
Suggested-by: Arnd Bergmann <arnd@arndb.de>
Reported-by: Linux Kernel Functional Testing <lkft@linaro.org>
Closes: https://lore.kernel.org/all/CA+G9fYtddf2Fd3be+YShHP6CmSDNcn0ptW8qg+stUKW+Cn0rjQ@mail.gmail.com/
Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20240306232052.21317-1-semen.protsenko@linaro.org
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-01-19 14:50:31 +01:00
..
alcor.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
android-goldfish.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
atmel-mci.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
au1xmmc.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
bcm2835.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cavium-octeon.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cavium-thunderx.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cavium.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cavium.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cb710-mmc.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cb710-mmc.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cqhci-core.c mmc: cqhci: Fix checking of CQHCI_HALT state 2025-01-19 00:09:58 +01:00
cqhci-crypto.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cqhci-crypto.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cqhci.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
davinci_mmc.c mmc: davinci: Don't strip remove function when driver is builtin 2024-11-19 14:19:01 +01:00
dw_mmc-bluefield.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
dw_mmc-exynos.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
dw_mmc-exynos.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
dw_mmc-hi3798cv200.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
dw_mmc-k3.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
dw_mmc-pci.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
dw_mmc-pltfm.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
dw_mmc-pltfm.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
dw_mmc-rockchip.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
dw_mmc-zx.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
dw_mmc-zx.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
dw_mmc.c mmc: dw_mmc: Fix IDMAC operation with pages bigger than 4K 2025-01-19 14:50:31 +01:00
dw_mmc.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
jz4740_mmc.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
Kconfig Revert "clkdev: remove CONFIG_CLKDEV_LOOKUP" 2025-01-02 17:01:18 +01:00
Makefile Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
meson-gx-mmc.c mmc: meson-gx: Remove setting of CMD_CFG_ERROR 2024-11-18 11:43:25 +01:00
meson-mx-sdhc-clkc.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
meson-mx-sdhc-mmc.c mmc: meson-mx-sdhc: Fix initialization frozen issue 2024-11-18 12:12:08 +01:00
meson-mx-sdhc.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
meson-mx-sdio.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mmc-sec-feature.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mmc-sec-feature.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mmc-sec-sysfs.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mmc-sec-sysfs.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mmc_hsq.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mmc_hsq.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mmc_spi.c mmc: mmc_spi: drop buggy snprintf() 2024-12-17 13:24:00 +01:00
mmci.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mmci.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mmci_qcom_dml.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mmci_stm32_sdmmc.c mmc: mmci: stm32: fix DMA API overlapping mappings warning 2024-11-18 23:19:34 +01:00
moxart-mmc.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mtk-sd.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mvsdio.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mvsdio.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mxcmmc.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mxs-mmc.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
of_mmc_spi.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
omap.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
omap_hsmmc.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
owl-mmc.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
pxamci.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
pxamci.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
renesas_sdhi.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
renesas_sdhi_core.c mmc: renesas_sdhi: use custom mask for TMIO_MASK_ALL 2024-11-18 10:58:28 +01:00
renesas_sdhi_internal_dmac.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
renesas_sdhi_sys_dmac.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
rtsx_pci_sdmmc.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
rtsx_usb_sdmmc.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
s3cmci.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
s3cmci.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sdhci-acpi.c mmc: sdhci-acpi: Disable write protect detection on Toshiba WT10-A 2024-11-19 12:27:18 +01:00
sdhci-bcm-kona.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sdhci-brcmstb.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sdhci-cadence.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sdhci-cns3xxx.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sdhci-cqhci.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sdhci-dove.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sdhci-esdhc-imx.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sdhci-esdhc-mcf.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sdhci-esdhc.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sdhci-iproc.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sdhci-milbeaut.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sdhci-msm.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sdhci-of-arasan.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sdhci-of-aspeed.c mmc: sdhci-of-aspeed: fix module autoloading 2024-11-23 23:21:00 +01:00
sdhci-of-at91.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sdhci-of-dwcmshc.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sdhci-of-esdhc.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sdhci-of-hlwd.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sdhci-of-sparx5.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sdhci-omap.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sdhci-pci-arasan.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sdhci-pci-core.c mmc: sdhci-pci: Add DMI quirk for missing CD GPIO on Vexia Edu Atla 10 tablet 2024-12-17 13:24:29 +01:00
sdhci-pci-data.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sdhci-pci-dwc-mshc.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sdhci-pci-gli.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sdhci-pci-o2micro.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sdhci-pci.h mmc: sdhci-pci: Add DMI quirk for missing CD GPIO on Vexia Edu Atla 10 tablet 2024-12-17 13:24:29 +01:00
sdhci-pic32.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sdhci-pltfm.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sdhci-pltfm.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sdhci-pxav2.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sdhci-pxav3.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sdhci-s3c.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sdhci-sirf.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sdhci-spear.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sdhci-sprd.c mmc: sdhci-sprd: Fix eMMC init failure after hw reset 2024-11-18 12:12:08 +01:00
sdhci-st.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sdhci-tegra.c mmc: sdhci-tegra: Remove SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC quirk 2025-01-15 16:29:41 +01:00
sdhci-xenon-phy.c mmc: sdhci-xenon: fix PHY init clock stability 2024-11-18 23:18:29 +01:00
sdhci-xenon.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sdhci-xenon.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sdhci.c mmc: sdhci: Do not lock spinlock around mmc_gpio_get_ro() 2024-11-19 14:19:33 +01:00
sdhci.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sdhci_am654.c mmc: sdhci_am654: Fix ITAPDLY for HS400 timing 2024-11-19 12:27:05 +01:00
sdhci_f_sdh30.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sdhci_f_sdh30.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sdricoh_cs.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sh_mmcif.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sunxi-mmc.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
tifm_sd.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
tmio_mmc.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
tmio_mmc.h mmc: renesas_sdhi: use custom mask for TMIO_MASK_ALL 2024-11-18 10:58:28 +01:00
tmio_mmc_core.c mmc: tmio: avoid concurrent runs of mmc_request_done() 2024-11-19 09:22:17 +01:00
toshsd.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
toshsd.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
uniphier-sd.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
usdhi6rol0.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ushc.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
via-sdmmc.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
vub300.c mmc: vub300: fix an error code 2024-11-18 11:43:22 +01:00
wbsd.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
wbsd.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
wmt-sdmmc.c mmc: wmt-sdmmc: remove an incorrect release_mem_region() call in the .remove function 2024-11-19 08:44:48 +01:00