Repository navigation
pwm: apple: runtime suspend on zero duty cycle - #3219
Conversation
Consumers such as leds-pwm keep state->enabled = true with duty_cycle = 0 when turning an LED off, which previously kept the PWM controller's runtime PM reference (and its PMGR domain, e.g. fpwm1 on T8103) permanently powered even with the keyboard backlight at 0. Keep programming the control and cycle registers identically so get_state() readback is unchanged, and hold the runtime PM output reference only while the controller actively drives a non-zero duty cycle (on_cycles > 0). Also preserve the same check at probe time. Extend pwm-apple KUnit coverage to verify reference release and hardware readback across register loss for explicit zero duty and sub-cycle duties rounding to zero cycles (40/40 tests pass). Signed-off-by: Erik Bourget <[email protected]>
RyanTheTide
left a comment
There was a problem hiding this comment.
Verdict: MERGE at ad65b1cf3a64 once CI is green
Blockers: none.
Checked:
- The output reference now follows
on_cycles > 0instead ofstate->enabled. Get/put stay balanced on every transition:- enabled-nonzero → enabled-zero puts it;
- enabled-zero → enabled-nonzero gets it;
- disabled puts it if one was held.
- Probe takes the boot-left reference only for a running non-zero output.
- The registers are still written for a zero duty, and readback survives a power-gated resume. The new KUnit case drives both an explicit 0 and a duty that rounds down to 0 cycles.
- J313 row at this head:
fpwm1goesoff-0at brightness 0, backonat 10, and stays off across deep S2R.pwm-appleKUnit 40/40.
Non-blocking: bool driving = false; sits after a statement in apple_pwm_apply(). Kernel builds use -Wdeclaration-after-statement, so if CI or a W=1 build flags it, moving it to the top of the function fixes it.
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
|
MERGETRAIN6: approved and has a row, but |
Update the host runtime-PM model test and its --negative-control hook to match drivers/pwm/pwm-apple.c suspending on enabled zero-duty outputs (driving = on_cycles > 0) and resuming cleanly when a non-zero duty is applied again. Signed-off-by: Erik Bourget <[email protected]>
|
Fixed |
|
@RyanTheTide All latest CI checks at The Regarding the non-blocking Since |
There was a problem hiding this comment.
Verdict: MERGE at 42a2c37f
Blockers: none (driver unchanged from previously verified ad65b1cf, host-tests 698/698 + pr-text green, exact-head J313 row PASS; ready to merge).
Checked:
drivers/pwm/pwm-apple.c(unchanged fromad65b1cf): runtime PM output reference trackson_cycles > 0with balanced get/put transitions across enabled-nonzero, enabled-zero, and disabled states, preserving register state and readback while letting idlefpwm1power-gate.tools/asahi/apple-pwm-pm-tests.py(42a2c37f): updated assertions and--negative-controlhook for zero-duty runtime suspend; 698/698host-testspass (run 45927630933).- Hardware row & policy: J313 M1 Air exact-head row PASS;
MERGEABLEonmain; humanSigned-off-by; no Apple material, tool attribution, private serials, or board gating.
Evidence
- Head:
42a2c37fd846(base: main,mergeable: MERGEABLE,+62/-10across 3 files).
|
code-owner ping @DjDeveloperr: closeout merge at |
|
Merging under the 6-point rule (Ryan 09:29, permanent), at |
|
Merged. Thanks @erikwb! |
What: Drop the
pwm-appleruntime PM output reference whenon_cycles == 0while preserving register state and readback, allowing idle PWM power domains (fpwm1) to power-gate whenleds-pwmsets brightness to 0.Tested: J313 M1 Air @
42a2c37fd846(driver unchanged fromad65b1cf3a64, default command line) —fpwm1drops tooff-0atkbd_backlight=0, wakes toonatbrightness=10, returns tooff-0atbrightness=0, and staysoff-0acrossdeepS2R; arm64 KUnitpwm-apple40/40 passed;apple-pwm-pm-tests.py+--negative-controlpassed; CIhost-tests(698/698) andpr-textpassed at42a2c37fd846. J713 (M4 Air, T8132, firmware 27.2) in fleet candidate90de523e9ed9(mainfcb124279183plus the unchanged headsfa6ca3bf0e0b(#3085),42a2c37fd846(#3219),3b32d06f7ae5(#3269),4654596c5a86(#3305),d3cf4ca61518(#3329) and5dde1e7a4ffb(#3335)), default command line pluspanic=10:fpwm1isoff-0atkbd_backlight=0,onatbrightness=10andoff-0again atbrightness=0(pm_genpd_summary; the keyboard-backlight daemon was stopped for the test and restarted after),0failed units,0AppArmor denials, nopwmerror line. A deep sleep on that candidate (rtcwake -d /dev/rtc1 -m mem -s 15) did not resume: the Mac reset, and the next boot read PMU panic counter1. It is not yet attributed to a PR in the candidate or tomain(themain-only control boot did not complete), so no sleep or resume claim is made for J713.Risk: two-way door · Apple Silicon Macs using
apple,s5l-fpwm(keyboard backlight and PWM consumers).Not yet: nothing.
Details
leds-pwmkeepsstate->enabled = truewithduty_cycle = 0when turning an LED off, which previously kept the runtime PM reference onapple_pwmheld permanently.APPLE_PWM_ON_CYCLES,APPLE_PWM_OFF_CYCLES, andAPPLE_PWM_CTRLidentically soapple_pwm_get_state()readback is unchanged (andapple_pwm_runtime_suspend()/resume()save and restore all three registers across power-domain loss).state->enabled && on_cycles > 0, matching the same check on bootloader-enabled outputs inapple_pwm_probe().tools/asahi/apple-pwm-pm-tests.pyto match the zero-duty runtime-suspend behavior.Evidence
tools/testing/kunit/kunit.py run --arch=arm64 --make_options=LLVM=1 --kunitconfig=drivers/pwm/pwm-apple.kunitconfig:Testing complete. Ran 40 tests: passed: 40.python3 tools/asahi/apple-pwm-pm-tests.py: 9/9 PASS;python3 tools/asahi/apple-pwm-pm-tests.py --negative-control:PASS negative control: missing output reference was detected.make ARCH=arm64 LLVM=1 W=1 drivers/pwm/pwm-apple.o: 0 warnings../scripts/checkpatch.pl --strict --git 2cb2c0034b36f41fcae3e9e47d5239a98e4fb89e..42a2c37fd846: 0 errors, 0 warnings, 0 checks across both commits.42a2c37fd846:host-testsrun 45927630933 passed (698/698 passed, includingapple-pwm-pm-testsandapple-pwm-pm-tests --negative-control);pr-textrun 45927720704 passed.pm_genpd_summary(ad65b1cf3a64, driver unchanged in42a2c37fd846):fpwm1transitionson(kbd_backlight=10) ->off-0(kbd_backlight=0), remainsoff-0afterdeepS2R.