The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <ukleinek@kernel.org>
To: Lee Jones <lee@kernel.org>
Cc: Sai Masarapu <Sai.Masarapu@imgtec.com>,
	 Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>,
	Naidu Tellapati <naidu.tellapati@gmail.com>,
	 Ezequiel Garcia <ezequiel.garcia@imgtec.com>,
	Thierry Reding <thierry.reding@gmail.com>,
	 Andrew Bresticker <abrestic@chromium.org>,
	linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org,
	 stable@vger.kernel.org
Subject: Re: [PATCH 8/8] pwm: img: Unregister PWM chip before disabling runtime PM and clocks
Date: Fri, 20 Nov 2026 13:10:16 +0100	[thread overview]
Message-ID: <awA38Fw5qLMCTjHP@monoceros> (raw)
In-Reply-To: <20261105143847.2559586-9-lee@kernel.org>

[-- Attachment #1: Type: text/plain, Size: 1801 bytes --]

On Thu, Nov 05, 2026 at 02:38:10PM +0000, Lee Jones wrote:
> img_pwm_remove() disables runtime PM and gates the peripheral clocks via
> img_pwm_runtime_suspend() before calling pwmchip_remove().  While the
> PWM chip is still registered, a consumer can call img_pwm_apply(), where
> pm_runtime_resume_and_get() returns -EACCES or succeeds without
> re-enabling clocks, leading to unclocked register access.
> 
> Call pwmchip_remove() before disabling runtime PM and suspending the
> device.
> 
> Fixes: 277bb6a29e00 ("pwm: Imagination Technologies PWM DAC driver")
> Closes: https://sashiko.dev/#/bug/linux-b06bab8d-dbf2-4ba2-9f5d-c5e141076abd
> Cc: stable@vger.kernel.org
> Signed-off-by: Lee Jones <lee@kernel.org>
> ---
>  drivers/pwm/pwm-img.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/pwm/pwm-img.c b/drivers/pwm/pwm-img.c
> index 91e0b19f0c08..b6e090674c07 100644
> --- a/drivers/pwm/pwm-img.c
> +++ b/drivers/pwm/pwm-img.c
> @@ -338,11 +338,11 @@ static void img_pwm_remove(struct platform_device *pdev)
>  {
>  	struct pwm_chip *chip = platform_get_drvdata(pdev);
>  
> -	pm_runtime_disable(&pdev->dev);
> -	if (!pm_runtime_status_suspended(&pdev->dev))
> -		img_pwm_runtime_suspend(&pdev->dev);
> -
>  	pwmchip_remove(chip);
> +
> +	pm_runtime_disable(&pdev->dev);
> +	if (!pm_runtime_status_suspended(&pdev->dev))
> +		img_pwm_runtime_suspend(&pdev->dev);

Calling pm_runtime_disable() might result in a call to
img_pwm_runtime_resume() (does it?). In img_pwm_runtime_resume() we
have:

	struct pwm_chip *chip = dev_get_drvdata(dev);
	struct img_pwm_chip *imgchip = to_img_pwm_chip(chip);
	...

which doesn't look like an operation that should be done after
pwmchip_remove()?

Best regards
Uwe

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-05 14:38 [PATCH 0/8] pwm: Fix various bugs reported by Sashiko Lee Jones
2026-11-05 14:38 ` [PATCH 1/8] pwm: tegra: Prevent 32-bit period truncation and division by zero Lee Jones
2026-11-05 15:46   ` Uwe Kleine-König
2026-11-18 17:16     ` Lee Jones
2026-11-19 14:44       ` Uwe Kleine-König
2026-11-05 14:38 ` [PATCH 2/8] pwm: mxs: Return early when disabling and fix error-path clock leak Lee Jones
2026-11-05 16:50   ` Frank Li
2026-11-20 12:12   ` Uwe Kleine-König
2026-11-05 14:38 ` [PATCH 3/8] pwm: loongson: Fix 32-bit control register truncation in pwm_loongson_set_polarity() Lee Jones
2026-11-05 14:38 ` [PATCH 4/8] pwm: axi-pwmgen: Enable clocks before accessing hardware registers in probe() Lee Jones
2026-11-05 15:48   ` Uwe Kleine-König
2026-11-05 18:26     ` Lee Jones
2026-11-05 18:26       ` Lee Jones
2026-11-06 13:01   ` Nuno Sá
2026-11-05 14:38 ` [PATCH 5/8] pwm: fsl-ftm: Enable ipg_clk around regcache_sync() during resume Lee Jones
2026-11-20 12:02   ` Uwe Kleine-König
2026-11-05 14:38 ` [PATCH 6/8] pwm: omap-dmtimer: Handle negative error codes from get_pwm_status() Lee Jones
2026-11-20 11:57   ` Uwe Kleine-König
2026-11-05 14:38 ` [PATCH 7/8] pwm: tiehrpwm: Enable runtime PM before registering PWM chip Lee Jones
2026-11-20 12:06   ` Uwe Kleine-König
2026-11-05 14:38 ` [PATCH 8/8] pwm: img: Unregister PWM chip before disabling runtime PM and clocks Lee Jones
2026-11-20 12:10   ` Uwe Kleine-König [this message]
2026-11-20 12:17 ` [PATCH 0/8] pwm: Fix various bugs reported by Sashiko Uwe Kleine-König

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=awA38Fw5qLMCTjHP@monoceros \
    --to=ukleinek@kernel.org \
    --cc=Sai.Masarapu@imgtec.com \
    --cc=abrestic@chromium.org \
    --cc=ezequiel.garcia@imgtec.com \
    --cc=lee@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=naidu.tellapati@gmail.com \
    --cc=stable@vger.kernel.org \
    --cc=thierry.reding@gmail.com \
    --cc=vladimir_zapolskiy@mentor.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox