Skip to contentSkip to conversation

FAILED: patch "[PATCH] pwm: imx-tpm: Count the number of enabled channels in probe" failed to apply to 6.1-stable tree

PATCH New [email protected] 3 participants 5 messages May 3 – May 15

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

The patch below does not apply to the 6.1-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

To reproduce the conflict and resubmit, you may use the following commands:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.1.y
git checkout FETCH_HEAD
git cherry-pick -x 3962c24f2d14e8a7f8a23f56b7ce320523947342
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026050332-washer-legislate-ef0e@gregkh' --subject-prefix 'PATCH 6.1.y' HEAD^..

Possible dependencies:

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From 3962c24f2d14e8a7f8a23f56b7ce320523947342 Mon Sep 17 00:00:00 2001
From: "Viorel Suman (OSS)" <[email protected]>
Date: Wed, 11 Mar 2026 14:33:09 +0200
Subject: [PATCH] pwm: imx-tpm: Count the number of enabled channels in probe
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

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 counting the enabled channels in probe function.

drivers/pwm/pwm-imx-tpm.c +8 -1
index 5b399de16d60..80fdb3303400 100644
@@ -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,13 @@ static int pwm_imx_tpm_probe(struct platform_device *pdev)
 
 	mutex_init(&tpm->lock);
 
+	/* count the enabled channels */
+	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;
+	}
+
 	ret = devm_pwmchip_add(&pdev->dev, chip);
 	if (ret)
 		return dev_err_probe(&pdev->dev, ret, "failed to add PWM chip\n");
maintainer
#1 lore raw

PATCH 1/1 pwm: imx-tpm: Count the number of enabled channels in probe

From: "Viorel Suman (OSS)" <[email protected]>

[ Upstream commit 3962c24f2d14e8a7f8a23f56b7ce320523947342 ]

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 counting the enabled channels in probe function.

Fixes 738a1cfec2ed ("pwm: Add i.MX TPM PWM driver support")
[ substituted `base` with `tpm->base` and `npwm` with `tpm->chip.npwm` to match the older non-devm probe layout ]
---
 drivers/pwm/pwm-imx-tpm.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/pwm/pwm-imx-tpm.c +8 -0
index 081f511cd2130..e1caaef7dbd16 100644
@@ -350,6 +350,7 @@ static int pwm_imx_tpm_probe(struct platform_device *pdev)
 {
 	struct imx_tpm_pwm_chip *tpm;
 	int ret;
+	unsigned int i;
 	u32 val;
 
 	tpm = devm_kzalloc(&pdev->dev, sizeof(*tpm), GFP_KERNEL);
@@ -383,6 +384,13 @@ static int pwm_imx_tpm_probe(struct platform_device *pdev)
 
 	mutex_init(&tpm->lock);
 
+	/* count the enabled channels */
+	for (i = 0; i < tpm->chip.npwm; ++i) {
+		val = readl(tpm->base + PWM_IMX_TPM_CnSC(i));
+		if (FIELD_GET(PWM_IMX_TPM_CnSC_ELS, val))
+			++tpm->enable_count;
+	}
+
 	ret = pwmchip_add(&tpm->chip);
 	if (ret) {
 		dev_err(&pdev->dev, "failed to add PWM chip: %d\n", ret);
Signature · 1 line
2.53.0
#2 lore raw
In reply to [email protected]

Hello Greg,

Quoted 6 lines · On Sun, May 03, 2026 at 01:46:32PM +0200, [email protected] wrote:

The patch below does not apply to the 6.1-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

Quoted 9 lines

To reproduce the conflict and resubmit, you may use the following commands:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.1.y
git checkout FETCH_HEAD
git cherry-pick -x 3962c24f2d14e8a7f8a23f56b7ce320523947342
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026050332-washer-legislate-ef0e@gregkh' --subject-prefix 'PATCH 6.1.y' HEAD^..

You wrote already on 2026-05-03 about this patch that failed to apply to 6.6, 6.1, 5.15 and 5.10. I replied to the 6.6 one with the exact patch that Sasha now recreated in reply to this new 6.1 failure. I would have expected that the 6.6 backport is tried to be applied to 6.1 and the other older versions given the mainline original doesn't apply cleanly.

:-( that this resulted in duplicate work being done

Uwe

author maintainer
#3 lore raw
Quoted 19 lines · Uwe Kleine-König

Hello Greg,

Quoted 6 lines · On Sun, May 03, 2026 at 01:46:32PM +0200, [email protected] wrote:

The patch below does not apply to the 6.1-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

Quoted 9 lines

To reproduce the conflict and resubmit, you may use the following commands:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.1.y
git checkout FETCH_HEAD
git cherry-pick -x 3962c24f2d14e8a7f8a23f56b7ce320523947342
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026050332-washer-legislate-ef0e@gregkh' --subject-prefix 'PATCH 6.1.y' HEAD^..

Quoted 7 lines

You wrote already on 2026-05-03 about this patch that failed to apply to 6.6, 6.1, 5.15 and 5.10. I replied to the 6.6 one with the exact patch that Sasha now recreated in reply to this new 6.1 failure. I would have expected that the 6.6 backport is tried to be applied to 6.1 and the other older versions given the mainline original doesn't apply cleanly.

:-( that this resulted in duplicate work being done

I've now taken your backport for both, but we have no idea that a commit you send for 6.6.y and says "backport for 6.6.y" should be applied to 6.1.y :)

thanks,

greg k-h

#4 lore raw
Quoted 26 lines · Greg KH
Quoted 25 lines · Uwe Kleine-König

Hello Greg,

Quoted 6 lines · On Sun, May 03, 2026 at 01:46:32PM +0200, [email protected] wrote:

The patch below does not apply to the 6.1-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

Quoted 9 lines

To reproduce the conflict and resubmit, you may use the following commands:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.1.y
git checkout FETCH_HEAD
git cherry-pick -x 3962c24f2d14e8a7f8a23f56b7ce320523947342
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026050332-washer-legislate-ef0e@gregkh' --subject-prefix 'PATCH 6.1.y' HEAD^..

You wrote already on 2026-05-03 about this patch that failed to apply to 6.6, 6.1, 5.15 and 5.10. I replied to the 6.6 one with the exact patch that Sasha now recreated in reply to this new 6.1 failure. I would have expected that the 6.6 backport is tried to be applied to 6.1 and the other older versions given the mainline original doesn't apply cleanly.

Quoted 5 lines
Quoted 1 line

:-( that this resulted in duplicate work being done

I've now taken your backport for both, but we have no idea that a commit you send for 6.6.y and says "backport for 6.6.y" should be applied to 6.1.y :)

Isn't that obvious at least after the fact that if backporting a mainline commit to 6.1 and 6.6 fails, and there appears a backport for 6.6, that trying to apply that 6.6 backport to 6.1 is a good idea?

(But I also learned my part and mentioned in today's backports that they also apply to the older versions (though only in the body, not the subject).)

Have a nice week-end (🤞 this really happens for you with all the mess you're into),
Uwe