Message ID | 20160321105718.GA7710@ad.usersys.redhat.com |
---|---|
State | New |
Headers | show |
On Mon, 21 Mar 2016 18:57:18 +0800 Fam Zheng <famz@redhat.com> wrote: > diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c > index 08275a9..47f8043 100644 > --- a/hw/virtio/virtio.c > +++ b/hw/virtio/virtio.c > @@ -1098,7 +1098,14 @@ void virtio_queue_notify_vq(VirtQueue *vq) > > void virtio_queue_notify(VirtIODevice *vdev, int n) > { > - virtio_queue_notify_vq(&vdev->vq[n]); > + VirtQueue *vq = &vdev->vq[n]; > + EventNotifier *n; > + n = virtio_queue_get_host_notifier(vq); > + if (n) { Isn't that always true, even if the notifier has not been setup? > + event_notifier_set(n); > + } else { > + virtio_queue_notify_vq(vq); > + } > } > > uint16_t virtio_queue_vector(VirtIODevice *vdev, int n) > >
On Mon, 03/21 12:15, Cornelia Huck wrote: > On Mon, 21 Mar 2016 18:57:18 +0800 > Fam Zheng <famz@redhat.com> wrote: > > > diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c > > index 08275a9..47f8043 100644 > > --- a/hw/virtio/virtio.c > > +++ b/hw/virtio/virtio.c > > @@ -1098,7 +1098,14 @@ void virtio_queue_notify_vq(VirtQueue *vq) > > > > void virtio_queue_notify(VirtIODevice *vdev, int n) > > { > > - virtio_queue_notify_vq(&vdev->vq[n]); > > + VirtQueue *vq = &vdev->vq[n]; > > + EventNotifier *n; > > + n = virtio_queue_get_host_notifier(vq); > > + if (n) { > > Isn't that always true, even if the notifier has not been setup? You are right, this doesn't make a correct fix. But we can still do a quick test with this as the else branch should never be used with ioeventfd=on. Am I right? Fam > > > + event_notifier_set(n); > > + } else { > > + virtio_queue_notify_vq(vq); > > + } > > } > > > > uint16_t virtio_queue_vector(VirtIODevice *vdev, int n) > > > > >
On Mon, 21 Mar 2016 20:45:27 +0800 Fam Zheng <famz@redhat.com> wrote: > On Mon, 03/21 12:15, Cornelia Huck wrote: > > On Mon, 21 Mar 2016 18:57:18 +0800 > > Fam Zheng <famz@redhat.com> wrote: > > > > > diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c > > > index 08275a9..47f8043 100644 > > > --- a/hw/virtio/virtio.c > > > +++ b/hw/virtio/virtio.c > > > @@ -1098,7 +1098,14 @@ void virtio_queue_notify_vq(VirtQueue *vq) > > > > > > void virtio_queue_notify(VirtIODevice *vdev, int n) > > > { > > > - virtio_queue_notify_vq(&vdev->vq[n]); > > > + VirtQueue *vq = &vdev->vq[n]; > > > + EventNotifier *n; > > > + n = virtio_queue_get_host_notifier(vq); > > > + if (n) { > > > > Isn't that always true, even if the notifier has not been setup? > > You are right, this doesn't make a correct fix. But we can still do a quick > test with this as the else branch should never be used with ioeventfd=on. Am I > right? > > Fam Won't we come through here for the very first kick, when we haven't registered the ioeventfd with the kernel yet? > > > > > > + event_notifier_set(n); > > > + } else { > > > + virtio_queue_notify_vq(vq); > > > + } > > > } > > > > > > uint16_t virtio_queue_vector(VirtIODevice *vdev, int n) > > > > > > > > >
On Mon, 03/21 14:02, Cornelia Huck wrote: > On Mon, 21 Mar 2016 20:45:27 +0800 > Fam Zheng <famz@redhat.com> wrote: > > > On Mon, 03/21 12:15, Cornelia Huck wrote: > > > On Mon, 21 Mar 2016 18:57:18 +0800 > > > Fam Zheng <famz@redhat.com> wrote: > > > > > > > diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c > > > > index 08275a9..47f8043 100644 > > > > --- a/hw/virtio/virtio.c > > > > +++ b/hw/virtio/virtio.c > > > > @@ -1098,7 +1098,14 @@ void virtio_queue_notify_vq(VirtQueue *vq) > > > > > > > > void virtio_queue_notify(VirtIODevice *vdev, int n) > > > > { > > > > - virtio_queue_notify_vq(&vdev->vq[n]); > > > > + VirtQueue *vq = &vdev->vq[n]; > > > > + EventNotifier *n; > > > > + n = virtio_queue_get_host_notifier(vq); > > > > + if (n) { > > > > > > Isn't that always true, even if the notifier has not been setup? > > > > You are right, this doesn't make a correct fix. But we can still do a quick > > test with this as the else branch should never be used with ioeventfd=on. Am I > > right? > > > > Fam > > Won't we come through here for the very first kick, when we haven't > registered the ioeventfd with the kernel yet? > The ioeventfd in virtio-ccw is registered in the main loop when VIRTIO_CONFIG_S_DRIVER_OK is set, so I think the first kick is okay. Fam
On Tue, 22 Mar 2016 07:45:19 +0800 Fam Zheng <famz@redhat.com> wrote: > On Mon, 03/21 14:02, Cornelia Huck wrote: > > On Mon, 21 Mar 2016 20:45:27 +0800 > > Fam Zheng <famz@redhat.com> wrote: > > > > > On Mon, 03/21 12:15, Cornelia Huck wrote: > > > > On Mon, 21 Mar 2016 18:57:18 +0800 > > > > Fam Zheng <famz@redhat.com> wrote: > > > > > > > > > diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c > > > > > index 08275a9..47f8043 100644 > > > > > --- a/hw/virtio/virtio.c > > > > > +++ b/hw/virtio/virtio.c > > > > > @@ -1098,7 +1098,14 @@ void virtio_queue_notify_vq(VirtQueue *vq) > > > > > > > > > > void virtio_queue_notify(VirtIODevice *vdev, int n) > > > > > { > > > > > - virtio_queue_notify_vq(&vdev->vq[n]); > > > > > + VirtQueue *vq = &vdev->vq[n]; > > > > > + EventNotifier *n; > > > > > + n = virtio_queue_get_host_notifier(vq); > > > > > + if (n) { > > > > > > > > Isn't that always true, even if the notifier has not been setup? > > > > > > You are right, this doesn't make a correct fix. But we can still do a quick > > > test with this as the else branch should never be used with ioeventfd=on. Am I > > > right? > > > > > > Fam > > > > Won't we come through here for the very first kick, when we haven't > > registered the ioeventfd with the kernel yet? > > > > The ioeventfd in virtio-ccw is registered in the main loop when > VIRTIO_CONFIG_S_DRIVER_OK is set, so I think the first kick is okay. You're right, for well-behaved drivers this will be done from set_status, so for testing that's fine.
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 08275a9..47f8043 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -1098,7 +1098,14 @@ void virtio_queue_notify_vq(VirtQueue *vq) void virtio_queue_notify(VirtIODevice *vdev, int n) { - virtio_queue_notify_vq(&vdev->vq[n]); + VirtQueue *vq = &vdev->vq[n]; + EventNotifier *n; + n = virtio_queue_get_host_notifier(vq); + if (n) { + event_notifier_set(n); + } else { + virtio_queue_notify_vq(vq); + } } uint16_t virtio_queue_vector(VirtIODevice *vdev, int n)