patch 'drivers/power: check for errors when writing frequency' has been queued to stable release 24.11.9
luca.boccassi at gmail.com
luca.boccassi at gmail.com
Tue Oct 27 12:50:18 CET 2026
Hi,
FYI, your patch has been queued to stable release 24.11.9
Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 10/29/26. So please
shout if anyone has objections.
Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.
Queued patches are on a temporary branch at:
https://github.com/bluca/dpdk-stable
This queued commit can be viewed at:
https://github.com/bluca/dpdk-stable/commit/69e879bc20079bf201ea6e489f7e80920012e837
Thanks.
Luca Boccassi
---
>From 69e879bc20079bf201ea6e489f7e80920012e837 Mon Sep 17 00:00:00 2001
From: Stephen Hemminger <stephen at networkplumber.org>
Date: Tue, 8 Sep 2026 09:52:33 -0700
Subject: [PATCH] drivers/power: check for errors when writing frequency
[ upstream commit 71b464c3b13a1ef4b0d104d517aa2ef2b896dfdc ]
The sysfs file is buffered, so fprintf() returns success even when the
kernel rejects the value. The error only shows up when the buffer is
flushed, and the fflush() return was never checked. A failed frequency
change was therefore reported as success.
Use write_core_sysfs_s() which already does the fseek, write and a
checked fflush.
Fixes: 445c6528b55f ("power: common interface for guest and host")
Fixes: ef1cc88f1837 ("power: support cppc_cpufreq driver")
Fixes: 1ed04d33cf19 ("power: support amd-pstate cpufreq driver")
Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
---
drivers/power/acpi/acpi_cpufreq.c | 12 +++++-------
drivers/power/amd_pstate/amd_pstate_cpufreq.c | 16 +++++++---------
drivers/power/cppc/cppc_cpufreq.c | 12 +++++-------
3 files changed, 17 insertions(+), 23 deletions(-)
diff --git a/drivers/power/acpi/acpi_cpufreq.c b/drivers/power/acpi/acpi_cpufreq.c
index 81a5e3f6eab..7a7298e488f 100644
--- a/drivers/power/acpi/acpi_cpufreq.c
+++ b/drivers/power/acpi/acpi_cpufreq.c
@@ -62,6 +62,8 @@ static struct acpi_power_info lcore_power_info[RTE_MAX_LCORE];
static int
set_freq_internal(struct acpi_power_info *pi, uint32_t idx)
{
+ char buf[16];
+
if (idx >= RTE_MAX_LCORE_FREQS || idx >= pi->nb_freqs) {
POWER_LOG(ERR, "Invalid frequency index %u, which "
"should be less than %u", idx, pi->nb_freqs);
@@ -74,17 +76,13 @@ set_freq_internal(struct acpi_power_info *pi, uint32_t idx)
POWER_DEBUG_LOG("Frequency[%u] %u to be set for lcore %u",
idx, pi->freqs[idx], pi->lcore_id);
- if (fseek(pi->f, 0, SEEK_SET) < 0) {
- POWER_LOG(ERR, "Fail to set file position indicator to 0 "
- "for setting frequency for lcore %u", pi->lcore_id);
- return -1;
- }
- if (fprintf(pi->f, "%u", pi->freqs[idx]) < 0) {
+
+ snprintf(buf, sizeof(buf), "%u", pi->freqs[idx]);
+ if (write_core_sysfs_s(pi->f, buf) != 0) {
POWER_LOG(ERR, "Fail to write new frequency for "
"lcore %u", pi->lcore_id);
return -1;
}
- fflush(pi->f);
pi->curr_idx = idx;
return 1;
diff --git a/drivers/power/amd_pstate/amd_pstate_cpufreq.c b/drivers/power/amd_pstate/amd_pstate_cpufreq.c
index 97e179b7eef..26b4354f973 100644
--- a/drivers/power/amd_pstate/amd_pstate_cpufreq.c
+++ b/drivers/power/amd_pstate/amd_pstate_cpufreq.c
@@ -66,17 +66,15 @@ static struct amd_pstate_power_info lcore_power_info[RTE_MAX_LCORE];
static int
write_freq(struct amd_pstate_power_info *pi, uint32_t idx)
{
- if (fseek(pi->f, 0, SEEK_SET) < 0) {
- POWER_LOG(ERR, "Fail to set file position indicator to 0 "
- "for setting frequency for lcore %u", pi->lcore_id);
+ char buf[16];
+
+ snprintf(buf, sizeof(buf), "%u", pi->freqs[idx]);
+
+ if (write_core_sysfs_s(pi->f, buf) != 0) {
+ POWER_LOG(ERR, "Fail to write new frequency for lcore %u",
+ pi->lcore_id);
return -1;
}
- if (fprintf(pi->f, "%u", pi->freqs[idx]) < 0) {
- POWER_LOG(ERR, "Fail to write new frequency for "
- "lcore %u", pi->lcore_id);
- return -1;
- }
- fflush(pi->f);
pi->curr_idx = idx;
return 1;
diff --git a/drivers/power/cppc/cppc_cpufreq.c b/drivers/power/cppc/cppc_cpufreq.c
index 3cd4165c834..e88f898179f 100644
--- a/drivers/power/cppc/cppc_cpufreq.c
+++ b/drivers/power/cppc/cppc_cpufreq.c
@@ -72,6 +72,8 @@ static struct cppc_power_info lcore_power_info[RTE_MAX_LCORE];
static int
set_freq_internal(struct cppc_power_info *pi, uint32_t idx)
{
+ char buf[16];
+
if (idx >= RTE_MAX_LCORE_FREQS || idx >= pi->nb_freqs) {
POWER_LOG(ERR, "Invalid frequency index %u, which "
"should be less than %u", idx, pi->nb_freqs);
@@ -84,17 +86,13 @@ set_freq_internal(struct cppc_power_info *pi, uint32_t idx)
POWER_DEBUG_LOG("Frequency[%u] %u to be set for lcore %u",
idx, pi->freqs[idx], pi->lcore_id);
- if (fseek(pi->f, 0, SEEK_SET) < 0) {
- POWER_LOG(ERR, "Fail to set file position indicator to 0 "
- "for setting frequency for lcore %u", pi->lcore_id);
- return -1;
- }
- if (fprintf(pi->f, "%u", pi->freqs[idx]) < 0) {
+
+ snprintf(buf, sizeof(buf), "%u", pi->freqs[idx]);
+ if (write_core_sysfs_s(pi->f, buf) != 0) {
POWER_LOG(ERR, "Fail to write new frequency for "
"lcore %u", pi->lcore_id);
return -1;
}
- fflush(pi->f);
pi->curr_idx = idx;
return 1;
--
2.47.3
---
Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- - 2026-10-27 11:43:58.506286801 +0000
+++ 0124-drivers-power-check-for-errors-when-writing-frequenc.patch 2026-10-27 11:43:53.650063658 +0000
@@ -1 +1 @@
-From 71b464c3b13a1ef4b0d104d517aa2ef2b896dfdc Mon Sep 17 00:00:00 2001
+From 69e879bc20079bf201ea6e489f7e80920012e837 Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit 71b464c3b13a1ef4b0d104d517aa2ef2b896dfdc ]
+
@@ -17 +18,0 @@
-Cc: stable at dpdk.org
@@ -27 +28 @@
-index af85a8cdec..4ee3d5bd26 100644
+index 81a5e3f6eab..7a7298e488f 100644
@@ -30 +31 @@
-@@ -54,6 +54,8 @@ static struct acpi_power_info lcore_power_info[RTE_MAX_LCORE];
+@@ -62,6 +62,8 @@ static struct acpi_power_info lcore_power_info[RTE_MAX_LCORE];
@@ -39 +40 @@
-@@ -66,17 +68,13 @@ set_freq_internal(struct acpi_power_info *pi, uint32_t idx)
+@@ -74,17 +76,13 @@ set_freq_internal(struct acpi_power_info *pi, uint32_t idx)
@@ -61 +62 @@
-index 13ffcefc84..f7e32fe0ac 100644
+index 97e179b7eef..26b4354f973 100644
@@ -64 +65 @@
-@@ -57,17 +57,15 @@ static struct amd_pstate_power_info lcore_power_info[RTE_MAX_LCORE];
+@@ -66,17 +66,15 @@ static struct amd_pstate_power_info lcore_power_info[RTE_MAX_LCORE];
@@ -90 +91 @@
-index aed44c1212..3bcd4dec41 100644
+index 3cd4165c834..e88f898179f 100644
@@ -93 +94 @@
-@@ -63,6 +63,8 @@ static struct cppc_power_info lcore_power_info[RTE_MAX_LCORE];
+@@ -72,6 +72,8 @@ static struct cppc_power_info lcore_power_info[RTE_MAX_LCORE];
@@ -102 +103 @@
-@@ -75,17 +77,13 @@ set_freq_internal(struct cppc_power_info *pi, uint32_t idx)
+@@ -84,17 +86,13 @@ set_freq_internal(struct cppc_power_info *pi, uint32_t idx)
More information about the stable
mailing list