From: Ilia Snezhkov To: peter.wang@mediatek.com, stanley.chu@mediatek.com, martin.petersen@oracle.com, James.Bottomley@HansenPartnership.com Cc: matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, louisalexis.eyraud@collabora.com, linux-scsi@vger.kernel.org, linux-mediatek@lists.infradead.org, phone-devel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 2/3] scsi: ufs: mediatek: allow clock scaling when ufs_fde is absent Date: Mon, 30 Nov 2026 10:34:08 +0000 Message-Id: <20261130103406.96018-3-iasnezhkov@gmail.com> In-Reply-To: <20261130103406.96018-1-iasnezhkov@gmail.com> References: <20261130103406.96018-1-iasnezhkov@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1796034847; l=2397; i=iasnezhkov@gmail.com; s=mindone2026; h=from:subject:message-id; bh=8Vh9/Si/cYPROBNCt2pF2UFpEqTVq/XI3+5+bGrkIQM=; b=foysmSDDnvap1LYzmIxoVychqrupp5DXm7nN1n6rPGZWfJHRZs5g3qfoN8RijQKIJdevY31cz KPSBDcyLyWDArm7qy4KKQ/u8cCi0SghyalO82AymXOZuub8bMWdNKmX X-Developer-Key: i=iasnezhkov@gmail.com; a=ed25519; pk=hQgXfiWi4ukk2jh4BHu1vRVhg9BUivo//AFp50AKMag= X-Endpoint-Received: by B4 Relay for iasnezhkov@gmail.com/mindone2026 with auth_id=1643 List-Id: B4 Relay Submissions ufs_mtk_is_clk_scale_ready() only requires ufs_sel, ufs_sel_max_src, and ufs_sel_min_src, and _ufs_mtk_clk_scale() already gates FDE clock scaling behind clk_fde_scale (mclk->ufs_fde_max_clki && mclk->ufs_fde_min_clki). However, _ufs_mtk_clk_scale() still returns early on !fde_clki. Because of that check, platforms without FDE clock scaling currently have to provide dummy ufs_fde entries in DT (pointing ufs_fde_min_src and ufs_fde_max_src to the same clock); otherwise _ufs_mtk_clk_scale() silently becomes a no-op and neither switches ufs_sel nor updates dvfsrc-vcore when called from devfreq scaling, suspend/resume, or ufs_mtk_fix_clock_scaling(). Only require clki (ufs_sel) in _ufs_mtk_clk_scale(), and gate clk_fde_scale on fde_clki being non-NULL alongside its min/max parents so platforms that do not use FDE scaling can omit the ufs_fde clock settings. Fixes: 5e5976f5242d ("scsi: ufs: host: mediatek: Support FDE (AES) clock scaling") Signed-off-by: Ilia Snezhkov --- Changes since v2: - Rewrote the commit message per Peter Wang's review: dropped the MT6789 DT example (mainline ufs_mtk_fix_clock_scaling() disables clock scaling below UFS 4.0) and explained that omitting ufs_fde removes the need for dummy identical ufs_fde_min_src/ufs_fde_max_src DT entries. - Rebased onto linux-next (no code changes). Changes since v1: - Moved AI coding assistant note below ---. - Found on hardware and drafted with an AI coding assistant. drivers/ufs/host/ufs-mediatek.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediatek.c index 4ba071e..a7981a3 100644 --- a/drivers/ufs/host/ufs-mediatek.c +++ b/drivers/ufs/host/ufs-mediatek.c @@ -2077,7 +2077,7 @@ static void _ufs_mtk_clk_scale(struct ufs_hba *hba, bool scale_up) if (!hba->clk_scaling.is_initialized) return; - if (!clki || !fde_clki) + if (!clki) return; reg = host->mclk.reg_vcore; @@ -2085,7 +2085,7 @@ static void _ufs_mtk_clk_scale(struct ufs_hba *hba, bool scale_up) if (reg && volt != 0) clk_bind_vcore = true; - if (mclk->ufs_fde_max_clki && mclk->ufs_fde_min_clki) + if (fde_clki && mclk->ufs_fde_max_clki && mclk->ufs_fde_min_clki) clk_fde_scale = true; ret = clk_prepare_enable(clki->clk); -- 2.54.0 (Apple Git-157)