Linux PCI subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Lukas Wunner" <lukas@wunner.de>, linux-pci@vger.kernel.org
Subject: Re: [PATCH v2 7/7] PCI/AER: Enable baseline capability error reporting
Date: Wed, 18 Nov 2026 11:19:03 +0000	[thread overview]
Message-ID: <sashiko-outbox-220816@kernel.org> (raw)
In-Reply-To: <40e4bd7f25b37af1bdc48a13be140bdd8e7d81ab.1794997749.git.lukas@wunner.de>

Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] PCI/AER: aer_get_device_error_info() misclassifies fatal
  errors when !aer
- [Medium] PCI/AER: aer_stats_attrs_are_visible() exposes rootport attrs
  when !aer_cap
- [Medium] PCI/AER: RsvdP PCI_EXP_AER_FLAGS in VF PCI_EXP_DEVCTL breaks
  VF baseline AER
--

commit 9287c85cae40e6093499911042f25e70c5543c73
Author: Lukas Wunner <lukas@wunner.de>

PCI/AER: Enable baseline capability error reporting

This commit enables PCIe baseline capability error reporting on devices that
do not implement the Advanced Error Reporting Extended Capability, using the
Device Control and Device Status registers.

Link: https://lore.kernel.org/r/20260826212619.GA1566339@bhelgaas/

> diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c
> index 9bb8e2127849e..3c28afca5d037 100644
> --- a/drivers/pci/pcie/aer.c
> +++ b/drivers/pci/pcie/aer.c
> @@ -403,21 +403,22 @@ void pci_aer_init(struct pci_dev *dev)
>  {
>  	int n;
>  
> -	dev->aer_cap = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR);
> -	if (!dev->aer_cap)
> +	if (!pci_is_pcie(dev))
>  		return;
>  
>  	dev->aer_info = kzalloc_obj(*dev->aer_info);
> -	if (!dev->aer_info) {
> -		dev->aer_cap = 0;
> +	if (!dev->aer_info)
>  		return;
> -	}
>  
>  	ratelimit_state_init(&dev->aer_info->correctable_ratelimit,
>  			     DEFAULT_RATELIMIT_INTERVAL, DEFAULT_RATELIMIT_BURST);
>  	ratelimit_state_init(&dev->aer_info->nonfatal_ratelimit,
>  			     DEFAULT_RATELIMIT_INTERVAL, DEFAULT_RATELIMIT_BURST);
>  
> +	dev->aer_cap = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR);
> +	if (!dev->aer_cap)
> +		goto enable;

[Severity: Medium]
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.

[ ... ]

> @@ -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);
> +	}

[Severity: Medium]
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.

[ ... ]

> @@ -1531,13 +1537,22 @@ int aer_get_device_error_info(struct aer_err_info *info, int i)
>  
>  	/* Must reset in this function */
>  	info->status = 0;
> +	info->mask = 0;
>  	info->anfe_status = 0;
> +	info->first_error = 0;
>  	info->tlp_header_valid = 0;
>  	info->is_cxl = pcie_is_cxl(dev);
>  
>  	/* 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), 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).  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 and increment the Unsupported Request counter in aer_dev_fatal
(which Documentation/ABI/testing/sysfs-bus-pci-devices-aer says must remain
0).

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1794997749.git.lukas@wunner.de?part=7

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

Thread overview: 15+ 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 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 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 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 [this message]

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=sashiko-outbox-220816@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lukas@wunner.de \
    --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