Skip to contentSkip to conversation

pwm: lpss: wait_for_update() before configuring pwm

PATCH In review Raag Jadav 2 participants 5 messages Aug 19, 2024 – Aug 22, 2024

Subsystems (2)
lore
Share & tools
lore

Raag Jadav

author
#0 lore raw

PATCH 1/1 pwm: lpss: wait_for_update() before configuring pwm

Wait for SW_UPDATE bit to clear before configuring pwm channel instead of failing right away, which will reduce failure rates on early access.

---
 drivers/pwm/pwm-lpss.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/pwm/pwm-lpss.c +1 -11
index 867e2bc8c601..4a634a43b133 100644
@@ -111,16 +111,6 @@ static int pwm_lpss_wait_for_update(struct pwm_device *pwm)
 	return err;
 }
 
-static inline int pwm_lpss_is_updating(struct pwm_device *pwm)
-{
-	if (pwm_lpss_read(pwm) & PWM_SW_UPDATE) {
-		dev_err(pwmchip_parent(pwm->chip), "PWM_SW_UPDATE is still set, skipping update\n");
-		return -EBUSY;
-	}
-
-	return 0;
-}
-
 static void pwm_lpss_prepare(struct pwm_lpss_chip *lpwm, struct pwm_device *pwm,
 			     int duty_ns, int period_ns)
 {
@@ -168,7 +158,7 @@ static int pwm_lpss_prepare_enable(struct pwm_lpss_chip *lpwm,
 {
 	int ret;
 
-	ret = pwm_lpss_is_updating(pwm);
+	ret = pwm_lpss_wait_for_update(pwm);
 	if (ret)
 		return ret;
 
Signature · 1 line
2.35.3
#1 lore raw
Quoted 1 line · Raag Jadav

Wait for SW_UPDATE bit to clear before configuring pwm channel instead of

PWM

Quoted 1 line

failing right away, which will reduce failure rates on early access.

So, what is the problem this patch solves (or is trying to solve)? Second, there are two important behavioural changes:
- error code change (it's visible to user space);
- an additional, quite a long by the way, timeout.

Second one does worry me a lot as it might add these 0.5s to the boot time or so per PWM in question.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author
#2 lore raw
Quoted 8 lines · Andy Shevchenko
Quoted 1 line · Raag Jadav

Wait for SW_UPDATE bit to clear before configuring pwm channel instead of

PWM

Quoted 1 line

failing right away, which will reduce failure rates on early access.

So, what is the problem this patch solves (or is trying to solve)?

Less failures with less code, so just a minor improvement.

Quoted 2 lines

Second, there are two important behavioural changes:
- error code change (it's visible to user space);

This function is already used in this path just a few lines below.

Quoted 4 lines

- an additional, quite a long by the way, timeout.

Second one does worry me a lot as it might add these 0.5s to the boot time or so per PWM in question.

On the contrary, having a working set of PWMs would be a relatively rewarding experience IMHO.

Raag

#3 lore raw
Quoted 11 lines · Raag Jadav
Quoted 8 lines · Andy Shevchenko
Quoted 1 line · Raag Jadav

Wait for SW_UPDATE bit to clear before configuring pwm channel instead of

PWM

Quoted 1 line

failing right away, which will reduce failure rates on early access.

So, what is the problem this patch solves (or is trying to solve)?

Less failures with less code, so just a minor improvement.

It's not an equivalent code as I mentioned below.
So, if it's just a "cleanup", I do not think we want it as code works now and have no penalties.

Quoted 4 lines
Quoted 2 lines

Second, there are two important behavioural changes:
- error code change (it's visible to user space);

This function is already used in this path just a few lines below.

Yes, I know, but it is used in a slightly different context.

Quoted 7 lines
Quoted 4 lines

- an additional, quite a long by the way, timeout.

Second one does worry me a lot as it might add these 0.5s to the boot time or so per PWM in question.

On the contrary, having a working set of PWMs would be a relatively rewarding experience IMHO.

I'm not sure what this patch tries to fix. Was something not working before? Was something become different on real hardware that makes this patch worth to apply? None of these questions has been answered in the commit message.

So, as long as this is considered a pure cleanup, here is formal NAK from me as this IP block is not stateless and may lead to freezes. Hence the rule of thumb "do not touch the working things".

Otherwise, please make the commit message crystal clear about the improvements besides the code lines and answer the questions, e.g., why waiting for half a second is not an issue.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author
#4 lore raw
Quoted 32 lines · Andy Shevchenko
Quoted 11 lines · Raag Jadav
Quoted 8 lines · Andy Shevchenko
Quoted 1 line · Raag Jadav

Wait for SW_UPDATE bit to clear before configuring pwm channel instead of

PWM

Quoted 1 line

failing right away, which will reduce failure rates on early access.

So, what is the problem this patch solves (or is trying to solve)?

Less failures with less code, so just a minor improvement.

It's not an equivalent code as I mentioned below.
So, if it's just a "cleanup", I do not think we want it as code works now and have no penalties.

Quoted 4 lines
Quoted 2 lines

Second, there are two important behavioural changes:
- error code change (it's visible to user space);

This function is already used in this path just a few lines below.

Yes, I know, but it is used in a slightly different context.

Quoted 7 lines
Quoted 4 lines

- an additional, quite a long by the way, timeout.

Second one does worry me a lot as it might add these 0.5s to the boot time or so per PWM in question.

On the contrary, having a working set of PWMs would be a relatively rewarding experience IMHO.

Quoted 7 lines

I'm not sure what this patch tries to fix. Was something not working before? Was something become different on real hardware that makes this patch worth to apply? None of these questions has been answered in the commit message.

So, as long as this is considered a pure cleanup, here is formal NAK from me as this IP block is not stateless and may lead to freezes. Hence the rule of thumb "do not touch the working things".

Fair enough. However, I was able to test it on Merrifield, Bay Trail and Broxton (both PCI and platform counterparts) without such problems, if it is helpful in any way.

Raag