[RFC PATCH] phy: qcom-mipi-csi2: round the requested settle interval up

fQwQf fqwqf at fqwqf.xyz
Sat Oct 10 02:23:20 PDT 2026


The settling counter represents the requested interval in timer ticks,
with the existing six-tick hardware offset. Truncating the division
programs fewer ticks than requested when the interval is not an exact
multiple of the timer period.

At a 402 MHz link frequency and a 100 MHz timer, the existing calculation
requests 92458 ps but programs nine ticks (90000 ps). Round up to ten
ticks instead. Preserve the existing minimum-counter handling and
hardware offset.

Signed-off-by: Jizhou Tong <fqwqf at fqwqf.xyz>
---
Incremental change against media-next at ee2e9bf41d3e, which includes
the v18 CSI2 PHY driver. The settle calculation still truncates.

Original series:
https://lore.kernel.org/all/20260917-x1e-csi2-phy-v18-2-6515b5255fa9@linaro.org/

An extracted-function test checks 7105 link/timer combinations. The
previous calculation violates the computed lower bound; rounding up
passes those cases. This validates the arithmetic, not the electrical
timing model.

I am sending this as an RFC to confirm that rounding up is appropriate
for the hardware counter and its existing six-tick offset. This change
has been used in my SL7 camera stack, but I have not isolated its effect
on capture reliability from the other camera changes.

 drivers/phy/qualcomm/phy-qcom-mipi-csi2-3ph-dphy.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

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 966d79c98f..ce1de1a689 100644
--- a/drivers/phy/qualcomm/phy-qcom-mipi-csi2-3ph-dphy.c
+++ b/drivers/phy/qualcomm/phy-qcom-mipi-csi2-3ph-dphy.c
@@ -236,7 +236,8 @@ static u8 phy_qcom_mipi_csi2_settle_cnt_calc(s64 link_freq, u32 timer_clk_rate)
 	if ((t_hs_settle_ps / timer_period_ps) < 6)
 		return 0;
 
-	settle_cnt = t_hs_settle_ps / timer_period_ps - 6;
+	/* Do not round the requested settling interval down. */
+	settle_cnt = DIV_ROUND_UP(t_hs_settle_ps, timer_period_ps) - 6;
 
 	return settle_cnt;
 }
-- 
2.53.0



More information about the linux-phy mailing list