mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/4] AER sysfs fixes
@ 2026-11-10 21:56 Yazen Ghannam
  2026-11-10 21:56 ` [PATCH 1/4] MAINTAINERS: Add the AER sysfs ABI file to PCI SUBSYSTEM Yazen Ghannam
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Yazen Ghannam @ 2026-11-10 21:56 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-kernel, bhelgaas

Hi all,

This series includes fixes for issues reported by Sashiko on the Flit
logging v1 set and were included in v2 of that set. But I figured it
might be better to send these separately since these are independent of
the Flit logging capability feature.

Thanks,
Yazen

Link:
https://lore.kernel.org/20260918145619.3016889-1-yazen.ghannam@amd.com

Yazen Ghannam (4):
  MAINTAINERS: Add the AER sysfs ABI file to PCI SUBSYSTEM
  PCI/AER: Clamp negative ratelimit burst to zero
  PCI/AER: Report the ratelimit interval in milliseconds
  PCI/AER: Hide the "aer" sysfs directory on devices without AER

 .../ABI/testing/sysfs-bus-pci-devices-aer     | 21 ++++++++++++------
 MAINTAINERS                                   |  1 +
 drivers/pci/pcie/aer.c                        | 22 +++++++++----------
 3 files changed, 26 insertions(+), 18 deletions(-)


base-commit: 6d69eeae8966bc3bea0facbd550f45ef9de41cc4
-- 
2.55.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/4] MAINTAINERS: Add the AER sysfs ABI file to PCI SUBSYSTEM
  2026-11-10 21:56 [PATCH 0/4] AER sysfs fixes Yazen Ghannam
@ 2026-11-10 21:56 ` Yazen Ghannam
  2026-11-10 21:56 ` [PATCH 2/4] PCI/AER: Clamp negative ratelimit burst to zero Yazen Ghannam
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Yazen Ghannam @ 2026-11-10 21:56 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-kernel, bhelgaas, Yazen Ghannam

get_maintainer.pl returns only the LKML catch-all for
Documentation/ABI/testing/sysfs-bus-pci-devices-aer, so changes to the
documented AER sysfs interface do not reach linux-pci.

Add the file to the PCI SUBSYSTEM entry.

Signed-off-by: Yazen Ghannam <yazen.ghannam@amd.com>
---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 93abbb315065..b109c9f8aad6 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -21609,6 +21609,7 @@ Q:	https://patchwork.kernel.org/project/linux-pci/list/
 B:	https://bugzilla.kernel.org
 C:	irc://irc.oftc.net/linux-pci
 T:	git git://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git
+F:	Documentation/ABI/testing/sysfs-bus-pci-devices-aer
 F:	Documentation/ABI/testing/sysfs-devices-pci-host-bridge
 F:	Documentation/PCI/
 F:	Documentation/devicetree/bindings/pci/
-- 
2.55.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 2/4] PCI/AER: Clamp negative ratelimit burst to zero
  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
  2026-11-10 21:56 ` [PATCH 3/4] PCI/AER: Report the ratelimit interval in milliseconds Yazen Ghannam
  2026-11-10 21:56 ` [PATCH 4/4] PCI/AER: Hide the "aer" sysfs directory on devices without AER Yazen Ghannam
  3 siblings, 0 replies; 6+ messages in thread
From: Yazen Ghannam @ 2026-11-10 21:56 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-kernel, bhelgaas, Yazen Ghannam

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 3/4] PCI/AER: Report the ratelimit interval in milliseconds
  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 ` [PATCH 2/4] PCI/AER: Clamp negative ratelimit burst to zero Yazen Ghannam
@ 2026-11-10 21:56 ` 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
  3 siblings, 1 reply; 6+ messages in thread
From: Yazen Ghannam @ 2026-11-10 21:56 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-kernel, bhelgaas, Yazen Ghannam

The "*_ratelimit_interval_ms" attributes convert milliseconds to jiffies
when storing. But they don't convert jiffies to milliseconds when
showing. So the user is presented with the raw jiffies value.

Do the jiffies to milliseconds conversion when showing the value.

Fixes: b4fe7398def6 ("PCI/AER: Add sysfs attributes for log ratelimits")
Signed-off-by: Yazen Ghannam <yazen.ghannam@amd.com>
---
 drivers/pci/pcie/aer.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c
index 401cd3a1b3d0..32a4c9101946 100644
--- a/drivers/pci/pcie/aer.c
+++ b/drivers/pci/pcie/aer.c
@@ -699,9 +699,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.55.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 4/4] PCI/AER: Hide the "aer" sysfs directory on devices without AER
  2026-11-10 21:56 [PATCH 0/4] AER sysfs fixes Yazen Ghannam
                   ` (2 preceding siblings ...)
  2026-11-10 21:56 ` [PATCH 3/4] PCI/AER: Report the ratelimit interval in milliseconds Yazen Ghannam
@ 2026-11-10 21:56 ` Yazen Ghannam
  3 siblings, 0 replies; 6+ messages in thread
From: Yazen Ghannam @ 2026-11-10 21:56 UTC (permalink / raw)
  To: linux-pci; +Cc: linux-kernel, bhelgaas, Yazen Ghannam

aer_attr_group is a named group, so sysfs creates an "aer" directory for
every PCI device. aer_attrs_are_visible() hides the attributes when the
device has no aer_info.

But this doesn't apply to the entire "aer" group. So devices without AER
end up having an empty "aer" directory.

Switch to DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE() which can use a single
check for all the AER attributes.

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>
---
 drivers/pci/pcie/aer.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c
index 32a4c9101946..5ea81a506a06 100644
--- a/drivers/pci/pcie/aer.c
+++ b/drivers/pci/pcie/aer.c
@@ -778,22 +778,19 @@ static struct attribute *aer_attrs[] = {
 	NULL
 };
 
-static umode_t aer_attrs_are_visible(struct kobject *kobj,
-				     struct attribute *a, int n)
+static bool aer_group_visible(struct kobject *kobj)
 {
-	struct device *dev = kobj_to_dev(kobj);
-	struct pci_dev *pdev = to_pci_dev(dev);
+	struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj));
 
-	if (!pdev->aer_info)
-		return 0;
-
-	return a->mode;
+	return !!pdev->aer_info;
 }
 
+DEFINE_SIMPLE_SYSFS_GROUP_VISIBLE(aer);
+
 const struct attribute_group aer_attr_group = {
 	.name = "aer",
 	.attrs = aer_attrs,
-	.is_visible = aer_attrs_are_visible,
+	.is_visible = SYSFS_GROUP_VISIBLE(aer),
 };
 
 static void pci_dev_aer_stats_incr(struct pci_dev *pdev,
-- 
2.55.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 3/4] PCI/AER: Report the ratelimit interval in milliseconds
  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
  0 siblings, 0 replies; 6+ messages in thread
From: Sang-Heon Jeon @ 2026-11-18 16:39 UTC (permalink / raw)
  To: Yazen Ghannam; +Cc: linux-pci, linux-kernel, bhelgaas

On Tue, Nov 10, 2026 at 03:56:13PM -0600, Yazen Ghannam wrote:
> The "*_ratelimit_interval_ms" attributes convert milliseconds to jiffies
> when storing. But they don't convert jiffies to milliseconds when
> showing. So the user is presented with the raw jiffies value.
>
> Do the jiffies to milliseconds conversion when showing the value.
>
> Fixes: b4fe7398def6 ("PCI/AER: Add sysfs attributes for log ratelimits")
> Signed-off-by: Yazen Ghannam <yazen.ghannam@amd.com>
> ---
>  drivers/pci/pcie/aer.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c
> index 401cd3a1b3d0..32a4c9101946 100644
> --- a/drivers/pci/pcie/aer.c
> +++ b/drivers/pci/pcie/aer.c
> @@ -699,9 +699,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							\

I found a similar issue in other subsystems, and this looks good to me.

Reviewed-by: Sang-Heon Jeon <ekffu200098@gmail.com>

Best Regards,
Sang-Heon Jeon

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-11-18 16:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH 2/4] PCI/AER: Clamp negative ratelimit burst to zero Yazen Ghannam
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

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®