Linux ACPI
 help / color / mirror / Atom feed
From: Yazen Ghannam <yazen.ghannam@amd.com>
To: <linux-pci@vger.kernel.org>
Cc: <linux-kernel@vger.kernel.org>, <linux-acpi@vger.kernel.org>,
	<linux-edac@vger.kernel.org>, <bhelgaas@google.com>,
	Yazen Ghannam <yazen.ghannam@amd.com>
Subject: [PATCH v2 03/10] PCI/AER: Report the ratelimit interval in milliseconds
Date: Fri, 18 Sep 2026 09:56:11 -0500	[thread overview]
Message-ID: <20260918145619.3016889-4-yazen.ghannam@amd.com> (raw)
In-Reply-To: <20260918145619.3016889-1-yazen.ghannam@amd.com>

The "*_ratelimit_interval_ms" attributes convert on the way in but not on
the way out. The store path runs msecs_to_jiffies() before assigning to
ratelimit_state.interval, and the show path prints that field raw.

The field therefore reads back in jiffies while the attribute name and
the ABI documentation both say milliseconds. The two only agree when
CONFIG_HZ is 1000. With CONFIG_HZ=250 the default reads as 1250 rather
than the documented 5000.

Convert back with jiffies_to_msecs() so the attribute reports the unit
it is named for. msecs_to_jiffies() rounds up, so a written value that
is not a whole number of jiffies reads back rounded up. Document what a
read returns, which the burst attributes beside it already do.

Fixes: b4fe7398def6 ("PCI/AER: Add sysfs attributes for log ratelimits")
Assisted-by: LLM
Signed-off-by: Yazen Ghannam <yazen.ghannam@amd.com>
---
 Documentation/ABI/testing/sysfs-bus-pci-devices-aer | 6 ++++++
 drivers/pci/pcie/aer.c                              | 8 ++++----
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/Documentation/ABI/testing/sysfs-bus-pci-devices-aer b/Documentation/ABI/testing/sysfs-bus-pci-devices-aer
index 215cf8bd4c30..732fc03ef5fb 100644
--- a/Documentation/ABI/testing/sysfs-bus-pci-devices-aer
+++ b/Documentation/ABI/testing/sysfs-bus-pci-devices-aer
@@ -135,6 +135,9 @@ Description:	Writing 0, or any negative value, disables AER correctable
 		ratelimit interval in ms. Default is
 		DEFAULT_RATELIMIT_INTERVAL (5000 ms).
 
+		Reading gets the current ratelimit interval in ms, rounded
+		up to a whole jiffy.
+
 What:		/sys/bus/pci/devices/<dev>/aer/correctable_ratelimit_burst
 Date:		May 2025
 KernelVersion:	6.16.0
@@ -156,6 +159,9 @@ Description:	Writing 0, or any negative value, disables AER non-fatal
 		value sets the ratelimit interval in ms. Default is
 		DEFAULT_RATELIMIT_INTERVAL (5000 ms).
 
+		Reading gets the current ratelimit interval in ms, rounded
+		up to a whole jiffy.
+
 What:		/sys/bus/pci/devices/<dev>/aer/nonfatal_ratelimit_burst
 Date:		May 2025
 KernelVersion:	6.16.0
diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c
index 350b57e5ccb1..5498fc605556 100644
--- a/drivers/pci/pcie/aer.c
+++ b/drivers/pci/pcie/aer.c
@@ -688,9 +688,9 @@ const struct attribute_group aer_stats_attr_group = {
 };
 
 /*
- * Ratelimit interval
+ * Ratelimit interval, in milliseconds
  * <=0: disabled with ratelimit.interval = 0
- * >0: enabled with ratelimit.interval in ms
+ * >0: enabled, ratelimit.interval held in jiffies
  */
 #define aer_ratelimit_interval_attr(name, ratelimit)			\
 	static ssize_t							\
@@ -698,9 +698,9 @@ const struct attribute_group aer_stats_attr_group = {
 					 char *buf)			\
 	{								\
 		struct pci_dev *pdev = to_pci_dev(dev);			\
+		unsigned long iv = pdev->aer_info->ratelimit.interval;	\
 									\
-		return sysfs_emit(buf, "%d\n",				\
-				  pdev->aer_info->ratelimit.interval);	\
+		return sysfs_emit(buf, "%u\n", jiffies_to_msecs(iv));	\
 	}								\
 									\
 	static ssize_t							\
-- 
2.43.0


  parent reply	other threads:[~2026-09-18 14:58 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-18 14:56 [PATCH v2 00/10] PCIe Flit Logging Ext Capability Support Yazen Ghannam
2026-09-18 14:56 ` [PATCH v2 01/10] MAINTAINERS: Add the AER sysfs ABI file to PCI SUBSYSTEM Yazen Ghannam
2026-09-18 14:56 ` [PATCH v2 02/10] PCI/AER: Clamp negative ratelimit burst to zero Yazen Ghannam
2026-09-18 14:56 ` Yazen Ghannam [this message]
2026-09-18 14:56 ` [PATCH v2 04/10] PCI/AER: Hide the "aer" sysfs directory when AER is unavailable Yazen Ghannam
2026-09-18 14:56 ` [PATCH v2 05/10] PCI: Share the AER ratelimit sysfs accessors Yazen Ghannam
2026-09-18 14:56 ` [PATCH v2 06/10] PCI/portdrv: Group PCI Exp Cap services into a single mask Yazen Ghannam
2026-09-18 14:56 ` [PATCH v2 07/10] PCI/FLIT: Add support for Flit Logging Extended Capability Yazen Ghannam
2026-09-18 16:38   ` Ilpo Järvinen
2026-09-18 14:56 ` [PATCH v2 08/10] PCI/FLIT: Add trace event for flit errors Yazen Ghannam
2026-09-18 14:56 ` [PATCH v2 09/10] PCI/FLIT: Ratelimit flit error logging Yazen Ghannam
2026-09-18 14:56 ` [PATCH v2 10/10] PCI/FLIT: Expose the error counter controls through sysfs 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=20260918145619.3016889-4-yazen.ghannam@amd.com \
    --to=yazen.ghannam@amd.com \
    --cc=bhelgaas@google.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-edac@vger.kernel.org \
    --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