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 v5 4/5] drm/bridge: trilinear: add the DPTX core and build glue
Date: Thu, 26 Nov 2026 06:20:44 +0000 [thread overview]
Message-ID: <sashiko-outbox-234833@kernel.org> (raw)
In-Reply-To: <20261126060003.3979478-5-Luo.Liu@cixtech.com>
Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [High] drm/bridge: trilinear: suspend race in dptx_prepare() and
dptx_unprepare()
- [Medium] drm/bridge: trilinear: dptx_pm_prepare() clears force_hpd
before core_off
- [Medium] drm/bridge: trilinear: dptx_detect() race drops HPD
notification in worker
- [Medium] drm/bridge: trilinear: dptx_host_deinit() disables host
before AUX poweroff
--
commit e4c145e1af987165c679844b15b259c9b490d6af
Author: Luo Liu <Luo.Liu@cixtech.com>
drm/bridge: trilinear: add the DPTX core and build glue
This commit adds the Trilinear DPTX bridge core, including probe, system
sleep, hotplug workers, and stream state management, 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/drm/bridge/trilinear/dptx_core.c
> new file mode 100644
> index 0000000000000..532f4fe0577f2
> --- /dev/null
> +++ b/drivers/gpu/drm/bridge/trilinear/dptx_core.c
> @@ -0,0 +1,1080 @@
[ ... ]
> +static void dptx_host_deinit(struct dptx_dev *dp)
> +{
> + if (dp->state & DPTX_STATE_READY)
> + dptx_core_off(dp);
> +
> + if (!(dp->state & DPTX_STATE_INITIALIZED))
> + return;
> +
> + dp->hw->ops->host_enable(dp->hw, false);
> + phy_exit(dp->phy);
> +
> + drm_dp_dpcd_set_powered(&dp->hw->aux, false);
> + dp->hw->ops->apb_clock(dp->hw, false);
> +
> + dp->state &= ~(DPTX_STATE_INITIALIZED | DPTX_STATE_INIT_TRAIN);
> +}
[Severity: Medium]
Should drm_dp_dpcd_set_powered(&dp->hw->aux, false) run before
host_enable(dp->hw, false) and phy_exit(dp->phy)?
DPCD transactions through /dev/drm_dp_auxN serialize on aux.hw_mutex and
aux.powered_down rather than dp->lock. Disabling the transmitter and
exiting the PHY before marking the AUX channel powered down lets a
concurrent DPCD access run dptx_hw_aux_transfer() while the host and PHY
are being torn down.
[ ... ]
> +static int dptx_detect_locked(struct dptx_dev *dp)
> +{
> + int ret;
> +
> + if (dp->released) {
> + ret = -ENODEV;
> + goto out;
> + }
> +
> + if (dp->state & DPTX_STATE_SUSPENDED) {
> + ret = -EBUSY;
> + goto out;
> + }
> +
> + if (!(dp->state & DPTX_STATE_INITIALIZED)) {
> + dev_warn_once(dp->dev, "detect with uninitialized host\n");
> + ret = -ENODEV;
> + goto out;
> + }
> +
> + if (!dptx_get_hpd_state(dp)) {
> + dptx_handle_disconnect(dp);
> + ret = -ENODEV;
> + goto out;
> + }
> +
> + ret = dptx_handle_connect(dp);
> +
> +out:
> + dp->status = dptx_ret_to_status(ret);
> +
> + return ret;
> +}
[ ... ]
> +static void dptx_hpd_event_work_func(struct work_struct *work)
> +{
> + struct dptx_dev *dp = container_of(work, struct dptx_dev,
> + hpd_event_work.work);
> + enum drm_connector_status old_status;
> + enum drm_connector_status status;
> + bool hpd;
> +
> + scoped_guard(mutex, &dp->lock) {
> + if (dptx_hpd_work_aborted(dp))
> + return;
> +
> + old_status = dp->status;
> + hpd = dptx_get_hpd_state(dp);
> + }
> +
> + if (hpd && dp->oob_hpd && !dptx_wait_phy_dp_mode(dp))
> + return;
> +
> + scoped_guard(mutex, &dp->lock) {
> + if (dptx_hpd_work_aborted(dp))
> + return;
> +
> + status = dptx_ret_to_status(dptx_detect_locked(dp));
> + }
> +
> + if (old_status != status && dp->bridge.dev)
> + dptx_notify_hpd(dp, status);
> +}
[Severity: Medium]
Can a concurrent dptx_detect() call update dp->status and cause
dptx_hpd_event_work_func() to drop its HPD notification?
CPU0 (hpd_event_work) CPU1 (connector probe / modeset)
dptx_queue_hpd_event()
dptx_detect()
lock(&dp->lock)
dptx_detect_locked()
dp->status = connected
unlock(&dp->lock)
dptx_hpd_event_work_func()
lock(&dp->lock)
old_status = dp->status
...
status = dptx_detect_locked()
unlock(&dp->lock)
old_status != status <-- false, dptx_notify_hpd() skipped
The same mismatch can happen on OOB hotplug when dptx_hpd_event_work_func()
captures old_status == connector_status_connected, drops dp->lock in
dptx_wait_phy_dp_mode(), and a concurrent dptx_bridge_detect() probes
before the PHY enters PHY_MODE_DP (setting dp->status and the DRM
connector to disconnected): once the PHY enters DP mode and
dptx_detect_locked() succeeds, status matches old_status and
dptx_notify_hpd() is skipped, leaving the DRM connector state disconnected.
[ ... ]
> +static int dptx_pm_prepare(struct dptx_dev *dp)
> +{
> + scoped_guard(mutex, &dp->lock) {
> + dptx_irq_off(dp);
> + dp->state |= DPTX_STATE_SUSPENDED;
> + }
> +
> + dptx_cancel_hpd_works(dp);
> +
> + scoped_guard(mutex, &dp->lock) {
> + if (!(dp->state & DPTX_STATE_SUSPENDED)) {
> + dptx_irq_off(dp);
> + dp->state |= DPTX_STATE_SUSPENDED;
> + }
> +
> + if (!dp->active_stream_cnt)
> + dptx_host_deinit(dp);
> + dp->status = connector_status_unknown;
> + dp->force_hpd = connector_status_unknown;
> + dp->state &= ~DPTX_STATE_CONNECTED;
> + }
> +
> + return 0;
> +}
[Severity: Medium]
When dp->active_stream_cnt is non-zero during dptx_pm_prepare(), does
clearing dp->force_hpd here prevent dptx_core_off() from powering down a
USB-C sink in D3?
When a stream is still active, dptx_pm_prepare() defers dptx_host_deinit()
to the suspend-time atomic disable commit in dptx_unprepare(), which calls
dptx_core_off() -> dpcd_power_down(dp->hw, dptx_get_hpd_state(dp)). On
oob_hpd transmitters hardware HPD is not wired, so once dp->force_hpd is
reset to connector_status_unknown, dptx_get_hpd_state() returns false and
dptx_hw_dpcd_power_down() skips writing DP_SET_POWER_D3.
[ ... ]
> +static int dptx_prepare(struct dptx_dev *dp)
> +{
> + int ret;
> +
> + guard(mutex)(&dp->lock);
> +
> + if (dp->released)
> + return -ENODEV;
> +
> + /* The controller's resume commit can precede dptx_pm_complete(). */
> + ret = dptx_host_resume(dp);
> + if (ret)
> + return ret;
> +
> + if (dp->state & DPTX_STATE_ENABLED)
> + return 0;
> +
> + if (!(dp->state & DPTX_STATE_INITIALIZED)) {
> + ret = dptx_host_init(dp);
> + if (ret)
> + return ret;
> + } else if (dp->state & DPTX_STATE_READY) {
> + /* core_on() finished, but the stream never became ENABLED. */
> + dptx_core_off(dp);
> + }
> +
> + if (!dptx_get_hpd_state(dp)) {
> + if (!dp->oob_hpd ||
> + dp->force_hpd != connector_status_unknown ||
> + phy_get_mode(dp->phy) != PHY_MODE_DP ||
> + !dp->hw->ops->sink_present(dp->hw))
> + return -ENODEV;
> +
> + dp->force_hpd = connector_status_connected;
> + }
> +
> + return dptx_handle_connect(dp);
> +}
> +
> +static int dptx_unprepare(struct dptx_dev *dp)
> +{
> + if (dp->active_stream_cnt)
> + return 0;
> +
> + if (!(dp->state & (DPTX_STATE_ENABLED | DPTX_STATE_READY)))
> + return 0;
> +
> + dptx_core_off(dp);
> +
> + /* dptx_pm_prepare() may have run before this suspend-time commit. */
> + if (dp->state & DPTX_STATE_SUSPENDED)
> + dptx_host_deinit(dp);
> +
> + dp->state &= ~DPTX_STATE_ENABLED;
> +
> + return 0;
> +}
[Severity: High]
Can an atomic enable racing with or running after dptx_pm_prepare() leave
the host initialized and dp->irq armed across system suspend or shutdown?
CPU0 (suspend / shutdown) CPU1 (atomic enable)
dptx_pm_prepare()
lock(&dp->lock)
dptx_irq_off()
dp->state |= DPTX_STATE_SUSPENDED
unlock(&dp->lock)
dptx_cancel_hpd_works()
dptx_bridge_atomic_enable()
dptx_prepare()
lock(&dp->lock)
dptx_host_resume()
dptx_host_init()
enable_irq(dp->irq)
dp->state &= ~DPTX_STATE_SUSPENDED
unlock(&dp->lock)
<HPD IRQ queues hpd_event_work>
lock(&dp->lock)
dptx_irq_off()
dp->state |= DPTX_STATE_SUSPENDED
dptx_host_deinit()
unlock(&dp->lock)
dptx_bridge_mode_set()
dptx_detect() -> -EBUSY
dptx_unprepare()
!(state & (ENABLED | READY))
return 0 <-- skips dptx_host_deinit()
There are three related issues in this path:
First, if dptx_prepare() runs after dptx_pm_prepare() has already finished
(for example after trilinear_dptx_suspend() or trilinear_dptx_shutdown()),
dptx_host_resume() re-initializes the host, calls enable_irq(dp->irq), and
clears DPTX_STATE_SUSPENDED, and nothing reinstates DPTX_STATE_SUSPENDED
or disables dp->irq afterwards.
Second, in dptx_unprepare(), the early return when neither
DPTX_STATE_ENABLED nor DPTX_STATE_READY is set sits above the
DPTX_STATE_SUSPENDED check, so when dptx_bridge_atomic_enable() fails in
dptx_bridge_mode_set() or dptx_core_on() and jumps to err_unprepare,
dptx_unprepare() returns without calling dptx_host_deinit().
Third, when dptx_prepare() runs while dptx_pm_prepare() has dropped
dp->lock for dptx_cancel_hpd_works(), dptx_host_resume() re-enables
dp->irq without dp->hpd_stopped set, so an interrupt can re-queue
hpd_event_work or hpd_irq_work after dptx_cancel_hpd_works() has returned;
and if dptx_encoder_enable() finishes before dptx_pm_prepare() re-acquires
dp->lock, dp->active_stream_cnt is non-zero and dptx_pm_prepare() returns
without calling dptx_host_deinit().
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261126060003.3979478-1-Luo.Liu@cixtech.com?part=4
next prev parent reply other threads:[~2026-11-26 6:20 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 5:59 [PATCH v5 0/5] drm/bridge: trilinear: add the Sky1 DisplayPort transmitter Luo Liu
2026-11-26 5:59 ` [PATCH v5 1/5] dt-bindings: display: add CIX " Luo Liu
2026-11-26 6:13 ` sashiko-bot
2026-11-26 6:27 ` 回复: " Luo Liu
2026-11-26 11:41 ` Sebastian Reichel
2026-11-26 6:00 ` [PATCH v5 2/5] drm/bridge: trilinear: add the DPTX hardware layer Luo Liu
2026-11-26 6:00 ` [PATCH v5 3/5] drm/bridge: trilinear: add the DPTX DRM bridge Luo Liu
2026-11-26 6:00 ` [PATCH v5 4/5] drm/bridge: trilinear: add the DPTX core and build glue Luo Liu
2026-11-26 6:20 ` sashiko-bot [this message]
2026-11-26 6:00 ` [PATCH v5 5/5] drm/cix: add the Sky1 DisplayPort platform glue Luo Liu
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-234833@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