From: sashiko-bot@kernel.org
To: "Luo Liu" <Luo.Liu@cixtech.com>
Cc: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org,
robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v9 5/5] drm/cix: add the Sky1 DisplayPort platform glue
Date: Fri, 04 Dec 2026 08:05:04 +0000 [thread overview]
Message-ID: <sashiko-outbox-249363@kernel.org> (raw)
In-Reply-To: <20261204074239.133559-6-Luo.Liu@cixtech.com>
Thank you for your contribution! Sashiko AI review found 5 potential
issues to consider:
- [Medium] drm/bridge: trilinear: dptx_deinit() races with
dptx_bridge_attach()
- [Medium] drm/bridge: trilinear: unlocked device_link_del() races with
purge
- [Low] drm/cix: MAINTAINERS omits drivers/gpu/drm/cix/ Kconfig and
Makefile
- [Low] drm/bridge: trilinear: 32-bit overflow in
dptx_hw_stream_timing_set()
- [Low] drm/cix: rely on undocumented dev_set_drvdata() in
trilinear_dptx_probe()
--
commit dc89c829eff9a7f0dba586da4c0b1ecdf3d742f9
Author: Luo Liu <Luo.Liu@cixtech.com>
drm/cix: add the Sky1 DisplayPort platform glue
This commit adds the Cix Sky1 DisplayPort platform glue driver, which maps
the SoC RCSU video adapter registers, configures pixel format and
pixel-per-clock settings, and binds the shared Trilinear DPTX bridge
driver.
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 9315302ab7628..2314af4da0b7a 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -6535,6 +6535,7 @@ L: dri-devel@lists.freedesktop.org
> S: Maintained
> F: Documentation/devicetree/bindings/display/cix,sky1-dp.yaml
> F: drivers/gpu/drm/bridge/trilinear/
> +F: drivers/gpu/drm/cix/dptx/
> F: include/drm/bridge/trilinear_dp.h
[Severity: Low]
Should this entry also cover drivers/gpu/drm/cix/Kconfig and
drivers/gpu/drm/cix/Makefile (for example via F: drivers/gpu/drm/cix/)?
Those two newly added files are not matched by any MAINTAINERS entry.
[ ... ]
> diff --git a/drivers/gpu/drm/cix/dptx/cix_dptx.c b/drivers/gpu/drm/cix/dptx/cix_dptx.c
> new file mode 100644
> index 0000000000000..a4e028181383a
> --- /dev/null
> +++ b/drivers/gpu/drm/cix/dptx/cix_dptx.c
[ ... ]
> + dp = trilinear_dptx_probe(dev, soc_data, priv);
> + if (IS_ERR(dp))
> + return PTR_ERR(dp);
> +
> + return 0;
> +}
[Severity: Low]
Should cix_dptx_probe() call platform_set_drvdata(pdev, dp) instead of
discarding dp?
cix_dptx_remove(), cix_dptx_pm_suspend(), cix_dptx_pm_resume(), and
cix_dptx_shutdown() all retrieve the struct dptx_dev pointer from drvdata.
This currently works only because trilinear_dptx_probe() calls
dev_set_drvdata(dev, dp) internally, even though the trilinear driver never
reads drvdata and include/drm/bridge/trilinear_dp.h does not document that
side effect.
Setting drvdata here and dropping dev_set_drvdata() from
trilinear_dptx_probe() would match other shared DRM bridge libraries and
avoid clobbering drvdata for future glue drivers.
> +
> +static void cix_dptx_remove(struct platform_device *pdev)
> +{
> + trilinear_dptx_remove(platform_get_drvdata(pdev));
> +}
[Severity: Medium]
Can dptx_deinit() race with dptx_bridge_attach() and leave dp->hpd_event_work
polling dp->phy after devres releases it?
In drivers/gpu/drm/bridge/trilinear/dptx_core.c, dptx_deinit() sets
dp->hpd_stopped = true and drops dp->lock to call dptx_cancel_hpd_works(),
setting dp->released = true only in a second dp->lock critical section:
CPU0 CPU1
cix_dptx_remove()
dptx_deinit()
lock(&dp->lock)
dp->hpd_stopped = true
unlock(&dp->lock)
dptx_cancel_hpd_works()
dptx_bridge_attach()
lock(&dp->lock)
/* dp->released is still false */
dp->hpd_stopped = false
unlock(&dp->lock)
dptx_replay_deferred_hotplug()
queue_delayed_work(hpd_event_work)
dptx_hpd_event_work_func()
/* passes abort check, unlocks */
dptx_wait_phy_dp_mode()
lock(&dp->lock)
dp->released = true
unlock(&dp->lock)
devres_release_all()
devm_phy_release(dp->phy)
phy_get_mode(dp->phy) <-- use-after-free
Because dp->hpd_stopped was cleared back to false and dptx_hpd_notify() only
checks dp->hpd_stopped (not dp->released), out-of-band HPD notifications on
cix,sky1-usbdp can also keep queueing HPD work after device removal.
Setting dp->released = true alongside dp->hpd_stopped = true in the first
dp->lock critical section of dptx_deinit() closes this window.
[Severity: Medium]
Can dropping dp->lock before device_link_del() in dptx_deinit() and
dptx_bridge_detach() race with device_links_purge()?
Both dptx_deinit() and dptx_bridge_detach() clear dp->link under dp->lock,
then drop dp->lock before calling device_link_del(link):
CPU0 CPU1
dptx_bridge_detach()
lock(&dp->lock)
link = dp->link
dp->link = NULL
unlock(&dp->lock)
device_del(dp->dev)
bus_remove_device()
cix_dptx_remove() -> dptx_deinit()
/* sees dp->link == NULL */
device_links_purge(dp->dev)
__device_link_del(&link->kref)
device_link_del(link)
<-- double delete / use-after-free
The symmetric race happens when dptx_deinit() steals dp->link and drops
dp->lock while the consumer device is being deleted. Calling
device_link_del(link) while still holding dp->lock (matching
device_link_add() in dptx_bridge_attach()) serializes deletion before
device_links_purge() can run.
[ ... ]
> +static const struct dptx_plat_data sky1_usbdp_data = {
> + .adapter_config = cix_dp_usbc_adapter_config,
> + .oob_hpd = true,
> + .max_bw_code = DP_LINK_BW_5_4,
> +};
> +
> +static const struct dptx_plat_data sky1_dp_data = {
> + .adapter_config = cix_dp_native_adapter_config,
> + .max_bw_code = DP_LINK_BW_5_4,
> +};
[Severity: Low]
Can setting max_bw_code to DP_LINK_BW_5_4 trigger a 32-bit overflow in
dptx_hw_stream_timing_set()?
drivers/gpu/drm/bridge/trilinear/dptx_hw.c:dptx_hw_stream_timing_set() {
...
dptx_hw_write(hw, DPTX_SECONDARY_DATA_WINDOW(stream_id),
(mode->htotal - mode->hdisplay) * (link_rate / 40) *
9 / mode->clock);
...
}
Because link_rate is u32, this multiplication is evaluated in 32-bit
unsigned arithmetic. At 540000 kHz, (link_rate / 40) * 9 is 121500, so
any custom mode with horizontal blanking (mode->htotal - mode->hdisplay)
of at least 35350 overflows U32_MAX before dividing by mode->clock.
Neither dptx_adjust_mode() nor dptx_bridge_atomic_check() bounds
horizontal blanking, so this writes a miscalculated secondary data window
to hardware. Computing the numerator in 64-bit arithmetic with div_u64()
avoids the wraparound.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204074239.133559-1-Luo.Liu@cixtech.com?part=5
prev parent reply other threads:[~2026-12-04 8:05 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 7:42 [PATCH v9 0/5] drm/bridge: trilinear: add the Sky1 DisplayPort transmitter Luo Liu
2026-12-04 7:42 ` [PATCH v9 1/5] dt-bindings: display: add CIX " Luo Liu
2026-12-04 7:42 ` [PATCH v9 2/5] drm/bridge: trilinear: add the DPTX hardware layer Luo Liu
2026-12-04 8:13 ` sashiko-bot
2026-12-04 7:42 ` [PATCH v9 3/5] drm/bridge: trilinear: add the DPTX DRM bridge Luo Liu
2026-12-04 8:19 ` sashiko-bot
2026-12-04 7:42 ` [PATCH v9 4/5] drm/bridge: trilinear: add the DPTX core and build glue Luo Liu
2026-12-04 8:16 ` sashiko-bot
2026-12-04 7:42 ` [PATCH v9 5/5] drm/cix: add the Sky1 DisplayPort platform glue Luo Liu
2026-12-04 8:05 ` 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=sashiko-outbox-249363@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Luo.Liu@cixtech.com \
--cc=conor+dt@kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox