Subject: Re: [PATCH v6 3/5] PCI/AER: Report fatal errors of RCiEP and EP if link recoverd

From: Lukas Wunner <[email-masked]>
Date: Mon, 20 Oct 2025 12:10:03 +0200

On Wed, Oct 15, 2025 at 10:41:57AM +0800, Shuai Xue wrote:
> +++ b/drivers/pci/pcie/err.c
> @@ -253,6 +254,16 @@ pci_ers_result_t pcie_do_recovery(struct pci_dev *dev,
>  			pci_warn(bridge, "subordinate device reset failed\n");
>  			goto failed;
>  		}
> +
> +		/* Link recovered, report fatal errors of RCiEP or EP */
> +		if (state == pci_channel_io_frozen &&
> +		    (type == PCI_EXP_TYPE_ENDPOINT || type == PCI_EXP_TYPE_RC_END)) {
> +			aer_add_error_device(&info, dev);
> +			info.severity = AER_FATAL;
> +			if (aer_get_device_error_info(&info, 0, true))
> +				aer_print_error(&info, 0);
> +			pci_dev_put(dev);
> +		}
>  	}

Where is the the pci_dev_get() to balance the pci_dev_put() here?

It feels awkward to leak AER-specific details into pcie_do_recovery().
That function is supposed to implement the flow described in
Documentation/PCI/pci-error-recovery.rst in a platform-agnostic way
so that powerpc (EEH) and s390 could conceivably take advantage of it.

Can you find a way to avoid this, e.g. report errors after
pcie_do_recovery() has concluded?

I'm also worried that errors are reported *during* recovery.
I imagine this looks confusing to a user.  The logged messages
should make it clear that these are errors that occurred *earlier*
and are reported belatedly.

Thanks,

Lukas