[PATCH v4 4/5] virt: acrn: dispatch asyncio request


Conghui Chen
 

When the User VM do an I/O access and trap to hypervisor, hypervisor
will parse the I/O base address, and check if it was registered. If yes,
hypervisor will queue the corresponding eventfd to the aysncio buffer,
and inject an interrupt to Service VM. ACRN HSM driver in Service VM
will traverse the fd list and signal the eventfd.

Signed-off-by: Conghui <conghui.chen@...>
---
drivers/virt/acrn/ioreq.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)

diff --git a/drivers/virt/acrn/ioreq.c b/drivers/virt/acrn/ioreq.c
index c047771712d1..ee284140313a 100644
--- a/drivers/virt/acrn/ioreq.c
+++ b/drivers/virt/acrn/ioreq.c
@@ -14,6 +14,7 @@
#include <linux/kthread.h>
#include <linux/mm.h>
#include <linux/slab.h>
+#include <linux/eventfd.h>

#include <asm/acrn.h>

@@ -203,6 +204,21 @@ static int ioreq_task(void *data)
return 0;
}

+static int acrn_asyncio_dispatch(struct acrn_vm *vm)
+{
+ shared_buf_t *sbuf = vm->asyncio_sbuf;
+ uint64_t *fd_ptr;
+
+ fd_ptr = acrn_sbuf_get_data_ptr(sbuf);
+ while (fd_ptr) {
+ eventfd_signal((struct eventfd_ctx *)(*fd_ptr) , 1);
+ acrn_sbuf_move_next(sbuf);
+ fd_ptr = acrn_sbuf_get_data_ptr(sbuf);
+ }
+ mb();
+
+ return 0;
+}
/*
* For the non-default I/O clients, give them chance to complete the current
* I/O requests if there are any. For the default I/O client, it is safe to
@@ -547,6 +563,8 @@ static void ioreq_dispatcher(struct work_struct *work)

read_lock(&acrn_vm_list_lock);
list_for_each_entry(vm, &acrn_vm_list, list) {
+ if (vm->asyncio_sbuf)
+ acrn_asyncio_dispatch(vm);
if (!vm->ioreq_buf)
break;
acrn_ioreq_dispatch(vm);
--
2.25.1