All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] vfio-ccw: Implement request notifier
@ 2020-11-20 18:15 Eric Farman
  2020-11-20 18:15 ` [PATCH v2 1/2] Update linux headers Eric Farman
  2020-11-20 18:15 ` [PATCH v2 2/2] vfio-ccw: Connect the device request notifier Eric Farman
  0 siblings, 2 replies; 3+ messages in thread
From: Eric Farman @ 2020-11-20 18:15 UTC (permalink / raw)
  To: Cornelia Huck, Thomas Huth, Alex Williamson
  Cc: Eric Farman, qemu-s390x, qemu-devel, Matthew Rosato

Updated QEMU code for the request notifier, to match version 2
of the kernel code [1]. No changes since the v1/RFC [2],
other than including Conny's r-b on patch 2 (Thank you!).

This registers the QEMU vfio-ccw code's ability to respond to
a request from the kernel to release the device, because of a
(probably fatal) device error that has removed it from the host
configuration, and thus its ability to be used by the guest.

[1] https://lore.kernel.org/kvm/20201120180740.87837-1-farman@linux.ibm.com/
[2] https://lore.kernel.org/qemu-devel/20201117032605.56831-1-farman@linux.ibm.com/

Eric Farman (2):
  Update linux headers
  vfio-ccw: Connect the device request notifier

 hw/vfio/ccw.c              | 40 ++++++++++++++++++++++++++++++++++----
 linux-headers/linux/vfio.h |  1 +
 2 files changed, 37 insertions(+), 4 deletions(-)

-- 
2.17.1



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v2 1/2] Update linux headers
  2020-11-20 18:15 [PATCH v2 0/2] vfio-ccw: Implement request notifier Eric Farman
@ 2020-11-20 18:15 ` Eric Farman
  2020-11-20 18:15 ` [PATCH v2 2/2] vfio-ccw: Connect the device request notifier Eric Farman
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Farman @ 2020-11-20 18:15 UTC (permalink / raw)
  To: Cornelia Huck, Thomas Huth, Alex Williamson
  Cc: Eric Farman, qemu-s390x, qemu-devel, Matthew Rosato

This is a placeholder for a proper run of scripts/update-linux-headers.sh

Signed-off-by: Eric Farman <farman@linux.ibm.com>
---
 linux-headers/linux/vfio.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/linux-headers/linux/vfio.h b/linux-headers/linux/vfio.h
index b92dcc4daf..609099e455 100644
--- a/linux-headers/linux/vfio.h
+++ b/linux-headers/linux/vfio.h
@@ -820,6 +820,7 @@ enum {
 enum {
 	VFIO_CCW_IO_IRQ_INDEX,
 	VFIO_CCW_CRW_IRQ_INDEX,
+	VFIO_CCW_REQ_IRQ_INDEX,
 	VFIO_CCW_NUM_IRQS
 };
 
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH v2 2/2] vfio-ccw: Connect the device request notifier
  2020-11-20 18:15 [PATCH v2 0/2] vfio-ccw: Implement request notifier Eric Farman
  2020-11-20 18:15 ` [PATCH v2 1/2] Update linux headers Eric Farman
@ 2020-11-20 18:15 ` Eric Farman
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Farman @ 2020-11-20 18:15 UTC (permalink / raw)
  To: Cornelia Huck, Thomas Huth, Alex Williamson
  Cc: Eric Farman, qemu-s390x, qemu-devel, Matthew Rosato

Now that the vfio-ccw code has a notifier interface to request that
a device be unplugged, let's wire that together.

Signed-off-by: Eric Farman <farman@linux.ibm.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
---
 hw/vfio/ccw.c | 40 ++++++++++++++++++++++++++++++++++++----
 1 file changed, 36 insertions(+), 4 deletions(-)

diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c
index d2755d7fc5..bc78a0ad76 100644
--- a/hw/vfio/ccw.c
+++ b/hw/vfio/ccw.c
@@ -49,6 +49,7 @@ struct VFIOCCWDevice {
     struct ccw_crw_region *crw_region;
     EventNotifier io_notifier;
     EventNotifier crw_notifier;
+    EventNotifier req_notifier;
     bool force_orb_pfch;
     bool warned_orb_pfch;
 };
@@ -287,6 +288,21 @@ static void vfio_ccw_crw_read(VFIOCCWDevice *vcdev)
     } while (1);
 }
 
+static void vfio_ccw_req_notifier_handler(void *opaque)
+{
+    VFIOCCWDevice *vcdev = opaque;
+    Error *err = NULL;
+
+    if (!event_notifier_test_and_clear(&vcdev->req_notifier)) {
+        return;
+    }
+
+    qdev_unplug(DEVICE(vcdev), &err);
+    if (err) {
+        warn_reportf_err(err, VFIO_MSG_PREFIX, vcdev->vdev.name);
+    }
+}
+
 static void vfio_ccw_crw_notifier_handler(void *opaque)
 {
     VFIOCCWDevice *vcdev = opaque;
@@ -386,6 +402,10 @@ static void vfio_ccw_register_irq_notifier(VFIOCCWDevice *vcdev,
         notifier = &vcdev->crw_notifier;
         fd_read = vfio_ccw_crw_notifier_handler;
         break;
+    case VFIO_CCW_REQ_IRQ_INDEX:
+        notifier = &vcdev->req_notifier;
+        fd_read = vfio_ccw_req_notifier_handler;
+        break;
     default:
         error_setg(errp, "vfio: Unsupported device irq(%d)", irq);
         return;
@@ -440,6 +460,9 @@ static void vfio_ccw_unregister_irq_notifier(VFIOCCWDevice *vcdev,
     case VFIO_CCW_CRW_IRQ_INDEX:
         notifier = &vcdev->crw_notifier;
         break;
+    case VFIO_CCW_REQ_IRQ_INDEX:
+        notifier = &vcdev->req_notifier;
+        break;
     default:
         error_report("vfio: Unsupported device irq(%d)", irq);
         return;
@@ -661,20 +684,28 @@ static void vfio_ccw_realize(DeviceState *dev, Error **errp)
 
     vfio_ccw_register_irq_notifier(vcdev, VFIO_CCW_IO_IRQ_INDEX, &err);
     if (err) {
-        goto out_notifier_err;
+        goto out_io_notifier_err;
     }
 
     if (vcdev->crw_region) {
         vfio_ccw_register_irq_notifier(vcdev, VFIO_CCW_CRW_IRQ_INDEX, &err);
         if (err) {
-            vfio_ccw_unregister_irq_notifier(vcdev, VFIO_CCW_IO_IRQ_INDEX);
-            goto out_notifier_err;
+            goto out_crw_notifier_err;
         }
     }
 
+    vfio_ccw_register_irq_notifier(vcdev, VFIO_CCW_REQ_IRQ_INDEX, &err);
+    if (err) {
+        goto out_req_notifier_err;
+    }
+
     return;
 
-out_notifier_err:
+out_req_notifier_err:
+    vfio_ccw_unregister_irq_notifier(vcdev, VFIO_CCW_CRW_IRQ_INDEX);
+out_crw_notifier_err:
+    vfio_ccw_unregister_irq_notifier(vcdev, VFIO_CCW_IO_IRQ_INDEX);
+out_io_notifier_err:
     vfio_ccw_put_region(vcdev);
 out_region_err:
     vfio_ccw_put_device(vcdev);
@@ -696,6 +727,7 @@ static void vfio_ccw_unrealize(DeviceState *dev)
     S390CCWDeviceClass *cdc = S390_CCW_DEVICE_GET_CLASS(cdev);
     VFIOGroup *group = vcdev->vdev.group;
 
+    vfio_ccw_unregister_irq_notifier(vcdev, VFIO_CCW_REQ_IRQ_INDEX);
     vfio_ccw_unregister_irq_notifier(vcdev, VFIO_CCW_CRW_IRQ_INDEX);
     vfio_ccw_unregister_irq_notifier(vcdev, VFIO_CCW_IO_IRQ_INDEX);
     vfio_ccw_put_region(vcdev);
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-11-20 18:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-20 18:15 [PATCH v2 0/2] vfio-ccw: Implement request notifier Eric Farman
2020-11-20 18:15 ` [PATCH v2 1/2] Update linux headers Eric Farman
2020-11-20 18:15 ` [PATCH v2 2/2] vfio-ccw: Connect the device request notifier Eric Farman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.