Re: [PATCH v3 06/10] s390/pci: Update the logic for detecting passthrough device

Niklas Schnelle
2025-09-15T09:22:30Z

On Thu, 2025-09-11 at 11:33 -0700, Farhan Ali wrote:
> 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.
>
> Signed-off-by: Farhan Ali <alifm@linux.ibm.com>
> ---
> arch/s390/include/asm/pci.h | 1 +
> arch/s390/pci/pci_event.c | 14 ++++----------
> drivers/vfio/pci/vfio_pci_zdev.c | 9 ++++++++-
> 3 files changed, 13 insertions(+), 11 deletions(-)
>
> diff --git a/arch/s390/include/asm/pci.h b/arch/s390/include/asm/pci.h
> index aed19a1aa9d7..f47f62fc3bfd 100644
> --- a/arch/s390/include/asm/pci.h
> +++ b/arch/s390/include/asm/pci.h
> @@ -169,6 +169,7 @@ struct zpci_dev {
>
> char res_name[16];
> bool mio_capable;
> + bool mediated_recovery;
> struct zpci_bar_struct bars[PCI_STD_NUM_BARS];
>
> u64 start_dma; /* Start of available DMA addresses */
> diff --git a/arch/s390/pci/pci_event.c b/arch/s390/pci/pci_event.c
> index d930416d4c90..541d536be052 100644
> --- a/arch/s390/pci/pci_event.c
> +++ b/arch/s390/pci/pci_event.c
> @@ -61,16 +61,10 @@ static inline bool ers_result_indicates_abort(pci_ers_result_t ers_res)
> }
> }
>
> -static bool is_passed_through(struct pci_dev *pdev)
> +static bool needs_mediated_recovery(struct pci_dev *pdev)
> {
> struct zpci_dev *zdev = to_zpci(pdev);
> - bool ret;
> -
> - mutex_lock(&zdev->kzdev_lock);
> - ret = !!zdev->kzdev;
> - mutex_unlock(&zdev->kzdev_lock);
> -
> - return ret;
> + return zdev->mediated_recovery;
> }
>
--- snip ---

Looks good to me.

Reviewed-by: Niklas Schnelle <schnelle@linux.ibm.com>