Linux PCI subsystem development
 help / color / mirror / Atom feed
From: Lukas Wunner <lukas@wunner.de>
To: sashiko-reviews@lists.linux.dev
Cc: linux-pci@vger.kernel.org
Subject: Re: [PATCH v2 7/7] PCI/AER: Enable baseline capability error reporting
Date: Wed, 18 Nov 2026 23:17:10 +0100	[thread overview]
Message-ID: <av4j5j9-In1uWC8T@wunner.de> (raw)
In-Reply-To: <sashiko-outbox-220816@kernel.org>

On Wed, Nov 18, 2026 at 11:19:03AM +0000, sashiko-bot@kernel.org wrote:
> Does allocating dev->aer_info for all PCIe devices cause
> aer_stats_attrs_are_visible() to expose the aer_rootport_total_err_* sysfs
> attributes on Root Ports and RCECs that lack an AER Extended Capability?
> 
> drivers/pci/pcie/aer.c:aer_stats_attrs_are_visible() {
> 	...
> 	if (!pdev->aer_info)
> 		return 0;
> 
> 	if ((a == &dev_attr_aer_rootport_total_err_cor.attr ||
> 	     a == &dev_attr_aer_rootport_total_err_fatal.attr ||
> 	     a == &dev_attr_aer_rootport_total_err_nonfatal.attr) &&
> 	    ((pci_pcie_type(pdev) != PCI_EXP_TYPE_ROOT_PORT) &&
> 	     (pci_pcie_type(pdev) != PCI_EXP_TYPE_RC_EC)))
> 		return 0;
> 	...
> }
> 
> Those counters are only updated from PCI_ERR_ROOT_STATUS in the AER
> capability and Documentation/ABI/testing/sysfs-bus-pci-devices-aer states
> that they only appear under AER-capable Root Ports or RCECs, so
> aer_stats_attrs_are_visible() should also require pdev->aer_cap for them.

A valid point.

> > @@ -1204,8 +1206,11 @@ static bool is_error_source(struct pci_dev *dev, struct aer_err_info *e_info)
> >  	if (!(reg16 & PCI_EXP_AER_FLAGS))
> >  		return false;
> >  
> > -	if (!aer)
> > -		return false;
> > +	if (!aer) {
> > +		pcie_capability_read_word(dev, PCI_EXP_DEVSTA, &reg16);
> > +		return reg16 & severity2devsta[e_info->severity] &&
> > +		       !PCI_POSSIBLE_ERROR(reg16);
> > +	}
> 
> Does checking PCI_EXP_AER_FLAGS in dev's own PCI_EXP_DEVCTL prevent
> is_error_source() and clear_status_iter() from working on SR-IOV Virtual
> Functions?
> 
> Per PCIe r7.1 sec 7.5.3.4 and sec 9.5.1.2, the PCI_EXP_AER_FLAGS bits in
> PCI_EXP_DEVCTL are RsvdP and hardwired to 0b on VFs, which inherit the
> associated Physical Function's PCI_EXP_DEVCTL settings while implementing
> per-VF status bits in PCI_EXP_DEVSTA.  Reading PCI_EXP_DEVCTL on a VF
> therefore always sees 0 for PCI_EXP_AER_FLAGS, so is_error_source() never
> checks PCI_EXP_DEVSTA on VFs and clear_status_iter() never clears it;
> meanwhile pci_enable_pcie_error_reporting() writes 1s to those RsvdP bits on
> VFs.

Hallucination.  Section 7.5.3.4 does not say anything about error bits being
"RsvdP and hardwired to 0b on VFs".  There is no section 9.5.1.2 in PCIe r7.1.

> >  	/* The device might not support AER */
> > -	if (!aer)
> > -		return 0;
> > +	if (!aer) {
> > +		if (info->severity != AER_CORRECTABLE) {
> > +			pcie_capability_read_word(dev, PCI_EXP_DEVSTA, &devsta);
> > +			if (devsta & PCI_EXP_DEVSTA_URD &&
> > +			    !PCI_POSSIBLE_ERROR(devsta))
> > +				info->status = PCI_ERR_UNC_UNSUP;
> > +		}
> > +		return 1;
> > +	}
> 
> [Severity: Medium]
> Should the !aer branch check info->severity == AER_NONFATAL instead of
> info->severity != AER_CORRECTABLE?
> 
> Without an AER capability, error severities are fixed to their defaults where
> Unsupported Request is always Non-Fatal (PCIe r7.1 sec 6.2.7),

Indeed checking against AER_NONFATAL makes more sense here, although this is
nowhere near as critical an issue as sashiko thinks:

> yet PCI_EXP_DEVSTA_URD is also set by prior Advisory Non-Fatal or Non-Fatal
> Unsupported Requests (sec 6.2.5 and 7.5.3.5).

Advisory Non-Fatal Errors are not signaled on AER-incapable devices
(as stated in the commit message).

> When an AER_FATAL error occurs
> on an AER-incapable device, reading PCI_EXP_DEVSTA accesses config space on
> an Endpoint or Upstream Port whose link may be down, and any set
> PCI_EXP_DEVSTA_URD bit causes aer_print_error() to misreport the fatal error
> as UnsupReq

No, the "!PCI_POSSIBLE_ERROR(devsta)" prevents that.

Below is a fixup patch for the two valid sashiko findings:

-- >8 --

diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c
index 3c28afca5d03..83682bc7764e 100644
--- a/drivers/pci/pcie/aer.c
+++ b/drivers/pci/pcie/aer.c
@@ -680,12 +680,16 @@ static umode_t aer_stats_attrs_are_visible(struct kobject *kobj,
 	if (!pdev->aer_info)
 		return 0;
 
-	if ((a == &dev_attr_aer_rootport_total_err_cor.attr ||
-	     a == &dev_attr_aer_rootport_total_err_fatal.attr ||
-	     a == &dev_attr_aer_rootport_total_err_nonfatal.attr) &&
-	    ((pci_pcie_type(pdev) != PCI_EXP_TYPE_ROOT_PORT) &&
-	     (pci_pcie_type(pdev) != PCI_EXP_TYPE_RC_EC)))
-		return 0;
+	if (a == &dev_attr_aer_rootport_total_err_cor.attr ||
+	    a == &dev_attr_aer_rootport_total_err_fatal.attr ||
+	    a == &dev_attr_aer_rootport_total_err_nonfatal.attr) {
+		if ((pci_pcie_type(pdev) != PCI_EXP_TYPE_ROOT_PORT) &&
+		    (pci_pcie_type(pdev) != PCI_EXP_TYPE_RC_EC))
+			return 0;
+
+		if (!pdev->aer_cap)
+			return 0;
+	}
 
 	return a->mode;
 }
@@ -1545,7 +1549,7 @@ int aer_get_device_error_info(struct aer_err_info *info, int i)
 
 	/* The device might not support AER */
 	if (!aer) {
-		if (info->severity != AER_CORRECTABLE) {
+		if (info->severity == AER_NONFATAL) {
 			pcie_capability_read_word(dev, PCI_EXP_DEVSTA, &devsta);
 			if (devsta & PCI_EXP_DEVSTA_URD &&
 			    !PCI_POSSIBLE_ERROR(devsta))

  reply	other threads:[~2026-11-18 22:17 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18 10:40 [PATCH v2 0/7] Error reporting for AER-incapable devices Lukas Wunner
2026-11-18 10:40 ` [PATCH v2 1/7] PCI/DPC: Avoid access to non-existent AER capability Lukas Wunner
2026-11-18 11:04   ` sashiko-bot
2026-11-18 16:00   ` Kuppuswamy Sathyanarayanan
2026-11-18 10:40 ` [PATCH v2 2/7] PCI/DPC: Reinstate support for AER-incapable ports Lukas Wunner
2026-11-18 11:03   ` sashiko-bot
2026-11-18 10:40 ` [PATCH v2 3/7] PCI/ERR: Clear error status bits more selectively Lukas Wunner
2026-11-18 11:09   ` sashiko-bot
2026-11-18 16:04   ` Kuppuswamy Sathyanarayanan
2026-11-18 10:40 ` [PATCH v2 4/7] PCI/ERR: Avoid stale error status bits on recovery failure Lukas Wunner
2026-11-18 11:18   ` sashiko-bot
2026-11-18 16:05   ` Kuppuswamy Sathyanarayanan
2026-11-18 10:40 ` [PATCH v2 5/7] PCI/AER: Drop AER native check from handles_cxl_errors() Lukas Wunner
2026-11-18 11:02   ` sashiko-bot
2026-11-18 10:40 ` [PATCH v2 6/7] PCI/AER: Move AER capability check out of pcie_aer_is_native() Lukas Wunner
2026-11-18 11:13   ` sashiko-bot
2026-11-18 10:40 ` [PATCH v2 7/7] PCI/AER: Enable baseline capability error reporting Lukas Wunner
2026-11-18 11:19   ` sashiko-bot
2026-11-18 22:17     ` Lukas Wunner [this message]
2026-11-19  1:03 ` [PATCH v2 0/7] Error reporting for AER-incapable devices Jason Perlow

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=av4j5j9-In1uWC8T@wunner.de \
    --to=lukas@wunner.de \
    --cc=linux-pci@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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