From: Ilia Snezhkov <iasnezhkov@gmail.com>
To: Peter Wang <peter.wang@mediatek.com>
Cc: martin.petersen@oracle.com,
James.Bottomley@HansenPartnership.com, matthias.bgg@gmail.com,
angelogioacchino.delregno@collabora.com,
louisalexis.eyraud@collabora.com, linux-scsi@vger.kernel.org,
linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/3] scsi: ufs: mediatek: allow clock scaling when ufs_fde is absent
Date: Fri, 27 Nov 2026 21:25:47 +0800 [thread overview]
Message-ID: <179578594781.39039.17064629203450675282@gmail.com> (raw)
In-Reply-To: <484a58e10c4bc9cde24ef731a4bd3051b9decac6.camel@mediatek.com>
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
next prev parent reply other threads:[~2026-11-27 13:25 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 3:10 [PATCH v2 0/3] scsi: ufs: mediatek: pre-UniPro-1.8 adapt and clock scaling fixes Ilia Snezhkov via B4 Relay
2026-11-26 3:10 ` [PATCH v2 1/3] scsi: ufs: mediatek: skip PA_TXHSADAPTTYPE on pre-UniPro-1.8 hosts Ilia Snezhkov via B4 Relay
2026-11-26 13:01 ` Peter Wang
2026-11-26 3:10 ` [PATCH v2 2/3] scsi: ufs: mediatek: allow clock scaling when ufs_fde is absent Ilia Snezhkov via B4 Relay
2026-11-26 13:03 ` Peter Wang
2026-11-27 1:10 ` Ilia Snezhkov
2026-11-27 6:44 ` Peter Wang
2026-11-27 13:25 ` Ilia Snezhkov [this message]
2026-11-30 8:25 ` Peter Wang
2026-11-26 3:10 ` [PATCH v2 3/3] scsi: ufs: mediatek: round scalable clock bounds to clk_round_rate() Ilia Snezhkov via B4 Relay
2026-11-26 13:04 ` Peter Wang
2026-11-27 1:14 ` Ilia Snezhkov
2026-11-27 7:11 ` Peter Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179578594781.39039.17064629203450675282@gmail.com \
--to=iasnezhkov@gmail.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-scsi@vger.kernel.org \
--cc=louisalexis.eyraud@collabora.com \
--cc=martin.petersen@oracle.com \
--cc=matthias.bgg@gmail.com \
--cc=peter.wang@mediatek.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®