mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v4] pwm: tiehrpwm: Enable pwmchip's parent device before setting  configuration
@ 2026-01-21  6:11 Gokul Praveen
  2026-01-21 10:18 ` Uwe Kleine-König
  0 siblings, 1 reply; 6+ messages in thread
From: Gokul Praveen @ 2026-01-21  6:11 UTC (permalink / raw)
  To: j-keerthy, ukleinek, linux-pwm, linux-kernel
  Cc: g-praveen, u-kumar1, n-francis

The period and duty cycle configurations on J7200 and J784S4 SoCs
does not get reflected after setting them using sysfs nodes.
This is because at the end of ehrpwm_pwm_config function,
the put_sync function is called which resets the hardware.

Hold the PWM controller out of low-power mode during .apply() to
make sure it accepts the writes to its registers.

This renders the calls to pm_runtime_get_sync() and
pm_runtime_put_sync() in ehrpwm_pwm_config() into no-ops, so
these can be dropped.

Fixes: 5f027d9b83db("pwm: tiehrpwm: Implement .apply() callback")
Signed-off-by: Gokul Praveen <g-praveen@ti.com>
---
v4 <==> v3
===========
* Modified subject line and commit description for better clarity.

v3 <==> v2
==========
* Simplified the logic by adding guard function for runtime power
  management.

v2 <==> v1
==========
* Removed space between Fixes and Signed-off tag

 drivers/pwm/pwm-tiehrpwm.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/pwm/pwm-tiehrpwm.c b/drivers/pwm/pwm-tiehrpwm.c
index 7a86cb090f76..2533c95b0ba9 100644
--- a/drivers/pwm/pwm-tiehrpwm.c
+++ b/drivers/pwm/pwm-tiehrpwm.c
@@ -237,8 +237,6 @@ static int ehrpwm_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
 	if (period_cycles < 1)
 		period_cycles = 1;
 
-	pm_runtime_get_sync(pwmchip_parent(chip));
-
 	/* Update clock prescaler values */
 	ehrpwm_modify(pc->mmio_base, TBCTL, TBCTL_CLKDIV_MASK, tb_divval);
 
@@ -290,8 +288,6 @@ static int ehrpwm_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
 	if (!(duty_cycles > period_cycles))
 		ehrpwm_write(pc->mmio_base, cmp_reg, duty_cycles);
 
-	pm_runtime_put_sync(pwmchip_parent(chip));
-
 	return 0;
 }
 
@@ -378,6 +374,8 @@ static int ehrpwm_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
 	int err;
 	bool enabled = pwm->state.enabled;
 
+	guard(pm_runtime_active)(pwmchip_parent(chip));
+
 	if (state->polarity != pwm->state.polarity) {
 		if (enabled) {
 			ehrpwm_pwm_disable(chip, pwm);
-- 
2.34.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v4] pwm: tiehrpwm: Enable pwmchip's parent device before setting  configuration
  2026-01-21  6:11 [PATCH v4] pwm: tiehrpwm: Enable pwmchip's parent device before setting configuration Gokul Praveen
@ 2026-01-21 10:18 ` Uwe Kleine-König
  2026-01-21 10:49   ` Gokul Praveen
  0 siblings, 1 reply; 6+ messages in thread
From: Uwe Kleine-König @ 2026-01-21 10:18 UTC (permalink / raw)
  To: Gokul Praveen; +Cc: j-keerthy, linux-pwm, linux-kernel, u-kumar1, n-francis

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

Hello Gokul,

On Wed, Jan 21, 2026 at 11:41:34AM +0530, Gokul Praveen wrote:
> The period and duty cycle configurations on J7200 and J784S4 SoCs
> does not get reflected after setting them using sysfs nodes.
> This is because at the end of ehrpwm_pwm_config function,
> the put_sync function is called which resets the hardware.
> 
> Hold the PWM controller out of low-power mode during .apply() to
> make sure it accepts the writes to its registers.
> 
> This renders the calls to pm_runtime_get_sync() and
> pm_runtime_put_sync() in ehrpwm_pwm_config() into no-ops, so
> these can be dropped.
> 
> Fixes: 5f027d9b83db("pwm: tiehrpwm: Implement .apply() callback")
> Signed-off-by: Gokul Praveen <g-praveen@ti.com>

I applied this patch to

	https://git.kernel.org/pub/scm/linux/kernel/git/ukleinek/linux.git pwm/for-next

and will send it during the next merge window. The problem is old
(v5.18-rc1~54^2~29 from 2021) and it's late in the development cycle, so
I won't bother Linus with it for 6.19.

Best regards
Uwe

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v4] pwm: tiehrpwm: Enable pwmchip's parent device before setting configuration
  2026-01-21 10:18 ` Uwe Kleine-König
@ 2026-01-21 10:49   ` Gokul Praveen
  2026-01-23 14:58     ` Kumar, Udit
  0 siblings, 1 reply; 6+ messages in thread
From: Gokul Praveen @ 2026-01-21 10:49 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: j-keerthy, linux-pwm, linux-kernel, u-kumar1, n-francis, Gokul Praveen

Hello Uwe,

On 21/01/26 15:48, Uwe Kleine-König wrote:
> Hello Gokul,
> 
> On Wed, Jan 21, 2026 at 11:41:34AM +0530, Gokul Praveen wrote:
>> The period and duty cycle configurations on J7200 and J784S4 SoCs
>> does not get reflected after setting them using sysfs nodes.
>> This is because at the end of ehrpwm_pwm_config function,
>> the put_sync function is called which resets the hardware.
>>
>> Hold the PWM controller out of low-power mode during .apply() to
>> make sure it accepts the writes to its registers.
>>
>> This renders the calls to pm_runtime_get_sync() and
>> pm_runtime_put_sync() in ehrpwm_pwm_config() into no-ops, so
>> these can be dropped.
>>
>> Fixes: 5f027d9b83db("pwm: tiehrpwm: Implement .apply() callback")
>> Signed-off-by: Gokul Praveen <g-praveen@ti.com>
> 
> I applied this patch to
> 
> 	https://git.kernel.org/pub/scm/linux/kernel/git/ukleinek/linux.git pwm/for-next
> 
> and will send it during the next merge window. The problem is old
> (v5.18-rc1~54^2~29 from 2021) and it's late in the development cycle, so
> I won't bother Linus with it for 6.19.
> 

Thank you for your continued support on this issue as well as for 
accepting the patch.

Best Regards
Gokul Praveen
> Best regards
> Uwe


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v4] pwm: tiehrpwm: Enable pwmchip's parent device before setting configuration
  2026-01-21 10:49   ` Gokul Praveen
@ 2026-01-23 14:58     ` Kumar, Udit
  2026-01-23 18:01       ` Uwe Kleine-König
  0 siblings, 1 reply; 6+ messages in thread
From: Kumar, Udit @ 2026-01-23 14:58 UTC (permalink / raw)
  To: Gokul Praveen, Uwe Kleine-König
  Cc: j-keerthy, linux-pwm, linux-kernel, n-francis, u-kumar1

Hi Uwe/Gokul,

On 1/21/2026 4:19 PM, Gokul Praveen wrote:
> Hello Uwe,
>
> On 21/01/26 15:48, Uwe Kleine-König wrote:
>> Hello Gokul,
>>
>> On Wed, Jan 21, 2026 at 11:41:34AM +0530, Gokul Praveen wrote:
>>> The period and duty cycle configurations on J7200 and J784S4 SoCs
>>> does not get reflected after setting them using sysfs nodes.
>>> This is because at the end of ehrpwm_pwm_config function,
>>> the put_sync function is called which resets the hardware.
>>>
>>> Hold the PWM controller out of low-power mode during .apply() to
>>> make sure it accepts the writes to its registers.
>>>
>>> This renders the calls to pm_runtime_get_sync() and
>>> pm_runtime_put_sync() in ehrpwm_pwm_config() into no-ops, so
>>> these can be dropped.
>>>
>>> Fixes: 5f027d9b83db("pwm: tiehrpwm: Implement .apply() callback")
>>> Signed-off-by: Gokul Praveen <g-praveen@ti.com>
>>
>> I applied this patch to
>>
>>     https://git.kernel.org/pub/scm/linux/kernel/git/ukleinek/linux.git 
>> pwm/for-next
>>
>> and will send it during the next merge window. The problem is old
>> (v5.18-rc1~54^2~29 from 2021) and it's late in the development cycle, so
>> I won't bother Linus with it for 6.19.
>>
>
fyi,

We are hitting compilation error with this patch

https://gist.github.com/uditkumarti/d23bc9ee1886bfce70cc76e4b19fbb59


> Thank you for your continued support on this issue as well as for 
> accepting the patch.
>
> Best Regards
> Gokul Praveen
>> Best regards
>> Uwe
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v4] pwm: tiehrpwm: Enable pwmchip's parent device before setting configuration
  2026-01-23 14:58     ` Kumar, Udit
@ 2026-01-23 18:01       ` Uwe Kleine-König
  2026-01-24  4:57         ` Kumar, Udit
  0 siblings, 1 reply; 6+ messages in thread
From: Uwe Kleine-König @ 2026-01-23 18:01 UTC (permalink / raw)
  To: Kumar, Udit; +Cc: Gokul Praveen, j-keerthy, linux-pwm, linux-kernel, n-francis

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

Hello,

On Fri, Jan 23, 2026 at 08:28:48PM +0530, Kumar, Udit wrote:
> On 1/21/2026 4:19 PM, Gokul Praveen wrote:
> > Hello Uwe,
> > 
> > On 21/01/26 15:48, Uwe Kleine-König wrote:
> > > Hello Gokul,
> > > 
> > > On Wed, Jan 21, 2026 at 11:41:34AM +0530, Gokul Praveen wrote:
> > > > The period and duty cycle configurations on J7200 and J784S4 SoCs
> > > > does not get reflected after setting them using sysfs nodes.
> > > > This is because at the end of ehrpwm_pwm_config function,
> > > > the put_sync function is called which resets the hardware.
> > > > 
> > > > Hold the PWM controller out of low-power mode during .apply() to
> > > > make sure it accepts the writes to its registers.
> > > > 
> > > > This renders the calls to pm_runtime_get_sync() and
> > > > pm_runtime_put_sync() in ehrpwm_pwm_config() into no-ops, so
> > > > these can be dropped.
> > > > 
> > > > Fixes: 5f027d9b83db("pwm: tiehrpwm: Implement .apply() callback")
> > > > Signed-off-by: Gokul Praveen <g-praveen@ti.com>
> > > 
> > > I applied this patch to
> > > 
> > >     https://git.kernel.org/pub/scm/linux/kernel/git/ukleinek/linux.git
> > > pwm/for-next
> > > 
> > > and will send it during the next merge window. The problem is old
> > > (v5.18-rc1~54^2~29 from 2021) and it's late in the development cycle, so
> > > I won't bother Linus with it for 6.19.
> > > 
> > 
> fyi,
> 
> We are hitting compilation error with this patch
> 
> https://gist.github.com/uditkumarti/d23bc9ee1886bfce70cc76e4b19fbb59

I assume you tried to compile this patch on top of a tree that doesn't
also has commit 9a0abc39450a3123fd52533a662fbd37e0d1508c?

Best regards
Uwe

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v4] pwm: tiehrpwm: Enable pwmchip's parent device before setting configuration
  2026-01-23 18:01       ` Uwe Kleine-König
@ 2026-01-24  4:57         ` Kumar, Udit
  0 siblings, 0 replies; 6+ messages in thread
From: Kumar, Udit @ 2026-01-24  4:57 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Gokul Praveen, j-keerthy, linux-pwm, linux-kernel, n-francis, u-kumar1


On 1/23/2026 11:31 PM, Uwe Kleine-König wrote:
> Hello,
>
> On Fri, Jan 23, 2026 at 08:28:48PM +0530, Kumar, Udit wrote:
>> On 1/21/2026 4:19 PM, Gokul Praveen wrote:
>>> Hello Uwe,
>>>
>>> On 21/01/26 15:48, Uwe Kleine-König wrote:
>>>> Hello Gokul,
>>>>
>>>> On Wed, Jan 21, 2026 at 11:41:34AM +0530, Gokul Praveen wrote:
>>>>> The period and duty cycle configurations on J7200 and J784S4 SoCs
>>>>> does not get reflected after setting them using sysfs nodes.
>>>>> This is because at the end of ehrpwm_pwm_config function,
>>>>> the put_sync function is called which resets the hardware.
>>>>>
>>>>> Hold the PWM controller out of low-power mode during .apply() to
>>>>> make sure it accepts the writes to its registers.
>>>>>
>>>>> This renders the calls to pm_runtime_get_sync() and
>>>>> pm_runtime_put_sync() in ehrpwm_pwm_config() into no-ops, so
>>>>> these can be dropped.
>>>>>
>>>>> Fixes: 5f027d9b83db("pwm: tiehrpwm: Implement .apply() callback")
>>>>> Signed-off-by: Gokul Praveen <g-praveen@ti.com>
>>>> I applied this patch to
>>>>
>>>>      https://git.kernel.org/pub/scm/linux/kernel/git/ukleinek/linux.git
>>>> pwm/for-next
>>>>
>>>> and will send it during the next merge window. The problem is old
>>>> (v5.18-rc1~54^2~29 from 2021) and it's late in the development cycle, so
>>>> I won't bother Linus with it for 6.19.
>>>>
>> fyi,
>>
>> We are hitting compilation error with this patch
>>
>> https://gist.github.com/uditkumarti/d23bc9ee1886bfce70cc76e4b19fbb59
> I assume you tried to compile this patch on top of a tree that doesn't
> also has commit 9a0abc39450a3123fd52533a662fbd37e0d1508c?


Thanks for pointing to this , I just cherry-pick only patch of Gokul,

after picking 9a0abc39450a3123fd52533a662fbd37e0d1508c, compile is ok 
for me .


>
> Best regards
> Uwe

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-01-24  4:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-21  6:11 [PATCH v4] pwm: tiehrpwm: Enable pwmchip's parent device before setting configuration Gokul Praveen
2026-01-21 10:18 ` Uwe Kleine-König
2026-01-21 10:49   ` Gokul Praveen
2026-01-23 14:58     ` Kumar, Udit
2026-01-23 18:01       ` Uwe Kleine-König
2026-01-24  4:57         ` Kumar, Udit

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®