* [PATCH] pwm: tiehrpwm: Clear period on disable to allow reconfiguration
@ 2026-09-29 12:08 A. Sverdlin
2026-09-30 6:29 ` Uwe Kleine-König
0 siblings, 1 reply; 2+ messages in thread
From: A. Sverdlin @ 2026-09-29 12:08 UTC (permalink / raw)
To: linux-pwm
Cc: Alexander Sverdlin, Uwe Kleine-König, Philip, Avinash,
Thierry Reding, linux-kernel, stable
From: Alexander Sverdlin <alexander.sverdlin@siemens.com>
Both channels share one period register, so ehrpwm_pwm_config() rejects a
period differing from the sibling's period_cycles[]. That value was cleared
only in .free(), not in .disable(), so a stopped channel kept blocking the
sibling from switching to a new frequency. Clear it in .disable() too.
Testcase:
cd /sys/class/pwm/pwmchip0; echo 0 > export; echo 1 > export
for p in pwm0 pwm1; do
echo 1000000 > $p/period; echo 500000 > $p/duty_cycle
echo 1 > $p/enable; echo 0 > $p/enable; echo 2000000 > $p/period
done
echo 1 > pwm0/enable # before: -EINVAL, after: succeeds
Fixes: 01b2d4536f02 ("pwm: pwm-tiehrpwm: Fix conflicting channel period setting")
Cc: stable@vger.kernel.org
Signed-off-by: Alexander Sverdlin <alexander.sverdlin@siemens.com>
---
drivers/pwm/pwm-tiehrpwm.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/pwm/pwm-tiehrpwm.c b/drivers/pwm/pwm-tiehrpwm.c
index 3a53489f0b982..e3407d0a1f7fe 100644
--- a/drivers/pwm/pwm-tiehrpwm.c
+++ b/drivers/pwm/pwm-tiehrpwm.c
@@ -358,6 +358,9 @@ static void ehrpwm_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
/* Disable clock on PWM disable */
pm_runtime_put_sync(pwmchip_parent(chip));
+
+ /* A disabled channel must not constrain the sibling's period */
+ pc->period_cycles[pwm->hwpwm] = 0;
}
static void ehrpwm_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm)
--
2.55.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] pwm: tiehrpwm: Clear period on disable to allow reconfiguration
2026-09-29 12:08 [PATCH] pwm: tiehrpwm: Clear period on disable to allow reconfiguration A. Sverdlin
@ 2026-09-30 6:29 ` Uwe Kleine-König
0 siblings, 0 replies; 2+ messages in thread
From: Uwe Kleine-König @ 2026-09-30 6:29 UTC (permalink / raw)
To: A. Sverdlin
Cc: linux-pwm, Philip, Avinash, Thierry Reding, linux-kernel, stable
[-- Attachment #1: Type: text/plain, Size: 2098 bytes --]
Hello Alexander,
On Tue, Sep 29, 2026 at 02:08:02PM +0200, A. Sverdlin wrote:
> From: Alexander Sverdlin <alexander.sverdlin@siemens.com>
>
> Both channels share one period register, so ehrpwm_pwm_config() rejects a
> period differing from the sibling's period_cycles[]. That value was cleared
> only in .free(), not in .disable(), so a stopped channel kept blocking the
> sibling from switching to a new frequency. Clear it in .disable() too.
>
> Testcase:
>
> cd /sys/class/pwm/pwmchip0; echo 0 > export; echo 1 > export
> for p in pwm0 pwm1; do
> echo 1000000 > $p/period; echo 500000 > $p/duty_cycle
> echo 1 > $p/enable; echo 0 > $p/enable; echo 2000000 > $p/period
> done
> echo 1 > pwm0/enable # before: -EINVAL, after: succeeds
>
> Fixes: 01b2d4536f02 ("pwm: pwm-tiehrpwm: Fix conflicting channel period setting")
> Cc: stable@vger.kernel.org
> Signed-off-by: Alexander Sverdlin <alexander.sverdlin@siemens.com>
> ---
> drivers/pwm/pwm-tiehrpwm.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/pwm/pwm-tiehrpwm.c b/drivers/pwm/pwm-tiehrpwm.c
> index 3a53489f0b982..e3407d0a1f7fe 100644
> --- a/drivers/pwm/pwm-tiehrpwm.c
> +++ b/drivers/pwm/pwm-tiehrpwm.c
> @@ -358,6 +358,9 @@ static void ehrpwm_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
>
> /* Disable clock on PWM disable */
> pm_runtime_put_sync(pwmchip_parent(chip));
> +
> + /* A disabled channel must not constrain the sibling's period */
> + pc->period_cycles[pwm->hwpwm] = 0;
> }
>
> static void ehrpwm_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm)
That looks right, applied to
https://git.kernel.org/pub/scm/linux/kernel/git/ukleinek/linux.git pwm/for-next
as merge window material.
Looking at the driver, the check for the sibling running could be
weakend a bit. So if the restriction by the other channel only results
in a smaller period, configuration could continue.
(But if you're looking for something to do, better invest the time and
convert the driver to waveform.)
Thanks,
Uwe
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-30 6:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-29 12:08 [PATCH] pwm: tiehrpwm: Clear period on disable to allow reconfiguration A. Sverdlin
2026-09-30 6:29 ` Uwe Kleine-König
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®