All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Frank Zhang" <rmxpzlb@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v7] drm/bridge: dw-hdmi-qp: serialize HDMI audio callbacks with PHY enable/disable
Date: Thu, 12 Nov 2026 10:29:40 +0000	[thread overview]
Message-ID: <sashiko-outbox-210943@kernel.org> (raw)
In-Reply-To: <20261112101155.47777-1-rmxpzlb@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] drm/bridge: dw-hdmi-qp: unbalanced PHY disable on init
  failure
--

commit 964bd3d6c9dd93511a7cc0697725f1d96d4a0a68
Author: Frank Zhang <rmxpzlb@gmail.com>

drm/bridge: dw-hdmi-qp: serialize HDMI audio callbacks with PHY enable/disable

This commit adds a mutex and an enabled flag to struct dw_hdmi_qp's phy
sub-structure to serialize HDMI audio and infoframe callbacks against PHY
initialization and disablement.

> diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi-qp.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-qp.c
> index 62835485d66a1..ef5ccf0f609ce 100644
> --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi-qp.c
> +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-qp.c

[ ... ]

> @@ -572,10 +597,25 @@ static void dw_hdmi_qp_bridge_atomic_enable(struct drm_bridge *bridge,
>  	scoped_guard(mutex, &hdmi->mutex)
>  		hdmi->curr_conn = connector;
>  
> -	hdmi->phy.ops->init(hdmi, hdmi->phy.data);
> +	ret = hdmi->phy.ops->init(hdmi, hdmi->phy.data);
> +	if (unlikely(ret)) {
> +		dev_err(hdmi->dev, "failed to initialize PHY: %d\n", ret);
> +		scoped_guard(mutex, &hdmi->mutex) {
> +			drm_connector_put(hdmi->curr_conn);
> +			hdmi->curr_conn = NULL;
> +		}
> +
> +		hdmi->phy.enabled = false;
> +		hdmi->tmds_char_rate = 0;
> +
> +		mutex_unlock(&hdmi->phy.lock);
> +		return;
> +	}
> +	hdmi->phy.enabled = true;
>  
>  	dw_hdmi_qp_mod(hdmi, HDCP2_BYPASS, HDCP2_BYPASS, HDCP2LOGIC_CONFIG0);
>  	dw_hdmi_qp_mod(hdmi, op_mode, OPMODE_DVI, LINK_CONFIG0);
> +	mutex_unlock(&hdmi->phy.lock);
>  
>  	drm_atomic_helper_connector_hdmi_update_infoframes(connector, state);
>  }
> @@ -593,12 +633,14 @@ static void dw_hdmi_qp_bridge_atomic_disable(struct drm_bridge *bridge,
>  		}
>  	}
>  
> +	guard(mutex)(&hdmi->phy.lock);
>  	hdmi->tmds_char_rate = 0;
>  
>  	connector = drm_atomic_get_old_connector_for_encoder(state, bridge->encoder);
>  	drm_connector_hdmi_disable_scrambling(connector);
>  
>  	hdmi->phy.ops->disable(hdmi, hdmi->phy.data);
> +	hdmi->phy.enabled = false;
>  }

[Severity: Medium]
If hdmi->phy.ops->init() fails in dw_hdmi_qp_bridge_atomic_enable(), can
the subsequent dw_hdmi_qp_bridge_atomic_disable() call
hdmi->phy.ops->disable() on a PHY that was never enabled?

Because atomic_enable returns void, the DRM atomic state still considers
the bridge enabled and will call dw_hdmi_qp_bridge_atomic_disable() on the
next modeset disable.  In the Rockchip glue driver, init() and disable()
wrap phy_power_on() and phy_power_off().  An unbalanced phy_power_off()
underflows phy->power_count from 0 to -1, which causes the next
phy_power_on() to increment phy->power_count back to 0 and return 0
without powering on the hardware; dw_hdmi_qp_bridge_atomic_enable() then
sets hdmi->phy.enabled = true and accesses controller registers with the
PHY off, triggering an SError panic.

In addition, the error path in dw_hdmi_qp_bridge_atomic_enable() returns
without calling drm_connector_hdmi_disable_scrambling(connector) to undo
the earlier drm_connector_hdmi_enable_scrambling() call and cancel
connector->hdmi.scdc_work.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261112101155.47777-1-rmxpzlb@gmail.com?part=1

      reply	other threads:[~2026-11-12 10:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12 10:11 [PATCH v7] drm/bridge: dw-hdmi-qp: serialize HDMI audio callbacks with PHY enable/disable Frank Zhang
2026-11-12 10:11 ` Frank Zhang
2026-11-12 10:29 ` sashiko-bot [this message]

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-210943@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=rmxpzlb@gmail.com \
    --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 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.