[PATCH v7 0/2] Error recovery for zPCI passthrough devices

Farhan Ali posted 2 patches 1 month, 2 weeks ago
Failed in applying to current master (apply log)
hw/s390x/s390-pci-bus.c          |  21 ++++++
hw/s390x/s390-pci-vfio-stubs.c   |   6 ++
hw/s390x/s390-pci-vfio.c         | 123 +++++++++++++++++++++++++++++++
include/hw/s390x/s390-pci-bus.h  |   1 +
include/hw/s390x/s390-pci-vfio.h |   1 +
5 files changed, 152 insertions(+)
[PATCH v7 0/2] Error recovery for zPCI passthrough devices
Posted by Farhan Ali 1 month, 2 weeks ago
Hi,

This patch series introduces support for error recovery for passthrough PCI
devices on System Z (s390x). This is the user space component for the Linux
kernel patches [1]. The kernel patches were merged for 7.3 release.

The current design for QEMU updates the callback for vfio error notifier to
an s390x specific error handler if the kernel supports the new device
feature VFIO_DEVICE_FEATURE_ZPCI_ERROR, for s390 vfio-pci devices. So now
on an eventfd notification for error notifier it will invoke the s390x
specific error handler.  The s390x error handler will retrieve the
architecture specific PCI error information and inject the information into
the guest. Once the guest receives the error information, the guest drivers
will drive the error recovery.  Typically recovery involves a device reset
which translate to CLP disable/enable cycle for the device.

I would appreciate some feedback on this patch series.

Thanks 
Farhan

[1] https://lore.kernel.org/all/20260818164326.387bb27b@shazbot.org/

ChangeLog
---------
v6 https://lore.kernel.org/all/20260922171756.920-1-alifm@linux.ibm.com/
v6 -> v7
    - Address Matt's feedback.
    - Add an explicit check for pci_aer (patch 1).
    - Change return code for s390_pci_get_feature_err() to return <0 on error
    and 0 (on ENOMSG) or 1 on success as suggested by Matt.
    - Use common code function pci_device_reset() as it will invoke the 
    VFIO_RESET_DEVICE ioctl.
    - Change state from ZPCI_FS_ERROR to ZPCI_FS_DISABLED on a reset from error state.


v5 https://lore.kernel.org/all/20260914174420.12309-1-alifm@linux.ibm.com/
v5 -> v6
    - Address Cedric's feedback (patch 1).
    - Update error handling to follow QEMU style (patch 1).
    - Rebase on master.
    - Remove linux-headers update as latest QEMU master has the VFIO headers
    merged.

v4 https://lore.kernel.org/all/20260831183151.12626-1-alifm@linux.ibm.com/
v4 -> v5
    - Remove err_handler() callback in vfio pci core.
    - Update the vfio error notifier callback to an s390x specific callback
    for s390x devices
    - Include linux headers for 7.3-rc3.
v3 https://lore.kernel.org/qemu-devel/20250925174852.1302-1-alifm@linux.ibm.com/
v3 -> v4
    - Include linux headers for 7.3-rc1.
    - Rework VFIO API changes based on the kernel API (patch 3).
    - Address Markus's comments from v3 (patch 2).

v2 https://lore.kernel.org/qemu-devel/20250825212434.2255-1-alifm@linux.ibm.com/
v2 -> v3
    - Update arch_err_handler to err_handler and include Error ** in
    function definition. (patch 2)

    - Introduce helper function to hide the internal indirection of device_feature()
    (patch 3)

    - Update function definitions to include Error ** (patch 4)
    


v1 https://lore.kernel.org/qemu-devel/20250813174152.1238-1-alifm@linux.ibm.com/
v1 -> v2
   - Use VFIO_DEVICE_FEATURE ioctl to get device error information.
   (Based on Alex's feedback on kernel series)

Farhan Ali (2):
  s390x/pci: Add PCI error handling for vfio pci devices
  s390x/pci: Reset a device in error state

 hw/s390x/s390-pci-bus.c          |  21 ++++++
 hw/s390x/s390-pci-vfio-stubs.c   |   6 ++
 hw/s390x/s390-pci-vfio.c         | 123 +++++++++++++++++++++++++++++++
 include/hw/s390x/s390-pci-bus.h  |   1 +
 include/hw/s390x/s390-pci-vfio.h |   1 +
 5 files changed, 152 insertions(+)

-- 
2.43.0
Re: [PATCH v7 0/2] Error recovery for zPCI passthrough devices
Posted by Matthew Rosato 1 month, 2 weeks ago
On 10/5/26 1:43 PM, Farhan Ali wrote:
> Hi,
> 
> This patch series introduces support for error recovery for passthrough PCI
> devices on System Z (s390x). This is the user space component for the Linux
> kernel patches [1]. The kernel patches were merged for 7.3 release.
> 
> The current design for QEMU updates the callback for vfio error notifier to
> an s390x specific error handler if the kernel supports the new device
> feature VFIO_DEVICE_FEATURE_ZPCI_ERROR, for s390 vfio-pci devices. So now
> on an eventfd notification for error notifier it will invoke the s390x
> specific error handler.  The s390x error handler will retrieve the
> architecture specific PCI error information and inject the information into
> the guest. Once the guest receives the error information, the guest drivers
> will drive the error recovery.  Typically recovery involves a device reset
> which translate to CLP disable/enable cycle for the device.
> 
> I would appreciate some feedback on this patch series.
> 
> Thanks 
> Farhan

@Eric: Series LGTM at this point, let's give Cédric and/or Alex some
time to look too.

This series should also either go after Konstantin's migration series or
at least we should take my patch from that series (s390x/pci: implement
IOMMU replay) to ensure that is in place prior to enabling this recovery
feature; basically, we want that patch with whichever feature lands first.

Thanks,
Matt


Re: [PATCH v7 0/2] Error recovery for zPCI passthrough devices
Posted by Cédric Le Goater 1 month, 2 weeks ago
On 10/5/26 23:44, Matthew Rosato wrote:
> On 10/5/26 1:43 PM, Farhan Ali wrote:
>> Hi,
>>
>> This patch series introduces support for error recovery for passthrough PCI
>> devices on System Z (s390x). This is the user space component for the Linux
>> kernel patches [1]. The kernel patches were merged for 7.3 release.
>>
>> The current design for QEMU updates the callback for vfio error notifier to
>> an s390x specific error handler if the kernel supports the new device
>> feature VFIO_DEVICE_FEATURE_ZPCI_ERROR, for s390 vfio-pci devices. So now
>> on an eventfd notification for error notifier it will invoke the s390x
>> specific error handler.  The s390x error handler will retrieve the
>> architecture specific PCI error information and inject the information into
>> the guest. Once the guest receives the error information, the guest drivers
>> will drive the error recovery.  Typically recovery involves a device reset
>> which translate to CLP disable/enable cycle for the device.
>>
>> I would appreciate some feedback on this patch series.
>>
>> Thanks
>> Farhan
> 
> @Eric: Series LGTM at this point, let's give Cédric and/or Alex some
> time to look too.


Looks OK to me. The ERRP_GUARD() is not useful anymore but it is minor.

Thanks,

C.


Re: [PATCH v7 0/2] Error recovery for zPCI passthrough devices
Posted by Eric Farman 1 month, 2 weeks ago

On 10/7/26 2:48 AM, Cédric Le Goater wrote:
> On 10/5/26 23:44, Matthew Rosato wrote:
>> On 10/5/26 1:43 PM, Farhan Ali wrote:
>>> Hi,
>>>
>>> This patch series introduces support for error recovery for 
>>> passthrough PCI
>>> devices on System Z (s390x). This is the user space component for the 
>>> Linux
>>> kernel patches [1]. The kernel patches were merged for 7.3 release.
>>>
>>> The current design for QEMU updates the callback for vfio error 
>>> notifier to
>>> an s390x specific error handler if the kernel supports the new device
>>> feature VFIO_DEVICE_FEATURE_ZPCI_ERROR, for s390 vfio-pci devices. So 
>>> now
>>> on an eventfd notification for error notifier it will invoke the s390x
>>> specific error handler.  The s390x error handler will retrieve the
>>> architecture specific PCI error information and inject the 
>>> information into
>>> the guest. Once the guest receives the error information, the guest 
>>> drivers
>>> will drive the error recovery.  Typically recovery involves a device 
>>> reset
>>> which translate to CLP disable/enable cycle for the device.
>>>
>>> I would appreciate some feedback on this patch series.
>>>
>>> Thanks
>>> Farhan
>>
>> @Eric: Series LGTM at this point, let's give Cédric and/or Alex some
>> time to look too.
> 
> 
> Looks OK to me. The ERRP_GUARD() is not useful anymore but it is minor.
> 
> Thanks,
> 
> C.
> 

Thanks, all! Applied to the s390x queue for 11.2