Skip to content

Commit 65dea11

Browse files
committed
Merge back earlier cpufreq material for 7.1
2 parents 6a28fb8 + 16fb8d8 commit 65dea11

7 files changed

Lines changed: 34 additions & 14 deletions

File tree

drivers/acpi/cppc_acpi.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1944,7 +1944,7 @@ static void cppc_find_dmi_mhz(const struct dmi_header *dm, void *private)
19441944
}
19451945

19461946
/* Look up the max frequency in DMI */
1947-
static u64 cppc_get_dmi_max_khz(void)
1947+
u64 cppc_get_dmi_max_khz(void)
19481948
{
19491949
u16 mhz = 0;
19501950

@@ -1958,6 +1958,7 @@ static u64 cppc_get_dmi_max_khz(void)
19581958

19591959
return KHZ_PER_MHZ * mhz;
19601960
}
1961+
EXPORT_SYMBOL_GPL(cppc_get_dmi_max_khz);
19611962

19621963
/*
19631964
* If CPPC lowest_freq and nominal_freq registers are exposed then we can

drivers/cpufreq/acpi-cpufreq.c

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,29 @@ static inline u64 get_max_boost_ratio(unsigned int cpu, u64 *nominal_freq)
675675
}
676676
#endif
677677

678+
static void acpi_cpufreq_resolve_max_freq(struct cpufreq_policy *policy,
679+
unsigned int pss_max_freq)
680+
{
681+
#ifdef CONFIG_ACPI_CPPC_LIB
682+
u64 max_speed = cppc_get_dmi_max_khz();
683+
/*
684+
* Use DMI "Max Speed" if it looks plausible: must be
685+
* above _PSS P0 frequency and within 2x of it.
686+
*/
687+
if (max_speed > pss_max_freq && max_speed < pss_max_freq * 2) {
688+
policy->cpuinfo.max_freq = max_speed;
689+
return;
690+
}
691+
#endif
692+
/*
693+
* If the maximum "boost" frequency is unknown, ask the arch
694+
* scale-invariance code to use the "nominal" performance for
695+
* CPU utilization scaling so as to prevent the schedutil
696+
* governor from selecting inadequate CPU frequencies.
697+
*/
698+
arch_set_max_freq_ratio(true);
699+
}
700+
678701
static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
679702
{
680703
struct cpufreq_frequency_table *freq_table;
@@ -849,13 +872,7 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
849872

850873
policy->cpuinfo.max_freq = freq * max_boost_ratio >> SCHED_CAPACITY_SHIFT;
851874
} else {
852-
/*
853-
* If the maximum "boost" frequency is unknown, ask the arch
854-
* scale-invariance code to use the "nominal" performance for
855-
* CPU utilization scaling so as to prevent the schedutil
856-
* governor from selecting inadequate CPU frequencies.
857-
*/
858-
arch_set_max_freq_ratio(true);
875+
acpi_cpufreq_resolve_max_freq(policy, freq_table[0].frequency);
859876
}
860877

861878
policy->freq_table = freq_table;

drivers/cpufreq/cpufreq.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2364,8 +2364,8 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy,
23642364
target_freq = __resolve_freq(policy, target_freq, policy->min,
23652365
policy->max, relation);
23662366

2367-
pr_debug("target for CPU %u: %u kHz, relation %u, requested %u kHz\n",
2368-
policy->cpu, target_freq, relation, old_target_freq);
2367+
pr_debug("CPU %u: cur %u kHz -> target %u kHz (req %u kHz, rel %u)\n",
2368+
policy->cpu, policy->cur, target_freq, old_target_freq, relation);
23692369

23702370
/*
23712371
* This might look like a redundant call as we are checking it again

drivers/cpufreq/cpufreq_governor.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <linux/kernel_stat.h>
2222
#include <linux/module.h>
2323
#include <linux/mutex.h>
24+
#include <linux/sysfs.h>
2425

2526
/* Ondemand Sampling types */
2627
enum {OD_NORMAL_SAMPLE, OD_SUB_SAMPLE};
@@ -57,15 +58,15 @@ static ssize_t file_name##_show \
5758
{ \
5859
struct dbs_data *dbs_data = to_dbs_data(attr_set); \
5960
struct _gov##_dbs_tuners *tuners = dbs_data->tuners; \
60-
return sprintf(buf, "%u\n", tuners->file_name); \
61+
return sysfs_emit(buf, "%u\n", tuners->file_name); \
6162
}
6263

6364
#define gov_show_one_common(file_name) \
6465
static ssize_t file_name##_show \
6566
(struct gov_attr_set *attr_set, char *buf) \
6667
{ \
6768
struct dbs_data *dbs_data = to_dbs_data(attr_set); \
68-
return sprintf(buf, "%u\n", dbs_data->file_name); \
69+
return sysfs_emit(buf, "%u\n", dbs_data->file_name); \
6970
}
7071

7172
#define gov_attr_ro(_name) \

drivers/cpufreq/intel_pstate.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3472,7 +3472,7 @@ static int intel_pstate_update_status(const char *buf, size_t size)
34723472
{
34733473
if (size == 3 && !strncmp(buf, "off", size)) {
34743474
if (!intel_pstate_driver)
3475-
return -EINVAL;
3475+
return 0;
34763476

34773477
if (hwp_active)
34783478
return -EBUSY;

include/acpi/cppc_acpi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ extern int cppc_set_enable(int cpu, bool enable);
156156
extern int cppc_get_perf_caps(int cpu, struct cppc_perf_caps *caps);
157157
extern bool cppc_perf_ctrs_in_pcc_cpu(unsigned int cpu);
158158
extern bool cppc_perf_ctrs_in_pcc(void);
159+
extern u64 cppc_get_dmi_max_khz(void);
159160
extern unsigned int cppc_perf_to_khz(struct cppc_perf_caps *caps, unsigned int perf);
160161
extern unsigned int cppc_khz_to_perf(struct cppc_perf_caps *caps, unsigned int freq);
161162
extern bool acpi_cpc_valid(void);

include/linux/cpufreq.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ static inline bool policy_is_inactive(struct cpufreq_policy *policy)
232232

233233
static inline bool policy_is_shared(struct cpufreq_policy *policy)
234234
{
235-
return cpumask_weight(policy->cpus) > 1;
235+
return cpumask_nth(1, policy->cpus) < nr_cpumask_bits;
236236
}
237237

238238
#ifdef CONFIG_CPU_FREQ

0 commit comments

Comments
 (0)