[RFC PATCH] phy: qcom-mipi-csi2: clamp the programmed settle count to six
Jizhou Tong
fqwqf at fqwqf.xyz
Thu Nov 5 11:19:09 PST 2026
The settle helper returns zero for intervals no greater than the
six-tick hardware offset. lanes_enable() then rejects the configuration.
For slightly larger intervals it can program a count between one and
five. Bryan requested a minimum programmed count of six instead of
rejecting the zero-count case.
Keep the six-tick offset separate from that minimum: first calculate the
rounded interval in ticks, then return six when subtracting the offset
would yield less than six. Check before subtracting to avoid underflow
for intervals shorter than the offset.
Link: https://lore.kernel.org/all/791c7eed-f0c2-47c3-9595-77be72f29771@kernel.org/
Signed-off-by: Jizhou Tong <fqwqf at fqwqf.xyz>
---
Hi Bryan,
This implements the minimum you described in the October 19 reply,
separately from the rounding patch. I have interpreted six as the minimum
programmed register value, after subtracting the existing six-tick offset.
Please confirm that this is the intended hardware policy.
For example, the rounded interval of six ticks at link_freq=600000000 Hz
and timer_clk_rate=66666666 Hz previously returned zero and failed lane
enable. It now programs six. Intervals of twelve ticks also program six;
thirteen ticks program seven. The offset itself is unchanged.
This is based on the accepted rounding RFC v3 [1]. The ARM64 W=1 object
build and 20,571 ASan/UBSan actual-helper cases pass. The previous helper
fails the minimum-count checks. No hardware test of the new floor is
claimed, and it is not installed in my running kernel.
[1] https://lore.kernel.org/all/010601a154d848df-37257f7a-0553-43ed-93c2-4fcc5b690d14-000000@ap-northeast-1.amazonses.com/
base-commit: d7e7bca7169873b46e857c025c10f3336c1258d8
prerequisite-patch-id: 1f072b82125ac6272dc2a011688afc6cabb0f99c
drivers/phy/qualcomm/phy-qcom-mipi-csi2-3ph-dphy.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/phy/qualcomm/phy-qcom-mipi-csi2-3ph-dphy.c b/drivers/phy/qualcomm/phy-qcom-mipi-csi2-3ph-dphy.c
index f07699ba1f..dd70f29669 100644
--- a/drivers/phy/qualcomm/phy-qcom-mipi-csi2-3ph-dphy.c
+++ b/drivers/phy/qualcomm/phy-qcom-mipi-csi2-3ph-dphy.c
@@ -223,19 +223,20 @@ static u8 phy_qcom_mipi_csi2_settle_cnt_calc(s64 link_freq, u32 timer_clk_rate)
{
u32 timer_period_ps;
u64 t_hs_settle_ps;
- u8 settle_cnt;
+ u64 settle_ticks;
/* Round the complete 6 * UI term up, avoiding an intermediate truncation. */
t_hs_settle_ps = 85000 + DIV64_U64_ROUND_UP(3 * PSEC_PER_SEC, link_freq);
timer_period_ps = div_u64(PSEC_PER_SEC, timer_clk_rate);
- if (div_u64(t_hs_settle_ps, timer_period_ps) < 6)
- return 0;
+ settle_ticks = DIV_U64_ROUND_UP(t_hs_settle_ps, timer_period_ps);
- settle_cnt = DIV_U64_ROUND_UP(t_hs_settle_ps, timer_period_ps) - 6;
+ /* The programmed counter has a minimum of six, in addition to its offset. */
+ if (settle_ticks < 12)
+ return 6;
- return settle_cnt;
+ return settle_ticks - 6;
}
static void
--
2.53.0
More information about the linux-phy
mailing list