Skip to content

Commit c28a280

Browse files
committed
ACPI: CPPC: Do not use CPUFREQ_ETERNAL as an error value
Instead of using CPUFREQ_ETERNAL for signaling an error condition in cppc_get_transition_latency(), change the return value type of that function to int and make it return a proper negative error code on failures. No intentional functional impact. Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org> Reviewed-by: Jie Zhan <zhanjie9@hisilicon.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Acked-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Qais Yousef <qyousef@layalina.io>
1 parent f965d11 commit c28a280

4 files changed

Lines changed: 16 additions & 18 deletions

File tree

drivers/acpi/cppc_acpi.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1876,7 +1876,7 @@ EXPORT_SYMBOL_GPL(cppc_set_perf);
18761876
* If desired_reg is in the SystemMemory or SystemIo ACPI address space,
18771877
* then assume there is no latency.
18781878
*/
1879-
unsigned int cppc_get_transition_latency(int cpu_num)
1879+
int cppc_get_transition_latency(int cpu_num)
18801880
{
18811881
/*
18821882
* Expected transition latency is based on the PCCT timing values
@@ -1889,31 +1889,29 @@ unsigned int cppc_get_transition_latency(int cpu_num)
18891889
* completion of a command before issuing the next command,
18901890
* in microseconds.
18911891
*/
1892-
unsigned int latency_ns = 0;
18931892
struct cpc_desc *cpc_desc;
18941893
struct cpc_register_resource *desired_reg;
18951894
int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, cpu_num);
18961895
struct cppc_pcc_data *pcc_ss_data;
1896+
int latency_ns = 0;
18971897

18981898
cpc_desc = per_cpu(cpc_desc_ptr, cpu_num);
18991899
if (!cpc_desc)
1900-
return CPUFREQ_ETERNAL;
1900+
return -ENODATA;
19011901

19021902
desired_reg = &cpc_desc->cpc_regs[DESIRED_PERF];
19031903
if (CPC_IN_SYSTEM_MEMORY(desired_reg) || CPC_IN_SYSTEM_IO(desired_reg))
19041904
return 0;
1905-
else if (!CPC_IN_PCC(desired_reg))
1906-
return CPUFREQ_ETERNAL;
19071905

1908-
if (pcc_ss_id < 0)
1909-
return CPUFREQ_ETERNAL;
1906+
if (!CPC_IN_PCC(desired_reg) || pcc_ss_id < 0)
1907+
return -ENODATA;
19101908

19111909
pcc_ss_data = pcc_data[pcc_ss_id];
19121910
if (pcc_ss_data->pcc_mpar)
19131911
latency_ns = 60 * (1000 * 1000 * 1000 / pcc_ss_data->pcc_mpar);
19141912

1915-
latency_ns = max(latency_ns, pcc_ss_data->pcc_nominal * 1000);
1916-
latency_ns = max(latency_ns, pcc_ss_data->pcc_mrtt * 1000);
1913+
latency_ns = max_t(int, latency_ns, pcc_ss_data->pcc_nominal * 1000);
1914+
latency_ns = max_t(int, latency_ns, pcc_ss_data->pcc_mrtt * 1000);
19171915

19181916
return latency_ns;
19191917
}

drivers/cpufreq/amd-pstate.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -872,10 +872,10 @@ static void amd_pstate_update_limits(struct cpufreq_policy *policy)
872872
*/
873873
static u32 amd_pstate_get_transition_delay_us(unsigned int cpu)
874874
{
875-
u32 transition_delay_ns;
875+
int transition_delay_ns;
876876

877877
transition_delay_ns = cppc_get_transition_latency(cpu);
878-
if (transition_delay_ns == CPUFREQ_ETERNAL) {
878+
if (transition_delay_ns < 0) {
879879
if (cpu_feature_enabled(X86_FEATURE_AMD_FAST_CPPC))
880880
return AMD_PSTATE_FAST_CPPC_TRANSITION_DELAY;
881881
else
@@ -891,10 +891,10 @@ static u32 amd_pstate_get_transition_delay_us(unsigned int cpu)
891891
*/
892892
static u32 amd_pstate_get_transition_latency(unsigned int cpu)
893893
{
894-
u32 transition_latency;
894+
int transition_latency;
895895

896896
transition_latency = cppc_get_transition_latency(cpu);
897-
if (transition_latency == CPUFREQ_ETERNAL)
897+
if (transition_latency < 0)
898898
return AMD_PSTATE_TRANSITION_LATENCY;
899899

900900
return transition_latency;

drivers/cpufreq/cppc_cpufreq.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,9 +310,9 @@ static int cppc_verify_policy(struct cpufreq_policy_data *policy)
310310

311311
static unsigned int __cppc_cpufreq_get_transition_delay_us(unsigned int cpu)
312312
{
313-
unsigned int transition_latency_ns = cppc_get_transition_latency(cpu);
313+
int transition_latency_ns = cppc_get_transition_latency(cpu);
314314

315-
if (transition_latency_ns == CPUFREQ_ETERNAL)
315+
if (transition_latency_ns < 0)
316316
return CPUFREQ_DEFAULT_TRANSITION_LATENCY_NS / NSEC_PER_USEC;
317317

318318
return transition_latency_ns / NSEC_PER_USEC;

include/acpi/cppc_acpi.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ extern unsigned int cppc_khz_to_perf(struct cppc_perf_caps *caps, unsigned int f
160160
extern bool acpi_cpc_valid(void);
161161
extern bool cppc_allow_fast_switch(void);
162162
extern int acpi_get_psd_map(unsigned int cpu, struct cppc_cpudata *cpu_data);
163-
extern unsigned int cppc_get_transition_latency(int cpu);
163+
extern int cppc_get_transition_latency(int cpu);
164164
extern bool cpc_ffh_supported(void);
165165
extern bool cpc_supported_by_cpu(void);
166166
extern int cpc_read_ffh(int cpunum, struct cpc_reg *reg, u64 *val);
@@ -216,9 +216,9 @@ static inline bool cppc_allow_fast_switch(void)
216216
{
217217
return false;
218218
}
219-
static inline unsigned int cppc_get_transition_latency(int cpu)
219+
static inline int cppc_get_transition_latency(int cpu)
220220
{
221-
return CPUFREQ_ETERNAL;
221+
return -ENODATA;
222222
}
223223
static inline bool cpc_ffh_supported(void)
224224
{

0 commit comments

Comments
 (0)