From: sashiko-bot@kernel.org
To: "Esben Haabendal" <esben@geanix.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v3 5/5] drm/bridge: nwl-dsi: Correct MIPI DSI horizontal sync timing
Date: Mon, 10 Aug 2026 07:26:52 +0000 [thread overview]
Message-ID: <20260810072653.515921F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260810-nwl-dsi-fixes-v3-5-256da9d672e1@geanix.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] Implicit 64-bit division using the `/` operator causes link errors on 32-bit architectures.
- [Low] Integer overflow in `dsi->mode.clock * 1000` for high pixel clocks.
- [Low] Redundant picosecond period conversion introduces precision loss and forces 64-bit math.
--
--- Patch [5]: [PATCH v3 5/5] drm/bridge: nwl-dsi: Correct MIPI DSI horizontal sync timing ---
commit 54cf1e5377e7b6795c12c78939b18d1607d54031
Author: Esben Haabendal <esben@geanix.com>
drm/bridge: nwl-dsi: Correct MIPI DSI horizontal sync timing
The commit updates the NWL MIPI Host controller's horizontal sync timing
calculations. It converts hfp, hsa, and hbp to DSI packet bytes and
subtracts the packet header size. This aligns the timing configuration
with the i.MX 8M reference manual.
> diff --git a/drivers/gpu/drm/bridge/nwl-dsi.c b/drivers/gpu/drm/bridge/nwl-dsi.c
> index e90588299c5ea..87d22b3bd79c7 100644
> --- a/drivers/gpu/drm/bridge/nwl-dsi.c
> +++ b/drivers/gpu/drm/bridge/nwl-dsi.c
[ ... ]
> @@ -317,9 +322,62 @@ static int nwl_dsi_config_dpi(struct nwl_dsi *dsi)
> dsi->mode.hdisplay);
> }
>
> - nwl_dsi_write(dsi, NWL_DSI_HFP, hfront_porch);
> - nwl_dsi_write(dsi, NWL_DSI_HBP, hback_porch);
> - nwl_dsi_write(dsi, NWL_DSI_HSA, hsync_len);
> + pclk_period = DIV_ROUND_UP_ULL(PSEC_PER_SEC, dsi->mode.clock * 1000);
[Severity: Low]
Could this multiplication overflow on high pixel clocks? dsi->mode.clock is a
signed 32-bit integer, so multiplying by 1000 could overflow if the clock
exceeds roughly 2.147 GHz. The resulting negative number would then be
sign-extended into a large unsigned long long for DIV_ROUND_UP_ULL(). Perhaps
casting to 1000ULL would avoid this?
> + DRM_DEV_DEBUG_DRIVER(dsi->dev, "pclk_period: %llu\n", pclk_period);
> +
> + hs_period = DIV_ROUND_UP_ULL(PSEC_PER_SEC, dsi->phy_cfg.mipi_dphy.hs_clk_rate);
> + DRM_DEV_DEBUG_DRIVER(dsi->dev, "hs_period: %llu\n", hs_period);
> +
> + /*
> + * Calculate the bytes needed, according to the RM formula:
> + * Time of DPI event = time to transmit x number of bytes on the DSI
> + * interface
> + * dpi_event_size * dpi_pclk_period = dsi_bytes * 8 * hs_bit_period /
> + * num_lanes
> + * ===>
> + * dsi_bytes = dpi_event_size * dpi_pclk_period * num_lanes /
> + * (8 * hs_bit_period)
> + */
> + hfp = hfront_porch * pclk_period * dsi->lanes / (8 * hs_period);
> + hbp = hback_porch * pclk_period * dsi->lanes / (8 * hs_period);
> + hsa = hsync_len * pclk_period * dsi->lanes / (8 * hs_period);
[Severity: Low]
Does calculating the period in picoseconds introduce unnecessary precision loss?
By calculating pclk_period and hs_period first and then dividing them, the
math effectively does (10^12 / pclk) / (10^12 / hs_clk). For example, 148.5MHz
becomes 6735ps instead of 6734.0067ps. Using the raw clock rates directly
might eliminate intermediate rounding errors.
[Severity: High]
Will this standard division operator cause build failures on 32-bit platforms?
pclk_period and hs_period are 64-bit variables, so using the / operator here
will result in undefined reference to __udivdi3 during linking on 32-bit
architectures. Using div64_u64() or refactoring to use a 32-bit denominator
would prevent this link error.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260810-nwl-dsi-fixes-v3-0-256da9d672e1@geanix.com?part=5
prev parent reply other threads:[~2026-08-10 7:26 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-10 7:14 [PATCH v3 0/5] drm/bridge: nwl-dsi: Various fixes Esben Haabendal
2026-08-10 7:14 ` [PATCH v3 1/5] drm/bridge: nwl-dsi: Cleanup endpoint mux control selection Esben Haabendal
2026-08-10 15:02 ` Luca Ceresoli
2026-08-10 7:14 ` [PATCH v3 2/5] drm/bridge: nwl-dsi: Limit LCDIF specific sync override Esben Haabendal
2026-08-10 7:14 ` [PATCH v3 3/5] drm/bridge: nwl-dsi: Correct auto-insert EOTP behavior Esben Haabendal
2026-08-10 7:14 ` [PATCH v3 4/5] drm/bridge: nwl-dsi: Add error handling of nwl_dsi_mode_set() Esben Haabendal
2026-08-10 7:22 ` sashiko-bot
2026-08-10 7:14 ` [PATCH v3 5/5] drm/bridge: nwl-dsi: Correct MIPI DSI horizontal sync timing Esben Haabendal
2026-08-10 7:26 ` sashiko-bot [this message]
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=20260810072653.515921F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=esben@geanix.com \
--cc=sashiko-reviews@lists.linux.dev \
/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