Skip to content

Commit 86c17c4

Browse files
committed
Merge branches 'pm-cpufreq' and 'pm-cpuidle'
Merge cpufreq and cpuidle changes for 5.18-rc1: - Make the schedutil cpufreq governor use to_gov_attr_set() instead of open coding it (Kevin Hao). - Replace acpi_bus_get_device() with acpi_fetch_acpi_dev() in the cpufreq longhaul driver (Rafael Wysocki). - Unify show() and store() naming in cpufreq and make it use __ATTR_XX (Lianjie Zhang). - Make the intel_pstate driver use the EPP value set by the firmware by default (Srinivas Pandruvada). - Re-order the init checks in the powernow-k8 cpufreq driver (Mario Limonciello). - Make the ACPI processor idle driver check for architectural support for LPI to avoid using it on x86 by mistake (Mario Limonciello). - Add Sapphire Rapids Xeon support to the intel_idle driver (Artem Bityutskiy). - Add 'preferred_cstates' module argument to the intel_idle driver to work around C1 and C1E handling issue on Sapphire Rapids (Artem Bityutskiy). - Add core C6 optimization on Sapphire Rapids to the intel_idle driver (Artem Bityutskiy). - Optimize the haltpoll cpuidle driver a bit (Li RongQing). - Remove leftover text from intel_idle() kerneldoc comment and fix up white space in intel_idle (Rafael Wysocki). * pm-cpufreq: cpufreq: powernow-k8: Re-order the init checks cpufreq: intel_pstate: Use firmware default EPP cpufreq: unify show() and store() naming and use __ATTR_XX cpufreq: longhaul: Replace acpi_bus_get_device() cpufreq: schedutil: Use to_gov_attr_set() to get the gov_attr_set cpufreq: Move to_gov_attr_set() to cpufreq.h * pm-cpuidle: cpuidle: intel_idle: Drop redundant backslash at line end cpuidle: intel_idle: Update intel_idle() kerneldoc comment cpuidle: haltpoll: Call cpuidle_poll_state_init() later intel_idle: add core C6 optimization for SPR intel_idle: add 'preferred_cstates' module argument intel_idle: add SPR support ACPI: processor idle: Check for architectural support for LPI cpuidle: PSCI: Move the `has_lpi` check to the beginning of the function
3 parents 524bb1d + 3870a44 + 03eb652 commit 86c17c4

14 files changed

Lines changed: 184 additions & 50 deletions

File tree

arch/arm64/kernel/cpuidle.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,16 @@ static int psci_acpi_cpu_init_idle(unsigned int cpu)
5454
struct acpi_lpi_state *lpi;
5555
struct acpi_processor *pr = per_cpu(processors, cpu);
5656

57+
if (unlikely(!pr || !pr->flags.has_lpi))
58+
return -EINVAL;
59+
5760
/*
5861
* If the PSCI cpu_suspend function hook has not been initialized
5962
* idle states must not be enabled, so bail out
6063
*/
6164
if (!psci_ops.cpu_suspend)
6265
return -EOPNOTSUPP;
6366

64-
if (unlikely(!pr || !pr->flags.has_lpi))
65-
return -EINVAL;
66-
6767
count = pr->power.count - 1;
6868
if (count <= 0)
6969
return -ENODEV;

drivers/acpi/processor_idle.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,6 +1080,11 @@ static int flatten_lpi_states(struct acpi_processor *pr,
10801080
return 0;
10811081
}
10821082

1083+
int __weak acpi_processor_ffh_lpi_probe(unsigned int cpu)
1084+
{
1085+
return -EOPNOTSUPP;
1086+
}
1087+
10831088
static int acpi_processor_get_lpi_info(struct acpi_processor *pr)
10841089
{
10851090
int ret, i;
@@ -1088,6 +1093,11 @@ static int acpi_processor_get_lpi_info(struct acpi_processor *pr)
10881093
struct acpi_device *d = NULL;
10891094
struct acpi_lpi_states_array info[2], *tmp, *prev, *curr;
10901095

1096+
/* make sure our architecture has support */
1097+
ret = acpi_processor_ffh_lpi_probe(pr->id);
1098+
if (ret == -EOPNOTSUPP)
1099+
return ret;
1100+
10911101
if (!osc_pc_lpi_support_confirmed)
10921102
return -EOPNOTSUPP;
10931103

@@ -1139,11 +1149,6 @@ static int acpi_processor_get_lpi_info(struct acpi_processor *pr)
11391149
return 0;
11401150
}
11411151

1142-
int __weak acpi_processor_ffh_lpi_probe(unsigned int cpu)
1143-
{
1144-
return -ENODEV;
1145-
}
1146-
11471152
int __weak acpi_processor_ffh_lpi_enter(struct acpi_lpi_state *lpi)
11481153
{
11491154
return -ENODEV;

drivers/cpufreq/cpufreq_conservative.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ static unsigned int cs_dbs_update(struct cpufreq_policy *policy)
146146

147147
/************************** sysfs interface ************************/
148148

149-
static ssize_t store_sampling_down_factor(struct gov_attr_set *attr_set,
149+
static ssize_t sampling_down_factor_store(struct gov_attr_set *attr_set,
150150
const char *buf, size_t count)
151151
{
152152
struct dbs_data *dbs_data = to_dbs_data(attr_set);
@@ -161,7 +161,7 @@ static ssize_t store_sampling_down_factor(struct gov_attr_set *attr_set,
161161
return count;
162162
}
163163

164-
static ssize_t store_up_threshold(struct gov_attr_set *attr_set,
164+
static ssize_t up_threshold_store(struct gov_attr_set *attr_set,
165165
const char *buf, size_t count)
166166
{
167167
struct dbs_data *dbs_data = to_dbs_data(attr_set);
@@ -177,7 +177,7 @@ static ssize_t store_up_threshold(struct gov_attr_set *attr_set,
177177
return count;
178178
}
179179

180-
static ssize_t store_down_threshold(struct gov_attr_set *attr_set,
180+
static ssize_t down_threshold_store(struct gov_attr_set *attr_set,
181181
const char *buf, size_t count)
182182
{
183183
struct dbs_data *dbs_data = to_dbs_data(attr_set);
@@ -195,7 +195,7 @@ static ssize_t store_down_threshold(struct gov_attr_set *attr_set,
195195
return count;
196196
}
197197

198-
static ssize_t store_ignore_nice_load(struct gov_attr_set *attr_set,
198+
static ssize_t ignore_nice_load_store(struct gov_attr_set *attr_set,
199199
const char *buf, size_t count)
200200
{
201201
struct dbs_data *dbs_data = to_dbs_data(attr_set);
@@ -220,7 +220,7 @@ static ssize_t store_ignore_nice_load(struct gov_attr_set *attr_set,
220220
return count;
221221
}
222222

223-
static ssize_t store_freq_step(struct gov_attr_set *attr_set, const char *buf,
223+
static ssize_t freq_step_store(struct gov_attr_set *attr_set, const char *buf,
224224
size_t count)
225225
{
226226
struct dbs_data *dbs_data = to_dbs_data(attr_set);

drivers/cpufreq/cpufreq_governor.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ static DEFINE_MUTEX(gov_dbs_data_mutex);
2727

2828
/* Common sysfs tunables */
2929
/*
30-
* store_sampling_rate - update sampling rate effective immediately if needed.
30+
* sampling_rate_store - update sampling rate effective immediately if needed.
3131
*
3232
* If new rate is smaller than the old, simply updating
3333
* dbs.sampling_rate might not be appropriate. For example, if the
@@ -41,7 +41,7 @@ static DEFINE_MUTEX(gov_dbs_data_mutex);
4141
* This must be called with dbs_data->mutex held, otherwise traversing
4242
* policy_dbs_list isn't safe.
4343
*/
44-
ssize_t store_sampling_rate(struct gov_attr_set *attr_set, const char *buf,
44+
ssize_t sampling_rate_store(struct gov_attr_set *attr_set, const char *buf,
4545
size_t count)
4646
{
4747
struct dbs_data *dbs_data = to_dbs_data(attr_set);
@@ -80,7 +80,7 @@ ssize_t store_sampling_rate(struct gov_attr_set *attr_set, const char *buf,
8080

8181
return count;
8282
}
83-
EXPORT_SYMBOL_GPL(store_sampling_rate);
83+
EXPORT_SYMBOL_GPL(sampling_rate_store);
8484

8585
/**
8686
* gov_update_cpu_data - Update CPU load data.

drivers/cpufreq/cpufreq_governor.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ static inline struct dbs_data *to_dbs_data(struct gov_attr_set *attr_set)
5151
}
5252

5353
#define gov_show_one(_gov, file_name) \
54-
static ssize_t show_##file_name \
54+
static ssize_t file_name##_show \
5555
(struct gov_attr_set *attr_set, char *buf) \
5656
{ \
5757
struct dbs_data *dbs_data = to_dbs_data(attr_set); \
@@ -60,20 +60,18 @@ static ssize_t show_##file_name \
6060
}
6161

6262
#define gov_show_one_common(file_name) \
63-
static ssize_t show_##file_name \
63+
static ssize_t file_name##_show \
6464
(struct gov_attr_set *attr_set, char *buf) \
6565
{ \
6666
struct dbs_data *dbs_data = to_dbs_data(attr_set); \
6767
return sprintf(buf, "%u\n", dbs_data->file_name); \
6868
}
6969

7070
#define gov_attr_ro(_name) \
71-
static struct governor_attr _name = \
72-
__ATTR(_name, 0444, show_##_name, NULL)
71+
static struct governor_attr _name = __ATTR_RO(_name)
7372

7473
#define gov_attr_rw(_name) \
75-
static struct governor_attr _name = \
76-
__ATTR(_name, 0644, show_##_name, store_##_name)
74+
static struct governor_attr _name = __ATTR_RW(_name)
7775

7876
/* Common to all CPUs of a policy */
7977
struct policy_dbs_info {
@@ -176,7 +174,7 @@ void od_register_powersave_bias_handler(unsigned int (*f)
176174
(struct cpufreq_policy *, unsigned int, unsigned int),
177175
unsigned int powersave_bias);
178176
void od_unregister_powersave_bias_handler(void);
179-
ssize_t store_sampling_rate(struct gov_attr_set *attr_set, const char *buf,
177+
ssize_t sampling_rate_store(struct gov_attr_set *attr_set, const char *buf,
180178
size_t count);
181179
void gov_update_cpu_data(struct dbs_data *dbs_data);
182180
#endif /* _CPUFREQ_GOVERNOR_H */

drivers/cpufreq/cpufreq_governor_attr_set.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@
88

99
#include "cpufreq_governor.h"
1010

11-
static inline struct gov_attr_set *to_gov_attr_set(struct kobject *kobj)
12-
{
13-
return container_of(kobj, struct gov_attr_set, kobj);
14-
}
15-
1611
static inline struct governor_attr *to_gov_attr(struct attribute *attr)
1712
{
1813
return container_of(attr, struct governor_attr, attr);

drivers/cpufreq/cpufreq_ondemand.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ static unsigned int od_dbs_update(struct cpufreq_policy *policy)
202202
/************************** sysfs interface ************************/
203203
static struct dbs_governor od_dbs_gov;
204204

205-
static ssize_t store_io_is_busy(struct gov_attr_set *attr_set, const char *buf,
205+
static ssize_t io_is_busy_store(struct gov_attr_set *attr_set, const char *buf,
206206
size_t count)
207207
{
208208
struct dbs_data *dbs_data = to_dbs_data(attr_set);
@@ -220,7 +220,7 @@ static ssize_t store_io_is_busy(struct gov_attr_set *attr_set, const char *buf,
220220
return count;
221221
}
222222

223-
static ssize_t store_up_threshold(struct gov_attr_set *attr_set,
223+
static ssize_t up_threshold_store(struct gov_attr_set *attr_set,
224224
const char *buf, size_t count)
225225
{
226226
struct dbs_data *dbs_data = to_dbs_data(attr_set);
@@ -237,7 +237,7 @@ static ssize_t store_up_threshold(struct gov_attr_set *attr_set,
237237
return count;
238238
}
239239

240-
static ssize_t store_sampling_down_factor(struct gov_attr_set *attr_set,
240+
static ssize_t sampling_down_factor_store(struct gov_attr_set *attr_set,
241241
const char *buf, size_t count)
242242
{
243243
struct dbs_data *dbs_data = to_dbs_data(attr_set);
@@ -265,7 +265,7 @@ static ssize_t store_sampling_down_factor(struct gov_attr_set *attr_set,
265265
return count;
266266
}
267267

268-
static ssize_t store_ignore_nice_load(struct gov_attr_set *attr_set,
268+
static ssize_t ignore_nice_load_store(struct gov_attr_set *attr_set,
269269
const char *buf, size_t count)
270270
{
271271
struct dbs_data *dbs_data = to_dbs_data(attr_set);
@@ -290,7 +290,7 @@ static ssize_t store_ignore_nice_load(struct gov_attr_set *attr_set,
290290
return count;
291291
}
292292

293-
static ssize_t store_powersave_bias(struct gov_attr_set *attr_set,
293+
static ssize_t powersave_bias_store(struct gov_attr_set *attr_set,
294294
const char *buf, size_t count)
295295
{
296296
struct dbs_data *dbs_data = to_dbs_data(attr_set);

drivers/cpufreq/intel_pstate.c

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1692,6 +1692,37 @@ static void intel_pstate_enable_hwp_interrupt(struct cpudata *cpudata)
16921692
}
16931693
}
16941694

1695+
static void intel_pstate_update_epp_defaults(struct cpudata *cpudata)
1696+
{
1697+
cpudata->epp_default = intel_pstate_get_epp(cpudata, 0);
1698+
1699+
/*
1700+
* If this CPU gen doesn't call for change in balance_perf
1701+
* EPP return.
1702+
*/
1703+
if (epp_values[EPP_INDEX_BALANCE_PERFORMANCE] == HWP_EPP_BALANCE_PERFORMANCE)
1704+
return;
1705+
1706+
/*
1707+
* If powerup EPP is something other than chipset default 0x80 and
1708+
* - is more performance oriented than 0x80 (default balance_perf EPP)
1709+
* - But less performance oriented than performance EPP
1710+
* then use this as new balance_perf EPP.
1711+
*/
1712+
if (cpudata->epp_default < HWP_EPP_BALANCE_PERFORMANCE &&
1713+
cpudata->epp_default > HWP_EPP_PERFORMANCE) {
1714+
epp_values[EPP_INDEX_BALANCE_PERFORMANCE] = cpudata->epp_default;
1715+
return;
1716+
}
1717+
1718+
/*
1719+
* Use hard coded value per gen to update the balance_perf
1720+
* and default EPP.
1721+
*/
1722+
cpudata->epp_default = epp_values[EPP_INDEX_BALANCE_PERFORMANCE];
1723+
intel_pstate_set_epp(cpudata, cpudata->epp_default);
1724+
}
1725+
16951726
static void intel_pstate_hwp_enable(struct cpudata *cpudata)
16961727
{
16971728
/* First disable HWP notification interrupt till we activate again */
@@ -1705,12 +1736,7 @@ static void intel_pstate_hwp_enable(struct cpudata *cpudata)
17051736
if (cpudata->epp_default >= 0)
17061737
return;
17071738

1708-
if (epp_values[EPP_INDEX_BALANCE_PERFORMANCE] == HWP_EPP_BALANCE_PERFORMANCE) {
1709-
cpudata->epp_default = intel_pstate_get_epp(cpudata, 0);
1710-
} else {
1711-
cpudata->epp_default = epp_values[EPP_INDEX_BALANCE_PERFORMANCE];
1712-
intel_pstate_set_epp(cpudata, cpudata->epp_default);
1713-
}
1739+
intel_pstate_update_epp_defaults(cpudata);
17141740
}
17151741

17161742
static int atom_get_min_pstate(void)

drivers/cpufreq/longhaul.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -668,9 +668,9 @@ static acpi_status longhaul_walk_callback(acpi_handle obj_handle,
668668
u32 nesting_level,
669669
void *context, void **return_value)
670670
{
671-
struct acpi_device *d;
671+
struct acpi_device *d = acpi_fetch_acpi_dev(obj_handle);
672672

673-
if (acpi_bus_get_device(obj_handle, &d))
673+
if (!d)
674674
return 0;
675675

676676
*return_value = acpi_driver_data(d);

drivers/cpufreq/powernow-k8.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,14 +1172,14 @@ static int powernowk8_init(void)
11721172
unsigned int i, supported_cpus = 0;
11731173
int ret;
11741174

1175+
if (!x86_match_cpu(powernow_k8_ids))
1176+
return -ENODEV;
1177+
11751178
if (boot_cpu_has(X86_FEATURE_HW_PSTATE)) {
11761179
__request_acpi_cpufreq();
11771180
return -ENODEV;
11781181
}
11791182

1180-
if (!x86_match_cpu(powernow_k8_ids))
1181-
return -ENODEV;
1182-
11831183
cpus_read_lock();
11841184
for_each_online_cpu(i) {
11851185
smp_call_function_single(i, check_supported_cpu, &ret, 1);

0 commit comments

Comments
 (0)