All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Sebastian Reichel" <sebastian.reichel@collabora.com>
Cc: dri-devel@lists.freedesktop.org, robh@kernel.org,
	conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v6 04/16] drm/bridge: synopsys: dw-dp: Add missing reinit_completion
Date: Fri, 24 Jul 2026 18:21:23 +0000	[thread overview]
Message-ID: <20260724182123.B758C1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260724-synopsys-dw-dp-improvements-v6-4-041d99a19c4e@collabora.com>

Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider:

Pre-existing issues:
- [High] The patch attempts to fix spurious completions from timed-out AUX transfers by adding `reinit_completion()`, but the fix is insufficient due to a TOCTOU race with the driver's threaded IRQ handler.
- [High] The driver fails to support DP AUX short reads, incorrectly rejecting them with -EBUSY instead of returning the number of bytes successfully transferred, which breaks I2C-over-AUX.
- [High] Missing hardware reset on AUX transfer timeout leaves the controller in an undefined/busy state.
- [High] The DP AUX channel and I2C adapter are registered and exposed before the hardware is initialized and interrupts are enabled, causing early access to fail with timeouts.
- [High] DP AUX transfers can execute with the PHY powered off, leading to hardware timeouts or crashes.
--

--- Patch [4]: [PATCH v6 04/16] drm/bridge: synopsys: dw-dp: Add missing reinit_completion ---
commit fc6159d600f530845f6f08962e449b720526ee08
Author: Sebastian Reichel <sebastian.reichel@collabora.com>
drm/bridge: synopsys: dw-dp: Add missing reinit_completion

This patch adds a reinit_completion call before sending an AUX command
to prevent subsequent transfers from immediately triggering if an earlier
one timed out and the interrupt fired later.

> diff --git a/drivers/gpu/drm/bridge/synopsys/dw-dp.c b/drivers/gpu/drm/bridge/synopsys/dw-dp.c
> index b28040d69fabf..2f0ee7ab7febd 100644
> --- a/drivers/gpu/drm/bridge/synopsys/dw-dp.c
> +++ b/drivers/gpu/drm/bridge/synopsys/dw-dp.c
> @@ -1465,6 +1465,8 @@ static ssize_t dw_dp_aux_transfer(struct drm_dp_aux *aux,
>  	if (WARN_ON(msg->size > 16))
>  		return -E2BIG;
>  
> +	reinit_completion(&dp->complete);
> +

[Severity: High]
This isn't a bug introduced by this patch, but the attempt to fix the
spurious completions seems incomplete due to a race condition. Because
reinit_completion is called locklessly here, could the threaded IRQ handler
execute concurrently?

If dw_dp_irq is processing a delayed interrupt from a previous timeout:

dw_dp_irq() {
    ...
    complete(&dp->complete);
}

Doesn't this mean it could call complete immediately after this
reinit_completion, instantly satisfying the new wait and causing the driver
to read garbage hardware status?

>  	switch (msg->request & ~DP_AUX_I2C_MOT) {
>  	case DP_AUX_NATIVE_WRITE:
>  	case DP_AUX_I2C_WRITE:

[Severity: High]
This is a pre-existing issue, but does this driver fail to support DP AUX
short reads?

Later in dw_dp_aux_transfer:

    if (count != msg->size)
        return -EBUSY;

If the hardware returns fewer bytes than requested, returning -EBUSY causes
the DRM core helper drm_dp_i2c_do_msg to endlessly retry the exact same
full-length transfer without advancing its buffer. Could this break
communication with I2C devices on the DP bus?

[Severity: High]
This is a pre-existing issue, but is a hardware reset missing when an AUX
transfer times out?

In the error path of dw_dp_aux_transfer:

    if (!status) {
        dev_err(dp->dev, "timeout waiting for AUX reply\n");
        return -ETIMEDOUT;
    }

If wait_for_completion_timeout expires, returning -ETIMEDOUT without
resetting the underlying AUX controller or clearing the pending state might
leave the hardware state machine permanently stuck. Will subsequent transfers
fail because the hardware is still busy?

[Severity: High]
This isn't a bug introduced by this patch, but is the AUX channel registered
before interrupts are enabled?

Looking at dw_dp_bind, the channel is registered early:

    ret = drm_dp_aux_register(&dp->aux);

But interrupts are enabled much later in the same function:

    enable_irq(dp->irq);

If a userspace tool like ddcutil or an I2C auto-prober attempts a transaction
in this window, won't dw_dp_aux_transfer fail because the hardware cannot
yet generate interrupts?

[Severity: High]
This is a pre-existing issue, but can DP AUX transfers execute with the PHY
powered off?

Direct accesses from userspace via the character device call directly into:

static ssize_t dw_dp_aux_transfer(struct drm_dp_aux *aux,
                                  struct drm_dp_aux_msg *msg)

Internal callers wrap this to ensure the PHY is powered on:

dw_dp_bridge_edid_read() {
    ...
    ret = phy_power_on(dp->phy);
    if (ret)
        return NULL;

    edid = drm_edid_read_ddc(connector, &dp->aux.ddc);

    phy_power_off(dp->phy);
    ...
}

Since dw_dp_aux_transfer itself doesn't check or manage the PHY power state,
could a direct userspace access while the display is suspended cause MMIO
timeouts or system crashes?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260724-synopsys-dw-dp-improvements-v6-0-041d99a19c4e@collabora.com?part=4

  reply	other threads:[~2026-07-24 18:21 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-24 18:03 [PATCH v6 00/16] Synopsys DisplayPort Controller improvements for Rockchip platforms Sebastian Reichel
2026-07-24 18:03 ` Sebastian Reichel
2026-07-24 18:03 ` [PATCH v6 01/16] drm/bridge: synopsys: dw-dp: Fix incorrect resource lifetimes in bind callback Sebastian Reichel
2026-07-24 18:03   ` Sebastian Reichel
2026-07-24 18:18   ` sashiko-bot
2026-07-24 18:03 ` [PATCH v6 02/16] drm/bridge: synopsys: dw-dp: Cancel pending HPD work on unbind Sebastian Reichel
2026-07-24 18:03   ` Sebastian Reichel
2026-07-24 18:03 ` [PATCH v6 03/16] drm/bridge: synopsys: dw-dp: Add missing mutex cleanups on module removal Sebastian Reichel
2026-07-24 18:03   ` Sebastian Reichel
2026-07-24 18:15   ` sashiko-bot
2026-07-24 18:03 ` [PATCH v6 04/16] drm/bridge: synopsys: dw-dp: Add missing reinit_completion Sebastian Reichel
2026-07-24 18:03   ` Sebastian Reichel
2026-07-24 18:21   ` sashiko-bot [this message]
2026-07-24 18:03 ` [PATCH v6 05/16] drm/bridge: synopsys: dw-dp: Free output_fmts when none are valid Sebastian Reichel
2026-07-24 18:03   ` Sebastian Reichel
2026-07-24 18:03 ` [PATCH v6 06/16] drm/bridge: synopsys: dw-dp: Support MEDIA_BUS_FMT_FIXED Sebastian Reichel
2026-07-24 18:03   ` Sebastian Reichel
2026-07-24 18:03 ` [PATCH v6 07/16] drm/bridge: synopsys: dw-dp: Add follow-up bridge support Sebastian Reichel
2026-07-24 18:03   ` Sebastian Reichel
2026-07-24 18:03 ` [PATCH v6 08/16] drm/bridge: Add out-of-band HPD notify handler Sebastian Reichel
2026-07-24 18:03   ` Sebastian Reichel
2026-07-24 18:03 ` [PATCH v6 09/16] drm/bridge: synopsys: dw-dp: Support software triggered OOB HPD Sebastian Reichel
2026-07-24 18:03   ` Sebastian Reichel
2026-07-24 18:03 ` [PATCH v6 10/16] drm/rockchip: dw_dp: Implement out-of-band HPD handling Sebastian Reichel
2026-07-24 18:03   ` Sebastian Reichel
2026-07-24 18:27   ` sashiko-bot
2026-07-24 18:03 ` [PATCH v6 11/16] drm/bridge: synopsys: dw-dp: Add Runtime PM support Sebastian Reichel
2026-07-24 18:03   ` Sebastian Reichel
2026-07-24 18:24   ` sashiko-bot
2026-07-24 18:03 ` [PATCH v6 12/16] drm/rockchip: dw_dp: Add runtime " Sebastian Reichel
2026-07-24 18:03   ` Sebastian Reichel
2026-07-24 18:27   ` sashiko-bot
2026-07-24 18:03 ` [PATCH v6 13/16] drm/bridge: synopsys: dw-dp: Protect sdp_reg_bank from concurrent access Sebastian Reichel
2026-07-24 18:03   ` Sebastian Reichel
2026-07-24 18:03 ` [PATCH v6 14/16] drm/bridge: synopsys: dw-dp: Use regmap_set_bits in dw_dp_send_sdp Sebastian Reichel
2026-07-24 18:03   ` Sebastian Reichel
2026-07-24 18:03 ` [PATCH v6 15/16] dt-bindings: display: rockchip: dw-dp: Fix sound DAI cells Sebastian Reichel
2026-07-24 18:03   ` Sebastian Reichel
2026-07-24 18:03 ` [PATCH v6 16/16] drm/bridge: synopsys: dw-dp: Add audio support Sebastian Reichel
2026-07-24 18:03   ` Sebastian Reichel
2026-07-24 18:34   ` 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=20260724182123.B758C1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --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 \
    --cc=sebastian.reichel@collabora.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.