From: Sumit Gupta <sumitg@nvidia.com>
To: <rafael@kernel.org>, <rui.zhang@intel.com>, <lenb@kernel.org>,
<treding@nvidia.com>, <jonathanh@nvidia.com>,
<linux-acpi@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Cc: <sumitg@nvidia.com>, <sanjayc@nvidia.com>,
<ksitaraman@nvidia.com>, <srikars@nvidia.com>,
<jbrasen@nvidia.com>, <bbasu@nvidia.com>
Subject: [Patch 2/2] ACPI: processor: Add support to configure CPUFREQ reduction pctg
Date: Thu, 17 Aug 2023 15:00:11 +0530 [thread overview]
Message-ID: <20230817093011.1378-3-sumitg@nvidia.com> (raw)
In-Reply-To: <20230817093011.1378-1-sumitg@nvidia.com>
From: Srikar Srimath Tirumala <srikars@nvidia.com>
Add support to configure the CPUFREQ reduction percentage and set the
maximum number of throttling steps accordingly. Current implementation
of processor_thermal performs software throttling in fixed steps of
"20%" which can be too coarse for some platforms. Change that by adding
new config to provide the reduction percentage.
Signed-off-by: Srikar Srimath Tirumala <srikars@nvidia.com>
Signed-off-by: Sumit Gupta <sumitg@nvidia.com>
---
drivers/acpi/Kconfig | 15 +++++++++++++++
drivers/acpi/processor_thermal.c | 19 ++++++++++++++++---
2 files changed, 31 insertions(+), 3 deletions(-)
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index 00dd309b6682..287cf58defbf 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -254,6 +254,21 @@ config ACPI_DOCK
config ACPI_CPU_FREQ_PSS
bool
+config ACPI_CPU_FREQ_THERM_HAS_PARAMS
+ bool "CPU frequency throttling control"
+ depends on ACPI_PROCESSOR
+
+config ACPI_CPU_FREQ_THERM_MIN_THROT_PCTG
+ int "Minimum throttle percentage for processor_thermal cooling device"
+ depends on ACPI_CPU_FREQ_THERM_HAS_PARAMS
+ default 20
+ help
+ The processor_thermal driver uses this config to calculate the
+ percentage amount by which cpu frequency must be reduced for each
+ cooling state. The config is also used to calculate the maximum number
+ of throttling steps or cooling states supported by the driver. Value
+ must be an unsigned integer in the range [1, 50].
+
config ACPI_PROCESSOR_CSTATE
def_bool y
depends on ACPI_PROCESSOR
diff --git a/drivers/acpi/processor_thermal.c b/drivers/acpi/processor_thermal.c
index b7c6287eccca..ee443cc69b73 100644
--- a/drivers/acpi/processor_thermal.c
+++ b/drivers/acpi/processor_thermal.c
@@ -25,8 +25,20 @@
* _any_ cpufreq driver and not only the acpi-cpufreq driver.
*/
-#define CPUFREQ_THERMAL_MIN_STEP 0
-#define CPUFREQ_THERMAL_MAX_STEP 3
+#define CPUFREQ_THERMAL_MIN_STEP 0
+#ifdef CONFIG_ACPI_CPU_FREQ_THERM_HAS_PARAMS
+#define CPUFREQ_THERMAL_PCTG CONFIG_ACPI_CPU_FREQ_THERM_MIN_THROT_PCTG
+
+/* Derive the MAX_STEP from minimum throttle percentage so that the reduction
+ * percentage does end up becoming negative. Also cap the MAX_STEP so that
+ * the CPU performance doesn't become 0.
+ */
+#define CPUFREQ_THERMAL_MAX_STEP ((100 / CPUFREQ_THERMAL_PCTG) - 1)
+
+#else
+#define CPUFREQ_THERMAL_MAX_STEP 3
+#define CPUFREQ_THERMAL_PCTG 20
+#endif
static DEFINE_PER_CPU(unsigned int, cpufreq_thermal_reduction_pctg);
@@ -113,7 +125,8 @@ static int cpufreq_set_cur_state(unsigned int cpu, int state)
if (!policy)
return -EINVAL;
- max_freq = (policy->cpuinfo.max_freq * (100 - reduction_pctg(i) * 20)) / 100;
+ max_freq = (policy->cpuinfo.max_freq *
+ (100 - reduction_pctg(i) * CPUFREQ_THERMAL_PCTG)) / 100;
cpufreq_cpu_put(policy);
--
2.17.1
next prev parent reply other threads:[~2023-08-17 9:31 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-17 9:30 [Patch 0/2] Add support for _TFP and configurable throttle pctg Sumit Gupta
2023-08-17 9:30 ` [Patch 1/2] ACPI: thermal: Add Thermal fast Sampling Period (_TFP) support Sumit Gupta
2023-08-18 18:33 ` Rafael J. Wysocki
2023-08-21 11:48 ` Sumit Gupta
2023-08-17 9:30 ` Sumit Gupta [this message]
2023-08-18 18:40 ` [Patch 2/2] ACPI: processor: Add support to configure CPUFREQ reduction pctg Rafael J. Wysocki
2023-08-21 13:24 ` Sumit Gupta
2023-08-21 17:09 ` Rafael J. Wysocki
2023-08-24 13:18 ` Sumit Gupta
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=20230817093011.1378-3-sumitg@nvidia.com \
--to=sumitg@nvidia.com \
--cc=bbasu@nvidia.com \
--cc=jbrasen@nvidia.com \
--cc=jonathanh@nvidia.com \
--cc=ksitaraman@nvidia.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=rui.zhang@intel.com \
--cc=sanjayc@nvidia.com \
--cc=srikars@nvidia.com \
--cc=treding@nvidia.com \
/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