|
|
902636 |
From ee9b03e774641fba8baaf85256706fcc5e8d8efa Mon Sep 17 00:00:00 2001
|
|
|
902636 |
From: Cornelia Huck <cohuck@redhat.com>
|
|
|
902636 |
Date: Tue, 23 Jun 2020 09:25:40 -0400
|
|
|
902636 |
Subject: [PATCH 06/12] vfio-ccw: Refactor ccw irq handler
|
|
|
902636 |
|
|
|
902636 |
RH-Author: Cornelia Huck <cohuck@redhat.com>
|
|
|
902636 |
Message-id: <20200623092543.358315-7-cohuck@redhat.com>
|
|
|
902636 |
Patchwork-id: 97695
|
|
|
902636 |
O-Subject: [RHEL-8.3.0 qemu-kvm PATCH 6/9] vfio-ccw: Refactor ccw irq handler
|
|
|
902636 |
Bugzilla: 1660916
|
|
|
902636 |
RH-Acked-by: Claudio Imbrenda <cimbrend@redhat.com>
|
|
|
902636 |
RH-Acked-by: David Hildenbrand <david@redhat.com>
|
|
|
902636 |
RH-Acked-by: Thomas Huth <thuth@redhat.com>
|
|
|
902636 |
|
|
|
902636 |
From: Eric Farman <farman@linux.ibm.com>
|
|
|
902636 |
|
|
|
902636 |
Make it easier to add new ones in the future.
|
|
|
902636 |
|
|
|
902636 |
Signed-off-by: Eric Farman <farman@linux.ibm.com>
|
|
|
902636 |
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
|
|
|
902636 |
Message-Id: <20200505125757.98209-5-farman@linux.ibm.com>
|
|
|
902636 |
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
|
|
|
902636 |
(cherry picked from commit 690e29b91102ac69810b35fe72cd90bc9fa1fff7)
|
|
|
902636 |
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
|
|
|
902636 |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
|
902636 |
---
|
|
|
902636 |
hw/vfio/ccw.c | 58 +++++++++++++++++++++++++++++++++++++--------------
|
|
|
902636 |
1 file changed, 42 insertions(+), 16 deletions(-)
|
|
|
902636 |
|
|
|
902636 |
diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c
|
|
|
902636 |
index 859ad646f1..94a0d9840d 100644
|
|
|
902636 |
--- a/hw/vfio/ccw.c
|
|
|
902636 |
+++ b/hw/vfio/ccw.c
|
|
|
902636 |
@@ -324,22 +324,36 @@ read_err:
|
|
|
902636 |
css_inject_io_interrupt(sch);
|
|
|
902636 |
}
|
|
|
902636 |
|
|
|
902636 |
-static void vfio_ccw_register_io_notifier(VFIOCCWDevice *vcdev, Error **errp)
|
|
|
902636 |
+static void vfio_ccw_register_irq_notifier(VFIOCCWDevice *vcdev,
|
|
|
902636 |
+ unsigned int irq,
|
|
|
902636 |
+ Error **errp)
|
|
|
902636 |
{
|
|
|
902636 |
VFIODevice *vdev = &vcdev->vdev;
|
|
|
902636 |
struct vfio_irq_info *irq_info;
|
|
|
902636 |
size_t argsz;
|
|
|
902636 |
int fd;
|
|
|
902636 |
+ EventNotifier *notifier;
|
|
|
902636 |
+ IOHandler *fd_read;
|
|
|
902636 |
+
|
|
|
902636 |
+ switch (irq) {
|
|
|
902636 |
+ case VFIO_CCW_IO_IRQ_INDEX:
|
|
|
902636 |
+ notifier = &vcdev->io_notifier;
|
|
|
902636 |
+ fd_read = vfio_ccw_io_notifier_handler;
|
|
|
902636 |
+ break;
|
|
|
902636 |
+ default:
|
|
|
902636 |
+ error_setg(errp, "vfio: Unsupported device irq(%d)", irq);
|
|
|
902636 |
+ return;
|
|
|
902636 |
+ }
|
|
|
902636 |
|
|
|
902636 |
- if (vdev->num_irqs < VFIO_CCW_IO_IRQ_INDEX + 1) {
|
|
|
902636 |
- error_setg(errp, "vfio: unexpected number of io irqs %u",
|
|
|
902636 |
+ if (vdev->num_irqs < irq + 1) {
|
|
|
902636 |
+ error_setg(errp, "vfio: unexpected number of irqs %u",
|
|
|
902636 |
vdev->num_irqs);
|
|
|
902636 |
return;
|
|
|
902636 |
}
|
|
|
902636 |
|
|
|
902636 |
argsz = sizeof(*irq_info);
|
|
|
902636 |
irq_info = g_malloc0(argsz);
|
|
|
902636 |
- irq_info->index = VFIO_CCW_IO_IRQ_INDEX;
|
|
|
902636 |
+ irq_info->index = irq;
|
|
|
902636 |
irq_info->argsz = argsz;
|
|
|
902636 |
if (ioctl(vdev->fd, VFIO_DEVICE_GET_IRQ_INFO,
|
|
|
902636 |
irq_info) < 0 || irq_info->count < 1) {
|
|
|
902636 |
@@ -347,37 +361,49 @@ static void vfio_ccw_register_io_notifier(VFIOCCWDevice *vcdev, Error **errp)
|
|
|
902636 |
goto out_free_info;
|
|
|
902636 |
}
|
|
|
902636 |
|
|
|
902636 |
- if (event_notifier_init(&vcdev->io_notifier, 0)) {
|
|
|
902636 |
+ if (event_notifier_init(notifier, 0)) {
|
|
|
902636 |
error_setg_errno(errp, errno,
|
|
|
902636 |
- "vfio: Unable to init event notifier for IO");
|
|
|
902636 |
+ "vfio: Unable to init event notifier for irq (%d)",
|
|
|
902636 |
+ irq);
|
|
|
902636 |
goto out_free_info;
|
|
|
902636 |
}
|
|
|
902636 |
|
|
|
902636 |
- fd = event_notifier_get_fd(&vcdev->io_notifier);
|
|
|
902636 |
- qemu_set_fd_handler(fd, vfio_ccw_io_notifier_handler, NULL, vcdev);
|
|
|
902636 |
+ fd = event_notifier_get_fd(notifier);
|
|
|
902636 |
+ qemu_set_fd_handler(fd, fd_read, NULL, vcdev);
|
|
|
902636 |
|
|
|
902636 |
- if (vfio_set_irq_signaling(vdev, VFIO_CCW_IO_IRQ_INDEX, 0,
|
|
|
902636 |
+ if (vfio_set_irq_signaling(vdev, irq, 0,
|
|
|
902636 |
VFIO_IRQ_SET_ACTION_TRIGGER, fd, errp)) {
|
|
|
902636 |
qemu_set_fd_handler(fd, NULL, NULL, vcdev);
|
|
|
902636 |
- event_notifier_cleanup(&vcdev->io_notifier);
|
|
|
902636 |
+ event_notifier_cleanup(notifier);
|
|
|
902636 |
}
|
|
|
902636 |
|
|
|
902636 |
out_free_info:
|
|
|
902636 |
g_free(irq_info);
|
|
|
902636 |
}
|
|
|
902636 |
|
|
|
902636 |
-static void vfio_ccw_unregister_io_notifier(VFIOCCWDevice *vcdev)
|
|
|
902636 |
+static void vfio_ccw_unregister_irq_notifier(VFIOCCWDevice *vcdev,
|
|
|
902636 |
+ unsigned int irq)
|
|
|
902636 |
{
|
|
|
902636 |
Error *err = NULL;
|
|
|
902636 |
+ EventNotifier *notifier;
|
|
|
902636 |
+
|
|
|
902636 |
+ switch (irq) {
|
|
|
902636 |
+ case VFIO_CCW_IO_IRQ_INDEX:
|
|
|
902636 |
+ notifier = &vcdev->io_notifier;
|
|
|
902636 |
+ break;
|
|
|
902636 |
+ default:
|
|
|
902636 |
+ error_report("vfio: Unsupported device irq(%d)", irq);
|
|
|
902636 |
+ return;
|
|
|
902636 |
+ }
|
|
|
902636 |
|
|
|
902636 |
- if (vfio_set_irq_signaling(&vcdev->vdev, VFIO_CCW_IO_IRQ_INDEX, 0,
|
|
|
902636 |
+ if (vfio_set_irq_signaling(&vcdev->vdev, irq, 0,
|
|
|
902636 |
VFIO_IRQ_SET_ACTION_TRIGGER, -1, &err)) {
|
|
|
902636 |
error_reportf_err(err, VFIO_MSG_PREFIX, vcdev->vdev.name);
|
|
|
902636 |
}
|
|
|
902636 |
|
|
|
902636 |
- qemu_set_fd_handler(event_notifier_get_fd(&vcdev->io_notifier),
|
|
|
902636 |
+ qemu_set_fd_handler(event_notifier_get_fd(notifier),
|
|
|
902636 |
NULL, NULL, vcdev);
|
|
|
902636 |
- event_notifier_cleanup(&vcdev->io_notifier);
|
|
|
902636 |
+ event_notifier_cleanup(notifier);
|
|
|
902636 |
}
|
|
|
902636 |
|
|
|
902636 |
static void vfio_ccw_get_region(VFIOCCWDevice *vcdev, Error **errp)
|
|
|
902636 |
@@ -565,7 +591,7 @@ static void vfio_ccw_realize(DeviceState *dev, Error **errp)
|
|
|
902636 |
goto out_region_err;
|
|
|
902636 |
}
|
|
|
902636 |
|
|
|
902636 |
- vfio_ccw_register_io_notifier(vcdev, &err;;
|
|
|
902636 |
+ vfio_ccw_register_irq_notifier(vcdev, VFIO_CCW_IO_IRQ_INDEX, &err;;
|
|
|
902636 |
if (err) {
|
|
|
902636 |
goto out_notifier_err;
|
|
|
902636 |
}
|
|
|
902636 |
@@ -594,7 +620,7 @@ static void vfio_ccw_unrealize(DeviceState *dev, Error **errp)
|
|
|
902636 |
S390CCWDeviceClass *cdc = S390_CCW_DEVICE_GET_CLASS(cdev);
|
|
|
902636 |
VFIOGroup *group = vcdev->vdev.group;
|
|
|
902636 |
|
|
|
902636 |
- vfio_ccw_unregister_io_notifier(vcdev);
|
|
|
902636 |
+ vfio_ccw_unregister_irq_notifier(vcdev, VFIO_CCW_IO_IRQ_INDEX);
|
|
|
902636 |
vfio_ccw_put_region(vcdev);
|
|
|
902636 |
vfio_ccw_put_device(vcdev);
|
|
|
902636 |
vfio_put_group(group);
|
|
|
902636 |
--
|
|
|
902636 |
2.27.0
|
|
|
902636 |
|