Re: [PATCH v2] pwm: tegra: Fix value discarding for duty and period
From: Karl Mehltretter
Date: Tue Oct 27 2026 - 02:55:03 EST
On Tue, Oct 20, 2026 at 03:39:38PM +0200, Uwe Kleine-König wrote:
> Compared to (implicit) v1
> (https://lore.kernel.org/linux-pwm/20261015085336.4181137-2-u.kleine-koenig@xxxxxxxxxxxx):
> this adds more adaptions to handle the bigger variable types, as found
> by both Sashiko and Mikko. I didn't think a lot about the
> required_clk_rate calculations, but I guess the saturating math I
> implemented should be fine.
Tested on Jetson Nano (Tegra210, 7000a000.pwm channel 0, PWM_CSR_0 at
0x7000a000) on v7.3-rc2 (5b0764a53235), starting from period = 10000,
duty_cycle = 5000, enable = 1 (PWM_CSR_0 = 0x8080003e):
- Unpatched: writing period = 4294987776 (0x100005000) succeeds and
truncates period_ns to 0x5000 (20480 ns), programming PWM_CSR_0 to
0x80fa001f. Setting period = 2415919104 (0x90000000) and duty_cycle =
2147483648 (0x80000000) casts duty_ns to a negative int and programs
PWM_CSR_0 to 0x999a001f.
- With v2 applied: both out-of-range writes fail with -EINVAL and
PWM_CSR_0 stays 0x8080003e.
Tested-by: Karl Mehltretter <kmehltretter@xxxxxxxxx>
Thanks,
Karl