From: Eric Farman <farman@linux.ibm.com>
To: qemu-devel@nongnu.org, qemu-s390x@nongnu.org
Cc: Halil Pasic <pasic@linux.ibm.com>,
Jason Herne <jjherne@linux.ibm.com>,
Eric Farman <farman@linux.ibm.com>,
Cornelia Huck <cohuck@redhat.com>,
Jared Rossi <jrossi@linux.ibm.com>
Subject: [PATCH v3 7/7] vfio-ccw: Add support for the CRW irq
Date: Fri, 17 Apr 2020 04:34:40 +0200 [thread overview]
Message-ID: <20200417023440.70514-8-farman@linux.ibm.com> (raw)
In-Reply-To: <20200417023440.70514-1-farman@linux.ibm.com>
From: Farhan Ali <alifm@linux.ibm.com>
The CRW irq will be used by vfio-ccw to notify the userspace
about any CRWs the userspace needs to handle. Let's add support
for it.
Signed-off-by: Farhan Ali <alifm@linux.ibm.com>
Signed-off-by: Eric Farman <farman@linux.ibm.com>
---
Notes:
v2->v3:
- Remove "size==0" check in CRW notifier [CH]
- Remove intermediate rsc/erc variables, use css_queue_crw_cont() [CH]
- s/crw0/crw/ [CH]
v1->v2:
- Add a loop to continually read region while data is
present, queueing CRWs as found [CH]
v0->v1: [EF]
- Check vcdev->crw_region before registering the irq,
in case host kernel does not have matching support
- Split the refactoring changes to an earlier (new) patch
(and don't remove the "num_irqs" check in the register
routine, but adjust it to the check the input variable)
- Don't revert the cool vfio_set_irq_signaling() stuff
- Unregister CRW IRQ before IO IRQ in unrealize
- s/crw1/crw0/
hw/vfio/ccw.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c
index ee3415a64a..cb4a331ced 100644
--- a/hw/vfio/ccw.c
+++ b/hw/vfio/ccw.c
@@ -48,6 +48,7 @@ struct VFIOCCWDevice {
uint64_t crw_region_offset;
struct ccw_crw_region *crw_region;
EventNotifier io_notifier;
+ EventNotifier crw_notifier;
bool force_orb_pfch;
bool warned_orb_pfch;
};
@@ -264,6 +265,39 @@ static void vfio_ccw_reset(DeviceState *dev)
ioctl(vcdev->vdev.fd, VFIO_DEVICE_RESET);
}
+static void vfio_ccw_crw_notifier_handler(void *opaque)
+{
+ VFIOCCWDevice *vcdev = opaque;
+ struct ccw_crw_region *region = vcdev->crw_region;
+ CRW crw;
+ int size;
+
+ if (!event_notifier_test_and_clear(&vcdev->crw_notifier)) {
+ return;
+ }
+
+ do {
+ memset(region, 0, sizeof(*region));
+ size = pread(vcdev->vdev.fd, region, vcdev->crw_region_size,
+ vcdev->crw_region_offset);
+
+ if (size == -1) {
+ error_report("vfio-ccw: Read crw region failed with errno=%d",
+ errno);
+ break;
+ }
+
+ if (region->crw == 0) {
+ /* No more CRWs to queue */
+ break;
+ }
+
+ memcpy(&crw, ®ion->crw, sizeof(CRW));
+
+ css_queue_crw_cont(crw);
+ } while (1);
+}
+
static void vfio_ccw_io_notifier_handler(void *opaque)
{
VFIOCCWDevice *vcdev = opaque;
@@ -350,6 +384,10 @@ static void vfio_ccw_register_irq_notifier(VFIOCCWDevice *vcdev,
notifier = &vcdev->io_notifier;
fd_read = vfio_ccw_io_notifier_handler;
break;
+ case VFIO_CCW_CRW_IRQ_INDEX:
+ notifier = &vcdev->crw_notifier;
+ fd_read = vfio_ccw_crw_notifier_handler;
+ break;
default:
error_setg(errp, "vfio: Unsupported device irq(%d)", irq);
return;
@@ -401,6 +439,9 @@ static void vfio_ccw_unregister_irq_notifier(VFIOCCWDevice *vcdev,
case VFIO_CCW_IO_IRQ_INDEX:
notifier = &vcdev->io_notifier;
break;
+ case VFIO_CCW_CRW_IRQ_INDEX:
+ notifier = &vcdev->crw_notifier;
+ break;
default:
error_report("vfio: Unsupported device irq(%d)", irq);
return;
@@ -621,6 +662,14 @@ static void vfio_ccw_realize(DeviceState *dev, Error **errp)
goto out_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;
+ }
+ }
+
return;
out_notifier_err:
@@ -645,6 +694,7 @@ static void vfio_ccw_unrealize(DeviceState *dev, Error **errp)
S390CCWDeviceClass *cdc = S390_CCW_DEVICE_GET_CLASS(cdev);
VFIOGroup *group = vcdev->vdev.group;
+ 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);
vfio_ccw_put_device(vcdev);
--
2.17.1
next prev parent reply other threads:[~2020-04-17 2:36 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-17 2:34 [PATCH v3 0/7] s390x/vfio-ccw: Channel Path Handling [QEMU] Eric Farman
2020-04-17 2:34 ` [PATCH v3 1/7] linux-headers: update Eric Farman
2020-04-17 2:34 ` [PATCH v3 2/7] vfio-ccw: Refactor cleanup of regions Eric Farman
2020-04-17 2:34 ` [PATCH v3 3/7] vfio-ccw: Add support for the schib region Eric Farman
2020-04-22 11:36 ` Cornelia Huck
2020-04-22 12:17 ` Eric Farman
2020-04-17 2:34 ` [PATCH v3 4/7] vfio-ccw: Add support for the crw region Eric Farman
2020-04-21 12:21 ` Cornelia Huck
2020-04-21 12:57 ` Eric Farman
2020-04-17 2:34 ` [PATCH v3 5/7] vfio-ccw: Refactor ccw irq handler Eric Farman
2020-04-17 2:34 ` [PATCH v3 6/7] s390x/css: Refactor the css_queue_crw() routine Eric Farman
2020-04-21 12:28 ` Cornelia Huck
2020-04-21 13:04 ` Eric Farman
2020-04-17 2:34 ` Eric Farman [this message]
2020-04-22 10:38 ` [PATCH v3 7/7] vfio-ccw: Add support for the CRW irq Cornelia Huck
2020-04-17 3:25 ` [PATCH v3 0/7] s390x/vfio-ccw: Channel Path Handling [QEMU] no-reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200417023440.70514-8-farman@linux.ibm.com \
--to=farman@linux.ibm.com \
--cc=cohuck@redhat.com \
--cc=jjherne@linux.ibm.com \
--cc=jrossi@linux.ibm.com \
--cc=pasic@linux.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-s390x@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.