diff --git a/devicemodel/hw/pci/virtio/vhost.c b/devicemodel/hw/pci/virtio/vhost.c index 6364170cc..154de4257 100644 --- a/devicemodel/hw/pci/virtio/vhost.c +++ b/devicemodel/hw/pci/virtio/vhost.c @@ -196,7 +196,7 @@ vhost_vq_register_eventfd(struct vhost_dev *vdev, irqfd.flags = ACRN_IRQFD_FLAG_DEASSIGN; } - virtio_register_ioeventfd(base, idx, is_register); + virtio_register_ioeventfd(base, idx, is_register, vq->kick_fd); /* register irqfd for notify */ mte = &vdev->base->dev->msix.table[vqi->msix_idx]; msi.msi_addr = mte->addr; diff --git a/devicemodel/hw/pci/virtio/virtio.c b/devicemodel/hw/pci/virtio/virtio.c index 598bdbc5f..6c328d00a 100644 --- a/devicemodel/hw/pci/virtio/virtio.c +++ b/devicemodel/hw/pci/virtio/virtio.c @@ -107,10 +107,10 @@ virtio_set_iothread(struct virtio_base *base, vq->viothrd.iomvt.fd = vq->viothrd.kick_fd; if (!iothread_add(vq->viothrd.kick_fd, &vq->viothrd.iomvt)) - if (!virtio_register_ioeventfd(base, idx, true)) + if (!virtio_register_ioeventfd(base, idx, true, vq->viothrd.kick_fd)) vq->viothrd.ioevent_started = true; } else { - if (!virtio_register_ioeventfd(base, idx, false)) + if (!virtio_register_ioeventfd(base, idx, false, vq->viothrd.kick_fd)) if (!iothread_del(vq->viothrd.kick_fd)) { vq->viothrd.ioevent_started = false; if (vq->viothrd.kick_fd) { @@ -1991,16 +1991,15 @@ acrn_parse_virtio_poll_interval(const char *optarg) return 0; } -int virtio_register_ioeventfd(struct virtio_base *base, int idx, bool is_register) +int virtio_register_ioeventfd(struct virtio_base *base, int idx, bool is_register, int fd) { struct acrn_ioeventfd ioeventfd = {0}; - struct virtio_vq_info *vq; struct pcibar *bar; int rc = 0; if (!is_register) ioeventfd.flags = ACRN_IOEVENTFD_FLAG_DEASSIGN; - else + else if (base->iothread) /* Enable ASYNCIO by default. If ASYNCIO is not supported by kernel * or hyperviosr, this flag will be ignored. */ @@ -2040,8 +2039,7 @@ int virtio_register_ioeventfd(struct virtio_base *base, int idx, bool is_registe ACRN_IOEVENTFD_FLAG_PIO); } - vq = &base->queues[idx]; - ioeventfd.fd = vq->viothrd.kick_fd; + ioeventfd.fd = fd; if (is_register) pr_info("[ioeventfd: %d][0x%lx@%d][flags: 0x%x][data: 0x%lx]\r\n", ioeventfd.fd, ioeventfd.addr, ioeventfd.len, diff --git a/devicemodel/include/virtio.h b/devicemodel/include/virtio.h index 370248bd5..17c766f5d 100644 --- a/devicemodel/include/virtio.h +++ b/devicemodel/include/virtio.h @@ -776,5 +776,5 @@ uint32_t virtio_device_cfg_read( int virtio_set_modern_pio_bar( struct virtio_base *base, int barnum); -int virtio_register_ioeventfd(struct virtio_base *base, int idx, bool is_register); +int virtio_register_ioeventfd(struct virtio_base *base, int idx, bool is_register, int fd); #endif /* _VIRTIO_H_ */