On 9/27/2026 11:02 AM, Lukas Wunner wrote:
> When firmware grants control of Advanced Error Reporting to the operating
> system, that not only encompasses the AER capability, but also error
> enable/status bits in the Device Control and Device Status registers
> (PCI Firmware r3.3 table 4-6 bit 3).
>
> PCIe devices without AER capability still support baseline capability
> error reporting through these enable/status bits (PCIe r7.1 sec 6.2.1),
> but the bits must not be modified unless AER control was granted.
>
> pcie_aer_is_native() is unsuitable to check for control of AER-incapable
> devices because it implicitly checks for presence of an AER capability.
>
> Move that check to its callers (where needed) to allow using the function
> for the imminent baseline capability error reporting.
Agreed that ownership and AER presence are separate questions, but
changing the semantics while keeping the name may trip up callers that
assume "native" implies "present". Would a separate ownership-only
helper (e.g. pcie_err_is_native()) be cleaner? It could also replace
cxl_error_is_native().
I think you also need to fix kernel-doc of pci_aer_unmask_internal_errors().
it says to check AER support with pcie_aer_is_native(). That's no longer
sufficient, and the function has no aer_cap check, Please update the comment
and ideally add an "if (!aer) return;".
>
> Signed-off-by: Lukas Wunner <[email protected]>
> ---
> drivers/pci/pcie/aer.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c
> index d8dcd238fda1..34a8eddc427a 100644
> --- a/drivers/pci/pcie/aer.c
> +++ b/drivers/pci/pcie/aer.c
> @@ -257,9 +257,6 @@ int pcie_aer_is_native(struct pci_dev *dev)
> {
> struct pci_host_bridge *host = pci_find_host_bridge(dev->bus);
>
> - if (!dev->aer_cap)
> - return 0;
> -
> return pcie_ports_native || host->native_aer;
> }
> EXPORT_SYMBOL_NS_GPL(pcie_aer_is_native, "CXL");
> @@ -280,7 +277,7 @@ int pci_aer_clear_nonfatal_status(struct pci_dev *dev)
> int aer = dev->aer_cap;
> u32 status, sev;
>
> - if (!pcie_aer_is_native(dev))
> + if (!aer || !pcie_aer_is_native(dev))
> return -EIO;
>
> /* Clear status bits for ERR_NONFATAL errors only */
> @@ -299,7 +296,7 @@ void pci_aer_clear_fatal_status(struct pci_dev *dev)
> int aer = dev->aer_cap;
> u32 status, sev;
>
> - if (!pcie_aer_is_native(dev))
> + if (!aer || !pcie_aer_is_native(dev))
> return;
>
> /* Clear status bits for ERR_FATAL errors only */
--
Sathyanarayanan Kuppuswamy
Linux Kernel Developer