From: Ronald Claveau <linux-kernel-dev@aliel.fr>
To: sashiko-reviews@lists.linux.dev
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 07/10] drm/meson: dw-hdmi: Use the generic PHY framework for the HDMI TX PHY
Date: Fri, 20 Nov 2026 18:52:50 +0100 [thread overview]
Message-ID: <ef1b7465-9639-4d11-9b10-4b0c9da21bd5@aliel.fr> (raw)
In-Reply-To: <sashiko-outbox-219549@kernel.org>
On 11/17/26 21:03, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 3 potential
> issues to consider:
> - [High] drm/meson: dw-hdmi: suspend/resume order breaks PHY state and
> HDMI output
> - [Medium] drm/meson: dw-hdmi: missing phy_exit() on dw_hdmi_probe()
> failure
> - [Medium] drm/meson: dw-hdmi: premature PHY teardown in
> meson_dw_hdmi_unbind()
> --
>
> commit 91e31ad4e0b36171e791e7c0487c9a4c66b12b31
> 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 meson_dw_hdmi from direct HHI_HDMI_PHY_CNTL0..5
> register writes to the generic PHY API, with a legacy fallback when the
> device tree lacks a "phys" property.
>
>> diff --git a/drivers/gpu/drm/meson/meson_dw_hdmi.c b/drivers/gpu/drm/meson/meson_dw_hdmi.c
>> index 20a821936b3af..f28cc1e6ee1df 100644
>> --- a/drivers/gpu/drm/meson/meson_dw_hdmi.c
>> +++ b/drivers/gpu/drm/meson/meson_dw_hdmi.c
>
>
> [Severity: Medium]
> Does meson_dw_hdmi_bind() leak a phy_init() reference if dw_hdmi_probe()
> fails later in this function (for example with -EPROBE_DEFER when the DDC
> I2C bus is not ready)?
>
> When the PHY comes from the external PHY provider, devres cleanup on a
> failed component bind only calls phy_put(), leaving phy->init_count at 1.
> On the next bind attempt, meson_dw_hdmi_init() resets hdmitx_phy and calls
> phy_init(), which sees init_count > 0 and skips phy->ops->init(), leaving
> HHI_HDMI_PHY_CNTL0 and HHI_HDMI_PHY_CNTL1 uninitialized after the hardware
> reset.
>
I will move revert this change.
> [Severity: Medium]
> Can tearing down meson_dw_hdmi->phy before devm_free_irq() and
> dw_hdmi_unbind() cause a use-after-free in dw_hdmi_top_thread_irq()?
>
> CPU0 CPU1
> meson_dw_hdmi_unbind()
> phy_exit(meson_dw_hdmi->phy)
> devm_phy_destroy(..., meson_dw_hdmi->phy)
> dw_hdmi_top_thread_irq()
> dw_hdmi_setup_rx_sense()
> ...
> dw_hdmi_phy_init()
> phy_configure(dw_hdmi->phy, ...)
> <-- use-after-free
> devm_free_irq(...)
> dw_hdmi_unbind(...)
>
> In the legacy PHY path, devm_phy_destroy() immediately unregisters and
> frees meson_dw_hdmi->phy while the threaded HPD interrupt handler is still
> active and can invoke dw_hdmi_phy_init() or dw_hdmi_phy_disable(). Even
> with a DT PHY, HPD handling or dw_hdmi_unbind() can access the PHY after
> phy_exit(). Should phy_exit() and devm_phy_destroy() run after
> devm_free_irq() and dw_hdmi_unbind()?
>
I will move the phy_destroy after unbind, phy_exit will be on
phy_disable only.
> [Severity: High]
> Does calling phy_exit() in meson_dw_hdmi_pm_suspend() and phy_init() in
> meson_dw_hdmi_pm_resume() break HDMI output across system suspend/resume?
>
> Because the HDMI TX platform device sits after the VPU master device on
> dpm_list (both from DT node order and because devm_phy_optional_get() adds
> a stateless device link to the PHY that reorders the consumer to the tail
> of dpm_list), system suspend runs meson_dw_hdmi_pm_suspend() before
> meson_drv_pm_suspend(), and system resume runs meson_drv_pm_resume()
> before meson_dw_hdmi_pm_resume().
>
> On suspend, meson_dw_hdmi_pm_suspend() calls phy_exit() while the PHY is
> still powered on, before meson_drv_pm_suspend() ->
> drm_mode_config_helper_suspend() -> dw_hdmi_phy_disable() calls
> phy_power_off().
>
> On resume, meson_drv_pm_resume() -> drm_mode_config_helper_resume() ->
> dw_hdmi_phy_init() calls phy_configure() and phy_power_on() while
> phy->init_count is still 0. Then meson_dw_hdmi_pm_resume() runs
> meson_dw_hdmi_init(), which resets hdmitx_phy and calls phy_init(); since
> phy->power_count > phy->init_count, phy_init() warns ("phy_power_on was
> called before phy_init") and runs meson_hdmi_phy_init(), overwriting
> HHI_HDMI_PHY_CNTL0 and HHI_HDMI_PHY_CNTL1 with cntl0_init and cntl1_init
> and clobbering the mode that meson_drv_pm_resume() just configured and
> powered on.
>
I will put phy_init in dw_hdmi_phy_init and phy_exit in
dw_hdmi_phy_disable for v2.
--
Best regards,
Ronald
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
next prev parent reply other threads:[~2026-11-20 17:55 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 19:33 [PATCH 00/10] phy/drm: amlogic: Extract Meson HDMI TX PHY into a dedicated driver Ronald Claveau via B4 Relay
2026-11-17 19:33 ` [PATCH 01/10] dt-bindings: soc: amlogic: meson-gx-hhi-sysctrl: Fix compatible matching in conditionals Ronald Claveau via B4 Relay
2026-11-17 19:33 ` [PATCH 02/10] dt-bindings: phy: amlogic: Add Meson HDMI TX PHY binding Ronald Claveau via B4 Relay
2026-11-17 19:33 ` [PATCH 03/10] dt-bindings: soc: amlogic: meson-gx-hhi-sysctrl: Add hdmi-phy child node Ronald Claveau via B4 Relay
2026-11-17 19:39 ` sashiko-bot
2026-11-17 19:33 ` [PATCH 04/10] phy: amlogic: Add Meson HDMI TX PHY driver Ronald Claveau via B4 Relay
2026-11-17 19:58 ` sashiko-bot
2026-11-19 16:29 ` Ronald Claveau
2026-11-17 19:33 ` [PATCH 05/10] dt-bindings: display: amlogic,meson-dw-hdmi: Add phys and phy-names Ronald Claveau via B4 Relay
2026-11-18 12:34 ` Neil Armstrong
2026-11-18 19:10 ` linux-kernel-dev
2026-11-17 19:33 ` [PATCH 06/10] drm/meson: dw-hdmi: Drop manual HHI clock and memory PD setup Ronald Claveau via B4 Relay
2026-11-17 20:11 ` sashiko-bot
2026-11-19 15:30 ` Ronald Claveau
2026-11-17 19:33 ` [PATCH 07/10] drm/meson: dw-hdmi: Use the generic PHY framework for the HDMI TX PHY Ronald Claveau via B4 Relay
2026-11-17 20:03 ` sashiko-bot
2026-11-20 17:52 ` Ronald Claveau [this message]
2026-11-17 19:33 ` [PATCH 08/10] arm64: dts: amlogic: Add HDMI TX PHY node for G12 Ronald Claveau via B4 Relay
2026-11-17 19:33 ` [PATCH 09/10] arm64: dts: amlogic: Add HDMI TX PHY node for GXBB Ronald Claveau via B4 Relay
2026-11-17 19:33 ` [PATCH 10/10] arm64: dts: amlogic: Add HDMI TX PHY node for GXL Ronald Claveau via B4 Relay
2026-11-18 12:38 ` [PATCH 00/10] phy/drm: amlogic: Extract Meson HDMI TX PHY into a dedicated driver Neil Armstrong
2026-11-18 19:35 ` linux-kernel-dev
2026-11-19 7:58 ` Neil Armstrong
2026-11-19 15:33 ` linux-kernel-dev
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=ef1b7465-9639-4d11-9b10-4b0c9da21bd5@aliel.fr \
--to=linux-kernel-dev@aliel.fr \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-amlogic@lists.infradead.org \
--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
all inboxes | Powered by JetHome®