From: Huang Rui <ray.huang@amd.com>
To: Shuah Khan <skhan@linuxfoundation.org>,
"Rafael J . Wysocki" <rafael.j.wysocki@intel.com>,
<linux-pm@vger.kernel.org>
Cc: Deepak Sharma <deepak.sharma@amd.com>,
Alex Deucher <alexander.deucher@amd.com>,
Mario Limonciello <mario.limonciello@amd.com>,
Steven Noonan <steven@valvesoftware.com>,
Nathan Fontenot <nathan.fontenot@amd.com>,
Jinzhou Su <Jinzhou.Su@amd.com>,
Xiaojian Du <Xiaojian.Du@amd.com>,
Perry Yuan <Perry.Yuan@amd.com>, Jassmine Meng <li.meng@amd.com>,
Borislav Petkov <bp@alien8.de>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@kernel.org>,
Viresh Kumar <viresh.kumar@linaro.org>,
Steven Rostedt <rostedt@goodmis.org>,
"Giovanni Gherdovich" <ggherdovich@suse.cz>,
<linux-kernel@vger.kernel.org>, Huang Rui <ray.huang@amd.com>
Subject: [PATCH v7 02/10] cpupower: Add the function to check AMD P-State enabled
Date: Tue, 22 Feb 2022 23:34:18 +0800 [thread overview]
Message-ID: <20220222153426.2216974-3-ray.huang@amd.com> (raw)
In-Reply-To: <20220222153426.2216974-1-ray.huang@amd.com>
The processor with AMD P-State function also supports legacy ACPI
hardware P-States feature as well. Once driver sets AMD P-State eanbled,
the processor will respond the finer grain AMD P-State feature instead of
legacy ACPI P-States. So it introduces the cpupower_amd_pstate_enabled()
to check whether the current kernel enables AMD P-State or AMD CPUFreq
module.
Signed-off-by: Huang Rui <ray.huang@amd.com>
---
tools/power/cpupower/utils/helpers/helpers.h | 10 ++++++++++
tools/power/cpupower/utils/helpers/misc.c | 18 ++++++++++++++++++
2 files changed, 28 insertions(+)
diff --git a/tools/power/cpupower/utils/helpers/helpers.h b/tools/power/cpupower/utils/helpers/helpers.h
index b4813efdfb00..62771a086871 100644
--- a/tools/power/cpupower/utils/helpers/helpers.h
+++ b/tools/power/cpupower/utils/helpers/helpers.h
@@ -11,6 +11,7 @@
#include <libintl.h>
#include <locale.h>
+#include <stdbool.h>
#include "helpers/bitmask.h"
#include <cpupower.h>
@@ -136,6 +137,12 @@ extern int decode_pstates(unsigned int cpu, int boost_states,
extern int cpufreq_has_boost_support(unsigned int cpu, int *support,
int *active, int * states);
+
+/* AMD P-State stuff **************************/
+bool cpupower_amd_pstate_enabled(void);
+
+/* AMD P-State stuff **************************/
+
/*
* CPUID functions returning a single datum
*/
@@ -168,6 +175,9 @@ static inline int cpufreq_has_boost_support(unsigned int cpu, int *support,
int *active, int * states)
{ return -1; }
+static inline bool cpupower_amd_pstate_enabled(void)
+{ return false; }
+
/* cpuid and cpuinfo helpers **************************/
static inline unsigned int cpuid_eax(unsigned int op) { return 0; };
diff --git a/tools/power/cpupower/utils/helpers/misc.c b/tools/power/cpupower/utils/helpers/misc.c
index fc6e34511721..0c483cdefcc2 100644
--- a/tools/power/cpupower/utils/helpers/misc.c
+++ b/tools/power/cpupower/utils/helpers/misc.c
@@ -3,9 +3,11 @@
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
+#include <string.h>
#include "helpers/helpers.h"
#include "helpers/sysfs.h"
+#include "cpufreq.h"
#if defined(__i386__) || defined(__x86_64__)
@@ -83,6 +85,22 @@ int cpupower_intel_set_perf_bias(unsigned int cpu, unsigned int val)
return 0;
}
+bool cpupower_amd_pstate_enabled(void)
+{
+ char *driver = cpufreq_get_driver(0);
+ bool ret = false;
+
+ if (!driver)
+ return ret;
+
+ if (!strcmp(driver, "amd-pstate"))
+ ret = true;
+
+ cpufreq_put_driver(driver);
+
+ return ret;
+}
+
#endif /* #if defined(__i386__) || defined(__x86_64__) */
/* get_cpustate
--
2.25.1
next prev parent reply other threads:[~2022-02-22 15:35 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-22 15:34 [PATCH v7 00/10] cpupower: Add AMD P-State Support Huang Rui
2022-02-22 15:34 ` [PATCH v7 01/10] cpupower: Add AMD P-State capability flag Huang Rui
2022-02-22 15:34 ` Huang Rui [this message]
2022-02-22 15:34 ` [PATCH v7 03/10] cpupower: Initial AMD P-State capability Huang Rui
2022-02-22 15:34 ` [PATCH v7 04/10] cpupower: Add the function to get the sysfs value from specific table Huang Rui
2022-02-22 15:34 ` [PATCH v7 05/10] cpupower: Introduce ACPI CPPC library Huang Rui
2022-02-22 15:34 ` [PATCH v7 06/10] cpupower: Add AMD P-State sysfs definition and access helper Huang Rui
2022-02-22 15:34 ` [PATCH v7 07/10] cpupower: Enable boost state support for AMD P-State module Huang Rui
2022-02-22 15:34 ` [PATCH v7 08/10] cpupower: Move print_speed function into misc helper Huang Rui
2022-02-22 15:34 ` [PATCH v7 09/10] cpupower: Add function to print AMD P-State performance capabilities Huang Rui
2022-02-22 15:34 ` [PATCH v7 10/10] cpupower: Add "perf" option to print AMD P-State information Huang Rui
2022-02-23 3:37 ` Huang Rui
2022-02-24 0:55 ` Shuah Khan
2022-02-23 1:44 ` [PATCH v7 00/10] cpupower: Add AMD P-State Support Shuah Khan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220222153426.2216974-3-ray.huang@amd.com \
--to=ray.huang@amd.com \
--cc=Jinzhou.Su@amd.com \
--cc=Perry.Yuan@amd.com \
--cc=Xiaojian.Du@amd.com \
--cc=alexander.deucher@amd.com \
--cc=bp@alien8.de \
--cc=deepak.sharma@amd.com \
--cc=ggherdovich@suse.cz \
--cc=li.meng@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=mario.limonciello@amd.com \
--cc=mingo@kernel.org \
--cc=nathan.fontenot@amd.com \
--cc=peterz@infradead.org \
--cc=rafael.j.wysocki@intel.com \
--cc=rostedt@goodmis.org \
--cc=skhan@linuxfoundation.org \
--cc=steven@valvesoftware.com \
--cc=viresh.kumar@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).