virtio: turn vq->notification into a nested counter
Polling should disable virtqueue notifications but that requires nested virtio_queue_set_notification() calls. Turn vq->notification into a counter so it is possible to do nesting. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Message-id: 20161201192652.9509-10-stefanha@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
23425cc2b7
commit
aff8fd18f1
@ -87,8 +87,8 @@ struct VirtQueue
|
|||||||
/* Last used index value we have signalled on */
|
/* Last used index value we have signalled on */
|
||||||
bool signalled_used_valid;
|
bool signalled_used_valid;
|
||||||
|
|
||||||
/* Notification enabled? */
|
/* Nested host->guest notification disabled counter */
|
||||||
bool notification;
|
unsigned int notification_disabled;
|
||||||
|
|
||||||
uint16_t queue_index;
|
uint16_t queue_index;
|
||||||
|
|
||||||
@ -201,7 +201,7 @@ static inline void vring_used_flags_unset_bit(VirtQueue *vq, int mask)
|
|||||||
static inline void vring_set_avail_event(VirtQueue *vq, uint16_t val)
|
static inline void vring_set_avail_event(VirtQueue *vq, uint16_t val)
|
||||||
{
|
{
|
||||||
hwaddr pa;
|
hwaddr pa;
|
||||||
if (!vq->notification) {
|
if (vq->notification_disabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pa = vq->vring.used + offsetof(VRingUsed, ring[vq->vring.num]);
|
pa = vq->vring.used + offsetof(VRingUsed, ring[vq->vring.num]);
|
||||||
@ -210,7 +210,13 @@ static inline void vring_set_avail_event(VirtQueue *vq, uint16_t val)
|
|||||||
|
|
||||||
void virtio_queue_set_notification(VirtQueue *vq, int enable)
|
void virtio_queue_set_notification(VirtQueue *vq, int enable)
|
||||||
{
|
{
|
||||||
vq->notification = enable;
|
if (enable) {
|
||||||
|
assert(vq->notification_disabled > 0);
|
||||||
|
vq->notification_disabled--;
|
||||||
|
} else {
|
||||||
|
vq->notification_disabled++;
|
||||||
|
}
|
||||||
|
|
||||||
if (virtio_vdev_has_feature(vq->vdev, VIRTIO_RING_F_EVENT_IDX)) {
|
if (virtio_vdev_has_feature(vq->vdev, VIRTIO_RING_F_EVENT_IDX)) {
|
||||||
vring_set_avail_event(vq, vring_avail_idx(vq));
|
vring_set_avail_event(vq, vring_avail_idx(vq));
|
||||||
} else if (enable) {
|
} else if (enable) {
|
||||||
@ -959,7 +965,7 @@ void virtio_reset(void *opaque)
|
|||||||
virtio_queue_set_vector(vdev, i, VIRTIO_NO_VECTOR);
|
virtio_queue_set_vector(vdev, i, VIRTIO_NO_VECTOR);
|
||||||
vdev->vq[i].signalled_used = 0;
|
vdev->vq[i].signalled_used = 0;
|
||||||
vdev->vq[i].signalled_used_valid = false;
|
vdev->vq[i].signalled_used_valid = false;
|
||||||
vdev->vq[i].notification = true;
|
vdev->vq[i].notification_disabled = 0;
|
||||||
vdev->vq[i].vring.num = vdev->vq[i].vring.num_default;
|
vdev->vq[i].vring.num = vdev->vq[i].vring.num_default;
|
||||||
vdev->vq[i].inuse = 0;
|
vdev->vq[i].inuse = 0;
|
||||||
}
|
}
|
||||||
@ -1770,7 +1776,7 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f, int version_id)
|
|||||||
vdev->vq[i].vring.desc = qemu_get_be64(f);
|
vdev->vq[i].vring.desc = qemu_get_be64(f);
|
||||||
qemu_get_be16s(f, &vdev->vq[i].last_avail_idx);
|
qemu_get_be16s(f, &vdev->vq[i].last_avail_idx);
|
||||||
vdev->vq[i].signalled_used_valid = false;
|
vdev->vq[i].signalled_used_valid = false;
|
||||||
vdev->vq[i].notification = true;
|
vdev->vq[i].notification_disabled = 0;
|
||||||
|
|
||||||
if (vdev->vq[i].vring.desc) {
|
if (vdev->vq[i].vring.desc) {
|
||||||
/* XXX virtio-1 devices */
|
/* XXX virtio-1 devices */
|
||||||
|
Loading…
Reference in New Issue
Block a user