Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Viorel Suman (OSS)" <viorel.suman@oss.nxp.com>
To: "Uwe Kleine-König" <ukleinek@kernel.org>
Cc: Frank Li <Frank.Li@nxp.com>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	 Pengutronix Kernel Team <kernel@pengutronix.de>,
	Fabio Estevam <festevam@gmail.com>,
	linux-pwm@vger.kernel.org,  imx@lists.linux.dev,
	linux-arm-kernel@lists.infradead.org,
	 linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] pwm: imx-tpm: keep channel state instead of counting
Date: Wed, 11 Mar 2026 12:25:20 +0200	[thread overview]
Message-ID: <abFBVBDf7lOAUEs-@fsr-ub1664-116> (raw)
In-Reply-To: <aalMdTmQd075dcF1@monoceros>

Hello,

On 26-03-05 10:29:21, Uwe Kleine-König wrote:
> Hello,
> 
> On Mon, Feb 02, 2026 at 12:47:38PM +0200, Viorel Suman (OSS) wrote:
> > On a soft reset TPM PWM IP may preserve its internal state from
> > previous runtime, therefore on a subsequent OS boot and driver
> > probe "enable_count" value and TPM PWM IP internal channels
> > "enabled" states may get unaligned. In consequence on a suspend/resume
> > cycle the call "if (--tpm->enable_count == 0)" may lead to
> > "enable_count" overflow the system being blocked from entering
> > suspend due to:
> > 
> >    if (tpm->enable_count > 0)
> >        return -EBUSY;
> > 
> > Fix the problem by replacing counting logic with per-channel state
> > handling and by aligning IP and driver state at probe.
> > 
> > Signed-off-by: Viorel Suman (OSS) <viorel.suman@oss.nxp.com>
> 
> I wonder if the following change would be enough:
> 
> diff --git a/drivers/pwm/pwm-imx-tpm.c b/drivers/pwm/pwm-imx-tpm.c
> index 5b399de16d60..36f873133f94 100644
> --- a/drivers/pwm/pwm-imx-tpm.c
> +++ b/drivers/pwm/pwm-imx-tpm.c
> @@ -352,7 +352,7 @@ static int pwm_imx_tpm_probe(struct platform_device *pdev)
>  	struct clk *clk;
>  	void __iomem *base;
>  	int ret;
> -	unsigned int npwm;
> +	unsigned int i, npwm;
>  	u32 val;
>  
>  	base = devm_platform_ioremap_resource(pdev, 0);
> @@ -382,6 +382,12 @@ static int pwm_imx_tpm_probe(struct platform_device *pdev)
>  
>  	mutex_init(&tpm->lock);
>  
> +	for (i = 0; i < npwm; ++i) {
> +		val = readl(base + PWM_IMX_TPM_CnSC(i));
> +		if (FIELD_GET(PWM_IMX_TPM_CnSC_ELS, val))
> +			++tpm->enable_count;
> +	}
> +

Yes, the change above would be enough, will send v3.

Regards,
Viorel


      reply	other threads:[~2026-03-11 10:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-02 10:47 [PATCH v2] pwm: imx-tpm: keep channel state instead of counting Viorel Suman (OSS)
2026-03-05  9:29 ` Uwe Kleine-König
2026-03-11 10:25   ` Viorel Suman (OSS) [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=abFBVBDf7lOAUEs-@fsr-ub1664-116 \
    --to=viorel.suman@oss.nxp.com \
    --cc=Frank.Li@nxp.com \
    --cc=festevam@gmail.com \
    --cc=imx@lists.linux.dev \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=ukleinek@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