2021-01-26 02:07:31

by Nathan Fontenot

[permalink] [raw]
Subject: [PATCH v2 0/8] cpupower: Updates and cleanup to support AMD Family 0x19

Updates to the cpupower command to add support for AMD family 0x19
and cleanup the code to remove many of the family checks to hopefully
make any future family updates easier.

The first couple of patches are simple updates to rename the structs
in the msr_pstate union to better reflect current support and correcting
the name of the CPUPOWER_CAP_AMD_CPB cpuid cap flag.

Patches 3, 5, and 8 update the family checks to either replace
them with a new cpuid cap flag based off of cpuid checks or check for
family >= 0x17 where removing the direct family check isn't possible.

The reamianing patches are cleanups to remove unneeded extra enabled bit
checking, remove passing no longer used variables, and remove unused
variables in decode_pstates().
---

Updates for v2:
- Patch 1/8: Add links to AMD PPR and BKDG to commit message.
- Patch 3/8: Update and add back removed comment.

---

Nathan Fontenot (7):
cpupower: Update msr_pstate union struct naming
cpupower: Add CPUPOWER_CAP_AMD_HW_PSTATE cpuid caps flag
cpupower: Remove unused pscur variable.
cpupower: Update family checks when decoding HW pstates
cpupower: Condense pstate enabled bit checks in decode_pstates()
cpupower: Remove family arg to decode_pstates()
cpupower: Add cpuid cap flag for MSR_AMD_HWCR support

Robert Richter (1):
cpupower: Correct macro name for CPB caps flag


tools/power/cpupower/utils/cpufreq-info.c | 3 -
tools/power/cpupower/utils/helpers/amd.c | 65 ++++++++++++--------------
tools/power/cpupower/utils/helpers/cpuid.c | 20 +++++++-
tools/power/cpupower/utils/helpers/helpers.h | 14 +++---
tools/power/cpupower/utils/helpers/misc.c | 9 +---
5 files changed, 57 insertions(+), 54 deletions(-)

--
Nathan Fontenot


2021-01-26 02:09:59

by Nathan Fontenot

[permalink] [raw]
Subject: [PATCH v2 2/8] cpupower: Correct macro name for CPB caps flag

From: Robert Richter <[email protected]>

The name is Core Performance Boost (CPB) for the cpuid flag. Correct
cpuid caps flag to use this name (instead of CBP).

Signed-off-by: Robert Richter <[email protected]>
Signed-off-by: Nathan Fontenot <[email protected]>
---
tools/power/cpupower/utils/helpers/cpuid.c | 2 +-
tools/power/cpupower/utils/helpers/helpers.h | 2 +-
tools/power/cpupower/utils/helpers/misc.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/power/cpupower/utils/helpers/cpuid.c b/tools/power/cpupower/utils/helpers/cpuid.c
index 73bfafc60e9b..f9a66a430b72 100644
--- a/tools/power/cpupower/utils/helpers/cpuid.c
+++ b/tools/power/cpupower/utils/helpers/cpuid.c
@@ -130,7 +130,7 @@ int get_cpu_info(struct cpupower_cpu_info *cpu_info)
cpu_info->vendor == X86_VENDOR_HYGON) {
if (ext_cpuid_level >= 0x80000007 &&
(cpuid_edx(0x80000007) & (1 << 9)))
- cpu_info->caps |= CPUPOWER_CAP_AMD_CBP;
+ cpu_info->caps |= CPUPOWER_CAP_AMD_CPB;

if (ext_cpuid_level >= 0x80000008 &&
cpuid_ebx(0x80000008) & (1 << 4))
diff --git a/tools/power/cpupower/utils/helpers/helpers.h b/tools/power/cpupower/utils/helpers/helpers.h
index 0642e60a6ce1..a84f85a9dbd2 100644
--- a/tools/power/cpupower/utils/helpers/helpers.h
+++ b/tools/power/cpupower/utils/helpers/helpers.h
@@ -64,7 +64,7 @@ enum cpupower_cpu_vendor {X86_VENDOR_UNKNOWN = 0, X86_VENDOR_INTEL,

#define CPUPOWER_CAP_INV_TSC 0x00000001
#define CPUPOWER_CAP_APERF 0x00000002
-#define CPUPOWER_CAP_AMD_CBP 0x00000004
+#define CPUPOWER_CAP_AMD_CPB 0x00000004
#define CPUPOWER_CAP_PERF_BIAS 0x00000008
#define CPUPOWER_CAP_HAS_TURBO_RATIO 0x00000010
#define CPUPOWER_CAP_IS_SNB 0x00000020
diff --git a/tools/power/cpupower/utils/helpers/misc.c b/tools/power/cpupower/utils/helpers/misc.c
index 650b9a9a6584..f9bcce9c72d5 100644
--- a/tools/power/cpupower/utils/helpers/misc.c
+++ b/tools/power/cpupower/utils/helpers/misc.c
@@ -26,7 +26,7 @@ int cpufreq_has_boost_support(unsigned int cpu, int *support, int *active,
if (ret)
return ret;

- if (cpupower_cpu_info.caps & CPUPOWER_CAP_AMD_CBP) {
+ if (cpupower_cpu_info.caps & CPUPOWER_CAP_AMD_CPB) {
*support = 1;

/* AMD Family 0x17 does not utilize PCI D18F4 like prior

2021-01-26 02:11:43

by Nathan Fontenot

[permalink] [raw]
Subject: [PATCH v2 4/8] cpupower: Remove unused pscur variable.

The pscur variable is set but not uused, just remove it.

This may have previsously been set to validate the MSR_AMD_PSTATE_STATUS
MSR. With the addition of the CPUPOWER_CAP_AMD_HW_PSTATE cap flag this
is no longer needed since the cpuid bit to enable this cap flag also
validates that the MSR_AMD_PSTATE_STATUS MSR is present.

Signed-off-by: Nathan Fontenot <[email protected]>
---
tools/power/cpupower/utils/helpers/amd.c | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/tools/power/cpupower/utils/helpers/amd.c b/tools/power/cpupower/utils/helpers/amd.c
index 8b69c7ff639a..fc2ac1e6bfb2 100644
--- a/tools/power/cpupower/utils/helpers/amd.c
+++ b/tools/power/cpupower/utils/helpers/amd.c
@@ -90,7 +90,7 @@ static int get_cof(int family, union core_pstate pstate)
int decode_pstates(unsigned int cpu, unsigned int cpu_family,
int boost_states, unsigned long *pstates, int *no)
{
- int i, psmax, pscur;
+ int i, psmax;
union core_pstate pstate;
unsigned long long val;

@@ -104,13 +104,6 @@ int decode_pstates(unsigned int cpu, unsigned int cpu_family,
return -1;

psmax = (val >> 4) & 0x7;
-
- if (read_msr(cpu, MSR_AMD_PSTATE_STATUS, &val))
- return -1;
-
- pscur = val & 0x7;
-
- pscur += boost_states;
psmax += boost_states;
for (i = 0; i <= psmax; i++) {
if (i >= MAX_HW_PSTATES) {

2021-01-27 00:36:06

by Shuah Khan

[permalink] [raw]
Subject: Re: [PATCH v2 0/8] cpupower: Updates and cleanup to support AMD Family 0x19

On 1/25/21 10:34 AM, Nathan Fontenot wrote:
> Updates to the cpupower command to add support for AMD family 0x19
> and cleanup the code to remove many of the family checks to hopefully
> make any future family updates easier.
>
> The first couple of patches are simple updates to rename the structs
> in the msr_pstate union to better reflect current support and correcting
> the name of the CPUPOWER_CAP_AMD_CPB cpuid cap flag.
>
> Patches 3, 5, and 8 update the family checks to either replace
> them with a new cpuid cap flag based off of cpuid checks or check for
> family >= 0x17 where removing the direct family check isn't possible.
>
> The reamianing patches are cleanups to remove unneeded extra enabled bit
> checking, remove passing no longer used variables, and remove unused
> variables in decode_pstates().
> ---
>
> Updates for v2:
> - Patch 1/8: Add links to AMD PPR and BKDG to commit message.
> - Patch 3/8: Update and add back removed comment.
>
> ---
>
> Nathan Fontenot (7):
> cpupower: Update msr_pstate union struct naming
> cpupower: Add CPUPOWER_CAP_AMD_HW_PSTATE cpuid caps flag
> cpupower: Remove unused pscur variable.
> cpupower: Update family checks when decoding HW pstates
> cpupower: Condense pstate enabled bit checks in decode_pstates()
> cpupower: Remove family arg to decode_pstates()
> cpupower: Add cpuid cap flag for MSR_AMD_HWCR support
>
> Robert Richter (1):
> cpupower: Correct macro name for CPB caps flag
>
>
> tools/power/cpupower/utils/cpufreq-info.c | 3 -
> tools/power/cpupower/utils/helpers/amd.c | 65 ++++++++++++--------------
> tools/power/cpupower/utils/helpers/cpuid.c | 20 +++++++-
> tools/power/cpupower/utils/helpers/helpers.h | 14 +++---
> tools/power/cpupower/utils/helpers/misc.c | 9 +---
> 5 files changed, 57 insertions(+), 54 deletions(-)
>
> --
> Nathan Fontenot
>

Thank you. Applied now for 5.12-rc1

https://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux.git/log/?h=cpupower

thanks,
-- Shuah