|
|
ddf19c |
From 58edd0fba4d9e98edfeb16139467d6035a1f4e61 Mon Sep 17 00:00:00 2001
|
|
|
ddf19c |
From: Cornelia Huck <cohuck@redhat.com>
|
|
|
ddf19c |
Date: Tue, 23 Jun 2020 09:25:42 -0400
|
|
|
ddf19c |
Subject: [PATCH 08/12] vfio-ccw: Add support for the CRW region and IRQ
|
|
|
ddf19c |
|
|
|
ddf19c |
RH-Author: Cornelia Huck <cohuck@redhat.com>
|
|
|
ddf19c |
Message-id: <20200623092543.358315-9-cohuck@redhat.com>
|
|
|
ddf19c |
Patchwork-id: 97698
|
|
|
ddf19c |
O-Subject: [RHEL-8.3.0 qemu-kvm PATCH 8/9] vfio-ccw: Add support for the CRW region and IRQ
|
|
|
ddf19c |
Bugzilla: 1660916
|
|
|
ddf19c |
RH-Acked-by: Claudio Imbrenda <cimbrend@redhat.com>
|
|
|
ddf19c |
RH-Acked-by: David Hildenbrand <david@redhat.com>
|
|
|
ddf19c |
RH-Acked-by: Thomas Huth <thuth@redhat.com>
|
|
|
ddf19c |
|
|
|
ddf19c |
From: Farhan Ali <alifm@linux.ibm.com>
|
|
|
ddf19c |
|
|
|
ddf19c |
The crw region can be used to obtain information about
|
|
|
ddf19c |
Channel Report Words (CRW) from vfio-ccw driver.
|
|
|
ddf19c |
|
|
|
ddf19c |
Currently only channel-path related CRWs are passed to
|
|
|
ddf19c |
QEMU from vfio-ccw driver.
|
|
|
ddf19c |
|
|
|
ddf19c |
Signed-off-by: Farhan Ali <alifm@linux.ibm.com>
|
|
|
ddf19c |
Signed-off-by: Eric Farman <farman@linux.ibm.com>
|
|
|
ddf19c |
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
|
|
|
ddf19c |
Message-Id: <20200505125757.98209-7-farman@linux.ibm.com>
|
|
|
ddf19c |
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
|
|
|
ddf19c |
(cherry picked from commit f030532f2ad6eeb200034915e9c6357cce81b538)
|
|
|
ddf19c |
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
|
|
|
ddf19c |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
|
ddf19c |
---
|
|
|
ddf19c |
hw/vfio/ccw.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
ddf19c |
1 file changed, 73 insertions(+)
|
|
|
ddf19c |
|
|
|
ddf19c |
diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c
|
|
|
ddf19c |
index 94a0d9840d..b72a505893 100644
|
|
|
ddf19c |
--- a/hw/vfio/ccw.c
|
|
|
ddf19c |
+++ b/hw/vfio/ccw.c
|
|
|
ddf19c |
@@ -44,7 +44,11 @@ struct VFIOCCWDevice {
|
|
|
ddf19c |
uint64_t schib_region_size;
|
|
|
ddf19c |
uint64_t schib_region_offset;
|
|
|
ddf19c |
struct ccw_schib_region *schib_region;
|
|
|
ddf19c |
+ uint64_t crw_region_size;
|
|
|
ddf19c |
+ uint64_t crw_region_offset;
|
|
|
ddf19c |
+ struct ccw_crw_region *crw_region;
|
|
|
ddf19c |
EventNotifier io_notifier;
|
|
|
ddf19c |
+ EventNotifier crw_notifier;
|
|
|
ddf19c |
bool force_orb_pfch;
|
|
|
ddf19c |
bool warned_orb_pfch;
|
|
|
ddf19c |
};
|
|
|
ddf19c |
@@ -254,6 +258,44 @@ static void vfio_ccw_reset(DeviceState *dev)
|
|
|
ddf19c |
ioctl(vcdev->vdev.fd, VFIO_DEVICE_RESET);
|
|
|
ddf19c |
}
|
|
|
ddf19c |
|
|
|
ddf19c |
+static void vfio_ccw_crw_read(VFIOCCWDevice *vcdev)
|
|
|
ddf19c |
+{
|
|
|
ddf19c |
+ struct ccw_crw_region *region = vcdev->crw_region;
|
|
|
ddf19c |
+ CRW crw;
|
|
|
ddf19c |
+ int size;
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+ /* Keep reading CRWs as long as data is returned */
|
|
|
ddf19c |
+ do {
|
|
|
ddf19c |
+ memset(region, 0, sizeof(*region));
|
|
|
ddf19c |
+ size = pread(vcdev->vdev.fd, region, vcdev->crw_region_size,
|
|
|
ddf19c |
+ vcdev->crw_region_offset);
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+ if (size == -1) {
|
|
|
ddf19c |
+ error_report("vfio-ccw: Read crw region failed with errno=%d",
|
|
|
ddf19c |
+ errno);
|
|
|
ddf19c |
+ break;
|
|
|
ddf19c |
+ }
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+ if (region->crw == 0) {
|
|
|
ddf19c |
+ /* No more CRWs to queue */
|
|
|
ddf19c |
+ break;
|
|
|
ddf19c |
+ }
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+ memcpy(&crw, ®ion->crw, sizeof(CRW));
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+ css_crw_add_to_queue(crw);
|
|
|
ddf19c |
+ } while (1);
|
|
|
ddf19c |
+}
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+static void vfio_ccw_crw_notifier_handler(void *opaque)
|
|
|
ddf19c |
+{
|
|
|
ddf19c |
+ VFIOCCWDevice *vcdev = opaque;
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+ while (event_notifier_test_and_clear(&vcdev->crw_notifier)) {
|
|
|
ddf19c |
+ vfio_ccw_crw_read(vcdev);
|
|
|
ddf19c |
+ }
|
|
|
ddf19c |
+}
|
|
|
ddf19c |
+
|
|
|
ddf19c |
static void vfio_ccw_io_notifier_handler(void *opaque)
|
|
|
ddf19c |
{
|
|
|
ddf19c |
VFIOCCWDevice *vcdev = opaque;
|
|
|
ddf19c |
@@ -340,6 +382,10 @@ static void vfio_ccw_register_irq_notifier(VFIOCCWDevice *vcdev,
|
|
|
ddf19c |
notifier = &vcdev->io_notifier;
|
|
|
ddf19c |
fd_read = vfio_ccw_io_notifier_handler;
|
|
|
ddf19c |
break;
|
|
|
ddf19c |
+ case VFIO_CCW_CRW_IRQ_INDEX:
|
|
|
ddf19c |
+ notifier = &vcdev->crw_notifier;
|
|
|
ddf19c |
+ fd_read = vfio_ccw_crw_notifier_handler;
|
|
|
ddf19c |
+ break;
|
|
|
ddf19c |
default:
|
|
|
ddf19c |
error_setg(errp, "vfio: Unsupported device irq(%d)", irq);
|
|
|
ddf19c |
return;
|
|
|
ddf19c |
@@ -391,6 +437,9 @@ static void vfio_ccw_unregister_irq_notifier(VFIOCCWDevice *vcdev,
|
|
|
ddf19c |
case VFIO_CCW_IO_IRQ_INDEX:
|
|
|
ddf19c |
notifier = &vcdev->io_notifier;
|
|
|
ddf19c |
break;
|
|
|
ddf19c |
+ case VFIO_CCW_CRW_IRQ_INDEX:
|
|
|
ddf19c |
+ notifier = &vcdev->crw_notifier;
|
|
|
ddf19c |
+ break;
|
|
|
ddf19c |
default:
|
|
|
ddf19c |
error_report("vfio: Unsupported device irq(%d)", irq);
|
|
|
ddf19c |
return;
|
|
|
ddf19c |
@@ -468,10 +517,24 @@ static void vfio_ccw_get_region(VFIOCCWDevice *vcdev, Error **errp)
|
|
|
ddf19c |
vcdev->schib_region = g_malloc(info->size);
|
|
|
ddf19c |
}
|
|
|
ddf19c |
|
|
|
ddf19c |
+ ret = vfio_get_dev_region_info(vdev, VFIO_REGION_TYPE_CCW,
|
|
|
ddf19c |
+ VFIO_REGION_SUBTYPE_CCW_CRW, &info;;
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+ if (!ret) {
|
|
|
ddf19c |
+ vcdev->crw_region_size = info->size;
|
|
|
ddf19c |
+ if (sizeof(*vcdev->crw_region) != vcdev->crw_region_size) {
|
|
|
ddf19c |
+ error_setg(errp, "vfio: Unexpected size of the CRW region");
|
|
|
ddf19c |
+ goto out_err;
|
|
|
ddf19c |
+ }
|
|
|
ddf19c |
+ vcdev->crw_region_offset = info->offset;
|
|
|
ddf19c |
+ vcdev->crw_region = g_malloc(info->size);
|
|
|
ddf19c |
+ }
|
|
|
ddf19c |
+
|
|
|
ddf19c |
g_free(info);
|
|
|
ddf19c |
return;
|
|
|
ddf19c |
|
|
|
ddf19c |
out_err:
|
|
|
ddf19c |
+ g_free(vcdev->crw_region);
|
|
|
ddf19c |
g_free(vcdev->schib_region);
|
|
|
ddf19c |
g_free(vcdev->async_cmd_region);
|
|
|
ddf19c |
g_free(vcdev->io_region);
|
|
|
ddf19c |
@@ -481,6 +544,7 @@ out_err:
|
|
|
ddf19c |
|
|
|
ddf19c |
static void vfio_ccw_put_region(VFIOCCWDevice *vcdev)
|
|
|
ddf19c |
{
|
|
|
ddf19c |
+ g_free(vcdev->crw_region);
|
|
|
ddf19c |
g_free(vcdev->schib_region);
|
|
|
ddf19c |
g_free(vcdev->async_cmd_region);
|
|
|
ddf19c |
g_free(vcdev->io_region);
|
|
|
ddf19c |
@@ -596,6 +660,14 @@ static void vfio_ccw_realize(DeviceState *dev, Error **errp)
|
|
|
ddf19c |
goto out_notifier_err;
|
|
|
ddf19c |
}
|
|
|
ddf19c |
|
|
|
ddf19c |
+ if (vcdev->crw_region) {
|
|
|
ddf19c |
+ vfio_ccw_register_irq_notifier(vcdev, VFIO_CCW_CRW_IRQ_INDEX, &err;;
|
|
|
ddf19c |
+ if (err) {
|
|
|
ddf19c |
+ vfio_ccw_unregister_irq_notifier(vcdev, VFIO_CCW_IO_IRQ_INDEX);
|
|
|
ddf19c |
+ goto out_notifier_err;
|
|
|
ddf19c |
+ }
|
|
|
ddf19c |
+ }
|
|
|
ddf19c |
+
|
|
|
ddf19c |
return;
|
|
|
ddf19c |
|
|
|
ddf19c |
out_notifier_err:
|
|
|
ddf19c |
@@ -620,6 +692,7 @@ static void vfio_ccw_unrealize(DeviceState *dev, Error **errp)
|
|
|
ddf19c |
S390CCWDeviceClass *cdc = S390_CCW_DEVICE_GET_CLASS(cdev);
|
|
|
ddf19c |
VFIOGroup *group = vcdev->vdev.group;
|
|
|
ddf19c |
|
|
|
ddf19c |
+ vfio_ccw_unregister_irq_notifier(vcdev, VFIO_CCW_CRW_IRQ_INDEX);
|
|
|
ddf19c |
vfio_ccw_unregister_irq_notifier(vcdev, VFIO_CCW_IO_IRQ_INDEX);
|
|
|
ddf19c |
vfio_ccw_put_region(vcdev);
|
|
|
ddf19c |
vfio_ccw_put_device(vcdev);
|
|
|
ddf19c |
--
|
|
|
ddf19c |
2.27.0
|
|
|
ddf19c |
|