From: "Uwe Kleine-König" <ukleinek@kernel.org>
To: Keguang Zhang <keguang.zhang@gmail.com>
Cc: Binbin Zhou <zhoubinbin@loongson.cn>,
linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/2] pwm: loongson: Fix low pulse buffer register handling
Date: Fri, 10 Jul 2026 07:52:06 +0200 [thread overview]
Message-ID: <alCIB5nGfYlEZsMg@monoceros> (raw)
In-Reply-To: <CAJhJPsVffZLTzXyA41rxm=A54sZhROVg-+K-gWo1KEzuKGv15w@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1014 bytes --]
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 <ukleinek@kernel.org> 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.
Best regards
Uwe
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2026-07-10 5:52 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-26 12:24 [PATCH v2 0/2] pwm: loongson: Fix PWM configuration handling Keguang Zhang via B4 Relay
2026-06-26 12:24 ` [PATCH v2 1/2] pwm: loongson: Fix low pulse buffer register handling Keguang Zhang via B4 Relay
2026-07-06 8:00 ` Uwe Kleine-König
2026-07-09 7:25 ` Keguang Zhang
2026-07-10 5:52 ` Uwe Kleine-König [this message]
2026-07-10 11:46 ` Keguang Zhang
2026-06-26 12:24 ` [PATCH v2 2/2] pwm: loongson: Reload PWM configuration through counter reset Keguang Zhang via B4 Relay
2026-07-06 8:03 ` Uwe Kleine-König
2026-07-09 7:29 ` Keguang Zhang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alCIB5nGfYlEZsMg@monoceros \
--to=ukleinek@kernel.org \
--cc=keguang.zhang@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=zhoubinbin@loongson.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome