Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 64c6a36

Browse files
committed
Merge tag 'pm-6.10-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull power management fixes from Rafael Wysocki: "These fix the intel_pstate and amd-pstate cpufreq drivers and the cpupower utility. Specifics: - Fix a recently introduced unchecked HWP MSR access in the intel_pstate driver (Srinivas Pandruvada) - Add missing conversion from MHz to KHz to amd_pstate_set_boost() to address sysfs inteface inconsistency and fix P-state frequency reporting on AMD Family 1Ah CPUs in the cpupower utility (Dhananjay Ugwekar) - Get rid of an excess global header file used by the amd-pstate cpufreq driver (Arnd Bergmann)" * tag 'pm-6.10-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: cpufreq: intel_pstate: Fix unchecked HWP MSR access cpufreq: amd-pstate: Fix the inconsistency in max frequency units cpufreq: amd-pstate: remove global header file tools/power/cpupower: Fix Pstate frequency reporting on AMD Family 1Ah CPUs
2 parents 19ca0d8 + 9b7e7ff commit 64c6a36

File tree

6 files changed

+61
-41
lines changed

6 files changed

+61
-41
lines changed

MAINTAINERS

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1107,7 +1107,6 @@ L: linux-pm@vger.kernel.org
11071107
S: Supported
11081108
F: Documentation/admin-guide/pm/amd-pstate.rst
11091109
F: drivers/cpufreq/amd-pstate*
1110-
F: include/linux/amd-pstate.h
11111110
F: tools/power/x86/amd_pstate_tracer/amd_pstate_trace.py
11121111

11131112
AMD PTDMA DRIVER

drivers/cpufreq/amd-pstate-ut.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@
2626
#include <linux/module.h>
2727
#include <linux/moduleparam.h>
2828
#include <linux/fs.h>
29-
#include <linux/amd-pstate.h>
3029

3130
#include <acpi/cppc_acpi.h>
3231

32+
#include "amd-pstate.h"
33+
3334
/*
3435
* Abbreviations:
3536
* amd_pstate_ut: used as a shortform for AMD P-State unit test.

drivers/cpufreq/amd-pstate.c

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
#include <linux/delay.h>
3737
#include <linux/uaccess.h>
3838
#include <linux/static_call.h>
39-
#include <linux/amd-pstate.h>
4039
#include <linux/topology.h>
4140

4241
#include <acpi/processor.h>
@@ -46,13 +45,46 @@
4645
#include <asm/processor.h>
4746
#include <asm/cpufeature.h>
4847
#include <asm/cpu_device_id.h>
48+
49+
#include "amd-pstate.h"
4950
#include "amd-pstate-trace.h"
5051

5152
#define AMD_PSTATE_TRANSITION_LATENCY 20000
5253
#define AMD_PSTATE_TRANSITION_DELAY 1000
5354
#define CPPC_HIGHEST_PERF_PERFORMANCE 196
5455
#define CPPC_HIGHEST_PERF_DEFAULT 166
5556

57+
#define AMD_CPPC_EPP_PERFORMANCE 0x00
58+
#define AMD_CPPC_EPP_BALANCE_PERFORMANCE 0x80
59+
#define AMD_CPPC_EPP_BALANCE_POWERSAVE 0xBF
60+
#define AMD_CPPC_EPP_POWERSAVE 0xFF
61+
62+
/*
63+
* enum amd_pstate_mode - driver working mode of amd pstate
64+
*/
65+
enum amd_pstate_mode {
66+
AMD_PSTATE_UNDEFINED = 0,
67+
AMD_PSTATE_DISABLE,
68+
AMD_PSTATE_PASSIVE,
69+
AMD_PSTATE_ACTIVE,
70+
AMD_PSTATE_GUIDED,
71+
AMD_PSTATE_MAX,
72+
};
73+
74+
static const char * const amd_pstate_mode_string[] = {
75+
[AMD_PSTATE_UNDEFINED] = "undefined",
76+
[AMD_PSTATE_DISABLE] = "disable",
77+
[AMD_PSTATE_PASSIVE] = "passive",
78+
[AMD_PSTATE_ACTIVE] = "active",
79+
[AMD_PSTATE_GUIDED] = "guided",
80+
NULL,
81+
};
82+
83+
struct quirk_entry {
84+
u32 nominal_freq;
85+
u32 lowest_freq;
86+
};
87+
5688
/*
5789
* TODO: We need more time to fine tune processors with shared memory solution
5890
* with community together.
@@ -669,7 +701,7 @@ static int amd_pstate_set_boost(struct cpufreq_policy *policy, int state)
669701
if (state)
670702
policy->cpuinfo.max_freq = cpudata->max_freq;
671703
else
672-
policy->cpuinfo.max_freq = cpudata->nominal_freq;
704+
policy->cpuinfo.max_freq = cpudata->nominal_freq * 1000;
673705

674706
policy->max = policy->cpuinfo.max_freq;
675707

include/linux/amd-pstate.h renamed to drivers/cpufreq/amd-pstate.h

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
/* SPDX-License-Identifier: GPL-2.0-only */
22
/*
3-
* linux/include/linux/amd-pstate.h
4-
*
53
* Copyright (C) 2022 Advanced Micro Devices, Inc.
64
*
75
* Author: Meng Li <li.meng@amd.com>
@@ -12,11 +10,6 @@
1210

1311
#include <linux/pm_qos.h>
1412

15-
#define AMD_CPPC_EPP_PERFORMANCE 0x00
16-
#define AMD_CPPC_EPP_BALANCE_PERFORMANCE 0x80
17-
#define AMD_CPPC_EPP_BALANCE_POWERSAVE 0xBF
18-
#define AMD_CPPC_EPP_POWERSAVE 0xFF
19-
2013
/*********************************************************************
2114
* AMD P-state INTERFACE *
2215
*********************************************************************/
@@ -108,30 +101,4 @@ struct amd_cpudata {
108101
bool suspended;
109102
};
110103

111-
/*
112-
* enum amd_pstate_mode - driver working mode of amd pstate
113-
*/
114-
enum amd_pstate_mode {
115-
AMD_PSTATE_UNDEFINED = 0,
116-
AMD_PSTATE_DISABLE,
117-
AMD_PSTATE_PASSIVE,
118-
AMD_PSTATE_ACTIVE,
119-
AMD_PSTATE_GUIDED,
120-
AMD_PSTATE_MAX,
121-
};
122-
123-
static const char * const amd_pstate_mode_string[] = {
124-
[AMD_PSTATE_UNDEFINED] = "undefined",
125-
[AMD_PSTATE_DISABLE] = "disable",
126-
[AMD_PSTATE_PASSIVE] = "passive",
127-
[AMD_PSTATE_ACTIVE] = "active",
128-
[AMD_PSTATE_GUIDED] = "guided",
129-
NULL,
130-
};
131-
132-
struct quirk_entry {
133-
u32 nominal_freq;
134-
u32 lowest_freq;
135-
};
136-
137104
#endif /* _LINUX_AMD_PSTATE_H */

drivers/cpufreq/intel_pstate.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1153,7 +1153,8 @@ static void intel_pstate_update_policies(void)
11531153
static void __intel_pstate_update_max_freq(struct cpudata *cpudata,
11541154
struct cpufreq_policy *policy)
11551155
{
1156-
intel_pstate_get_hwp_cap(cpudata);
1156+
if (hwp_active)
1157+
intel_pstate_get_hwp_cap(cpudata);
11571158

11581159
policy->cpuinfo.max_freq = READ_ONCE(global.no_turbo) ?
11591160
cpudata->pstate.max_freq : cpudata->pstate.turbo_freq;

tools/power/cpupower/utils/helpers/amd.c

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,27 @@ union core_pstate {
4141
unsigned res1:31;
4242
unsigned en:1;
4343
} pstatedef;
44+
/* since fam 1Ah: */
45+
struct {
46+
unsigned fid:12;
47+
unsigned res1:2;
48+
unsigned vid:8;
49+
unsigned iddval:8;
50+
unsigned idddiv:2;
51+
unsigned res2:31;
52+
unsigned en:1;
53+
} pstatedef2;
4454
unsigned long long val;
4555
};
4656

4757
static int get_did(union core_pstate pstate)
4858
{
4959
int t;
5060

61+
/* Fam 1Ah onward do not use did */
62+
if (cpupower_cpu_info.family >= 0x1A)
63+
return 0;
64+
5165
if (cpupower_cpu_info.caps & CPUPOWER_CAP_AMD_PSTATEDEF)
5266
t = pstate.pstatedef.did;
5367
else if (cpupower_cpu_info.family == 0x12)
@@ -61,12 +75,18 @@ static int get_did(union core_pstate pstate)
6175
static int get_cof(union core_pstate pstate)
6276
{
6377
int t;
64-
int fid, did, cof;
78+
int fid, did, cof = 0;
6579

6680
did = get_did(pstate);
6781
if (cpupower_cpu_info.caps & CPUPOWER_CAP_AMD_PSTATEDEF) {
68-
fid = pstate.pstatedef.fid;
69-
cof = 200 * fid / did;
82+
if (cpupower_cpu_info.family >= 0x1A) {
83+
fid = pstate.pstatedef2.fid;
84+
if (fid > 0x0f)
85+
cof = (fid * 5);
86+
} else {
87+
fid = pstate.pstatedef.fid;
88+
cof = 200 * fid / did;
89+
}
7090
} else {
7191
t = 0x10;
7292
fid = pstate.pstate.fid;

0 commit comments

Comments
 (0)