Re: [PATCH v4 1/2] pwm: imx27: fix race condition .apply,.get_state

From: Uwe Kleine-König
Date: Mon Feb 26 2024 - 04:23:24 EST


Hello,

On Sat, Feb 24, 2024 at 12:29:00PM +0100, Leif Middelschulte wrote:
> From: Leif Middelschulte <Leif.Middelschulte@xxxxxxxxxxxxx>
>
> With CONFIG_PWM_DEBUG=y after writing a value to the PWMSAR
> register in .apply(), the register is read in .get_state().
> Unless a period completed in the meantime, this read yields the
> previously used duty cycle configuration. As the PWM_DEBUG code
> applies the read out configuration for testing purposes this
> effectively undoes the intended effect by rewriting the previous
> hardware state.
>
> Note that this change merely implements a sensible heuristic.
> The i.MX has a 4 slot FIFO to configure the duty cycle. This FIFO
> cannot be read back in its entirety. The "write x then read back
> x from hw" semantics are therefore not easily applicable.
> With this change, the .get_state() function tries to wait for some
> stabilization in the FIFO (empty state). In this state it keeps
> applying the last value written to the sample register.
>
> Signed-off-by: Leif Middelschulte <Leif.Middelschulte@xxxxxxxxxxxxx>

Another few things I noticed only after replying to this patch and
trying to apply #2:

- Please make sure you have a S-o-b line for the sender (i.e. you with
your gmail identity).
- My reply to your klsmartin.com address couldn't be delivered, The MS
mailserver told: "leif.middelschulte wasn't found at klsmartin.com."
- Please start a new thread if you send a v5, as applying patches from
a thread containing many patches is a bit less trivial.
- Consider using git format-patch's --base parameter to document your
patch base.

Best regards
Uwe

--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | https://www.pengutronix.de/ |

Attachment: signature.asc
Description: PGP signature