Re: [PATCH v16 4/7] s390/pci: Store PCI error information for passthrough devices
From: Niklas Schnelle
Date: Mon May 18 2026 - 06:13:15 EST
On Thu, 2026-05-14 at 11:00 -0700, Farhan Ali wrote:
> For a passthrough device we need co-operation from user space to recover
> the device. This would require to bubble up any error information to user
> space. Let's store this error information for passthrough devices, so it
> can be retrieved later.
>
> We can now have userspace drivers (vfio-pci based) on s390x. The userspace
> drivers will not have any KVM fd and so no kzdev associated with them. So
> we need to update the logic for detecting passthrough devices to not depend
> on struct kvm_zdev.
>
> Reviewed-by: Matthew Rosato <mjrosato@xxxxxxxxxxxxx>
> Signed-off-by: Farhan Ali <alifm@xxxxxxxxxxxxx>
> ---
> arch/s390/include/asm/pci.h | 30 ++++++++
> arch/s390/pci/pci.c | 1 +
> arch/s390/pci/pci_event.c | 114 +++++++++++++++++--------------
> drivers/vfio/pci/vfio_pci_zdev.c | 18 ++++-
> 4 files changed, 109 insertions(+), 54 deletions(-)
>
--- snip ---
> @@ -216,12 +223,23 @@ static pci_ers_result_t zpci_event_attempt_error_recovery(struct pci_dev *pdev)
> goto out_unlock;
> }
>
> + mediated_recovery = zpci_store_pci_error(pdev, ccdf) == 0 ? true : false;
> +
This incorrectly treats it as not-mediated recovery when the queue runs
full and zpci_store_pci_error() returns -ENOMEM (Sashiko also noticed
this though the explanation is a bit hard to read).
> ers_res = zpci_event_notify_error_detected(pdev, driver);
> if (ers_result_indicates_abort(ers_res)) {
> status_str = "failed (abort on detection)";
> goto out_unlock;
> }
>
> + if (mediated_recovery) {
> + pr_info("%s: Leaving recovery of pass-through device to user-space\n",
> + pci_name(pdev));
> + ers_res = PCI_ERS_RESULT_RECOVERED;
> + status_str = "in progress";
> + mutex_unlock(&zdev->pending_errs_lock);
The unlock here seems like a bad leftover from the previous code.
You're not holding that lock here. (Also found by Sashiko).
> + goto out_unlock;
> + }
> +
--- snip ---