Re: [PATCH v2 1/2] pwm: loongson: Fix low pulse buffer register handling
Keguang Zhang <[email protected]> Fri, 10 Jul 2026 19:46:38 +0800
| Newsgroups | org.kernel.vger.linux-pwm,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <CAJhJPsXf+XoKhMZSjwziRmpj+_BKKqJhsbACd6ViYJPUXw45Kg@mail.gmail.com> |
On Fri, Jul 10, 2026 at 1:52 PM Uwe Kleine-König <[email protected]> wrote: > > Hello, > > On Thu, Jul 09, 2026 at 03:25:38PM +0800, Keguang Zhang wrote: > > On Mon, Jul 6, 2026 at 4:00 PM Uwe Kleine-König <[email protected]> wrote: > > > > - /* duty & period have a max of 2^32, so we can't overflow */ > > > > - state->duty_cycle = DIV64_U64_ROUND_UP((u64)duty * NSEC_PER_SEC, ddata->clk_rate); > > > > + /* low & period have a max of 2^32, so we can't overflow */ > > > > + state->duty_cycle = DIV64_U64_ROUND_UP((u64)(period - low) * NSEC_PER_SEC, ddata->clk_rate); > > > > > > What happens if low > period? > > > > pwm_state_valid() in drivers/pwm/core.c ensures that duty_cycle <= > > period before the framework calls the driver's .apply(). Since this > > driver always programs low = period - duty, low cannot exceed period > > when configured through the PWM framework. > > But this is only the case when .get_state() is called after the hardware > was programmed by Linux. The function should also work for the state the > bootloader left the hardware in. > Thanks for the clarification. I'll handle the low > period case in the next version. > Best regards > Uwe -- Best regards, Keguang Zhang