Commit 2e3d8d71 authored by Tony Krowiak's avatar Tony Krowiak Committed by Alexander Gordeev
Browse files

s390/vfio-ap: wire in the vfio_device_ops request callback



The mdev device is being removed, so pass the request to userspace to
ask for a graceful cleanup. This should free up the thread that
would otherwise loop waiting for the device to be fully released.

Signed-off-by: default avatarTony Krowiak <akrowiak@linux.ibm.com>
Reviewed-by: default avatarCédric Le Goater <clg@redhat.com>
Reviewed-by: default avatarMatthew Rosato <mjrosato@linux.ibm.com>
Tested-by: default avatarMatthew Rosato <mjrosato@linux.ibm.com>
Acked-by: default avatarAlex Williamson <alex.williamson@redhat.com>
Link: https://lore.kernel.org/r/20230530223538.279198-4-akrowiak@linux.ibm.com


Signed-off-by: default avatarAlexander Gordeev <agordeev@linux.ibm.com>
parent bf48961f
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -1736,6 +1736,26 @@ static void vfio_ap_mdev_close_device(struct vfio_device *vdev)
	vfio_ap_mdev_unset_kvm(matrix_mdev);
}

static void vfio_ap_mdev_request(struct vfio_device *vdev, unsigned int count)
{
	struct device *dev = vdev->dev;
	struct ap_matrix_mdev *matrix_mdev;

	matrix_mdev = container_of(vdev, struct ap_matrix_mdev, vdev);

	if (matrix_mdev->req_trigger) {
		if (!(count % 10))
			dev_notice_ratelimited(dev,
					       "Relaying device request to user (#%u)\n",
					       count);

		eventfd_signal(matrix_mdev->req_trigger, 1);
	} else if (count == 0) {
		dev_notice(dev,
			   "No device request registered, blocked until released by user\n");
	}
}

static int vfio_ap_mdev_get_device_info(unsigned long arg)
{
	unsigned long minsz;
@@ -1955,6 +1975,7 @@ static const struct vfio_device_ops vfio_ap_matrix_dev_ops = {
	.bind_iommufd = vfio_iommufd_emulated_bind,
	.unbind_iommufd = vfio_iommufd_emulated_unbind,
	.attach_ioas = vfio_iommufd_emulated_attach_ioas,
	.request = vfio_ap_mdev_request
};

static struct mdev_driver vfio_ap_matrix_driver = {