From: sashiko-bot@kernel.org
To: "Cristian Ciocaltea" <cristian.ciocaltea@collabora.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org,
dri-devel@lists.freedesktop.org, conor+dt@kernel.org
Subject: Re: [PATCH v2 05/13] drm/rockchip: vop2: Fix VOP2_MAX_DCLK_RATE overflow on 32-bit
Date: Mon, 06 Jul 2026 19:47:55 +0000 [thread overview]
Message-ID: <20260706194756.BA1DB1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260706-dw-hdmi-qp-yuv-v2-5-b91beb33dedf@collabora.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
Pre-existing issues:
- [High] Sleeping functions are called from CRTC atomic enable and disable callbacks, which execute in atomic context.
- [High] 32-bit integer overflow in MIPI D-PHY target clock calculation before 64-bit promotion.
- [High] 32-bit integer overflow in HDMI PHY link rate calculation.
--
commit 5fecee5ab858bfe428aa0c5173e40c8dd13919cc
Author: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
drm/rockchip: vop2: Fix VOP2_MAX_DCLK_RATE overflow on 32-bit
This commit fixes a 32-bit integer overflow when calculating the maximum
DCLK for the HDMI PHY PLL by redefining VOP2_MAX_DCLK_RATE as an
unsigned long long. This ensures the value is evaluated in 64-bit
arithmetic, preventing high-resolution modes from being wrongly rejected.
Closes: https://lore.kernel.org/all/20260623203310.9F8C81F000E9@smtp.kernel.org/
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
> index e966c0a0266ea..0799eb0dd29fc 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
> @@ -102,7 +102,7 @@ enum vop2_afbc_format {
> VOP2_AFBC_FMT_INVALID = -1,
> };
>
> -#define VOP2_MAX_DCLK_RATE 600000000UL
> +#define VOP2_MAX_DCLK_RATE 600000000ULL
>
> /*
> * bus-format types.
[Severity: High]
This is a pre-existing issue, but do vop2_crtc_atomic_enable() and
vop2_crtc_atomic_disable() call sleeping functions from atomic context?
Looking at drivers/gpu/drm/rockchip/rockchip_drm_vop2.c:
vop2_crtc_atomic_enable() {
...
vop2_lock(vop2);
...
}
And:
vop2_crtc_atomic_disable() {
...
vop2_lock(vop2);
...
}
According to the DRM display hardware programming guidelines, CRTC atomic
enable and disable callbacks run in atomic context during non-blocking commits,
where sleeping is strictly forbidden.
However, vop2_crtc_atomic_enable() calls vop2_lock() (which takes a mutex),
clk_prepare_enable(), and vop2_enable(). Similarly, vop2_crtc_atomic_disable()
calls vop2_lock(), wait_for_completion_timeout(), clk_disable_unprepare(), and
vop2_disable().
Can this cause kernel warnings, system instability, and potential deadlocks?
[Severity: High]
This isn't a bug introduced by this patch, but does the MIPI D-PHY target clock
calculation in dw_mipi_dsi2_get_lane_mbps() overflow on 32-bit architectures?
Looking at drivers/gpu/drm/rockchip/dw-mipi-dsi2-rockchip.c:
dw_mipi_dsi2_get_lane_mbps() {
...
target_phyclk = DIV_ROUND_CLOSEST_ULL(lane_rate_kbps * lanes * 1000, bpp);
...
}
The multiplication lane_rate_kbps * lanes * 1000 is evaluated in 32-bit
arithmetic before DIV_ROUND_CLOSEST_ULL() can promote it to 64-bit. For
high-resolution outputs, this could exceed the 32-bit unsigned maximum and wrap
around.
Does this result in an incorrectly configured PHY clock?
[Severity: High]
This is a pre-existing issue, but does the HDMI PHY link rate calculation in
rk_hdptx_phy_clk_set_rate() also suffer from a 32-bit integer overflow?
Looking at drivers/phy/rockchip/phy-rockchip-samsung-hdptx.c:
rk_hdptx_phy_clk_set_rate() {
...
link_rate = DIV_ROUND_CLOSEST_ULL(rate * hdptx->hdmi_cfg.bpc, 8);
...
}
The expression rate * hdptx->hdmi_cfg.bpc is evaluated as an unsigned long.
On 32-bit architectures, this is a 32-bit operation. When rate is large (e.g.,
594,000,000 for 4K@60Hz) and bpc is 8, the product exceeds the 32-bit unsigned
limit, causing an overflow before promotion to 64-bit.
Could this yield an invalid HDMI PHY link rate and break display output on
32-bit architectures?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260706-dw-hdmi-qp-yuv-v2-0-b91beb33dedf@collabora.com?part=5
next prev parent reply other threads:[~2026-07-06 19:47 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-06 19:32 [PATCH v2 00/13] Support 10-bit YUV422 and 8/10-bit YUV420 color format on DW HDMI QP Cristian Ciocaltea
2026-07-06 19:32 ` Cristian Ciocaltea
2026-07-06 19:32 ` [PATCH v2 01/13] dt-bindings: display: vop2: Add missing reset properties Cristian Ciocaltea
2026-07-06 19:32 ` Cristian Ciocaltea
2026-07-06 19:32 ` [PATCH v2 02/13] drm/rockchip: vop2: Fix resource leak on vop2_enable() error path Cristian Ciocaltea
2026-07-06 19:32 ` Cristian Ciocaltea
2026-07-06 19:32 ` [PATCH v2 03/13] drm/rockchip: vop2: Balance state on atomic_enable error paths Cristian Ciocaltea
2026-07-06 19:32 ` Cristian Ciocaltea
2026-07-06 19:49 ` sashiko-bot
2026-07-06 19:32 ` [PATCH v2 04/13] drm/rockchip: vop2: Avoid division by zero when computing max_dclk Cristian Ciocaltea
2026-07-06 19:32 ` Cristian Ciocaltea
2026-07-06 19:41 ` sashiko-bot
2026-07-06 19:32 ` [PATCH v2 05/13] drm/rockchip: vop2: Fix VOP2_MAX_DCLK_RATE overflow on 32-bit Cristian Ciocaltea
2026-07-06 19:32 ` Cristian Ciocaltea
2026-07-06 19:47 ` sashiko-bot [this message]
2026-07-06 19:32 ` [PATCH v2 06/13] drm/rockchip: vop2: Reset AXI and DCLK to improve robustness Cristian Ciocaltea
2026-07-06 19:32 ` Cristian Ciocaltea
2026-07-06 19:32 ` [PATCH v2 07/13] drm/rockchip: vop2: Avoid DCLK source switch for 10-bit YUV422 output Cristian Ciocaltea
2026-07-06 19:32 ` Cristian Ciocaltea
2026-07-06 19:32 ` [PATCH v2 08/13] drm/rockchip: vop2: Consolidate HDMI PHY PLL clock parent switch Cristian Ciocaltea
2026-07-06 19:32 ` Cristian Ciocaltea
2026-07-06 19:32 ` [PATCH v2 09/13] drm/rockchip: vop2: Switch to enum vop_csc_format Cristian Ciocaltea
2026-07-06 19:32 ` Cristian Ciocaltea
2026-07-06 19:32 ` [PATCH v2 10/13] drm/bridge: dw-hdmi-qp: Log resolution and refresh rate in atomic_enable() Cristian Ciocaltea
2026-07-06 19:32 ` Cristian Ciocaltea
2026-07-06 19:32 ` [PATCH v2 11/13] drm/rockchip: dw_hdmi_qp: Support 10-bit YUV422 output format Cristian Ciocaltea
2026-07-06 19:32 ` Cristian Ciocaltea
2026-07-06 19:43 ` sashiko-bot
2026-07-06 19:32 ` [PATCH v2 12/13] drm/rockchip: dw_hdmi_qp: Enable YUV420 " Cristian Ciocaltea
2026-07-06 19:32 ` Cristian Ciocaltea
2026-07-06 19:32 ` [PATCH v2 13/13] arm64: dts: rockchip: Add RK3588 VOP2 resets Cristian Ciocaltea
2026-07-06 19:32 ` Cristian Ciocaltea
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=20260706194756.BA1DB1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=cristian.ciocaltea@collabora.com \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=robh@kernel.org \
--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 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.