Devicetree
 help / color / mirror / Atom feed
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 v11 3/5] drm/bridge: trilinear: add the DPTX DRM bridge
Date: Fri, 04 Dec 2026 14:19:52 +0000	[thread overview]
Message-ID: <sashiko-outbox-249957@kernel.org> (raw)
In-Reply-To: <20261204131053.351956-4-Luo.Liu@cixtech.com>

Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [High] drm/bridge: lock inversion and late mode_changed in
  dptx_bridge_atomic_check()
- [Medium] drm/bridge: trilinear: dptx_hpd_notify() echo filter bypassed
  downstream
- [Medium] drm/bridge: trilinear: unlocked display_info read in
  dptx_bridge_mode_set()
- [Low] drm/bridge: trilinear: dptx_bridge_get_modes() skips clearing
  stale EDID
--

commit 0fb996722a63499df5034e482ec6a2609d1bce26
Author: Luo Liu <Luo.Liu@cixtech.com>

drm/bridge: trilinear: add the DPTX DRM bridge

This commit adds the DRM bridge layer for the Trilinear DisplayPort
transmitter, implementing connector detection, EDID and downstream mode
enumeration, mode validation, atomic check, and atomic enable/disable.

> diff --git a/drivers/gpu/drm/bridge/trilinear/dptx_drm.c b/drivers/gpu/drm/bridge/trilinear/dptx_drm.c
> new file mode 100644
> index 0000000000000..5372cbf920084
> --- /dev/null
> +++ b/drivers/gpu/drm/bridge/trilinear/dptx_drm.c

[ ... ]

> +static enum drm_connector_status dptx_bridge_detect(struct drm_bridge *bridge,
> +						    struct drm_connector *connector)
> +{
> +	struct dptx_dev *dp = bridge_to_dp(bridge);
> +	enum drm_connector_status status;
> +
> +	status = dp->ops->detect_status(dp);
> +	WRITE_ONCE(dp->detect_task, current);
> +
> +	return status;
> +}
> +
> +static void dptx_hpd_notify(struct dptx_dev *dp,
> +			    enum drm_connector_status hpd_state)
> +{
> +	if (READ_ONCE(dp->detect_task) == current) {
> +		WRITE_ONCE(dp->detect_task, NULL);
> +		return;
> +	}
> +
> +	if (READ_ONCE(dp->notify_task) == current) {
> +		WRITE_ONCE(dp->notify_task, NULL);
> +		return;
> +	}
> +
> +	if (!dp->oob_hpd)
> +		return;
> +
> +	guard(mutex)(&dp->lock);
> +
> +	if (dp->hpd_stopped ||
> +	    hpd_state == connector_status_unknown)
> +		return;
> +
> +	dp->force_hpd = hpd_state;
> +
> +	if (!(dp->state & DPTX_STATE_SUSPENDED)) {
> +		queue_delayed_work(system_freezable_wq, &dp->hpd_event_work, 0);
> +		if (hpd_state == connector_status_connected)
> +			queue_delayed_work(system_freezable_wq,
> +					   &dp->hpd_irq_work,
> +					   msecs_to_jiffies(20));
> +	}
> +}

[Severity: Medium]
Can the echo filter in dptx_hpd_notify() be bypassed when a downstream
bridge advertises DRM_BRIDGE_OP_DETECT?

drm_bridge_connector_init() assigns bridge_detect to the last bridge in
the chain that sets DRM_BRIDGE_OP_DETECT.  When dp->oob_hpd is true and
a downstream bridge sets DRM_BRIDGE_OP_DETECT, connector probes call
that bridge's detect() instead of dptx_bridge_detect(), leaving
dp->detect_task NULL, and drm_bridge_connector_hpd_notify() still
notifies dp->bridge.  Every read-only probe then overwrites
dp->force_hpd and queues hpd_event_work (and hpd_irq_work when
connected).

In addition, commit "drm/bridge: trilinear: add the DPTX core and build
glue" only omits DRM_BRIDGE_OP_HPD on dp->bridge when the immediate
dp->next_bridge sets DRM_BRIDGE_OP_DETECT.  With an intermediate
pass-through bridge (ops == 0) ahead of a downstream detect-only bridge,
dp->bridge remains bridge_hpd: drm_bridge_connector_handle_hpd() clears
dp->notify_task via drm_bridge_connector_hpd_notify() before calling
drm_kms_helper_connector_hotplug_event() -> drm_client_dev_hotplug() ->
drm_bridge_connector_detect_ctx(), which re-enters dptx_hpd_notify() and
re-queues hpd_event_work with zero delay in an infinite hotplug loop.

[ ... ]

> +static int dptx_bridge_get_modes(struct drm_bridge *bridge,
> +				 struct drm_connector *connector)
> +{
> +	struct dptx_dev *dp = bridge_to_dp(bridge);
> +	const struct drm_edid *edid;
> +	struct drm_display_mode *mode;
> +	int ret;
> +
> +	scoped_guard(mutex, &dp->lock) {
> +		if (dp->released ||
> +		    (dp->state & DPTX_STATE_SUSPENDED) ||
> +		    !(dp->state & DPTX_STATE_INITIALIZED) ||
> +		    !(dp->state & DPTX_STATE_CONNECTED))
> +			return 0;
> +
> +		edid = drm_edid_read(connector);
> +	}
> +
> +	if (edid) {
> +		drm_edid_connector_update(connector, edid);
> +		ret = drm_edid_connector_add_modes(connector);
> +		drm_edid_free(edid);
> +
> +		return ret;
> +	}
> +
> +	drm_edid_connector_update(connector, NULL);

[Severity: Low]
Does this early return leave a stale EDID blob and stale
connector->display_info fields on the connector?

When a connector is forced on (DRM_FORCE_ON or DRM_FORCE_ON_DIGITAL)
after a sink is unplugged, drm_helper_probe_single_connector_modes()
skips its disconnected EDID-clearing path and calls get_modes()
directly.  Returning 0 before drm_edid_connector_update(connector, NULL)
leaves the previous sink's bpc, color_formats, and YCbCr 4:2:0 mode
masks populated; clearing EDID before returning 0 would match
drm_bridge_connector_get_modes_edid().

[ ... ]

> +static int dptx_bridge_mode_set(struct dptx_dev *dp,
> +				struct drm_crtc_state *crtc_state,
> +				struct drm_connector_state *conn_state)
> +{
> +	struct drm_display_mode *adjusted_mode = &crtc_state->adjusted_mode;
> +	int color_format;
> +	int link_rate;
> +	int bw_code;
> +	int bpc;
> +	int bpp;
> +	int ret;
> +
> +	ret = dp->ops->detect(dp);
> +	if (ret)
> +		return ret;
> +
> +	guard(mutex)(&dp->lock);
> +
> +	if (dp->released)
> +		return -ENODEV;
> +
> +	ret = dptx_pick_config(dp, conn_state, &crtc_state->mode,
> +			       adjusted_mode, &color_format, &bpc, &bpp);

[Severity: Medium]
Is there a data race on connector->display_info between
dptx_bridge_mode_set() and a concurrent connector probe?

CPU0 (commit_work)                CPU1 (DRM_IOCTL_MODE_GETCONNECTOR)
------------------                ----------------------------------
                                  drm_helper_probe_single_connector_modes()
                                    dptx_bridge_get_modes()
                                      /* releases dp->lock */
dptx_bridge_atomic_enable()
  dptx_bridge_mode_set()
    lock(&dp->lock)
                                      drm_edid_connector_update()
                                        drm_reset_display_info()
                                          info->color_formats = 0;
                                          memset(&info->hdmi, 0, ...);
    dptx_pick_config()  <-- data race on connector->display_info

For a non-blocking atomic commit, drm_mode_atomic_ioctl() drops
connection_mutex after queuing state->commit_work, so
dptx_bridge_mode_set() holds only dp->lock while dptx_bridge_get_modes()
calls drm_edid_connector_update() without dp->lock.  If
dptx_pick_config() runs during drm_reset_display_info() for a mode that
needs YCbCr 4:2:0 or 4:2:2, it fails with -EINVAL and
dptx_bridge_atomic_enable() aborts, leaving the output blank after the
ioctl already succeeded.  Storing the format, bpc, and bpp computed in
dptx_bridge_atomic_check() in bridge state would avoid reading
display_info in atomic_enable.

[ ... ]

> +static int dptx_bridge_atomic_check(struct drm_bridge *bridge,
> +				    struct drm_bridge_state *bridge_state,
> +				    struct drm_crtc_state *crtc_state,
> +				    struct drm_connector_state *conn_state)
> +{

[ ... ]

> +	if (vsc_supported) {
> +		const struct drm_connector_state *old_conn_state;
> +
> +		old_conn_state =
> +			drm_atomic_get_old_connector_state(bridge_state->base.state,
> +							   conn_state->connector);
> +		if (old_conn_state &&
> +		    old_conn_state->colorspace != conn_state->colorspace) {
> +			crtc_state->mode_changed = true;
> +
> +			ret = drm_atomic_add_affected_planes(bridge_state->base.state,
> +							     crtc_state->crtc);
> +			if (ret)
> +				return ret;
> +		}
> +	}

[Severity: High]
Can calling drm_atomic_add_affected_planes() from
dptx_bridge_atomic_check() cause an ABBA deadlock with
encoder->bridge_chain_mutex?

CPU0                              CPU1
----                              ----
lock(&encoder->bridge_chain_mutex)
                                  lock(&plane->mutex)
lock(&plane->mutex)
                                  lock(&encoder->bridge_chain_mutex)

 *** DEADLOCK ***

CPU0: drm_atomic_bridge_chain_check() -> dptx_bridge_atomic_check()
      -> drm_atomic_add_affected_planes() -> drm_atomic_get_plane_state()
CPU1: drm_atomic_helper_check_modeset() -> drm_atomic_add_affected_planes()
      -> mode_fixup() -> drm_atomic_bridge_chain_check()

drm_atomic_bridge_chain_check() holds the plain mutex
encoder->bridge_chain_mutex across dptx_bridge_atomic_check(), whereas
drm_atomic_add_affected_planes() acquires plane->mutex (a crtc_ww_class
ww_mutex).  Because encoder->bridge_chain_mutex is not a ww_mutex, CPU1
cannot back off with -EDEADLK when a colorspace-only atomic commit races
with a commit holding plane->mutex.

Setting crtc_state->mode_changed here also happens after mode_fixup() in
drm_atomic_helper_check_modeset() has already skipped copying mode into
adjusted_mode, so the CRTC's mode_fixup() runs on a stale adjusted_mode.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261204131053.351956-1-Luo.Liu@cixtech.com?part=3

  reply	other threads:[~2026-12-04 14:19 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04 13:10 [PATCH v11 0/5] drm/bridge: trilinear: add the Sky1 DisplayPort transmitter Luo Liu
2026-12-04 13:10 ` [PATCH v11 1/5] dt-bindings: display: add CIX " Luo Liu
2026-12-04 13:10 ` [PATCH v11 2/5] drm/bridge: trilinear: add the DPTX hardware layer Luo Liu
2026-12-04 13:48   ` sashiko-bot
2026-12-04 13:10 ` [PATCH v11 3/5] drm/bridge: trilinear: add the DPTX DRM bridge Luo Liu
2026-12-04 14:19   ` sashiko-bot [this message]
2026-12-04 13:10 ` [PATCH v11 4/5] drm/bridge: trilinear: add the DPTX core and build glue Luo Liu
2026-12-04 14:53   ` sashiko-bot
2026-12-04 13:10 ` [PATCH v11 5/5] drm/cix: add the Sky1 DisplayPort platform glue Luo Liu
2026-12-04 15:06   ` sashiko-bot

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-249957@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