From: Robert Killick <robert@killick.dev>
To: Sebastian Reichel <sre@kernel.org>
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
Robert Killick <robert@killick.dev>
Subject: [PATCH] power: supply: sysfs: Ratelimit "unavailable enum value" warning
Date: Mon, 05 Oct 2026 14:56:45 +0100 [thread overview]
Message-ID: <20261005-ratelimit-enum-warn-v1-1-b77b48de3c47@killick.dev> (raw)
power_supply_show_enum_with_available() warns every time a driver
reports a value that is not in its declared set of available values.
For usb_type this happens on every sysfs read and on every uevent, so a
driver that reports such a value and calls power_supply_changed()
frequently can flood the kernel log.
This can happen with drivers that pass a firmware-provided value
through unchanged, as qcom_battmgr does for usb_type. On a OnePlus 10
Pro (SM8450), whose firmware reports a vendor-specific usb_type, this
produced ~128 warnings per second and kept systemd-journald at ~30% CPU.
The bug that causes the bad value needs fixing in the driver itself,
but one misbehaving driver should not be able to flood the kernel log.
Use dev_warn_ratelimited(), as power_supply_show_property() already
does for its own errors, so the problem is still reported, just not on
every read.
Signed-off-by: Robert Killick <robert@killick.dev>
---
drivers/power/supply/power_supply_sysfs.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c
index b0f524d152cf..9704557ffe1d 100644
--- a/drivers/power/supply/power_supply_sysfs.c
+++ b/drivers/power/supply/power_supply_sysfs.c
@@ -310,7 +310,8 @@ static ssize_t power_supply_show_enum_with_available(
}
if (!match) {
- dev_warn(dev, "driver reporting unavailable enum value %d\n", value);
+ dev_warn_ratelimited(dev, "driver reporting unavailable enum value %d\n",
+ value);
return -EINVAL;
}
---
base-commit: 4fc88ba435dadbc05990951e3f3fbd8ccd2df140
change-id: 20261002-ratelimit-enum-warn-f360abcae8be
Best regards,
--
Robert Killick <robert@killick.dev>
WARNING: multiple messages have this Message-ID (diff)
From: Robert Killick via B4 Relay <devnull+robert.killick.dev@kernel.org>
To: Sebastian Reichel <sre@kernel.org>
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
Robert Killick <robert@killick.dev>
Subject: [PATCH] power: supply: sysfs: Ratelimit "unavailable enum value" warning
Date: Mon, 05 Oct 2026 14:56:45 +0100 [thread overview]
Message-ID: <20261005-ratelimit-enum-warn-v1-1-b77b48de3c47@killick.dev> (raw)
From: Robert Killick <robert@killick.dev>
power_supply_show_enum_with_available() warns every time a driver
reports a value that is not in its declared set of available values.
For usb_type this happens on every sysfs read and on every uevent, so a
driver that reports such a value and calls power_supply_changed()
frequently can flood the kernel log.
This can happen with drivers that pass a firmware-provided value
through unchanged, as qcom_battmgr does for usb_type. On a OnePlus 10
Pro (SM8450), whose firmware reports a vendor-specific usb_type, this
produced ~128 warnings per second and kept systemd-journald at ~30% CPU.
The bug that causes the bad value needs fixing in the driver itself,
but one misbehaving driver should not be able to flood the kernel log.
Use dev_warn_ratelimited(), as power_supply_show_property() already
does for its own errors, so the problem is still reported, just not on
every read.
Signed-off-by: Robert Killick <robert@killick.dev>
---
drivers/power/supply/power_supply_sysfs.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c
index b0f524d152cf..9704557ffe1d 100644
--- a/drivers/power/supply/power_supply_sysfs.c
+++ b/drivers/power/supply/power_supply_sysfs.c
@@ -310,7 +310,8 @@ static ssize_t power_supply_show_enum_with_available(
}
if (!match) {
- dev_warn(dev, "driver reporting unavailable enum value %d\n", value);
+ dev_warn_ratelimited(dev, "driver reporting unavailable enum value %d\n",
+ value);
return -EINVAL;
}
---
base-commit: 4fc88ba435dadbc05990951e3f3fbd8ccd2df140
change-id: 20261002-ratelimit-enum-warn-f360abcae8be
Best regards,
--
Robert Killick <robert@killick.dev>
next reply other threads:[~2026-10-05 13:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-05 13:56 Robert Killick [this message]
2026-10-05 13:56 ` [PATCH] power: supply: sysfs: Ratelimit "unavailable enum value" warning Robert Killick via B4 Relay
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=20261005-ratelimit-enum-warn-v1-1-b77b48de3c47@killick.dev \
--to=robert@killick.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=sre@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.