LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
To: Lukas Wunner <lukas@wunner.de>,
	Bjorn Helgaas <helgaas@kernel.org>,
	Raag Jadav <raag.jadav@intel.com>,
	linux-pci@vger.kernel.org
Cc: Sourabh Jain <sourabhjain@linux.ibm.com>,
	Oliver OHalloran <oohall@gmail.com>,
	linuxppc-dev@lists.ozlabs.org,
	Aravind Iddamsetty <aravind.iddamsetty@intel.com>,
	Srinivasa Adatrao <srinivasa.adatrao@intel.com>,
	Terry Bowman <terry.bowman@amd.com>,
	Keith Busch <kbusch@kernel.org>,
	Maciej Grochowski <Maciej.Grochowski@sony.com>,
	Yazen Ghannam <yazen.ghannam@amd.com>,
	Darshit Shah <darnshah@amazon.de>,
	Jason Perlow <jperlow@gmail.com>,
	Riana Tauro <riana.tauro@intel.com>,
	Yury Murashka <yurypm@arista.com>,
	Matthew W Carlis <mattc@purestorage.com>
Subject: Re: [PATCH v2 1/7] PCI/DPC: Avoid access to non-existent AER capability
Date: Wed, 18 Nov 2026 08:00:16 -0800	[thread overview]
Message-ID: <62178920-f5e9-4d0b-8fc6-0bf0e2a53fd8@linux.intel.com> (raw)
In-Reply-To: <34c9ee153876bac953135b4518035194b7c07c6c.1794997749.git.lukas@wunner.de>



On 11/18/26 02:40, Lukas Wunner wrote:
> Downstream Port Containment does not mandate presence of an Advanced Error
> Reporting capability, so a Downstream Port may support DPC, but not AER
> (PCIe r7.1 sec 6.2.11.2).
> 
> In February 2019, commit 9f08a5d896ce ("PCI/DPC: Fix print AER status in
> DPC event handling") amended the DPC driver to access the AER capability
> without checking for its presence.
> 
> This did not cause actual problems because in March 2018, commit
> 4e5fad429bd1 ("PCI/DPC: Do not enable DPC if AER control is not allowed by
> the BIOS") had seemingly inadvertently prevented instantiation of a DPC
> port service on AER-incapable ports.
> 
> However in October 2019, commit 35a0b2378c19 ("PCI/DPC: Add
> "pcie_ports=dpc-native" to allow DPC without AER control") made it
> possible to override this:  The DPC driver may access a non-existent AER
> capability if "pcie_ports=dpc-native" is passed on the command line.
> 
> Fix it by making the DPC driver cope with AER-unsupporting Downstream
> Ports.
> 
> There are two places where the AER capability is accessed:
> 
> - dpc_get_aer_uncorrect_severity() uses it to discern whether a Fatal or
>   Non-Fatal Error triggered DPC.  Access the Device Status Register
>   instead, in accordance with PCIe r7.1 sec 6.2.5.
> 
> - dpc_is_surprise_removal() uses it to detect whether a Surprise Down
>   Error triggered DPC.  Return false on AER-unsupporting devices.  The
>   function works around an AMD-specific quirk and it seems reasonable to
>   assume that all affected products are AER-supporting.  In any case the
>   detection is not possible without AER capability.
> 
> Insert a temporary check for an AER capability after the call to
> aer_get_device_error_info() because the function currently returns false
> for AER-unsupporting devices.  The check will become obsolete and will be
> removed with the imminent baseline capability error reporting.
> 
> Fixes: 35a0b2378c19 ("PCI/DPC: Add "pcie_ports=dpc-native" to allow DPC without AER control")
> Signed-off-by: Lukas Wunner <lukas@wunner.de>
> Cc: stable@vger.kernel.org # v5.5+
> ---

Looks good to me.

Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>


> Changes v1 -> v2:
>   * On AER-capable devices, infer severity from AER Extended Capability
>     instead of Device Status register because the latter also logs masked
>     errors (Sathya).
>   * Fix storytelling in commit message because 4e5fad429bd1 changed
>     behavior, not 708b20003624 (Sathya).
>  
>  drivers/pci/pcie/dpc.c | 45 ++++++++++++++++++++++++++++++------------
>  1 file changed, 32 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/pci/pcie/dpc.c b/drivers/pci/pcie/dpc.c
> index 2b779bd1d861..d02cbbbe3143 100644
> --- a/drivers/pci/pcie/dpc.c
> +++ b/drivers/pci/pcie/dpc.c
> @@ -238,19 +238,35 @@ static int dpc_get_aer_uncorrect_severity(struct pci_dev *dev,
>  {
>  	int pos = dev->aer_cap;
>  	u32 status, mask, sev;
> +	u16 devsta;
>  
> -	pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS, &status);
> -	pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_MASK, &mask);
> -	status &= ~mask;
> -	if (!status)
> -		return 0;
> -
> -	pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_SEVER, &sev);
> -	status &= sev;
> -	if (status)
> -		info->severity = AER_FATAL;
> -	else
> -		info->severity = AER_NONFATAL;
> +	/*
> +	 * Infer severity from AER Extended Capability if present, else from
> +	 * Device Status register.  The latter cannot be used on AER-capable
> +	 * ports because it also logs masked errors (PCIe r7.1 sec 7.5.3.5).
> +	 */
> +	if (pos) {
> +		pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS, &status);
> +		pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_MASK, &mask);
> +		status &= ~mask;
> +		if (!status)
> +			return 0;
> +
> +		pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_SEVER, &sev);
> +		status &= sev;
> +		if (status)
> +			info->severity = AER_FATAL;
> +		else
> +			info->severity = AER_NONFATAL;
> +	} else {
> +		pcie_capability_read_word(dev, PCI_EXP_DEVSTA, &devsta);
> +		if (devsta & PCI_EXP_DEVSTA_FED)
> +			info->severity = AER_FATAL;
> +		else if (devsta & PCI_EXP_DEVSTA_NFED)
> +			info->severity = AER_NONFATAL;
> +		else
> +			return 0;
> +	}
>  
>  	info->level = KERN_ERR;
>  
> @@ -275,7 +291,7 @@ void dpc_process_error(struct pci_dev *pdev)
>  		pci_warn(pdev, "containment event, status:%#06x: unmasked uncorrectable error detected\n",
>  			 status);
>  		if (dpc_get_aer_uncorrect_severity(pdev, &info) &&
> -		    aer_get_device_error_info(&info, 0)) {
> +		    (aer_get_device_error_info(&info, 0) || !pdev->aer_cap)) {
>  			aer_print_error(&info, 0);
>  			pci_aer_clear_nonfatal_status(pdev);
>  			pci_aer_clear_fatal_status(pdev);
> @@ -353,6 +369,9 @@ static bool dpc_is_surprise_removal(struct pci_dev *pdev)
>  	if (!pdev->is_hotplug_bridge)
>  		return false;
>  
> +	if (!pdev->aer_cap)
> +		return false;
> +
>  	if (pci_read_config_word(pdev, pdev->aer_cap + PCI_ERR_UNCOR_STATUS,
>  				 &status))
>  		return false;

-- 
Sathyanarayanan Kuppuswamy
Linux Kernel Developer



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

Thread overview: 12+ 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 16:00   ` Kuppuswamy Sathyanarayanan [this message]
2026-11-18 10:40 ` [PATCH v2 2/7] PCI/DPC: Reinstate support for AER-incapable ports Lukas Wunner
2026-11-18 10:40 ` [PATCH v2 3/7] PCI/ERR: Clear error status bits more selectively Lukas Wunner
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 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 10:40 ` [PATCH v2 6/7] PCI/AER: Move AER capability check out of pcie_aer_is_native() Lukas Wunner
2026-11-18 10:40 ` [PATCH v2 7/7] PCI/AER: Enable baseline capability error reporting Lukas Wunner
2026-11-20 18:19 ` [PATCH v2 0/7] Error reporting for AER-incapable devices Bjorn Helgaas

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=62178920-f5e9-4d0b-8fc6-0bf0e2a53fd8@linux.intel.com \
    --to=sathyanarayanan.kuppuswamy@linux.intel.com \
    --cc=Maciej.Grochowski@sony.com \
    --cc=aravind.iddamsetty@intel.com \
    --cc=darnshah@amazon.de \
    --cc=helgaas@kernel.org \
    --cc=jperlow@gmail.com \
    --cc=kbusch@kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=lukas@wunner.de \
    --cc=mattc@purestorage.com \
    --cc=oohall@gmail.com \
    --cc=raag.jadav@intel.com \
    --cc=riana.tauro@intel.com \
    --cc=sourabhjain@linux.ibm.com \
    --cc=srinivasa.adatrao@intel.com \
    --cc=terry.bowman@amd.com \
    --cc=yazen.ghannam@amd.com \
    --cc=yurypm@arista.com \
    /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