Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 27 additions & 25 deletions drivers/cpufreq/apple-soc-cpufreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,13 @@ static int apple_fast_die_hp_state;

struct apple_soc_cpufreq_info {
bool has_ps2;
/*
* The command register reads back the accepted state, and each
* request is checked against it. Requests from the scheduler's
* fast-switch path are checked by a timer instead of waited for,
* see "Lazy verification".
*/
bool verify_transition;
bool lazy_verify;
/* Fail closed when the DT describes no fast die-temperature limit. */
bool needs_thermal_policy;
bool needs_thermal_owner;
Expand Down Expand Up @@ -289,15 +294,11 @@ static const struct apple_soc_cpufreq_info soc_t8112_info = {
/*
* T8140 uses 5-bit PS1 state IDs starting at 1. The command register reads
* back the last accepted request, not a measured frequency; each request is
* verified. Requests from the scheduler's fast-switch path are verified by a
* timer rather than waited for, so schedutil can switch from the scheduler,
* see apple_soc_cpufreq_lazy_request(); requests through ->target_index
* (suspend, the static governors) are still waited for. Voltage, PLL and
* firmware throttling configuration are left as the bootloader set them.
* verified. Voltage, PLL and firmware throttling configuration are left as
* the bootloader set them.
*/
static const struct apple_soc_cpufreq_info soc_t8140_info = {
.verify_transition = true,
.lazy_verify = true,
.needs_thermal_policy = true,
.min_pstate = 1,
.max_pstate = 31,
Expand Down Expand Up @@ -525,7 +526,7 @@ static int apple_soc_cpufreq_request(struct cpufreq_policy *policy,
}

/*
* Lazy verification (lazy_verify SoCs)
* Lazy verification (verify_transition SoCs)
*
* A transition takes about 50 us. The scheduler's fast-switch path must not
* wait for one, nor drop a request: schedutil records the frequency it asked
Expand Down Expand Up @@ -734,9 +735,9 @@ static unsigned int apple_soc_cpufreq_lazy_request(struct cpufreq_policy *policy

/*
* Applies a new fast die-temperature limit, whose highest P-state is @cap at
* @freq, to a lazy_verify cluster at once. schedutil picks up a lower limit
* only at its next frequency update, which a nohz_full CPU running with its
* tick stopped may not have for a long time. The cluster is moved to the
* @freq, to a verify_transition cluster at once. schedutil picks up a lower
* limit only at its next frequency update, which a nohz_full CPU running with
* its tick stopped may not have for a long time. The cluster is moved to the
* P-state the scheduler last asked for, at most @cap, and later requests are
* clamped to @cap. That also restores the request when the limit rises
* again before schedutil has seen it fall: the QoS request is then left
Expand Down Expand Up @@ -808,7 +809,7 @@ static int apple_soc_cpufreq_set_target(struct cpufreq_policy *policy,
struct apple_cpu_priv *priv = policy->driver_data;

/* A waited-for request replaces a pending one, see "Lazy verification". */
if (priv->info->lazy_verify)
if (priv->info->verify_transition)
apple_soc_cpufreq_drain(priv);

return apple_soc_cpufreq_request(policy, index);
Expand All @@ -827,13 +828,13 @@ static unsigned int apple_soc_cpufreq_pstate_freq(struct cpufreq_policy *policy,
}

/*
* On a lazy_verify SoC policy->cur is the last fast-switch request, which the
* cluster may not hold: it may still be pending, be lost to a failure that
* stopped requests, or have been moved since by a fast die-temperature limit,
* see apple_soc_cpufreq_lazy_cap(). The core skips a suspend frequency equal
* to policy->cur, so settle the cluster first, writing and verifying the
* pending request or reporting the failure, and record the state it settled
* in as policy->cur before the generic suspend.
* On a verify_transition SoC policy->cur is the last fast-switch request,
* which the cluster may not hold: it may still be pending, be lost to a
* failure that stopped requests, or have been moved since by a fast
* die-temperature limit, see apple_soc_cpufreq_lazy_cap(). The core skips a
* suspend frequency equal to policy->cur, so settle the cluster first,
* writing and verifying the pending request or reporting the failure, and
* record the state it settled in as policy->cur before the generic suspend.
*/
static int apple_soc_cpufreq_suspend(struct cpufreq_policy *policy)
{
Expand All @@ -852,7 +853,7 @@ static int apple_soc_cpufreq_suspend(struct cpufreq_policy *policy)
spin_unlock_bh(&fd->lock);
}

if (priv->info->lazy_verify) {
if (priv->info->verify_transition) {
int pstate = apple_soc_cpufreq_drain(priv);
unsigned int freq;
int ret;
Expand Down Expand Up @@ -913,7 +914,7 @@ static unsigned int apple_soc_cpufreq_fast_switch(struct cpufreq_policy *policy,

if (idx < 0)
return 0;
if (priv->info->lazy_verify)
if (priv->info->verify_transition)
return apple_soc_cpufreq_lazy_request(policy, idx);
if (apple_soc_cpufreq_request(policy, idx))
return 0;
Expand Down Expand Up @@ -1010,8 +1011,8 @@ static void apple_fast_die_arm(struct apple_fast_die *fd)
}

/*
* Applies @limit to a lazy_verify cluster at once, as its fastest state at or
* below the limit, see apple_soc_cpufreq_lazy_cap().
* Applies @limit to a verify_transition cluster at once, as its fastest state
* at or below the limit, see apple_soc_cpufreq_lazy_cap().
*/
static void apple_fast_die_cap(struct apple_fast_die *fd, unsigned int limit)
{
Expand All @@ -1021,7 +1022,7 @@ static void apple_fast_die_cap(struct apple_fast_die *fd, unsigned int limit)
unsigned int cap = 0, freq = 0;
int moved;

if (!priv->info->lazy_verify)
if (!priv->info->verify_transition)
return;

cpufreq_for_each_valid_entry(pos, policy->freq_table) {
Expand Down Expand Up @@ -1537,7 +1538,8 @@ static int apple_soc_cpufreq_init(struct cpufreq_policy *policy)

policy->cpuinfo.transition_latency = transition_latency;
policy->dvfs_possible_from_any_cpu = true;
policy->fast_switch_possible = !info->verify_transition || info->lazy_verify;
/* Verified transitions are checked lazily on the fast-switch path. */
policy->fast_switch_possible = true;
policy->suspend_freq = freq_table[0].frequency;

return 0;
Expand Down
Loading