Repository navigation
cpufreq: apple: keep T8140 policy->cur in step with the cluster - #239
Merged
DjDeveloperr merged 1 commit intoOct 26, 2026
Merged
Conversation
The fast die-temperature limit moves a lazy_verify cluster without a scheduler request. It lowers a request above a new limit, and it restores the scheduler's request when the limit rises again before the QoS request was updated. policy->cur kept the value the last fast-switch request returned. If that was a capped frequency equal to the suspend frequency, cpufreq_generic_suspend() skipped the driver after the limit rose, and the cluster suspended at the restored, higher state. The suspend step now records the state it settles the cluster in as policy->cur before the generic suspend, so the suspend frequency is written whenever the cluster is elsewhere. When the limit moves the cluster, policy->cur is updated too, for scaling_cur_freq and the statistics, until the next fast-switch request sets it. Checked on T8140 with a diagnostic build. The limit was set to the suspend frequency under load, then restored before the QoS request changed, and policy->cur was left at the suspend frequency. A pm_test=devices suspend then left the cluster at 3336 MHz, because the generic suspend skipped the driver. With this change, policy->cur followed the restored state, and the suspend frequency was written and verified. Signed-off-by: DjDeveloperr <hey@djdev.me>
DjDeveloperr
requested review from
chriskearney,
maralcbr and
scottjones
as code owners
October 26, 2026 06:22
maralcbr
approved these changes
Oct 26, 2026
maralcbr
left a comment
Member
There was a problem hiding this comment.
Approving at f360510, with CI green.
This closes the hole from #227: after the suspend step settles the cluster, it records that state as policy->cur before cpufreq_generic_suspend(), so the suspend frequency is written whenever the cluster is elsewhere and skipped only when it really is there. The diag-build run of the exact sequence (cap at suspend_freq with a spinner, cap restored, pm_test=devices) going from "suspended at 3336 MHz" to "P-state 1 written and verified" is the evidence I was after. Pending requests are drained and verified before they're recorded, resume clears schedutil's cached target, and the E-cluster takes the same path.
Two nits, not blocking:
policy->curpublication race.apple_fast_die_cap()writespolicy->curafterlazy_cap()dropspriv->lock, and the core publishes a fast-switch result after->fast_switch()returns, outside that lock too. Either update can overwrite the other with a stale value. It only affectsscaling_cur_freq, since suspend now re-records it, but note that moving the write underpriv->lockalone wouldn't fully fix it.- Comment wording. A direct
policy->curwrite doesn't go throughcpufreq_stats_record_transition()orarch_set_freq_scale(), so "the statistics" overstates what follows the cap. Frequency invariance also stays at the last fast-switch value after a cap move (that part predates this PR).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This is a follow-up to #227, merged as 98ef5ae, for the hole maralcbr found in its last review.
The fast die-temperature limit moves a lazy_verify cluster without a scheduler request. It lowers a request above a new limit, and it restores the scheduler's request when the limit rises again before the QoS request was updated.
policy->curkept the value the last fast-switch request returned. If that was a capped frequency equal to the suspend frequency,cpufreq_generic_suspend()skipped the driver after the limit rose, and the cluster suspended at the restored, higher state.policy->curbefore the generic suspend, so the suspend frequency is written whenever the cluster is elsewhere.policy->curfollows, forscaling_cur_freqand the statistics, until the next fast-switch request sets it.Only lazy_verify SoCs (T8140) run either path.
Testing
On Neo (7.3), with a diagnostic build that sets the cap without touching the QoS request and prints the cluster's state at suspend. Each case set the cap to
suspend_freq(744000 kHz) while a spinner ran, restored it, then ran apm_test=devicessuspend.policy->curstill 744000policy->cur3924000 / 4044000 / 3648000policy->cur==suspend_freqThe E-cluster wrote its suspend frequency in every run. There were no DVFS errors and no driver suspend errors.
Under real load the stale
policy->currarely survives to suspend, because the real fast die limit changes the QoS request within about 0.3 s and schedutil asks again. The diagnostic therefore restores that state at suspend entry, to exercise the case.Builds with W=1. checkpatch --strict is clean.