mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yazen Ghannam <yazen.ghannam@amd.com>
To: <linux-pci@vger.kernel.org>
Cc: <linux-kernel@vger.kernel.org>, <bhelgaas@google.com>,
	Yazen Ghannam <yazen.ghannam@amd.com>
Subject: [PATCH 2/4] PCI/AER: Clamp negative ratelimit burst to zero
Date: Tue, 10 Nov 2026 15:56:12 -0600	[thread overview]
Message-ID: <20261110215614.3931232-3-yazen.ghannam@amd.com> (raw)
In-Reply-To: <20261110215614.3931232-1-yazen.ghannam@amd.com>

The correctable and nonfatal "_ratelimit_burst" attributes store
whatever kstrtoint() parses, so a negative value lands directly in
ratelimit_state.burst.

___ratelimit() reads a negative burst as an uninitialized
ratelimit_state and gives a WARNing.

Clamp negative values to zero and document the clamping behavior.

Fixes: b4fe7398def6 ("PCI/AER: Add sysfs attributes for log ratelimits")
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://lore.kernel.org/linux-pci/20260714191826.BA81E1F000E9@smtp.kernel.org/
Signed-off-by: Yazen Ghannam <yazen.ghannam@amd.com>
---
 .../ABI/testing/sysfs-bus-pci-devices-aer     | 21 ++++++++++++-------
 drivers/pci/pcie/aer.c                        |  3 +++
 2 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/Documentation/ABI/testing/sysfs-bus-pci-devices-aer b/Documentation/ABI/testing/sysfs-bus-pci-devices-aer
index 5ed284523956..215cf8bd4c30 100644
--- a/Documentation/ABI/testing/sysfs-bus-pci-devices-aer
+++ b/Documentation/ABI/testing/sysfs-bus-pci-devices-aer
@@ -130,9 +130,10 @@ What:		/sys/bus/pci/devices/<dev>/aer/correctable_ratelimit_interval_ms
 Date:		May 2025
 KernelVersion:	6.16.0
 Contact:	linux-pci@vger.kernel.org
-Description:	Writing 0 disables AER correctable error log ratelimiting.
-		Writing a positive value sets the ratelimit interval in ms.
-		Default is DEFAULT_RATELIMIT_INTERVAL (5000 ms).
+Description:	Writing 0, or any negative value, disables AER correctable
+		error log ratelimiting. Writing a positive value sets the
+		ratelimit interval in ms. Default is
+		DEFAULT_RATELIMIT_INTERVAL (5000 ms).
 
 What:		/sys/bus/pci/devices/<dev>/aer/correctable_ratelimit_burst
 Date:		May 2025
@@ -143,14 +144,17 @@ Description:	Ratelimit burst for correctable error logs. Writing a value
 		before ratelimiting. Reading gets the current ratelimit
 		burst. Default is DEFAULT_RATELIMIT_BURST (10).
 
+		Writing 0, or any negative value, suppresses all logs
+		unless the interval attribute is also 0.
+
 What:		/sys/bus/pci/devices/<dev>/aer/nonfatal_ratelimit_interval_ms
 Date:		May 2025
 KernelVersion:	6.16.0
 Contact:	linux-pci@vger.kernel.org
-Description:	Writing 0 disables AER non-fatal uncorrectable error log
-		ratelimiting. Writing a positive value sets the ratelimit
-		interval in ms. Default is DEFAULT_RATELIMIT_INTERVAL
-		(5000 ms).
+Description:	Writing 0, or any negative value, disables AER non-fatal
+		uncorrectable error log ratelimiting. Writing a positive
+		value sets the ratelimit interval in ms. Default is
+		DEFAULT_RATELIMIT_INTERVAL (5000 ms).
 
 What:		/sys/bus/pci/devices/<dev>/aer/nonfatal_ratelimit_burst
 Date:		May 2025
@@ -161,3 +165,6 @@ Description:	Ratelimit burst for non-fatal uncorrectable error logs.
 		allowed per interval before ratelimiting. Reading gets the
 		current ratelimit burst. Default is DEFAULT_RATELIMIT_BURST
 		(10).
+
+		Writing 0, or any negative value, suppresses all logs
+		unless the interval attribute is also 0.
diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c
index 6f2460231422..401cd3a1b3d0 100644
--- a/drivers/pci/pcie/aer.c
+++ b/drivers/pci/pcie/aer.c
@@ -752,6 +752,9 @@ const struct attribute_group aer_stats_attr_group = {
 		if (kstrtoint(buf, 0, &burst) < 0)			\
 			return -EINVAL;					\
 									\
+		if (burst < 0)						\
+			burst = 0;					\
+									\
 		pdev->aer_info->ratelimit.burst = burst;		\
 									\
 		return count;						\
-- 
2.55.0


  parent reply	other threads:[~2026-11-10 21:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-10 21:56 [PATCH 0/4] AER sysfs fixes Yazen Ghannam
2026-11-10 21:56 ` [PATCH 1/4] MAINTAINERS: Add the AER sysfs ABI file to PCI SUBSYSTEM Yazen Ghannam
2026-11-10 21:56 ` Yazen Ghannam [this message]
2026-11-10 21:56 ` [PATCH 3/4] PCI/AER: Report the ratelimit interval in milliseconds Yazen Ghannam
2026-11-18 16:39   ` Sang-Heon Jeon
2026-11-10 21:56 ` [PATCH 4/4] PCI/AER: Hide the "aer" sysfs directory on devices without AER Yazen Ghannam

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=20261110215614.3931232-3-yazen.ghannam@amd.com \
    --to=yazen.ghannam@amd.com \
    --cc=bhelgaas@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®