Re: [PATCH v2 2/3] scsi: ufs: mediatek: allow clock scaling when ufs_fde is absent

From: Ilia Snezhkov

Date: Fri Nov 27 2026 - 08:26:15 EST


Hi Peter,

Thank you for clarifying — and I apologize for missing
ufs_mtk_fix_clock_scaling() (commit 86a678a25108) in my previous reply.

1. Why ufs_sel_max_src / ufs_sel_min_src were set in our MT6789 DT:
We initially hit this on an older Android 6.12/6.18 tree whose
ufs-mediatek.c predated commit 86a678a25108 ("scsi: ufs: host:
mediatek: Fine-tune clock scaling"). In that local DT we added
ufs_sel_max_src (msdcpll_d2, 192 MHz) and ufs_sel_min_src
(tck_26m_mx9, 26 MHz) to idle the ufs_sel mux at 26 MHz on a
small-battery handheld.

Re-checking mainline, you are completely right about MT6789:
ufs_mtk_fix_clock_scaling() clears UFSHCD_CAP_CLK_SCALING whenever
wspecversion < 0x0400 and calls _ufs_mtk_clk_scale(hba, false). So an
upstream MT6789 DT should not define ufs_sel_max_src / ufs_sel_min_src
(otherwise mainline would permanently drop ufs_sel to ufs_sel_min_src).

2. What behavior clock scaling changed in power mode on HS-G3:
None — because ufs-mediatek does not implement .freq_to_gear_speed,
ufshcd_scale_gear() uses the legacy path and only lowers gear when
hba->pwr_info.gear_{tx,rx} > hba->clk_scaling.min_gear (UFS_HS_G4).
At HS-G3 (gear 3 < 4), new_pwr_info stays identical to hba->pwr_info
(and saved_pwr_info is also HS-G3 on scale-up), so
ufshcd_config_pwr_mode(..., UFSHCD_PMC_POLICY_DONT_FORCE) does not
issue any UIC power-mode change; only the ufs_sel clock mux switched
between 26 MHz and 192 MHz (plus ufs_mtk_scale_perf() PM QoS).

3. For mainline Patch 2/3 itself:
Even without MT6789, commit 5e5976f5242d ("scsi: ufs: host: mediatek:
Support FDE (AES) clock scaling") left an inconsistency in mainline:
ufs_mtk_is_clk_scale_ready() only checks ufs_sel, ufs_sel_max_src, and
ufs_sel_min_src, and _ufs_mtk_clk_scale() already gates all FDE clock
operations behind clk_fde_scale (mclk->ufs_fde_max_clki &&
mclk->ufs_fde_min_clki), yet line 2065 still returns early on
`if (!clki || !fde_clki)`.

As a result, on any platform whose DT provides ufs_sel{,_max_src,_min_src}
without ufs_fde — including a UFS 4.0 host without FDE scaling, or a
UFS 4.0-capable SoC attached to a UFS < 4.0 device where
ufs_mtk_fix_clock_scaling() or suspend/resume calls _ufs_mtk_clk_scale()
to switch ufs_sel and update dvfsrc-vcore — _ufs_mtk_clk_scale()
silently becomes a no-op.

Should ufs_fde remain optional as ufs_mtk_is_clk_scale_ready() and
clk_fde_scale indicate? If so, I will update Patch 2/3's commit message
in v3 to describe the mainline 5e5976f5242d mismatch cleanly (dropping
the misleading MT6789 example) and carry your Reviewed-by tags on
Patches 1/3 and 3/3. Or if ufs_fde is intended to be mandatory whenever
clock scaling is enabled, please let me know and I can adjust accordingly.

Best regards,
Ilia