Skip to content

Commit 40e8e98

Browse files
committed
Merge tag 'pm-6.5-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull power management updates from Rafael Wysocki: "These add Intel TPMI (Topology Aware Register and PM Capsule Interface) support to the power capping subsystem, extend the intel_idle driver to work in VM guests where MWAIT is not available, extend the system-wide power management diagnostics, fix bugs and clean up code. Specifics: - Introduce power capping core support for Intel TPMI (Topology Aware Register and PM Capsule Interface) and a TPMI interface driver for Intel RAPL (Zhang Rui, Dan Carpenter) - Fix CONFIG_IOSF_MBI dependency in the Intel RAPL power capping driver (Zhang Rui) - Fix invalid initialization for pl4_supported field in the Intel RAPL power capping driver (Sumeet Pawnikar) - Clean up the intel_idle driver, make it work with VM guests that cannot use the MWAIT instruction and address the case in which the host may enter a deep idle state when the guest is idle (Arjan van de Ven) - Prevent cpufreq drivers that provide the ->adjust_perf() callback without a ->fast_switch() one which is used as a fallback from the former in some cases (Wyes Karny) - Fix some issues related to the AMD P-state cpufreq driver (Mario Limonciello, Wyes Karny) - Fix the energy_performance_preference attribute handling in the intel_pstate driver in passive mode (Tero Kristo) - Fix the handling of pm_suspend_target_state when CONFIG_PM is unset (Kai-Heng Feng) - Correct spelling mistake in a comment in the hibernation code (Wang Honghui) - Add arch_resume_nosmt() prototype to avoid a "missing prototypes" build warning (Arnd Bergmann) - Restrict pm_pr_dbg() to system-wide power transitions and use it in a few additional places (Mario Limonciello) - Drop verification of in-params from genpd_add_device() and ensure that all of its callers will do it (Ulf Hansson) - Prevent possible integer overflows from occurring in genpd_parse_state() (Nikita Zhandarovich) - Reorder fieldls in 'struct devfreq_dev_status' to reduce its size somewhat (Christophe JAILLET) - Ensure that the Exynos PPMU driver is already loaded before the Exynos Bus driver starts probing so as to avoid a possible freeze loading of the kernel modules (Marek Szyprowski) - Fix variable deferencing before NULL check in the mtk-cci devfreq driver (Sukrut Bellary)" * tag 'pm-6.5-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (42 commits) intel_idle: Add a "Long HLT" C1 state for the VM guest mode cpufreq: intel_pstate: Fix energy_performance_preference for passive cpufreq: amd-pstate: Add a kernel config option to set default mode cpufreq: amd-pstate: Set a fallback policy based on preferred_profile ACPI: CPPC: Add definition for undefined FADT preferred PM profile value cpufreq: amd-pstate: Set default governor to schedutil PM: domains: Move the verification of in-params from genpd_add_device() cpufreq: amd-pstate: Make amd-pstate EPP driver name hyphenated cpufreq: amd-pstate: Write CPPC enable bit per-socket intel_idle: Add support for using intel_idle in a VM guest using just hlt cpufreq: Fail driver register if it has adjust_perf without fast_switch intel_idle: clean up the (new) state_update_enter_method function intel_idle: refactor state->enter manipulation into its own function platform/x86/amd: pmc: Use pm_pr_dbg() for suspend related messages pinctrl: amd: Use pm_pr_dbg to show debugging messages ACPI: x86: Add pm_debug_messages for LPS0 _DSM state tracking include/linux/suspend.h: Only show pm_pr_dbg messages at suspend/resume powercap: RAPL: Fix a NULL vs IS_ERR() bug powercap: RAPL: Fix CONFIG_IOSF_MBI dependency powercap: RAPL: fix invalid initialization for pl4_supported field ...
2 parents bb69505 + c89a27f commit 40e8e98

File tree

27 files changed

+1324
-494
lines changed

27 files changed

+1324
-494
lines changed

drivers/acpi/x86/s2idle.c

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ static int lps0_dsm_func_mask;
5959

6060
static guid_t lps0_dsm_guid_microsoft;
6161
static int lps0_dsm_func_mask_microsoft;
62+
static int lps0_dsm_state;
6263

6364
/* Device constraint entry structure */
6465
struct lpi_device_info {
@@ -320,6 +321,44 @@ static void lpi_check_constraints(void)
320321
}
321322
}
322323

324+
static bool acpi_s2idle_vendor_amd(void)
325+
{
326+
return boot_cpu_data.x86_vendor == X86_VENDOR_AMD;
327+
}
328+
329+
static const char *acpi_sleep_dsm_state_to_str(unsigned int state)
330+
{
331+
if (lps0_dsm_func_mask_microsoft || !acpi_s2idle_vendor_amd()) {
332+
switch (state) {
333+
case ACPI_LPS0_SCREEN_OFF:
334+
return "screen off";
335+
case ACPI_LPS0_SCREEN_ON:
336+
return "screen on";
337+
case ACPI_LPS0_ENTRY:
338+
return "lps0 entry";
339+
case ACPI_LPS0_EXIT:
340+
return "lps0 exit";
341+
case ACPI_LPS0_MS_ENTRY:
342+
return "lps0 ms entry";
343+
case ACPI_LPS0_MS_EXIT:
344+
return "lps0 ms exit";
345+
}
346+
} else {
347+
switch (state) {
348+
case ACPI_LPS0_SCREEN_ON_AMD:
349+
return "screen on";
350+
case ACPI_LPS0_SCREEN_OFF_AMD:
351+
return "screen off";
352+
case ACPI_LPS0_ENTRY_AMD:
353+
return "lps0 entry";
354+
case ACPI_LPS0_EXIT_AMD:
355+
return "lps0 exit";
356+
}
357+
}
358+
359+
return "unknown";
360+
}
361+
323362
static void acpi_sleep_run_lps0_dsm(unsigned int func, unsigned int func_mask, guid_t dsm_guid)
324363
{
325364
union acpi_object *out_obj;
@@ -331,14 +370,15 @@ static void acpi_sleep_run_lps0_dsm(unsigned int func, unsigned int func_mask, g
331370
rev_id, func, NULL);
332371
ACPI_FREE(out_obj);
333372

334-
acpi_handle_debug(lps0_device_handle, "_DSM function %u evaluation %s\n",
335-
func, out_obj ? "successful" : "failed");
373+
lps0_dsm_state = func;
374+
if (pm_debug_messages_on) {
375+
acpi_handle_info(lps0_device_handle,
376+
"%s transitioned to state %s\n",
377+
out_obj ? "Successfully" : "Failed to",
378+
acpi_sleep_dsm_state_to_str(lps0_dsm_state));
379+
}
336380
}
337381

338-
static bool acpi_s2idle_vendor_amd(void)
339-
{
340-
return boot_cpu_data.x86_vendor == X86_VENDOR_AMD;
341-
}
342382

343383
static int validate_dsm(acpi_handle handle, const char *uuid, int rev, guid_t *dsm_guid)
344384
{

drivers/base/power/domain.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1632,9 +1632,6 @@ static int genpd_add_device(struct generic_pm_domain *genpd, struct device *dev,
16321632

16331633
dev_dbg(dev, "%s()\n", __func__);
16341634

1635-
if (IS_ERR_OR_NULL(genpd) || IS_ERR_OR_NULL(dev))
1636-
return -EINVAL;
1637-
16381635
gpd_data = genpd_alloc_dev_data(dev, gd);
16391636
if (IS_ERR(gpd_data))
16401637
return PTR_ERR(gpd_data);
@@ -1676,6 +1673,9 @@ int pm_genpd_add_device(struct generic_pm_domain *genpd, struct device *dev)
16761673
{
16771674
int ret;
16781675

1676+
if (!genpd || !dev)
1677+
return -EINVAL;
1678+
16791679
mutex_lock(&gpd_list_lock);
16801680
ret = genpd_add_device(genpd, dev, dev);
16811681
mutex_unlock(&gpd_list_lock);
@@ -2523,6 +2523,9 @@ int of_genpd_add_device(struct of_phandle_args *genpdspec, struct device *dev)
25232523
struct generic_pm_domain *genpd;
25242524
int ret;
25252525

2526+
if (!dev)
2527+
return -EINVAL;
2528+
25262529
mutex_lock(&gpd_list_lock);
25272530

25282531
genpd = genpd_get_from_provider(genpdspec);
@@ -2939,10 +2942,10 @@ static int genpd_parse_state(struct genpd_power_state *genpd_state,
29392942

29402943
err = of_property_read_u32(state_node, "min-residency-us", &residency);
29412944
if (!err)
2942-
genpd_state->residency_ns = 1000 * residency;
2945+
genpd_state->residency_ns = 1000LL * residency;
29432946

2944-
genpd_state->power_on_latency_ns = 1000 * exit_latency;
2945-
genpd_state->power_off_latency_ns = 1000 * entry_latency;
2947+
genpd_state->power_on_latency_ns = 1000LL * exit_latency;
2948+
genpd_state->power_off_latency_ns = 1000LL * entry_latency;
29462949
genpd_state->fwnode = &state_node->fwnode;
29472950

29482951
return 0;

drivers/base/power/wakeup.c

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

2020
#include "power.h"
2121

22-
#ifndef CONFIG_SUSPEND
23-
suspend_state_t pm_suspend_target_state;
24-
#define pm_suspend_target_state (PM_SUSPEND_ON)
25-
#endif
26-
2722
#define list_for_each_entry_rcu_locked(pos, head, member) \
2823
list_for_each_entry_rcu(pos, head, member, \
2924
srcu_read_lock_held(&wakeup_srcu))

drivers/cpufreq/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ choice
3838
prompt "Default CPUFreq governor"
3939
default CPU_FREQ_DEFAULT_GOV_USERSPACE if ARM_SA1110_CPUFREQ
4040
default CPU_FREQ_DEFAULT_GOV_SCHEDUTIL if ARM64 || ARM
41-
default CPU_FREQ_DEFAULT_GOV_SCHEDUTIL if X86_INTEL_PSTATE && SMP
41+
default CPU_FREQ_DEFAULT_GOV_SCHEDUTIL if (X86_INTEL_PSTATE || X86_AMD_PSTATE) && SMP
4242
default CPU_FREQ_DEFAULT_GOV_PERFORMANCE
4343
help
4444
This option sets which CPUFreq governor shall be loaded at

drivers/cpufreq/Kconfig.x86

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,23 @@ config X86_AMD_PSTATE
5151

5252
If in doubt, say N.
5353

54+
config X86_AMD_PSTATE_DEFAULT_MODE
55+
int "AMD Processor P-State default mode"
56+
depends on X86_AMD_PSTATE
57+
default 3 if X86_AMD_PSTATE
58+
range 1 4
59+
help
60+
Select the default mode the amd-pstate driver will use on
61+
supported hardware.
62+
The value set has the following meanings:
63+
1 -> Disabled
64+
2 -> Passive
65+
3 -> Active (EPP)
66+
4 -> Guided
67+
68+
For details, take a look at:
69+
<file:Documentation/admin-guide/pm/amd-pstate.rst>.
70+
5471
config X86_AMD_PSTATE_UT
5572
tristate "selftest for AMD Processor P-State driver"
5673
depends on X86 && ACPI_PROCESSOR

drivers/cpufreq/amd-pstate.c

Lines changed: 102 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@
6262
static struct cpufreq_driver *current_pstate_driver;
6363
static struct cpufreq_driver amd_pstate_driver;
6464
static struct cpufreq_driver amd_pstate_epp_driver;
65-
static int cppc_state = AMD_PSTATE_DISABLE;
65+
static int cppc_state = AMD_PSTATE_UNDEFINED;
66+
static bool cppc_enabled;
6667

6768
/*
6869
* AMD Energy Preference Performance (EPP)
@@ -228,14 +229,38 @@ static int amd_pstate_set_energy_pref_index(struct amd_cpudata *cpudata,
228229

229230
static inline int pstate_enable(bool enable)
230231
{
231-
return wrmsrl_safe(MSR_AMD_CPPC_ENABLE, enable);
232+
int ret, cpu;
233+
unsigned long logical_proc_id_mask = 0;
234+
235+
if (enable == cppc_enabled)
236+
return 0;
237+
238+
for_each_present_cpu(cpu) {
239+
unsigned long logical_id = topology_logical_die_id(cpu);
240+
241+
if (test_bit(logical_id, &logical_proc_id_mask))
242+
continue;
243+
244+
set_bit(logical_id, &logical_proc_id_mask);
245+
246+
ret = wrmsrl_safe_on_cpu(cpu, MSR_AMD_CPPC_ENABLE,
247+
enable);
248+
if (ret)
249+
return ret;
250+
}
251+
252+
cppc_enabled = enable;
253+
return 0;
232254
}
233255

234256
static int cppc_enable(bool enable)
235257
{
236258
int cpu, ret = 0;
237259
struct cppc_perf_ctrls perf_ctrls;
238260

261+
if (enable == cppc_enabled)
262+
return 0;
263+
239264
for_each_present_cpu(cpu) {
240265
ret = cppc_set_enable(cpu, enable);
241266
if (ret)
@@ -251,6 +276,7 @@ static int cppc_enable(bool enable)
251276
}
252277
}
253278

279+
cppc_enabled = enable;
254280
return ret;
255281
}
256282

@@ -1045,6 +1071,26 @@ static const struct attribute_group amd_pstate_global_attr_group = {
10451071
.attrs = pstate_global_attributes,
10461072
};
10471073

1074+
static bool amd_pstate_acpi_pm_profile_server(void)
1075+
{
1076+
switch (acpi_gbl_FADT.preferred_profile) {
1077+
case PM_ENTERPRISE_SERVER:
1078+
case PM_SOHO_SERVER:
1079+
case PM_PERFORMANCE_SERVER:
1080+
return true;
1081+
}
1082+
return false;
1083+
}
1084+
1085+
static bool amd_pstate_acpi_pm_profile_undefined(void)
1086+
{
1087+
if (acpi_gbl_FADT.preferred_profile == PM_UNSPECIFIED)
1088+
return true;
1089+
if (acpi_gbl_FADT.preferred_profile >= NR_PM_PROFILES)
1090+
return true;
1091+
return false;
1092+
}
1093+
10481094
static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy)
10491095
{
10501096
int min_freq, max_freq, nominal_freq, lowest_nonlinear_freq, ret;
@@ -1102,10 +1148,14 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy)
11021148
policy->max = policy->cpuinfo.max_freq;
11031149

11041150
/*
1105-
* Set the policy to powersave to provide a valid fallback value in case
1151+
* Set the policy to provide a valid fallback value in case
11061152
* the default cpufreq governor is neither powersave nor performance.
11071153
*/
1108-
policy->policy = CPUFREQ_POLICY_POWERSAVE;
1154+
if (amd_pstate_acpi_pm_profile_server() ||
1155+
amd_pstate_acpi_pm_profile_undefined())
1156+
policy->policy = CPUFREQ_POLICY_PERFORMANCE;
1157+
else
1158+
policy->policy = CPUFREQ_POLICY_POWERSAVE;
11091159

11101160
if (boot_cpu_has(X86_FEATURE_CPPC)) {
11111161
ret = rdmsrl_on_cpu(cpudata->cpu, MSR_AMD_CPPC_REQ, &value);
@@ -1356,26 +1406,36 @@ static struct cpufreq_driver amd_pstate_epp_driver = {
13561406
.online = amd_pstate_epp_cpu_online,
13571407
.suspend = amd_pstate_epp_suspend,
13581408
.resume = amd_pstate_epp_resume,
1359-
.name = "amd_pstate_epp",
1409+
.name = "amd-pstate-epp",
13601410
.attr = amd_pstate_epp_attr,
13611411
};
13621412

1413+
static int __init amd_pstate_set_driver(int mode_idx)
1414+
{
1415+
if (mode_idx >= AMD_PSTATE_DISABLE && mode_idx < AMD_PSTATE_MAX) {
1416+
cppc_state = mode_idx;
1417+
if (cppc_state == AMD_PSTATE_DISABLE)
1418+
pr_info("driver is explicitly disabled\n");
1419+
1420+
if (cppc_state == AMD_PSTATE_ACTIVE)
1421+
current_pstate_driver = &amd_pstate_epp_driver;
1422+
1423+
if (cppc_state == AMD_PSTATE_PASSIVE || cppc_state == AMD_PSTATE_GUIDED)
1424+
current_pstate_driver = &amd_pstate_driver;
1425+
1426+
return 0;
1427+
}
1428+
1429+
return -EINVAL;
1430+
}
1431+
13631432
static int __init amd_pstate_init(void)
13641433
{
13651434
struct device *dev_root;
13661435
int ret;
13671436

13681437
if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD)
13691438
return -ENODEV;
1370-
/*
1371-
* by default the pstate driver is disabled to load
1372-
* enable the amd_pstate passive mode driver explicitly
1373-
* with amd_pstate=passive or other modes in kernel command line
1374-
*/
1375-
if (cppc_state == AMD_PSTATE_DISABLE) {
1376-
pr_info("driver load is disabled, boot with specific mode to enable this\n");
1377-
return -ENODEV;
1378-
}
13791439

13801440
if (!acpi_cpc_valid()) {
13811441
pr_warn_once("the _CPC object is not present in SBIOS or ACPI disabled\n");
@@ -1386,6 +1446,33 @@ static int __init amd_pstate_init(void)
13861446
if (cpufreq_get_current_driver())
13871447
return -EEXIST;
13881448

1449+
switch (cppc_state) {
1450+
case AMD_PSTATE_UNDEFINED:
1451+
/* Disable on the following configs by default:
1452+
* 1. Undefined platforms
1453+
* 2. Server platforms
1454+
* 3. Shared memory designs
1455+
*/
1456+
if (amd_pstate_acpi_pm_profile_undefined() ||
1457+
amd_pstate_acpi_pm_profile_server() ||
1458+
!boot_cpu_has(X86_FEATURE_CPPC)) {
1459+
pr_info("driver load is disabled, boot with specific mode to enable this\n");
1460+
return -ENODEV;
1461+
}
1462+
ret = amd_pstate_set_driver(CONFIG_X86_AMD_PSTATE_DEFAULT_MODE);
1463+
if (ret)
1464+
return ret;
1465+
break;
1466+
case AMD_PSTATE_DISABLE:
1467+
return -ENODEV;
1468+
case AMD_PSTATE_PASSIVE:
1469+
case AMD_PSTATE_ACTIVE:
1470+
case AMD_PSTATE_GUIDED:
1471+
break;
1472+
default:
1473+
return -EINVAL;
1474+
}
1475+
13891476
/* capability check */
13901477
if (boot_cpu_has(X86_FEATURE_CPPC)) {
13911478
pr_debug("AMD CPPC MSR based functionality is supported\n");
@@ -1438,21 +1525,7 @@ static int __init amd_pstate_param(char *str)
14381525
size = strlen(str);
14391526
mode_idx = get_mode_idx_from_str(str, size);
14401527

1441-
if (mode_idx >= AMD_PSTATE_DISABLE && mode_idx < AMD_PSTATE_MAX) {
1442-
cppc_state = mode_idx;
1443-
if (cppc_state == AMD_PSTATE_DISABLE)
1444-
pr_info("driver is explicitly disabled\n");
1445-
1446-
if (cppc_state == AMD_PSTATE_ACTIVE)
1447-
current_pstate_driver = &amd_pstate_epp_driver;
1448-
1449-
if (cppc_state == AMD_PSTATE_PASSIVE || cppc_state == AMD_PSTATE_GUIDED)
1450-
current_pstate_driver = &amd_pstate_driver;
1451-
1452-
return 0;
1453-
}
1454-
1455-
return -EINVAL;
1528+
return amd_pstate_set_driver(mode_idx);
14561529
}
14571530
early_param("amd_pstate", amd_pstate_param);
14581531

drivers/cpufreq/cpufreq.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2828,7 +2828,8 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
28282828
(driver_data->setpolicy && (driver_data->target_index ||
28292829
driver_data->target)) ||
28302830
(!driver_data->get_intermediate != !driver_data->target_intermediate) ||
2831-
(!driver_data->online != !driver_data->offline))
2831+
(!driver_data->online != !driver_data->offline) ||
2832+
(driver_data->adjust_perf && !driver_data->fast_switch))
28322833
return -EINVAL;
28332834

28342835
pr_debug("trying to register driver %s\n", driver_data->name);

drivers/cpufreq/intel_pstate.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,8 @@ static ssize_t store_energy_performance_preference(
824824
err = cpufreq_start_governor(policy);
825825
if (!ret)
826826
ret = err;
827+
} else {
828+
ret = 0;
827829
}
828830
}
829831

drivers/devfreq/exynos-bus.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,7 @@ static struct platform_driver exynos_bus_platdrv = {
518518
};
519519
module_platform_driver(exynos_bus_platdrv);
520520

521+
MODULE_SOFTDEP("pre: exynos_ppmu");
521522
MODULE_DESCRIPTION("Generic Exynos Bus frequency driver");
522523
MODULE_AUTHOR("Chanwoo Choi <[email protected]>");
523524
MODULE_LICENSE("GPL v2");

0 commit comments

Comments
 (0)