[PATCH v2 0/2] Add mmc_send_tuning_timeout() and use it in dw_mmc-rockchip

Ulf Hansson ulf.hansson at oss.qualcomm.com
Tue Sep 29 06:34:22 PDT 2026


On Thu, Sep 24, 2026 at 10:51 AM Shawn Lin <shawn.lin at rock-chips.com> wrote:
>
>
> The tuning specs guarantee that a *sequence* of 40 tuning commands
> completes within 150 ms, exclusive of any host overhead:
>
>   eMMC, JESD84-B51B 6.6.5.1 "Sampling Tuning Sequence for HS200":
>
>     "The Device is guaranteed to complete a sequence of 40 times CMD21
>      executions within 150 ms. This is exclusive of any host overhead."
>
>   SD Physical Layer Specification Version 4.00:
>
>     "The card shall complete a sequence of 40 times CMD19 executions
>      in no more than 150ms. The tuning process is normally shorter than
>      40 executions of CMD19, and therefore should be shorter than
>      150 ms."
>
> mmc_send_tuning() however applied that 150 ms as the data timeout of
> every single CMD19/CMD21, i.e. 40x the per-execution budget implied
> by the specs (150 ms / 40 = 3.75 ms of device time, excluding host
> overhead).
>
> The data timeout only matters for tuning commands where the device
> never returns the tuning block at all; a wrong sampling phase
> normally fails fast with a CRC error instead.  Waiting 150 ms per
> such test makes software phase scanning painfully slow.  With
> dw_mmc-rockchip HS200 eMMC the TMOUT register saturates at ~112 ms
> for the requested 150 ms, and dw_mmc-rockchip's execute_tuning() scans every
> phase of the tuning window, stalling that long on each phase that
> misses the window.  Multi-second boot slowdowns have been reported[1].
>
> This also increases the cost of runtime re-tuning, not just the tuning
> performed at enumeration time.  So this series introduces a new helper
> for host drivers to provide their own timeout for each tuning command.
>
> [1] Link: https://bugzilla.kernel.org/show_bug.cgi?id=221781
>
>
> Changes in v2:
> - Let drivers provide the timeout via a new mmc_send_tuning_timeout()
>   instead of shortening the default for everybody, as suggested by
>   Adrian, so it is less likely to cause a regression.
> - Split into two patches; mmc_send_tuning() keeps its current
>   behaviour (150 ms) and dw_mmc-rockchip opts in with 5 ms.
>
> Shawn Lin (2):
>   mmc: core: add mmc_send_tuning_timeout()
>   mmc: dw_mmc-rockchip: use a tighter per-command tuning timeout
>
>  drivers/mmc/core/mmc_ops.c         | 22 +++++++++++++++-------
>  drivers/mmc/host/dw_mmc-rockchip.c |  2 +-
>  include/linux/mmc/host.h           |  2 ++
>  3 files changed, 18 insertions(+), 8 deletions(-)
>
> --
> 2.7.4
>

The v2 series applied for next, thanks!

I decided to not tag this for stable kernels, but if you decide to
send manual backports I am all for it!

Kind regards
Uffe



More information about the Linux-rockchip mailing list