All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Sebastian Reichel" <sebastian.reichel@collabora.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org,
	dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v5 02/15] drm/bridge: synopsys: dw-dp: Cancel pending HPD work on unbind
Date: Thu, 23 Jul 2026 22:32:22 +0000	[thread overview]
Message-ID: <20260723223222.D43A91F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260724-synopsys-dw-dp-improvements-v5-2-9445c2e87441@collabora.com>

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

Pre-existing issues:
- [High] The completion `dp->complete` is not re-initialized before starting a new AUX transfer, causing subsequent transfers to falsely complete immediately if a previous transfer timed out.
- [High] The AUX read length calculation incorrectly subtracts 1 instead of adding 1, causing all DP AUX reads to fail with `-EBUSY`.
--

--- Patch [2]: [PATCH v5 02/15] drm/bridge: synopsys: dw-dp: Cancel pending HPD work on unbind ---
commit 7fd4acc667a3adf3c285f78c69b39dea1318c0a1
Author: Sebastian Reichel <sebastian.reichel@collabora.com>
Subject: drm/bridge: synopsys: dw-dp: Cancel pending HPD work on unbind

This commit fixes a race condition during device unbind where the HPD worker
thread might access invalid resources if started exactly when unbind happens.
It avoids this by canceling any pending HPD work immediately after disabling
the interrupt.

> diff --git a/drivers/gpu/drm/bridge/synopsys/dw-dp.c b/drivers/gpu/drm/bridge/synopsys/dw-dp.c
> index 368e1f85e6253..21bd08571dcfe 100644
> --- a/drivers/gpu/drm/bridge/synopsys/dw-dp.c
> +++ b/drivers/gpu/drm/bridge/synopsys/dw-dp.c
> @@ -2009,6 +2009,7 @@ EXPORT_SYMBOL_GPL(dw_dp_bind);
>  void dw_dp_unbind(struct dw_dp *dp)
>  {
>  	disable_irq(dp->irq);
> +	cancel_work_sync(&dp->hpd_work);
>  	phy_exit(dp->phy);
>  	drm_dp_aux_unregister(&dp->aux);
>  	drm_bridge_remove(&dp->bridge);

[Severity: High]
This isn't a bug introduced by this patch, but looking at dw_dp_aux_transfer()
in drivers/gpu/drm/bridge/synopsys/dw-dp.c, it seems dp->complete is not
re-initialized before waiting for completion:

drivers/gpu/drm/bridge/synopsys/dw-dp.c:dw_dp_aux_transfer() {
    ...
    if (msg->size > 0)
        value = FIELD_PREP(AUX_LEN_REQ, msg->size - 1);
    ...
    regmap_write(dp->regmap, DW_DP_AUX_CMD, value);

    status = wait_for_completion_timeout(&dp->complete, timeout);
    ...
}

If a previous transfer timed out, the completion count would remain 0.
If the hardware eventually finishes and fires a late interrupt, the interrupt
handler could call complete(&dp->complete).

Could a subsequent call to dw_dp_aux_transfer() then falsely complete
immediately if wait_for_completion_timeout() consumes this stale completion?

Would adding a call to reinit_completion(&dp->complete) before writing the
command resolve this?

[Severity: High]
This is a pre-existing issue, but further down in dw_dp_aux_transfer(), is there
a logic error in the AUX read length calculation?

drivers/gpu/drm/bridge/synopsys/dw-dp.c:dw_dp_aux_transfer() {
    ...
    if (msg->size > 0 && msg->reply == DP_AUX_NATIVE_REPLY_ACK) {
        if (msg->request & DP_AUX_I2C_READ) {
            size_t count = FIELD_GET(AUX_BYTES_READ, value) - 1;

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

Because 1 is subtracted from FIELD_GET(AUX_BYTES_READ, value) instead of being
added, count can never equal msg->size.

For example, if the hardware reports msg->size or msg->size - 1, subtracting 1
guarantees count evaluates to either msg->size - 1 or msg->size - 2.

Does this cause all DP AUX reads to unconditionally fail with -EBUSY, breaking
EDID reading and link training?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260724-synopsys-dw-dp-improvements-v5-0-9445c2e87441@collabora.com?part=2

  reply	other threads:[~2026-07-23 22:32 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-23 22:17 [PATCH v5 00/15] Synopsys DisplayPort Controller improvements for Rockchip platforms Sebastian Reichel
2026-07-23 22:17 ` Sebastian Reichel
2026-07-23 22:17 ` [PATCH v5 01/15] drm/bridge: synopsys: dw-dp: Fix incorrect resource lifetimes in bind callback Sebastian Reichel
2026-07-23 22:17   ` Sebastian Reichel
2026-07-23 22:34   ` sashiko-bot
2026-07-23 22:17 ` [PATCH v5 02/15] drm/bridge: synopsys: dw-dp: Cancel pending HPD work on unbind Sebastian Reichel
2026-07-23 22:17   ` Sebastian Reichel
2026-07-23 22:32   ` sashiko-bot [this message]
2026-07-23 22:17 ` [PATCH v5 03/15] drm/bridge: synopsys: dw-dp: Add missing mutex cleanups on module removal Sebastian Reichel
2026-07-23 22:17   ` Sebastian Reichel
2026-07-23 22:48   ` sashiko-bot
2026-07-23 22:17 ` [PATCH v5 04/15] drm/bridge: synopsys: dw-dp: Move dw_dp_bridge_atomic_get_output_bus_fmts() Sebastian Reichel
2026-07-23 22:17   ` Sebastian Reichel
2026-07-23 22:28   ` sashiko-bot
2026-07-23 22:17 ` [PATCH v5 05/15] drm/bridge: synopsys: dw-dp: Support MEDIA_BUS_FMT_FIXED Sebastian Reichel
2026-07-23 22:17   ` Sebastian Reichel
2026-07-23 22:31   ` sashiko-bot
2026-07-23 22:17 ` [PATCH v5 06/15] drm/bridge: synopsys: dw-dp: Add follow-up bridge support Sebastian Reichel
2026-07-23 22:17   ` Sebastian Reichel
2026-07-23 22:17 ` [PATCH v5 07/15] drm/bridge: Add out-of-band HPD notify handler Sebastian Reichel
2026-07-23 22:17   ` Sebastian Reichel
2026-07-23 22:17 ` [PATCH v5 08/15] drm/bridge: synopsys: dw-dp: Support software triggered OOB HPD Sebastian Reichel
2026-07-23 22:17   ` Sebastian Reichel
2026-07-23 22:17 ` [PATCH v5 09/15] drm/rockchip: dw_dp: Implement out-of-band HPD handling Sebastian Reichel
2026-07-23 22:17   ` Sebastian Reichel
2026-07-23 22:34   ` sashiko-bot
2026-07-23 22:17 ` [PATCH v5 10/15] drm/bridge: synopsys: dw-dp: Add Runtime PM support Sebastian Reichel
2026-07-23 22:17   ` Sebastian Reichel
2026-07-23 22:37   ` sashiko-bot
2026-07-23 22:17 ` [PATCH v5 11/15] drm/rockchip: dw_dp: Add runtime " Sebastian Reichel
2026-07-23 22:17   ` Sebastian Reichel
2026-07-23 22:40   ` sashiko-bot
2026-07-23 22:17 ` [PATCH v5 12/15] drm/bridge: synopsys: dw-dp: Protect sdp_reg_bank from concurrent access Sebastian Reichel
2026-07-23 22:17   ` Sebastian Reichel
2026-07-23 22:17 ` [PATCH v5 13/15] drm/bridge: synopsys: dw-dp: Use regmap_set_bits in dw_dp_send_sdp Sebastian Reichel
2026-07-23 22:17   ` Sebastian Reichel
2026-07-23 22:17 ` [PATCH v5 14/15] dt-bindings: display: rockchip: dw-dp: Fix sound DAI cells Sebastian Reichel
2026-07-23 22:17   ` Sebastian Reichel
2026-07-23 22:17 ` [PATCH v5 15/15] drm/bridge: synopsys: dw-dp: Add audio support Sebastian Reichel
2026-07-23 22:17   ` Sebastian Reichel
2026-07-23 22:38   ` 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=20260723223222.D43A91F000E9@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.