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=1796386558; b=gtF7toJwK7/uFTy0imk6XknWHctyjhyv9HVSYmJouH68ac+sTsC5U6kIZh0JWF55jlXQ qDuSGL1nfvNbAbvR+/0+isJm56tWGy515jyWD0wbFkr/uQqPKJkW0MzGZrsPvw9lBwgzJ IbUBuvooddvMU2Nj5tIy6oRNNty6ntPdQB+TQwX9nRi05qty2bHrLeljf5/h5iaWAcZEo UKoClropXo/KrNusKXed866hrhLIQDGy2uoiAsLYq0vHKtaQSbjF02ALtpn0F9tWwCSeM lwhOy4u7p9cyvhwlFkaD/w0I/h1JnWE6PwNQIFWV2h/KKZSQ4YkgdfWd1cDsqFTjxqg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796386558; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=52d7szNk6sMReDF1G9LoFw0B7CSgke60qQTMjWAMrHk=; b=CDuKJRIU+r0vEyPFBEbeuHW8uwNpBtSgHUZd2nypUpdkOtArrxL7FLks8UerlnutNID0 Hgh7MbzGhlirIQX8EB1cteAGjo3A3McBLnHyqXu2yZGm5qgjU/Gu1AcxguQjPkZED7aJ4 GX6SofPLwnm56s7KV2jmixCe0g/7+UQubbpBLniEfs6LagiSE39T6FsHNUo2sfy7sFnYN 4nvlLpUvQy5fZl2+xKWDMe16e327CC5ODoMrJ5tYb70D2yIfCZltec33izjz6i1dU4CDN vlICvQ8+5mZ7tKJRyBDFnNTLWwZ+FHitz363zl60xXgmEw2w+h+AxgY7za09gvqeGRg== 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=F3pDtTWx; 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 8B938606A322 for ; Fri, 4 Dec 2026 12:15:58 +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=F3pDtTWx Received: by smtp.kernel.org (Postfix) with ESMTPSA id 191EA1F00897; Fri, 4 Dec 2026 12:15:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796386558; bh=52d7szNk6sMReDF1G9LoFw0B7CSgke60qQTMjWAMrHk=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=F3pDtTWxrFsw/BCia8jmfdz4HsO2xICX/fui3EomXzWhyrOQyaSFrdNzADuv5L+DJ nDc1JMRZB6MlqWjRgcZaqCOjOZENeWF0JRBH/ZKo344qdpXafbhnSQGJT8l7HHTYUt ho6sAQ4+Vkamc2qKTP2cpFHPUR7XmC2TK+EPcfqkYgrTdZdnJfTeDp3U7wnX637y/V RFZTxeGINJXIpDtADdo7ugO7Cd47XdruY7hy//vYHCGY/Mv4lU8sRlkbz9qj+q7wAs cq2x+Ja2PuE4jhS9eHsDoLFFtkES6ZUG1YdURqe4tI8mUGjjI8F46P+p3mTdKm/9fn kSiri58JRziMQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v10 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: <20261204114332.280808-5-Luo.Liu@cixtech.com> References: <20261204114332.280808-1-Luo.Liu@cixtech.com> <20261204114332.280808-5-Luo.Liu@cixtech.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 12:15:57 +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 7 potential issues to consider: - [High] drm/bridge: trilinear: dptx_hw_link_vs_emph() returns byte count as error - [Medium] drm/bridge: trilinear: UAF on dp->dev calling device_link_remove() unlocked - [Medium] drm/bridge: trilinear: dptx_deinit() lets detach skip aux_unregister() - [Medium] drm/bridge: trilinear: UAF of dp->dev in dptx_bridge_mode_set() - [Medium] drm/bridge: trilinear: port@1 chaining breaks OOB HPD replay and notify - [Low] drm/bridge: trilinear: dptx_init() leaks IRQ_DISABLE_UNLAZY on error - [Low] drm/bridge: trilinear: redundant OF lookup and __free() style in probe -- commit 73b96bebc6d815be1eb22b178ab9b6dfb9d2585a Author: Luo Liu drm/bridge: trilinear: add the DPTX core and build glue This commit adds the Trilinear DisplayPort transmitter core driver (probe, PM callbacks, hotplug workers, and stream/link state machine), exports trilinear_dptx_remove(), and hooks the driver into the DRM bridge Kconfig and Makefile. > 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..5ca90acfb981f > --- /dev/null > +++ b/drivers/gpu/drm/bridge/trilinear/dptx_core.c [ ... ] > +static int dptx_train_loop(struct dptx_dev *dp) > +{ [ ... ] > + ret =3D dp->hw->ops->link_train(dp->hw, dp->phy, > + mode->bw_code, > + mode->lane_cnt); > + 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; > + } > + > + if (ret !=3D -EIO) > + goto err_restore; [Severity: High] Will link training always fail here when the first DPCD write succeeds? In drivers/gpu/drm/bridge/trilinear/dptx_hw.c, dptx_hw_link_vs_emph() returns the result of drm_dp_dpcd_write() directly, which is the positive byte count (lane_cnt) on success rather than 0: drivers/gpu/drm/bridge/trilinear/dptx_hw.c:dptx_hw_link_vs_emph() { ... return drm_dp_dpcd_write(&hw->aux, DP_TRAINING_LANE0_SET, hw->train_setting, lane_cnt); } Both dptx_hw_link_clock_recovery() and dptx_hw_link_channel_equalization() treat any non-zero return as an error (if (ret) return ret;), so positive lane_cnt propagates back to dptx_train_loop(), hits the ret !=3D -EIO branc= h, and causes dptx_core_on() to power down the link on every enable. Using drm_dp_dpcd_write_data() in dptx_hw_link_vs_emph() (or normalizing a non-negative return to 0) would fix this. [ ... ] > +static int dptx_init(struct dptx_dev *dp) > +{ [ ... ] > + irq_set_status_flags(dp->irq, IRQ_DISABLE_UNLAZY); > + ret =3D devm_request_threaded_irq(dp->dev, dp->irq, NULL, > + dptx_irq_handler, IRQF_ONESHOT, > + dev_name(dp->dev), dp); > + if (ret < 0) > + goto err_deinit; > + > + return 0; > + > +err_deinit: > + dptx_host_deinit(dp); > +err_configured: > + dp->state &=3D ~DPTX_STATE_CONFIGURED; > + return ret; > +} [Severity: Low] Does the err_deinit path leave IRQ_DISABLE_UNLAZY set on dp->irq if devm_request_threaded_irq() fails? __free_irq() only clears IRQ_DISABLE_UNLAZY when freeing a registered action, so a failed request leaks the flag on the IRQ descriptor. Setting IRQ_DISABLE_UNLAZY after devm_request_threaded_irq() succeeds (or clearing it on err_deinit) avoids that. > + > +static void dptx_deinit(struct dptx_dev *dp) > +{ > + struct device *consumer =3D NULL; > + > + scoped_guard(mutex, &dp->lock) { > + if (!(dp->state & DPTX_STATE_CONFIGURED)) > + return; > + > + WRITE_ONCE(dp->hpd_stopped, true); > + dp->released =3D true; > + dptx_irq_off(dp); > + } [Severity: Medium] Can dptx_bridge_mode_set() hit a use-after-free on dp->dev if platform removal runs between dp->ops->detect() and acquiring dp->lock? Because dp->dev is not refcounted and the DL_FLAG_STATELESS device link does not unbind the display controller when the DPTX device is removed, trilinear_dptx_remove() can run concurrently with a modeset: CPU0 CPU1 dptx_bridge_mode_set() dp->ops->detect(dp) mutex_lock(&dp->lock) ... mutex_unlock(&dp->lock) trilinear_dptx_remove() dptx_deinit() dp->released =3D true device_del(dp->dev) put_device(dp->dev) (freed) mutex_lock(&dp->lock) ... dev_dbg(dp->dev, ...) <-- use-after-free dptx_bridge_mode_set() in dptx_drm.c does not recheck dp->released after acquiring dp->lock before calling dev_dbg(dp->dev, ...). Rechecking dp->released under dp->lock (or logging with drm_dbg_kms(dp->bridge.dev, ...)) avoids dereferencing a freed dp->dev. > + > + dptx_cancel_hpd_works(dp); > + > + scoped_guard(mutex, &dp->lock) { > + dptx_stop_streams(dp); > + dptx_host_deinit(dp); > + dp->hw->ops->aux_unregister(dp->hw); [Severity: Medium] Can setting dp->released before dptx_cancel_hpd_works() cause dptx_bridge_detach() to skip aux_unregister() and leave aux->drm_dev dangling? In dptx_drm.c, dptx_bridge_detach() only calls aux_unregister() when !dp->released: CPU0 CPU1 dptx_deinit() mutex_lock(&dp->lock) dp->released =3D true mutex_unlock(&dp->lock) dptx_cancel_hpd_works() dptx_bridge_detach() mutex_lock(&dp->lock) /* dp->released is true: skips aux_unregister() */ mutex_unlock(&dp->lock) drm_dev_release(bridge->dev) (freed) mutex_lock(&dp->lock) dptx_host_deinit() dptx_hw_dpcd_power_down() drm_dp_dpcd_readb(&hw->aux) <-- use-after-free aux_unregister(dp->hw) While /dev/drm_dp_auxN and the I2C adapter stay registered, both dptx_hw_dpcd_power_down() (via drm_dp_dump_access() -> drm_dbg_dp()) and concurrent userspace AUX transfers can dereference the freed struct drm_device. Since dptx_hw_aux_unregister() is idempotent, dptx_bridge_detach() can unregister AUX unconditionally under dp->lock, and dptx_deinit() should avoid DPCD transfers with a stale aux->drm_dev. > + dp->state &=3D ~(DPTX_STATE_CONFIGURED); > + consumer =3D dp->link_consumer; > + dp->link_consumer =3D NULL; > + } > + > + if (consumer) > + device_link_remove(consumer, dp->dev); > +} [Severity: Medium] Can calling device_link_remove() outside dp->lock race with platform device removal and cause a use-after-free on dp->dev? Both dptx_deinit() and dptx_bridge_detach() clear dp->link_consumer under dp->lock and drop the lock before calling device_link_remove(). Because the link is DL_FLAG_STATELESS, supplier removal does not unbind the consumer first: CPU0 CPU1 dptx_bridge_detach() mutex_lock(&dp->lock) consumer =3D dp->link_consumer dp->link_consumer =3D NULL mutex_unlock(&dp->lock) trilinear_dptx_remove() dptx_deinit() /* sees link_consumer =3D=3D NULL */ device_del(dp->dev) put_device(dp->dev) (freed) device_link_remove(consumer, dp->dev) list_for_each_entry(..., &dp->dev->links.consumers, ...) <-- use-after-free Calling device_link_remove() while holding dp->lock in both dptx_bridge_detach() and dptx_deinit() (matching device_link_add() in dptx_bridge_attach()) serializes link removal against supplier teardown. [ ... ] > +struct dptx_dev *trilinear_dptx_probe(struct device *dev, > + const struct dptx_plat_data *soc_data, > + void *priv) > +{ > + struct device_node *remote __free(device_node) =3D NULL; [Severity: Low] This isn't a bug, but remote is declared with __free(device_node) =3D NULL = at the top of the function and assigned much later, whereas the cleanup API convention is to initialize __free() variables at acquisition. In addition, of_drm_get_bridge_by_endpoint() already calls of_graph_get_remote_node() internally and returns ERR_PTR(-ENODEV) when no remote endpoint is present, so calling of_drm_get_bridge_by_endpoint() directly and ignoring -ENODEV drops both the redundant OF lookup and the remote variable. [ ... ] > + remote =3D of_graph_get_remote_node(dev->of_node, 1, 0); > + if (remote) { > + dp->next_bridge =3D of_drm_get_bridge_by_endpoint(dev->of_node, > + 1, 0); > + if (IS_ERR(dp->next_bridge)) { > + ret =3D PTR_ERR(dp->next_bridge); > + dp->next_bridge =3D NULL; > + dptx_deinit(dp); > + return ERR_PTR(ret); > + } > + } [Severity: Medium] Does chaining a downstream bridge on port@1 break out-of-band HPD replay and notifications on USB-C DisplayPort? In upstream USB-C DP Alt Mode topologies, the chain ends at a drm_aux_hpd_bridge (which sets DRM_BRIDGE_OP_HPD), and a dp-connector with hpd-gpios also sets DRM_BRIDGE_OP_HPD. drm_bridge_connector_init() picks the last bridge with DRM_BRIDGE_OP_HPD as bridge_connector->bridge_hpd, so drm_bridge_connector_enable_hpd() never calls dptx_bridge_hpd_enable() on &dp->bridge and dp->bridge.hpd_cb stays NULL. As a result, boot-time dptx_replay_deferred_hotplug() never runs for an already-plugged USB-C sink, and dptx_notify_hpd() becomes a silent no-op, dropping notifications from delayed PHY DP-mode polling and system resume in dptx_pm_complete(). Conversely, wiring port@1 directly to a USB-C combo PHY that does not register a struct drm_bridge (as documented in cix,sky1-dp.yaml) makes of_drm_get_bridge_by_endpoint() return -EPROBE_DEFER indefinitely. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204114332.2808= 08-1-Luo.Liu@cixtech.com?part=3D4