Re: [PATCH v20 2/3] vfio-pci/zdev: Add a device feature for error information
From: Alex Williamson
Date: Fri Jul 17 2026 - 17:27:07 EST
On Tue, 30 Jun 2026 09:55:52 -0700
Farhan Ali <alifm@xxxxxxxxxxxxx> wrote:
> For zPCI devices, we have platform specific error information. The platform
> firmware provides this error information to the operating system in an
> architecture specific mechanism. To enable recovery from userspace for
> these devices, we want to expose this error information to userspace. Add a
> new device feature to expose this information.
>
> Userspace needs to be provide a buffer of fixed size. This size is provided
> to userspace via the VFIO_DEVICE_INFO_CAP_ZPCI_BASE capability.
>
> Reviewed-by: Matthew Rosato <mjrosato@xxxxxxxxxxxxx>
> Reviewed-by: Niklas Schnelle <schnelle@xxxxxxxxxxxxx>
> Signed-off-by: Farhan Ali <alifm@xxxxxxxxxxxxx>
> ---
> arch/s390/include/asm/pci.h | 2 ++
> arch/s390/pci/pci_event.c | 19 ++++++++++++++
> drivers/vfio/pci/vfio_pci_core.c | 2 ++
> drivers/vfio/pci/vfio_pci_priv.h | 9 +++++++
> drivers/vfio/pci/vfio_pci_zdev.c | 45 ++++++++++++++++++++++++++++++--
> include/uapi/linux/vfio.h | 23 ++++++++++++++++
> include/uapi/linux/vfio_zdev.h | 2 ++
> 7 files changed, 100 insertions(+), 2 deletions(-)
>
> diff --git a/arch/s390/include/asm/pci.h b/arch/s390/include/asm/pci.h
> index 016386f7ef4a..88a125b92bdd 100644
> --- a/arch/s390/include/asm/pci.h
> +++ b/arch/s390/include/asm/pci.h
> @@ -364,6 +364,8 @@ int zpci_clear_error_state(struct zpci_dev *zdev);
> int zpci_reset_load_store_blocked(struct zpci_dev *zdev);
> void zpci_start_mediated_recovery(struct zpci_dev *zdev);
> void zpci_stop_mediated_recovery(struct zpci_dev *zdev);
> +int zpci_get_pending_error(struct zpci_dev *zdev,
> + struct zpci_ccdf_err *ccdf);
>
> #ifdef CONFIG_NUMA
>
> diff --git a/arch/s390/pci/pci_event.c b/arch/s390/pci/pci_event.c
> index 8934b640a095..3ad16038e005 100644
> --- a/arch/s390/pci/pci_event.c
> +++ b/arch/s390/pci/pci_event.c
> @@ -77,6 +77,25 @@ static int zpci_store_pci_error(struct pci_dev *pdev,
> return 0;
> }
>
> +int zpci_get_pending_error(struct zpci_dev *zdev,
> + struct zpci_ccdf_err *ccdf)
> +{
> + int head = 0;
Nit, unnecessary initialization.
Otherwise LGTM and I can drop the initialization on commit if there's
no other reason for respin. I think we just need a branch from Bjorn
to base this on once he's happy with the PCI series. Thanks,
Alex
> +
> + guard(mutex)(&zdev->pending_errs_lock);
> +
> + if (!zdev->pending_errs.count)
> + return -ENOMSG;
> +
> + head = zdev->pending_errs.head % ZPCI_ERR_PENDING_MAX;
> + memcpy(ccdf, &zdev->pending_errs.err[head],
> + sizeof(struct zpci_ccdf_err));
> + zdev->pending_errs.head++;
> + zdev->pending_errs.count--;
> + return 0;
> +}
> +EXPORT_SYMBOL_GPL(zpci_get_pending_error);
> +
> void zpci_start_mediated_recovery(struct zpci_dev *zdev)
> {
> guard(mutex)(&zdev->pending_errs_lock);