Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796372217; b=H4Ldy8mtPSKgtDi9+ZLuIVjI3k31Bl5ovKkSsME+xqYbkUdmUAoS13ForPrUmAsRhuKX LBHiKnZBugpODTjJcobPIDLFyUf2gYqyYsCS0Z4NXxWBynUU1SjRtuZbQGGCYCwmmxdSX I5VUdatEWRcnjNO8AohuqlXXv3IVCogqkJZYJtetDGEZ4ceB4sLUccVgwfDLb6zna3pT5 IAxA1FVponN2TeQKIOdqTeUV6Jv1MYYgD9cGJiIBAIJN2FDEGt4QBgJS0qunHVRdjEq0P YLtfJ28K6p8xMC8Nd1Davlqxx5LSGgHqC+ZYoZu/xK94av5RROJtt3FHQF7/yTMZgNg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796372217; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=8y8HmR2NwhtGVFhFjUNyPHBDH/rq5PlpGxjp/LjrbXQ=; b=IkgEJoO5DfkDZawMKI7UDPyPquMvFPBu0rJTTKmHjhybeLOBaZi0wB/mFECPHbIYpsRU V1nCB9gIt+DRV/CavtZeihyuj1OViVvB3oMdSw6O30BWcNUf411YJ/iTfkQUCKg16udNE IrA2kFn48Ppp0fzZwLT801EZ/U2ts7pGYivWqlvio7lmrK4yWZ2lGZKucy+LD2DM5FBFG y1ardmRzwHA7ACMP7CqmOHs5IQ7QCMANj/oUJjCFWcNAoZ5kzkwsqNnSg/OCZAchBYuCN oRaJcGIqA0HShfYZMMWTOEWMMr28gSUK/bLpV76Z6lVqBMOV21fJPcl6fdL89rtbcxg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="M3GPZvx/"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D42D9606A322 for ; Fri, 4 Dec 2026 08:16:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=M3GPZvx/ Received: by smtp.kernel.org (Postfix) with ESMTPSA id EB1E81F00897; Fri, 4 Dec 2026 08:16:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796372217; bh=8y8HmR2NwhtGVFhFjUNyPHBDH/rq5PlpGxjp/LjrbXQ=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=M3GPZvx/5lrsNbb9gBw1j9c/tJcpauStSzo0dSEb8VdgHPUSrO7X7FcXb/lLRtkc3 3wqRZJJssEZmtxn9z0EKb3F1IAZ6/RdDPEoLcnJ8tk/OrTaNCr1to/XOe9sW98nz/y owtDfN5R2lxYhdJ8qMX44PMAK+JFhzbbYx9f6PPAZirb7wkXpDf1u6ynS3L1mICyXB LTicDLijtRF1/kP5SzKn9t2pGzbRjCDGINPoXcYcvblgPxEOksgI5vcQJsqDSjKCF9 dAl+joMaWxEJ++Mb9ckLSIoYuVgeENljwuh3cEn852nrpqW0bu8gWfDxCWRdhR+UON sMfjSI0ryMwAA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v9 4/5] drm/bridge: trilinear: add the DPTX core and build glue Reply-To: sashiko-reviews@lists.linux.dev To: "Luo Liu" Cc: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org In-Reply-To: <20261204074239.133559-5-Luo.Liu@cixtech.com> References: <20261204074239.133559-1-Luo.Liu@cixtech.com> <20261204074239.133559-5-Luo.Liu@cixtech.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 08:16:56 +0000 X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 9 potential issues to consider: - [Medium] drm/bridge: trilinear: dptx_deinit() attach race leaves HPD work uncancelled - [Medium] drm/bridge: trilinear: UAF in device_link_del() after consumer device removal - [Medium] drm/bridge: trilinear: device_link_del() outside dp->lock races with purge - [Medium] drm/bridge: trilinear: 10s poll in dptx_wait_phy_dp_mode() stalls suspend - [Medium] drm/bridge: trilinear: HPD work queued before drm_bridge_hpd_enable() - [Medium] drm/bridge: trilinear: dptx_train_loop() lacks timeout/HPD abort under lock - [Medium] drm/bridge: trilinear: undivided stream clock rate in dptx_ctrl_stream_on() - [Low] drm/bridge: trilinear: 32-bit overflow in dptx_hw_stream_timing_set() - [Low] drm/bridge: undocumented dev_set_drvdata() in trilinear_dptx_probe() -- commit ce7e7d7a9064fd3b813169fe3cb4592f1803c9c6 Author: Luo Liu drm/bridge: trilinear: add the DPTX core and build glue This commit adds the Trilinear DisplayPort transmitter core driver (probe, hotplug workers, stream state machine, and PM/teardown helpers) along with its Kconfig and Makefile entries. > diff --git a/drivers/gpu/drm/bridge/trilinear/dptx_core.c b/drivers/gpu/d= rm/bridge/trilinear/dptx_core.c > new file mode 100644 > index 0000000000000..b4d3248ba5a83 > --- /dev/null > +++ b/drivers/gpu/drm/bridge/trilinear/dptx_core.c [ ... ] > + dp->hw->ops->stream_timing(dp->hw, stream_id, mode, > + dp->config.bpp, dp->mode.lane_cnt, > + dp->mode.link_rate, dp->pixel_per_cycle); [Severity: Low] Can the secondary data window calculation in dptx_hw_stream_timing_set() overflow 32-bit arithmetic? 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 mode->htotal and mode->hdisplay are u16 and link_rate is u32, the numerator is computed in 32-bit unsigned arithmetic. At HBR2 (540000 kHz), any mode with horizontal blanking of at least 35350 pixels wraps modulo 2^32 before dividing by mode->clock, misprogramming the secondary data packet window. Promoting the numerator to u64 with mul_u32_u32() and div_u64() avoids the overflow. [ ... ] > + pixel_clock =3D (unsigned long)mode->clock * 1000; > + ret =3D dp->hw->ops->stream_clock_rate_set(dp->hw, stream_id, pixel_clo= ck); [Severity: Medium] Should pixel_clock be divided by dp->pixel_per_cycle before calling stream_clock_rate_set()? For non-YUV420 modes above DPTX_MAX_FREQ (600 MHz), dptx_pick_ppc() selects 2 pixels per cycle and dptx_hw_stream_timing_set() programs DPTX_USER_PIXEL_COUNT to 2, but stream_clock_rate_set() still passes the undivided pixel clock (up to 1.2 GHz) directly to clk_set_rate(). Unless the platform clock tree or adapter divides the video clock internally when 2ppc is enabled, clk_set_rate() can fail, clamp to 600 MHz, or clock the video input at twice the required rate, breaking output for modes above 600 MHz. [ ... ] > + for (i =3D 0; i < DP_MAX_TRAINING_LOOP; i++) { > + for (j =3D 0; j <=3D 3; j++) { > + if (!(dp->state & DPTX_STATE_READY)) { > + ret =3D -ENODEV; > + goto err_restore; > + } > + > + ret =3D dp->hw->ops->link_train(dp->hw, dp->phy, > + mode->bw_code, > + mode->lane_cnt, > + DPTX_MAX_LANES); > + if (!ret) { > + if (dp->active_stream_cnt && > + (mode->bw_code !=3D prev_bw || > + mode->lane_cnt !=3D prev_lanes)) > + dptx_active_streams(dp); > + return 0; > + } > + > + ret =3D dptx_mode_configure(dp, mode->pclock, bw_code, > + bpp, true); > + if (ret < 0) > + break; [Severity: Medium] Can dptx_train_loop() hold dp->lock through repeated AUX timeouts if the sink is unplugged or stops responding during link training? Both callers (dptx_core_on() and dptx_hpd_irq_work_func()) hold dp->lock across dptx_train_loop(), so DPTX_STATE_READY cannot change inside the loop. When link_train() fails with -ETIMEDOUT, the loop ignores the error code and HPD state, downshifting through every link rate across DP_MAX_TRAINING_LOOP iterations. Because drm_dp_dpcd_access() retries each failed DPCD access 32 times, this stalls dp->lock for hundreds of milliseconds (up to ~1.5 s if the 4 ms AUX or 100 ms PHY-ready poll ceiling is hit), blocking disconnect handling, suspend, and modeset callbacks, and masks -ETIMEDOUT as -EIO. Aborting the loop when !dptx_get_hpd_state(dp) or when link_train() returns a transport error other than -EIO avoids the stall. [ ... ] > +static bool dptx_wait_phy_dp_mode(struct dptx_dev *dp) > +{ > + enum phy_mode mode; > + > + read_poll_timeout(phy_get_mode, mode, > + mode =3D=3D PHY_MODE_DP || dptx_hpd_wait_aborted(dp), > + 100 * USEC_PER_MSEC, > + DP_HPD_MAX_TRIES * 100 * USEC_PER_MSEC, false, > + dp->phy); [Severity: Medium] Can this 10-second read_poll_timeout() in dptx_hpd_event_work_func() stall system suspend freezing? hpd_event_work runs on system_freezable_wq. During suspend, try_to_freeze_tasks() waits for all WQ_FREEZABLE workqueues to drain before device suspend callbacks run dptx_pm_prepare() to set DPTX_STATE_SUSPENDED, so dptx_hpd_wait_aborted() stays false. If the PHY transition depends on userspace or another freezable workqueue, the poll blocks freezing for the full 10 seconds (or causes freezing to fail if freeze_timeout_msecs is shorter). Re-arming hpd_event_work with a 100 ms delay and a retry counter instead of sleeping inside the worker avoids blocking suspend and teardown. [ ... ] > +static void dptx_replay_deferred_hotplug(struct dptx_dev *dp) > +{ > + guard(mutex)(&dp->lock); > + > + if (!dptx_deferred_hotplug_pending(dp)) > + return; > + > + if (dptx_get_hpd_state(dp)) { > + queue_delayed_work(system_freezable_wq, &dp->hpd_event_work, 0); > + return; > + } > + > + if (!dp->oob_hpd || phy_get_mode(dp->phy) !=3D PHY_MODE_DP) > + return; > + > + if (!dp->hw->ops->sink_present(dp->hw)) > + return; > + > + dp->force_hpd =3D connector_status_connected; > + > + queue_delayed_work(system_freezable_wq, &dp->hpd_event_work, 0); > +} [Severity: Medium] Can the deferred hotplug queued here be silently dropped before bridge->hpd_cb is installed? dptx_bridge_attach() calls dptx_replay_deferred_hotplug() with zero delay, which runs before drm_bridge_connector_init() and drm_kms_helper_poll_init() -> drm_bridge_hpd_enable() register bridge->hpd_cb. Because bridge->dev is already set, dptx_hpd_event_work_func() calls drm_bridge_hpd_notify() while bridge->hpd_cb is still NULL and the event is lost. Since dptx_bridge_funcs does not implement .hpd_enable, the dropped hotplug is never replayed once HPD callbacks are wired up, leaving connector->status as unknown when no in-kernel DRM client probes at boot. Replaying deferred hotplug from .hpd_enable avoids losing the initial plug event. [ ... ] > +static void dptx_deinit(struct dptx_dev *dp) > +{ > + struct device_link *link =3D NULL; > + > + scoped_guard(mutex, &dp->lock) { > + if (!(dp->state & DPTX_STATE_CONFIGURED)) > + return; > + > + WRITE_ONCE(dp->hpd_stopped, true); > + dptx_irq_off(dp); > + } > + > + dptx_cancel_hpd_works(dp); > + > + scoped_guard(mutex, &dp->lock) { > + dp->released =3D true; [Severity: Medium] Can a concurrent dptx_bridge_attach() race with dptx_deinit() and leave hpd_event_work running after teardown? Because trilinear_dptx_remove() and dptx_dev_release() run before devm_drm_bridge_add() removes the bridge from bridge_list, a display controller can attach during the unlocked window around dptx_cancel_hpd_works(), while dp->released is still false: CPU0 CPU1 dptx_deinit() lock(&dp->lock) dp->hpd_stopped =3D true unlock(&dp->lock) dptx_cancel_hpd_works() dptx_bridge_attach() lock(&dp->lock) /* dp->released is false */ dp->hpd_stopped =3D false dp->attached =3D true unlock(&dp->lock) replay_deferred_hotplug() queue_delayed_work(hpd_event_work) lock(&dp->lock) dp->released =3D true ... unlock(&dp->lock) devres_release_all() drm_bridge_remove() devm_phy_release() dptx_hpd_event_work_func() phy_get_mode(dp->phy) <-- use-after-free The worker can also call dptx_notify_hpd() after drm_bridge_remove() destroys bridge->hpd_mutex, and because dp->hpd_stopped stays false, dptx_hpd_notify() can continue queueing HPD work after teardown. [ ... ] > + link =3D dp->link; > + dp->link =3D NULL; > + } > + > + if (link) > + device_link_del(link); > +} [Severity: Medium] Can device_link_del(link) here (and in dptx_bridge_detach()) trigger a use-after-free if the consumer device is removed first? dptx_bridge_attach() caches a raw struct device_link * in dp->link. If the display controller device (bridge->dev->dev) is removed while a client still holds /dev/dri/cardN open, device_del() -> device_links_purge() frees that link before deferred drm_mode_config_cleanup() runs dptx_bridge_detach(), and without clearing dp->link. A subsequent dptx_deinit() or dptx_bridge_detach() then passes the freed pointer to device_link_del(). Using device_link_remove() with the consumer and supplier devices avoids dereferencing a stale link pointer. [Severity: Medium] Can releasing dp->lock before calling device_link_del(link) race with device_links_purge() on the other teardown path? Both dptx_deinit() and dptx_bridge_detach() clear dp->link under dp->lock and call device_link_del(link) after unlocking: CPU0 CPU1 dptx_bridge_detach() lock(&dp->lock) link =3D dp->link dp->link =3D NULL unlock(&dp->lock) device_del(dp->dev) trilinear_dptx_remove() dptx_deinit() /* sees dp->link =3D=3D NULL */ device_links_purge(dp->dev) __device_link_del(&link->kref) device_link_del(link) <-- use-after-free The symmetric race occurs when dptx_deinit() clears dp->link first and dptx_bridge_detach() returns to consumer device_del(). Removing the link while still holding dp->lock prevents the other path from reaching device_links_purge() first. [ ... ] > + dev_set_drvdata(dev, dp); [Severity: Low] Should trilinear_dptx_probe() leave dev_set_drvdata() to the platform glue driver, or document that it takes ownership of dev->driver_data? trilinear_dptx_probe() returns struct dptx_dev *, all companion helpers take dp explicitly, and nothing in drivers/gpu/drm/bridge/trilinear/ calls dev_get_drvdata(). Silently overwriting drvdata breaks platform drivers that store their own private data before calling trilinear_dptx_probe(). Note that commit "drm/cix: add the Sky1 DisplayPort platform glue" currently relies on this side effect instead of calling platform_set_drvdata(). --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204074239.1335= 59-1-Luo.Liu@cixtech.com?part=3D4