Repository navigation
Conversation
DjDeveloperr
left a comment
There was a problem hiding this comment.
Formal §1–§6 pre-PR checklist review at 370f111f4ae402394df98426725db6c370d23de3.
Routing apple_pmc_dcs_vote() through __apple_pmc_floor_update() and adding apple_pmc_test_dcs_floor_pending is the right direction, and apple_pmc_floor_set() / apple_pmc_resume_early() handle the new error return cleanly. However, apple_pmc_dcs_set_cur_state() has a state-desynchronization bug on the new error path.
Blocker
- DCS thermal-limit rollback desynchronizes
pmc->dcs_statefrom hardwarerail_enable(drivers/pmdomain/apple/pmc.c:486-530):
Previouslyapple_pmc_dcs_vote()returnedvoid, soapple_pmc_dcs_limit()could only fail ifapple_pmc_enable_write()failed — which is why:522states "The rail enable did not change, so neither did the limit: go back to the old state".
Now, when leaving a DCS limit (old > 0,state == 0):apple_pmc_dcs_limit(pmc, 0)callsapple_pmc_enable_write(pmc, rail)first (:499), which succeeds and re-enables all other agents on the DCS rail in hardware (lifting the thermal limit).- It then calls
apple_pmc_dcs_vote(pmc)(:501). IfPMC_PENDINGis stuck (-ETIMEDOUT) or readback fails (-EIO),apple_pmc_dcs_limit()returns an error. apple_pmc_dcs_set_cur_state()then rolls back withapple_pmc_dcs_limit(pmc, old)(:527). Becauseold > 0, that call setspmc->dcs_state = old(:491), callsapple_pmc_dcs_vote(pmc)(:493), fails again on the same pending/EIO condition, and returns early at:495without callingapple_pmc_enable_write(pmc, rail).- Result:
pmc->dcs_stateremainsold(thermal core believes cooling stateoldis active anddcs_workkeeps polling), while the hardwarerail_enableregister remains unlimited (all agents enabled), violating the driver invariant (pmc->dcs_state != 0iff onlyap_agentis enabled ondcs_rail). - Fix: Ensure
pmc->dcs_stateand hardwarerail_enablestay consistent whenapple_pmc_dcs_vote()fails afterapple_pmc_enable_write()already succeeded on thestate == 0path (and add a KUnit test coveringapple_pmc_dcs_set_cur_state(..., 0)whenPMC_PENDINGis set on the AP agent).
§1–§6 Checklist
- §1 No model gating: Pass (uses existing
hw->has_pendinghardware property). - §2 Production-ready, no hacks: Pass (proper pending-bit polling via
__apple_pmc_floor_update()). - §3 Safety: Fail (Blocker #1: thermal cooling state
pmc->dcs_statecan silently diverge from uncapped hardwarerail_enableon pending-vote timeout). - §4 Clean-room & attribution: Pass (human author/committer + human
Signed-off-by:only, zero AI trailers in commit; PR body includesAssisted-by:). - §5 Evidence: Pass for current head (16/16 arm64 QEMU KUnit
apple-pmc,lobataM5 Max J775c debugfs & health tuple, CIhost-tests+kunitpassed; please re-run KUnit with the new rollback test on the fixed head). - §6 Naming: Pass.
Assisted-by: LLM (Gemini 4 Neon)
|
Gemini 4 Neon on @satchlj's behalf: Updated
Will post the exact-head |
370f111 to
ebecada
Compare
|
Gemini 4 Neon on @satchlj's behalf. Hardware verification on
|
DjDeveloperr
left a comment
There was a problem hiding this comment.
Formal §1–§6 pre-PR re-review at live head ebecadaa39fb6a332dffeed5ee63762e4359c160 (base integration/aurora 5746ef8a5afd, not superseded; MERGEABLE/CLEAN; live CI host-tests + kunit PASS).
Resolved Since 370f111f4ae4
- DCS thermal-limit rollback desynchronization: Fixed cleanly in
apple_pmc_dcs_limit()/apple_pmc_dcs_set_cur_state(). On thestate == 0path, ifapple_pmc_dcs_vote()fails afterapple_pmc_enable_write()succeeded,pmc->dcs_stateis restored tooldandapple_pmc_enable_write()re-restricts the rail (or resetspmc->dcs_state = 0if re-restricting fails too).apple_pmc_test_dcs_floor_pendingandapple_pmc_test_dcs_limit_release_pendingcover both failure modes and pass CIkunit. - §5 hardware run (
lobata/ J775c): Exact-head boot0535fd99-4dca-412e-b2ca-a4042e37cd4c(Image.gz5b3848aa..., default cmdline,dcs limit: state 0 of 6, 0 pending-vote timeouts, clean health tuple) was posted in the follow-up comment.
Remaining Blockers
-
Inaccurate kernel-doc committed in
drivers/pmdomain/apple/pmc.c:88-89(§2):- Commit
ebecadaa39fbadds:* @has_pending: true if the PMC exposes the pending-vote handshake bit * (APPLE_PMC_VOTE_PENDING) on floor words
- No
APPLE_PMC_VOTE_PENDINGmacro exists anywhere inpmc.c(or the tree), and the pending bit is not on the floor word (reg);__apple_pmc_floor_update()(pmc.c:346-359) pollsBIT(agent)in the separate pending word atreg + 4(as documented atpmc.c:1527: "the T8132 pending word after each floor word"). Please fix the@has_pendingkernel-doc to accurately describe thereg + 4per-agent pending word.
- Commit
-
PR description contradicts the actual diff and omits the §5 boot tuple / §1 multi-Mac note:
- The PR body (and comment
22:17:11Z) still describes nonexistent symbols/behavior (APPLE_PMC_VOTE_PENDINGbit 31,apple_pmc_t6050_hw,apple_pmc_set_floor(),apple_pmc_dcs_release(),5 uspolling step, rate-limited timeout logging, and claims T6050-onlyhas_pendinggating whenhas_pending = truewas already set on bothapple_pmc_hw_t8132andapple_pmc_hw_t6050). - Please refresh the PR body to match the actual commit, move the
lobataboot0535fd99evidence into the PR body (replacing "verified in upcoming combined fix boot"), and include a §1 multi-Mac test request for otherapple-pmcSoCs (especiallyt8132withhas_pending = true).
- The PR body (and comment
§1–§6 Checklist
- §1 No model gating: Pass in code (uses existing
hw->has_pendingproperty); add multi-Mac request note in PR body. - §2 Production-ready, no hacks: Request changes (Blocker #1: fabricated symbol/register description in
pmc.c:88-89kernel-doc; Blocker #2: mismatched PR body). - §3 Safety: Pass (
apple_pmc_dcs_limit()rollback now preservesdcs_state/rail_enableinvariant). - §4 Clean-room & attribution: Pass (commit
ebecadaa39fbhas human author/committerSatya Benson <satya@benson.earth>and humanSigned-off-by:only, zero AI commit trailers; PR body ends withAssisted-by:). - §5 Evidence: Code/KUnit/hardware run exist (17/17 KUnit +
lobataboot0535fd99in comment); consolidate into PR body alongside the kernel-doc fix. - §6 Naming: Pass.
Assisted-by: LLM (Gemini 4 Neon)
apple_pmc_dcs_vote() wrote the AP agent's DCS vote directly with writel() instead of going through __apple_pmc_floor_update(). On PMCs with has_pending = true (T8132, T6050), if a previous vote on the AP agent was still pending in the reg + 4 pending word (BIT(agent)), the direct write bypassed the pending-bit poll and could race with the PMC consuming the earlier update. Route apple_pmc_dcs_vote() through __apple_pmc_floor_update() and propagate its return value through apple_pmc_dcs_limit(), apple_pmc_floor_apply(), and apple_pmc_resume_early(). Keep pmc->dcs_state synchronized with the hardware rail_enable mask on partial failure in apple_pmc_dcs_limit(), including rolling rail_enable back to the AP agent when leaving a DCS limit fails on a pending AP vote. Add KUnit tests for both a pending DCS floor write and a pending DCS limit release rollback. Signed-off-by: Satya Benson <satya@benson.earth>
ebecada to
36f71e4
Compare
|
Gemini 4 Neon on @satchlj's behalf. Addressed both documentation blockers at
|
Route
apple_pmc_dcs_vote()through__apple_pmc_floor_update()so DCS votes wait out any pending vote on PMCs that expose the per-agent pending word atreg + 4(hw->has_pending = true, already set onapple_pmc_hw_t8132andapple_pmc_hw_t6050).Summary
writel()inapple_pmc_dcs_vote()with__apple_pmc_floor_update(pmc, hw->ap_agent, APPLE_PMC_RAIL_MASK(hw->dcs_rail), state << APPLE_PMC_RAIL_SHIFT(hw->dcs_rail)), which polls!(readl(reg + 4) & BIT(agent))(1 us step, 1000 us timeout) before and after writing wheneverpmc->hw->has_pendingis true, and document@has_pendinginstruct apple_pmc_hwkernel-doc.intreturn value ofapple_pmc_dcs_vote()throughapple_pmc_dcs_limit(),apple_pmc_floor_apply(), andapple_pmc_resume_early().pmc->dcs_statesynchronized with the hardwarerail_enablemask on partial failure inapple_pmc_dcs_limit():state != 0), restorepmc->dcs_state = oldifapple_pmc_dcs_vote()orapple_pmc_enable_write()fails (and restore the AP DCS vote ifapple_pmc_enable_write()fails).state == 0), ifapple_pmc_dcs_vote()fails afterapple_pmc_enable_write()already re-enabled all agents, restorepmc->dcs_state = oldand re-restrictrail_enable(falling back topmc->dcs_state = 0if re-restricting fails too).apple-pmcKUnit tests indrivers/pmdomain/apple/pmc-test.c(apple_pmc_test_dcs_floor_pendingandapple_pmc_test_dcs_limit_release_pending).Verification
scripts/checkpatch.pl --strict(36f71e498530): 0 errors, 0 warnings, 0 checks.W=1compile ofdrivers/pmdomain/apple/pmc.o: 0 new warnings (code identical toebecadaa39fb;36f71e498530is a 2-line@has_pendingkernel-doc comment fix only).apple-pmcKUnit (--arch=arm64): 17/17 pass (includingapple_pmc_test_dcs_floor_pendingandapple_pmc_test_dcs_limit_release_pending).lobata, Mac Studio M5 Max, J775c / T6050): combined kernel fromorigin/integration/aurora(160ca431b325) + identical compiled code (ebecadaa39fb,Image.gzSHA-2565b3848aaf84041154d36e3268d904db95a9a176398d78c1a01730a6cd8c9b7dc, J775c DTB0442bec28ef4c650d4e3395589f7001808c7e5b4a3bdd4971fc466d68f9de0ed) on default cmdline (rdinit=/init nr_cpus=18 maxcpus=18 root=UUID=3da7492b-6c5e-4e84-9eac-65b89fae44c6 arm64.nomte,boot_id:0535fd99-4dca-412e-b2ca-a4042e37cd4c):/sys/kernel/debug/apple-pmc/286806000.power-management/status:agent1 floor: 0x00000024 honoured: 0x00000024,dcs limit: state 0 of 6, 0 pending-vote timeouts across boot andpm_test=devicess2idlesuspend/resume.-SELINUX); 0 new failed systemd units (ac-power-mode.servicepre-existing due to baselineapple-spmiGen4-95); 0 newdmesg -l err,crit,alert,emerglines beyond the 4 pre-existing baseline lines (apple-spmi-95,apple_aop-61,apple-dcpx2).hw->has_pendingis also enabled onapple_pmc_hw_t8132(M4) and disabled on olderapple-pmcSoCs; a quick boot/thermal DCS-limit sanity check on at8132Mac (and any olderhas_pending = falseMac) is welcome to verify cross-SoC parity.Assisted-by: LLM (Google:Gemini 4 Neon)