patch 'drivers/power: check for errors when writing frequency' has been queued to stable release 25.11.5
Kevin Traynor
ktraynor at redhat.com
Thu Dec 3 14:01:13 CET 2026
Hi,
FYI, your patch has been queued to stable release 25.11.5
Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 12/08/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/kevintraynor/dpdk-stable
This queued commit can be viewed at:
https://github.com/kevintraynor/dpdk-stable/commit/ccf5b6af65bb162ecfe92f8699fde69e561e9ae2
Thanks.
Kevin
---
>From ccf5b6af65bb162ecfe92f8699fde69e561e9ae2 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 81a5e3f6ea..7a7298e488 100644
--- a/drivers/power/acpi/acpi_cpufreq.c
+++ b/drivers/power/acpi/acpi_cpufreq.c
@@ -63,4 +63,6 @@ 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 "
@@ -75,15 +77,11 @@ 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;
diff --git a/drivers/power/amd_pstate/amd_pstate_cpufreq.c b/drivers/power/amd_pstate/amd_pstate_cpufreq.c
index 97e179b7ee..26b4354f97 100644
--- a/drivers/power/amd_pstate/amd_pstate_cpufreq.c
+++ b/drivers/power/amd_pstate/amd_pstate_cpufreq.c
@@ -67,15 +67,13 @@ 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;
diff --git a/drivers/power/cppc/cppc_cpufreq.c b/drivers/power/cppc/cppc_cpufreq.c
index 3cd4165c83..e88f898179 100644
--- a/drivers/power/cppc/cppc_cpufreq.c
+++ b/drivers/power/cppc/cppc_cpufreq.c
@@ -73,4 +73,6 @@ 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 "
@@ -85,15 +87,11 @@ 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;
--
2.56.1
---
Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- - 2026-12-03 12:52:43.454464155 +0000
+++ 0147-drivers-power-check-for-errors-when-writing-frequenc.patch 2026-12-03 12:52:39.136582429 +0000
@@ -1 +1 @@
-From 71b464c3b13a1ef4b0d104d517aa2ef2b896dfdc Mon Sep 17 00:00:00 2001
+From ccf5b6af65bb162ecfe92f8699fde69e561e9ae2 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 81a5e3f6ea..7a7298e488 100644
@@ -30 +31 @@
-@@ -55,4 +55,6 @@ static int
+@@ -63,4 +63,6 @@ static int
@@ -37 +38 @@
-@@ -67,15 +69,11 @@ set_freq_internal(struct acpi_power_info *pi, uint32_t idx)
+@@ -75,15 +77,11 @@ set_freq_internal(struct acpi_power_info *pi, uint32_t idx)
@@ -57 +58 @@
-index 13ffcefc84..f7e32fe0ac 100644
+index 97e179b7ee..26b4354f97 100644
@@ -60 +61 @@
-@@ -58,15 +58,13 @@ static int
+@@ -67,15 +67,13 @@ static int
@@ -84 +85 @@
-index aed44c1212..3bcd4dec41 100644
+index 3cd4165c83..e88f898179 100644
@@ -87 +88 @@
-@@ -64,4 +64,6 @@ static int
+@@ -73,4 +73,6 @@ static int
@@ -94 +95 @@
-@@ -76,15 +78,11 @@ set_freq_internal(struct cppc_power_info *pi, uint32_t idx)
+@@ -85,15 +87,11 @@ set_freq_internal(struct cppc_power_info *pi, uint32_t idx)
More information about the stable
mailing list