Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ronald Claveau" <linux-kernel-dev@aliel.fr>
Cc: devicetree@vger.kernel.org, linux-amlogic@lists.infradead.org,
	linux-phy@lists.infradead.org, dri-devel@lists.freedesktop.org,
	robh@kernel.org, conor+dt@kernel.org, neil.armstrong@linaro.org,
	vkoul@kernel.org, olteanv@gmail.com
Subject: Re: [PATCH v3 08/11] drm/meson: dw-hdmi: Use the generic PHY framework for the HDMI TX PHY
Date: Sat, 21 Nov 2026 19:37:03 +0000	[thread overview]
Message-ID: <sashiko-outbox-227314@kernel.org> (raw)
In-Reply-To: <20261121-meson-drm-create-hdmitx-phy-v3-8-f8f471788076@aliel.fr>

Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [High] drm/meson: dw-hdmi: invalid phy_destroy() in
  meson_dw_hdmi_bind() error path
- [Medium] drm/meson: dw-hdmi: stateless device link leaked in
  meson_dw_hdmi_unbind()
- [Medium] drm/meson: dw-hdmi: meson_venc_init() clobbers PHY CNTL0 on
  system resume
--

commit 60b745dc55898638b05c8fcafed9d3683b30dff0
Author: Ronald Claveau <linux-kernel-dev@aliel.fr>

drm/meson: dw-hdmi: Use the generic PHY framework for the HDMI TX PHY

This commit converts the Meson DW-HDMI glue driver to manage the HDMI TX
PHY through the generic PHY framework, with a legacy fallback when the
device tree lacks a "phys" property, and adds a stateless device link
between the VPU master and HDMI-TX device.

> diff --git a/drivers/gpu/drm/meson/meson_dw_hdmi.c b/drivers/gpu/drm/meson/meson_dw_hdmi.c
> index 20a821936b3af..8fdb997c28b40 100644
> --- a/drivers/gpu/drm/meson/meson_dw_hdmi.c
> +++ b/drivers/gpu/drm/meson/meson_dw_hdmi.c

[ ... ]

> @@ -746,7 +663,26 @@ static int meson_dw_hdmi_bind(struct device *dev, struct device *master,
>  		return ret;
>  	}
>  
> -	meson_dw_hdmi_init(meson_dw_hdmi);
> +	meson_dw_hdmi->phy = devm_phy_optional_get(dev, NULL);
> +	if (IS_ERR(meson_dw_hdmi->phy))
> +		return dev_err_probe(dev, PTR_ERR(meson_dw_hdmi->phy),
> +				     "failed to get HDMI PHY\n");
> +
> +	if (!meson_dw_hdmi->phy) {
> +		/* DEPRECATED: DT without "phys" */
> +		dev_warn(dev, "missing \"phys\", using legacy HDMI PHY\n");
> +		meson_dw_hdmi->phy = meson_hdmi_phy_create_legacy(dev, priv->hhi,
> +						meson_dw_hdmi->data->phy_soc);
> +		if (IS_ERR(meson_dw_hdmi->phy))
> +			return dev_err_probe(dev, PTR_ERR(meson_dw_hdmi->phy),
> +					     "failed to create legacy HDMI PHY\n");
> +
> +		meson_dw_hdmi->legacy_phy = true;
> +	}
> +
> +	ret = meson_dw_hdmi_init(meson_dw_hdmi);
> +	if (ret)
> +		return ret;
>  
>  	/* Bridge / Connector */
>  
> @@ -767,14 +703,26 @@ static int meson_dw_hdmi_bind(struct device *dev, struct device *master,
>  	platform_set_drvdata(pdev, meson_dw_hdmi);
>  
>  	meson_dw_hdmi->hdmi = dw_hdmi_probe(pdev, &meson_dw_hdmi->dw_plat_data);
> -	if (IS_ERR(meson_dw_hdmi->hdmi))
> -		return PTR_ERR(meson_dw_hdmi->hdmi);
> +	if (IS_ERR(meson_dw_hdmi->hdmi)) {
> +		ret = PTR_ERR(meson_dw_hdmi->hdmi);
> +		goto err_hdmi_probe;
> +	}
>  
>  	meson_dw_hdmi->bridge = of_drm_find_and_get_bridge(pdev->dev.of_node);
>  
> +	link = device_link_add(master, dev, DL_FLAG_STATELESS);
> +	if (!link)
> +		dev_warn(dev, "failed to link HDMI (supplier) to DRM master (consumer)\n");
> +
>  	DRM_DEBUG_DRIVER("HDMI controller initialized\n");
>  
>  	return 0;
> +
> +err_hdmi_probe:
> +	phy_exit(meson_dw_hdmi->phy);
> +	phy_destroy(meson_dw_hdmi->phy);
> +
> +	return ret;
>  }

[Severity: High]
Does calling phy_destroy(meson_dw_hdmi->phy) in err_hdmi_probe cause a
double free or destroy the external provider's PHY when dw_hdmi_probe()
fails (for example with -EPROBE_DEFER)?

Both devm_phy_optional_get() and meson_hdmi_phy_create_legacy() (which
uses devm_phy_create()) are devres-managed in the component devres group
that component_bind() releases on bind failure.  When legacy_phy is
false, meson_dw_hdmi is only a consumer, so phy_destroy() unregisters
the external PHY provider's device while the provider remains bound.
When legacy_phy is true, component_bind() immediately runs
devm_phy_consume() -> phy_destroy() a second time on the already-freed
phy.

Dropping phy_destroy() from err_hdmi_probe and leaving the cleanup to
component_bind()'s devres release avoids both issues.

>  
>  static void meson_dw_hdmi_unbind(struct device *dev, struct device *master,
> @@ -786,6 +734,10 @@ static void meson_dw_hdmi_unbind(struct device *dev, struct device *master,
>  
>  	devm_free_irq(dev, irq, meson_dw_hdmi);
>  	dw_hdmi_unbind(meson_dw_hdmi->hdmi);
> +
> +	phy_exit(meson_dw_hdmi->phy);
> +	if (meson_dw_hdmi->legacy_phy)
> +		devm_phy_destroy(dev, meson_dw_hdmi->phy);
>  	drm_bridge_put(meson_dw_hdmi->bridge);
>  }

[Severity: Medium]
Does meson_dw_hdmi_unbind() leak the DL_FLAG_STATELESS device link
created in meson_dw_hdmi_bind()?  Stateless device links are not removed
automatically by the driver core on unbind and require an explicit
device_link_remove(master, dev) or device_link_del().

> @@ -801,6 +753,8 @@ static int __maybe_unused meson_dw_hdmi_pm_suspend(struct device *dev)
>  	if (!meson_dw_hdmi)
>  		return 0;
>  
> +	phy_exit(meson_dw_hdmi->phy);
> +
>  	/* Reset TOP */
>  	meson_dw_hdmi->data->top_write(meson_dw_hdmi,
>  				       HDMITX_TOP_SW_RESET, 0);
> @@ -811,11 +765,14 @@ static int __maybe_unused meson_dw_hdmi_pm_suspend(struct device *dev)
>  static int __maybe_unused meson_dw_hdmi_pm_resume(struct device *dev)
>  {
>  	struct meson_dw_hdmi *meson_dw_hdmi = dev_get_drvdata(dev);
> +	int ret;
>  
>  	if (!meson_dw_hdmi)
>  		return 0;
>  
> -	meson_dw_hdmi_init(meson_dw_hdmi);
> +	ret = meson_dw_hdmi_init(meson_dw_hdmi);
> +	if (ret)
> +		return ret;
>  
>  	dw_hdmi_resume(meson_dw_hdmi->hdmi);

[Severity: Medium]
With the new device link ordering dev (supplier) to resume before master
(consumer), will meson_drv_pm_resume() -> meson_venc_init() clobber
HHI_HDMI_PHY_CNTL0 after meson_dw_hdmi_pm_resume() has initialized the
PHY?

drivers/gpu/drm/meson/meson_venc.c:meson_venc_init() {
	...
	/* Disable HDMI PHY */
	regmap_write(priv->hhi, HHI_HDMI_PHY_CNTL0, 0);
	...
}

meson_dw_hdmi_init() calls phy_init(), which programs HHI_HDMI_PHY_CNTL0
to cntl0_init (0x000b4242 on G12A for the bandgap).  When the consumer
meson_drv_pm_resume() runs next, meson_venc_init() overwrites
HHI_HDMI_PHY_CNTL0 with 0, leaving the G12A bandgap disabled whenever no
HDMI mode is active across suspend and resume.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261121-meson-drm-create-hdmitx-phy-v3-0-f8f471788076@aliel.fr?part=8

  reply	other threads:[~2026-11-21 19:37 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-21 19:21 [PATCH v3 00/11] phy/drm: amlogic: Extract Meson HDMI TX PHY into a dedicated driver Ronald Claveau via B4 Relay
2026-11-21 19:21 ` [PATCH v3 01/11] dt-bindings: soc: amlogic: meson-gx-hhi-sysctrl: Fix compatible matching in conditionals Ronald Claveau via B4 Relay
2026-11-21 19:21 ` [PATCH v3 02/11] dt-bindings: phy: amlogic: Add Meson HDMI TX PHY binding Ronald Claveau via B4 Relay
2026-11-21 19:26   ` sashiko-bot
2026-11-21 19:21 ` [PATCH v3 03/11] dt-bindings: soc: amlogic: meson-gx-hhi-sysctrl: Add hdmi-phy child node Ronald Claveau via B4 Relay
2026-11-21 19:21 ` [PATCH v3 04/11] phy: amlogic: Add Meson HDMI TX PHY driver Ronald Claveau via B4 Relay
2026-11-21 19:43   ` sashiko-bot
2026-11-21 19:21 ` [PATCH v3 05/11] dt-bindings: display: amlogic,meson-dw-hdmi: Add phys Ronald Claveau via B4 Relay
2026-11-21 19:21 ` [PATCH v3 06/11] pmdomain: amlogic: meson-ee-pwrc: power up memories for boot-enabled domains Ronald Claveau via B4 Relay
2026-11-21 19:21 ` [PATCH v3 07/11] drm/meson: dw-hdmi: Drop manual HHI clock and memory PD setup Ronald Claveau via B4 Relay
2026-11-21 19:21 ` [PATCH v3 08/11] drm/meson: dw-hdmi: Use the generic PHY framework for the HDMI TX PHY Ronald Claveau via B4 Relay
2026-11-21 19:37   ` sashiko-bot [this message]
2026-11-21 19:21 ` [PATCH v3 09/11] arm64: dts: amlogic: Add HDMI TX PHY node for G12 Ronald Claveau via B4 Relay
2026-11-21 19:21 ` [PATCH v3 10/11] arm64: dts: amlogic: Add HDMI TX PHY node for GXBB Ronald Claveau via B4 Relay
2026-11-21 19:21 ` [PATCH v3 11/11] arm64: dts: amlogic: Add HDMI TX PHY node for GXL Ronald Claveau via B4 Relay

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-227314@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-amlogic@lists.infradead.org \
    --cc=linux-kernel-dev@aliel.fr \
    --cc=linux-phy@lists.infradead.org \
    --cc=neil.armstrong@linaro.org \
    --cc=olteanv@gmail.com \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=vkoul@kernel.org \
    /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