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 3/7] PCI/ERR: Clear error status bits more selectively
Date: Wed, 18 Nov 2026 08:04:51 -0800	[thread overview]
Message-ID: <5cc37811-961a-43a7-8c87-278572c91ad5@linux.intel.com> (raw)
In-Reply-To: <8ab33b2307e9136719f72ccc2d9f946417651eab.1794997749.git.lukas@wunner.de>



On 11/18/26 02:40, Lukas Wunner wrote:
> After recovery from a PCIe error, all of the error status bits in the
> Device Status register are cleared indiscriminately, regardless of the
> error's severity.
> 
> So when a Correctable Error occurs simultaneously to an Uncorrectable
> Error, after the former is handled, it is cleared alongside the latter.
> As a result, the Uncorrectable Error isn't handled at all.
> 
> Conversely, an Uncorrectable Error occurring shortly before a Correctable
> Error may cause the latter to be cleared and thus ignored.
> 
> Avoid by clearing only the error bits corresponding to the error severity
> being handled.
> 
> Signed-off-by: Lukas Wunner <lukas@wunner.de>
> ---

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


> Changes v1 -> v2:
>   * New patch to clear error status bits more selectively (sashiko).
>  
>  drivers/pci/pcie/aer.c | 20 +++++++++++++++++++-
>  drivers/pci/pcie/err.c |  7 ++++++-
>  2 files changed, 25 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c
> index 6f2460231422..51cf2ff8c85a 100644
> --- a/drivers/pci/pcie/aer.c
> +++ b/drivers/pci/pcie/aer.c
> @@ -141,6 +141,12 @@ struct aer_info {
>  					PCI_ERR_ROOT_MULTI_COR_RCV |	\
>  					PCI_ERR_ROOT_MULTI_UNCOR_RCV)
>  
> +static const u8 severity2devsta[] = {
> +	[AER_NONFATAL]    = PCI_EXP_DEVSTA_NFED,
> +	[AER_FATAL]       = PCI_EXP_DEVSTA_FED,
> +	[AER_CORRECTABLE] = PCI_EXP_DEVSTA_CED,
> +};
> +
>  static bool pcie_aer_disable;
>  static pci_ers_result_t aer_root_reset(struct pci_dev *dev);
>  
> @@ -1314,6 +1320,17 @@ bool is_aer_internal_error(struct aer_err_info *info)
>  }
>  #endif
>  
> +static void pcie_clear_device_status_sev(struct pci_dev *dev, u8 severity,
> +					 u32 uncor_status)
> +{
> +	u16 devsta = severity2devsta[severity];
> +
> +	if (uncor_status & PCI_ERR_UNC_UNSUP)
> +		devsta |= PCI_EXP_DEVSTA_URD;
> +
> +	pcie_capability_write_word(dev, PCI_EXP_DEVSTA, devsta);
> +}
> +
>  /**
>   * pci_aer_handle_error - handle logging error into an event log
>   * @dev: pointer to pci_dev data structure of error source device
> @@ -1344,7 +1361,8 @@ static void pci_aer_handle_error(struct pci_dev *dev, struct aer_err_info *info)
>  			if (pdrv && pdrv->err_handler &&
>  			    pdrv->err_handler->cor_error_detected)
>  				pdrv->err_handler->cor_error_detected(dev);
> -			pcie_clear_device_status(dev);
> +			pcie_clear_device_status_sev(dev, AER_CORRECTABLE,
> +						     info->anfe_status);
>  		}
>  	} else if (info->severity == AER_NONFATAL)
>  		pcie_do_recovery(dev, pci_channel_io_normal, aer_root_reset);
> diff --git a/drivers/pci/pcie/err.c b/drivers/pci/pcie/err.c
> index 1a7fc71c79d8..24a8a8263c2e 100644
> --- a/drivers/pci/pcie/err.c
> +++ b/drivers/pci/pcie/err.c
> @@ -21,6 +21,10 @@
>  #include "portdrv.h"
>  #include "../pci.h"
>  
> +#define PCI_EXP_DEVSTA_UNC_MASK	(PCI_EXP_DEVSTA_NFED | \
> +				 PCI_EXP_DEVSTA_FED | \
> +				 PCI_EXP_DEVSTA_URD)
> +
>  static pci_ers_result_t merge_result(enum pci_ers_result orig,
>  				  enum pci_ers_result new)
>  {
> @@ -274,7 +278,8 @@ pci_ers_result_t pcie_do_recovery(struct pci_dev *dev,
>  	 * signaling device may not even be visible to the OS.
>  	 */
>  	if (host->native_aer) {
> -		pcie_clear_device_status(dev);
> +		pcie_capability_write_word(dev, PCI_EXP_DEVSTA,
> +					   PCI_EXP_DEVSTA_UNC_MASK);
>  		pci_aer_clear_nonfatal_status(dev);
>  	}
>  

-- 
Sathyanarayanan Kuppuswamy
Linux Kernel Developer



  reply	other threads:[~2026-11-18 16:04 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
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 [this message]
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=5cc37811-961a-43a7-8c87-278572c91ad5@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