All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: fQwQf <fqwqf@fqwqf.xyz>
Cc: media-ci@linuxtv.org, neil.armstrong@linaro.org,
	linux-phy@lists.infradead.org, vkoul@kernel.org,
	olteanv@gmail.com
Subject: Re: [RFC PATCH] phy: qcom-mipi-csi2: round the requested settle interval up
Date: Sat, 10 Oct 2026 09:33:37 +0000	[thread overview]
Message-ID: <sashiko-outbox-166399@kernel.org> (raw)
In-Reply-To: <010601a1251fbfb9-9afc4070-5194-4714-86b1-5358791e7770-000000@ap-northeast-1.amazonses.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] phy: qcom-mipi-csi2: ui_ps precision loss breaks DIV_ROUND_UP fix
--

commit e880e6c62291c5b55c478c5e10a255d82c92d9de
Author: Jizhou Tong <fqwqf@fqwqf.xyz>

phy: qcom-mipi-csi2: round the requested settle interval up

This commit updates the settling counter calculation to round up instead of
truncating when dividing by the timer period. This aims to ensure the
programmed ticks do not fall short of the required interval.

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

> 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 966d79c98f9b2..ce1de1a689429 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;

[Severity: Medium]
Does the intermediate truncation in the calculation of t_hs_settle_ps defeat
the purpose of this DIV_ROUND_UP fix?

Earlier in phy_qcom_mipi_csi2_settle_cnt_calc(), the unit interval is
calculated with two integer divisions:

        ui_ps = div64_u64(PSEC_PER_SEC, link_freq);
        ui_ps /= 2;

This underestimates the unit interval by up to ~1.5ps. Since
t_hs_prepare_max_ps multiplies this by 6, the truncation error is amplified
to ~9ps.

If the true maximum prepare time is just above a multiple of the timer
period (for example, 90,002ps), this 9ps error pushes the computed
t_hs_settle_ps just below that multiple (for example, 89,998ps).

In that scenario, DIV_ROUND_UP produces 1 tick less (9 ticks instead of 10),
causing the receiver window to open a full timer period too early. This
would violate the MIPI D-PHY T_HS-PREPARE max timing protocol on borderline
link frequencies.

Could this be avoided by using DIV_ROUND_UP_ULL(3 * PSEC_PER_SEC, link_freq)
to prevent the intermediate truncation?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/010601a1251fbfb9-9afc4070-5194-4714-86b1-5358791e7770-000000@ap-northeast-1.amazonses.com?part=1

-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

  reply	other threads:[~2026-10-10  9:33 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-16 23:58 [PATCH v18 0/2] phy: qcom-mipi-csi2: Add a CSI2 MIPI DPHY driver Bryan O'Donoghue
2026-09-16 23:58 ` Bryan O'Donoghue
2026-09-16 23:58 ` [PATCH v18 1/2] dt-bindings: phy: qcom: Add CSI2 C-PHY/DPHY schema Bryan O'Donoghue
2026-09-16 23:58   ` Bryan O'Donoghue
2026-09-17  0:05   ` sashiko-bot
2026-09-17  0:05     ` sashiko-bot
2026-09-23  8:29   ` Krzysztof Kozlowski
2026-09-23  8:29     ` Krzysztof Kozlowski
2026-09-16 23:58 ` [PATCH v18 2/2] phy: qcom-mipi-csi2: Add a CSI2 MIPI DPHY driver Bryan O'Donoghue
2026-09-16 23:58   ` Bryan O'Donoghue
2026-09-17  0:08   ` sashiko-bot
2026-09-17  0:08     ` sashiko-bot
2026-09-22 12:15   ` Neil Armstrong
2026-09-22 12:15     ` Neil Armstrong
2026-09-22 13:15   ` Manivannan Sadhasivam
2026-09-22 13:15     ` Manivannan Sadhasivam
2026-10-10  9:23   ` [RFC PATCH] phy: qcom-mipi-csi2: round the requested settle interval up fQwQf
2026-10-10  9:23     ` fQwQf
2026-10-10  9:33     ` sashiko-bot [this message]
2026-10-13  2:54     ` [RFC PATCH v2] " Jizhou Tong
2026-10-13  2:54       ` Jizhou Tong
2026-10-13  3:04       ` sashiko-bot
2026-09-23 12:35 ` [PATCH v18 0/2] phy: qcom-mipi-csi2: Add a CSI2 MIPI DPHY driver Vinod Koul
2026-09-23 12:35   ` Vinod Koul

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=sashiko-outbox-166399@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=fqwqf@fqwqf.xyz \
    --cc=linux-phy@lists.infradead.org \
    --cc=media-ci@linuxtv.org \
    --cc=neil.armstrong@linaro.org \
    --cc=olteanv@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=vkoul@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.