Linux-PHY Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Aristo Chen" <aristo.chen@canonical.com>
Cc: linux-phy@lists.infradead.org, neil.armstrong@linaro.org,
	vkoul@kernel.org, olteanv@gmail.com
Subject: Re: [PATCH 1/1] phy: freescale: fsl-samsung-hdmi: initialize default rate
Date: Thu, 03 Sep 2026 06:03:41 +0000	[thread overview]
Message-ID: <20260903060341.9599E1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260903054811.9720-1-aristo.chen@canonical.com>

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

Pre-existing issues:
- [High] The clk_set_rate callback directly accesses PHY hardware registers without ensuring that PM runtime is active (apbclk) and the reference clock (refclk) is enabled.
- [High] Unsynchronized concurrent execution of fsl_samsung_hdmi_phy_configure() corrupts hardware state.
--

commit ca3b78db8bc5347322f2f22c6db7f47c219232b3
Author: Aristo Chen <aristo.chen@canonical.com>

    phy: freescale: fsl-samsung-hdmi: initialize default rate
    
    The HDMI PHY clock reports 74.25 MHz when cur_cfg is unset, but does
    not establish that rate in hardware. The common clock framework caches
    the reported rate when registering the clock and skips a first
    clk_set_rate(74250000) request because the rate appears unchanged.

> diff --git a/drivers/phy/freescale/phy-fsl-samsung-hdmi.c b/drivers/phy/freescale/phy-fsl-samsung-hdmi.c
> index 0f25d81de61bb..41addd4ad4149 100644
> --- a/drivers/phy/freescale/phy-fsl-samsung-hdmi.c
> +++ b/drivers/phy/freescale/phy-fsl-samsung-hdmi.c
[ ... ]
> @@ -710,11 +727,23 @@ static int __maybe_unused fsl_samsung_hdmi_phy_resume(struct device *dev)
>  		return ret;
>  	}
>  
> -	if (phy->cur_cfg)
> -		ret = fsl_samsung_hdmi_phy_configure(phy, phy->cur_cfg);
> +	if (!phy->cur_cfg)
> +		return 0;
>  
> -	return ret;
> +	ret = clk_prepare_enable(phy->refclk);
> +	if (ret) {
> +		dev_err(phy->dev, "failed to enable ref clk\n");
> +		goto disable_apbclk;
> +	}
> +
> +	ret = fsl_samsung_hdmi_phy_configure(phy, phy->cur_cfg);

[Severity: High]
This isn't a bug introduced by this patch, but does the clk_set_rate callback
directly access PHY hardware registers without ensuring that PM runtime is
active (apbclk) and the reference clock (refclk) is enabled?

The clock framework invokes fsl_samsung_hdmi_phy_clk_set_rate() when a
consumer (like the imx8mp LCDIF driver) configures the pixel clock rate during
a display modeset:

drivers/phy/freescale/phy-fsl-samsung-hdmi.c:fsl_samsung_hdmi_phy_clk_set_rate() {
    ...
    return fsl_samsung_hdmi_phy_configure(phy, target_settings);
}

Because this driver does not implement a .prepare callback to manage its PM
runtime state, the PHY device can be auto-suspended (and its apbclk disabled)
before the modeset occurs.

Could this lead to a system crash (synchronous external abort) due to
accessing memory-mapped registers while the APB clock is disabled, or a
guaranteed PLL lock timeout because the reference clock is disabled?

[Severity: High]
This is a pre-existing issue, but can unsynchronized concurrent execution of
fsl_samsung_hdmi_phy_configure() corrupt hardware state?

fsl_samsung_hdmi_phy_configure() modifies shared state (phy->cur_cfg) and
writes to multiple registers sequentially. It is called here from the PM
runtime resume callback, and it is also called from the CCF clk_set_rate
callback:

drivers/phy/freescale/phy-fsl-samsung-hdmi.c:fsl_samsung_hdmi_phy_clk_set_rate() {
    ...
    return fsl_samsung_hdmi_phy_configure(phy, target_settings);
}

Since clk_set_rate does not hold a PM runtime reference, it can run
concurrently with a PM resume triggered by sysfs or another driver.

Could this race between a display modeset and a PM runtime resume request lead
to interleaved hardware register writes, undefined PHY hardware state, and
display corruption?

Fixing the PM runtime management in clk_set_rate would also inherently
serialize these paths.

> +	clk_disable_unprepare(phy->refclk);
> +	if (!ret)
> +		return 0;
>  
> +disable_apbclk:
> +	clk_disable_unprepare(phy->apbclk);
> +	return ret;
>  }

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260903054811.9720-1-aristo.chen@canonical.com?part=1

-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

      reply	other threads:[~2026-09-03  6:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-03  5:47 [PATCH 1/1] phy: freescale: fsl-samsung-hdmi: initialize default rate Aristo Chen
2026-09-03  6:03 ` 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=20260903060341.9599E1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=aristo.chen@canonical.com \
    --cc=linux-phy@lists.infradead.org \
    --cc=neil.armstrong@linaro.org \
    --cc=olteanv@gmail.com \
    --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