From: Alex Williamson <alex@shazbot.org>
To: Farhan Ali <alifm@linux.ibm.com>
Cc: linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-pci@vger.kernel.org, helgaas@kernel.org, lukas@wunner.de,
kbusch@kernel.org, clg@redhat.com, stable@vger.kernel.org,
schnelle@linux.ibm.com, mjrosato@linux.ibm.com, alex@shazbot.org
Subject: Re: [PATCH v11 7/9] vfio-pci/zdev: Add a device feature for error information
Date: Wed, 25 Mar 2026 11:18:08 -0600 [thread overview]
Message-ID: <20260325111808.263aef2c@shazbot.org> (raw)
In-Reply-To: <20260316191544.2279-8-alifm@linux.ibm.com>
On Mon, 16 Mar 2026 12:15:42 -0700
Farhan Ali <alifm@linux.ibm.com> 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.
>
> Signed-off-by: Farhan Ali <alifm@linux.ibm.com>
> ---
> drivers/vfio/pci/vfio_pci_core.c | 2 ++
> drivers/vfio/pci/vfio_pci_priv.h | 9 ++++++++
> drivers/vfio/pci/vfio_pci_zdev.c | 36 ++++++++++++++++++++++++++++++++
> include/uapi/linux/vfio.h | 17 +++++++++++++++
> 4 files changed, 64 insertions(+)
>
> diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_core.c
> index d43745fe4c84..bbdb625e35ef 100644
> --- a/drivers/vfio/pci/vfio_pci_core.c
> +++ b/drivers/vfio/pci/vfio_pci_core.c
> @@ -1534,6 +1534,8 @@ int vfio_pci_core_ioctl_feature(struct vfio_device *device, u32 flags,
> return vfio_pci_core_feature_token(vdev, flags, arg, argsz);
> case VFIO_DEVICE_FEATURE_DMA_BUF:
> return vfio_pci_core_feature_dma_buf(vdev, flags, arg, argsz);
> + case VFIO_DEVICE_FEATURE_ZPCI_ERROR:
> + return vfio_pci_zdev_feature_err(device, flags, arg, argsz);
> default:
> return -ENOTTY;
> }
> diff --git a/drivers/vfio/pci/vfio_pci_priv.h b/drivers/vfio/pci/vfio_pci_priv.h
> index 27ac280f00b9..eed69926d8a1 100644
> --- a/drivers/vfio/pci/vfio_pci_priv.h
> +++ b/drivers/vfio/pci/vfio_pci_priv.h
> @@ -89,6 +89,8 @@ int vfio_pci_info_zdev_add_caps(struct vfio_pci_core_device *vdev,
> struct vfio_info_cap *caps);
> int vfio_pci_zdev_open_device(struct vfio_pci_core_device *vdev);
> void vfio_pci_zdev_close_device(struct vfio_pci_core_device *vdev);
> +int vfio_pci_zdev_feature_err(struct vfio_device *device, u32 flags,
> + void __user *arg, size_t argsz);
> #else
> static inline int vfio_pci_info_zdev_add_caps(struct vfio_pci_core_device *vdev,
> struct vfio_info_cap *caps)
> @@ -103,6 +105,13 @@ static inline int vfio_pci_zdev_open_device(struct vfio_pci_core_device *vdev)
>
> static inline void vfio_pci_zdev_close_device(struct vfio_pci_core_device *vdev)
> {}
> +
> +static inline int vfio_pci_zdev_feature_err(struct vfio_device *device,
> + u32 flags, void __user *arg,
> + size_t argsz)
> +{
> + return -ENODEV;
-ENOTTY
> +}
> #endif
>
> static inline bool vfio_pci_is_vga(struct pci_dev *pdev)
> diff --git a/drivers/vfio/pci/vfio_pci_zdev.c b/drivers/vfio/pci/vfio_pci_zdev.c
> index 2be37eab9279..d2748dd67c55 100644
> --- a/drivers/vfio/pci/vfio_pci_zdev.c
> +++ b/drivers/vfio/pci/vfio_pci_zdev.c
> @@ -141,6 +141,42 @@ int vfio_pci_info_zdev_add_caps(struct vfio_pci_core_device *vdev,
> return ret;
> }
>
> +int vfio_pci_zdev_feature_err(struct vfio_device *device, u32 flags,
> + void __user *arg, size_t argsz)
> +{
> + struct vfio_device_feature_zpci_err err;
> + struct vfio_pci_core_device *vdev;
> + struct zpci_dev *zdev;
> + int head = 0;
> + int ret;
> +
> + vdev = container_of(device, struct vfio_pci_core_device, vdev);
> + zdev = to_zpci(vdev->pdev);
> + if (!zdev)
> + return -ENODEV;
> +
> + ret = vfio_check_feature(flags, argsz, VFIO_DEVICE_FEATURE_GET,
> + sizeof(err));
> + if (ret != 1)
> + return ret;
> +
> + mutex_lock(&zdev->pending_errs_lock);
> + if (zdev->pending_errs.count) {
> + head = zdev->pending_errs.head % ZPCI_ERR_PENDING_MAX;
> + err.pec = zdev->pending_errs.err[head].pec;
> + zdev->pending_errs.head++;
> + zdev->pending_errs.count--;
> + err.pending_errors = zdev->pending_errs.count;
> + }
> + mutex_unlock(&zdev->pending_errs_lock);
> +
> + err.version = 1;
Returns uninitialized kernel data for case where there are no pending
errors, initialize err with = {};
> + if (copy_to_user(arg, &err, sizeof(err)))
> + return -EFAULT;
> +
> + return 0;
> +}
> +
> int vfio_pci_zdev_open_device(struct vfio_pci_core_device *vdev)
> {
> struct zpci_dev *zdev = to_zpci(vdev->pdev);
> diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h
> index bb7b89330d35..21b1473e4779 100644
> --- a/include/uapi/linux/vfio.h
> +++ b/include/uapi/linux/vfio.h
> @@ -1510,6 +1510,23 @@ struct vfio_device_feature_dma_buf {
> struct vfio_region_dma_range dma_ranges[] __counted_by(nr_ranges);
> };
>
> +/**
> + * VFIO_DEVICE_FEATURE_ZPCI_ERROR feature provides PCI error information to
> + * userspace for vfio-pci devices on s390x. On s390x PCI error recovery involves
> + * platform firmware and notification to operating system is done by
> + * architecture specific mechanism. Exposing this information to userspace
> + * allows userspace to take appropriate actions to handle an error on the
> + * device.
This should include some explicit discussion of how pending_errors in
interpreted, ie. pending _additional_ errors, userspace should read
until zero. Thanks,
Alex
> + */
> +
> +struct vfio_device_feature_zpci_err {
> + __u8 version;
> + __u8 pending_errors;
> + __u16 pec;
> +};
> +
> +#define VFIO_DEVICE_FEATURE_ZPCI_ERROR 12
> +
> /* -------- API for Type1 VFIO IOMMU -------- */
>
> /**
next prev parent reply other threads:[~2026-03-25 17:18 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-16 19:15 [PATCH v11 0/9] Error recovery for vfio-pci devices on s390x Farhan Ali
2026-03-16 19:15 ` [PATCH v11 1/9] PCI: Allow per function PCI slots Farhan Ali
2026-03-24 21:55 ` Bjorn Helgaas
2026-03-24 23:08 ` Farhan Ali
2026-03-24 23:20 ` Bjorn Helgaas
2026-03-16 19:15 ` [PATCH v11 2/9] s390/pci: Add architecture specific resource/bus address translation Farhan Ali
2026-03-24 23:06 ` Bjorn Helgaas
2026-03-24 23:47 ` Farhan Ali
2026-03-25 11:58 ` Ilpo Järvinen
2026-03-25 17:44 ` Farhan Ali
2026-03-16 19:15 ` [PATCH v11 3/9] PCI: Avoid saving config space state if inaccessible Farhan Ali
2026-03-24 21:40 ` Bjorn Helgaas
2026-03-24 22:38 ` Farhan Ali
2026-03-24 22:52 ` Bjorn Helgaas
2026-03-16 19:15 ` [PATCH v11 4/9] PCI: Add additional checks for flr reset Farhan Ali
2026-03-24 22:49 ` Bjorn Helgaas
2026-03-24 23:22 ` Farhan Ali
2026-03-25 16:25 ` Alex Williamson
2026-03-25 18:40 ` Farhan Ali
2026-03-16 19:15 ` [PATCH v11 5/9] s390/pci: Update the logic for detecting passthrough device Farhan Ali
2026-03-25 16:46 ` Alex Williamson
2026-03-16 19:15 ` [PATCH v11 6/9] s390/pci: Store PCI error information for passthrough devices Farhan Ali
2026-03-25 17:01 ` Alex Williamson
2026-03-25 18:06 ` Farhan Ali
2026-03-16 19:15 ` [PATCH v11 7/9] vfio-pci/zdev: Add a device feature for error information Farhan Ali
2026-03-25 17:18 ` Alex Williamson [this message]
2026-03-16 19:15 ` [PATCH v11 8/9] vfio: Add a reset_done callback for vfio-pci driver Farhan Ali
2026-03-25 17:30 ` Alex Williamson
2026-03-16 19:15 ` [PATCH v11 9/9] vfio: Remove the pcie check for VFIO_PCI_ERR_IRQ_INDEX Farhan Ali
2026-03-24 21:26 ` Bjorn Helgaas
2026-03-24 22:30 ` Farhan Ali
2026-03-25 17:50 ` Alex Williamson
2026-03-24 19:34 ` [PATCH v11 0/9] Error recovery for vfio-pci devices on s390x Farhan Ali
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=20260325111808.263aef2c@shazbot.org \
--to=alex@shazbot.org \
--cc=alifm@linux.ibm.com \
--cc=clg@redhat.com \
--cc=helgaas@kernel.org \
--cc=kbusch@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=lukas@wunner.de \
--cc=mjrosato@linux.ibm.com \
--cc=schnelle@linux.ibm.com \
--cc=stable@vger.kernel.org \
/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