Lines Matching full:vm
19 * @list: Entry within &acrn_vm.ioeventfds of ioeventfds of a VM
43 static void acrn_ioeventfd_shutdown(struct acrn_vm *vm, struct hsm_ioeventfd *p) in acrn_ioeventfd_shutdown() argument
45 lockdep_assert_held(&vm->ioeventfds_lock); in acrn_ioeventfd_shutdown()
52 static bool hsm_ioeventfd_is_conflict(struct acrn_vm *vm, in hsm_ioeventfd_is_conflict() argument
57 lockdep_assert_held(&vm->ioeventfds_lock); in hsm_ioeventfd_is_conflict()
60 list_for_each_entry(p, &vm->ioeventfds, list) in hsm_ioeventfd_is_conflict()
72 * Assign an eventfd to a VM and create a HSM ioeventfd associated with the
76 static int acrn_ioeventfd_assign(struct acrn_vm *vm, in acrn_ioeventfd_assign() argument
121 mutex_lock(&vm->ioeventfds_lock); in acrn_ioeventfd_assign()
123 if (hsm_ioeventfd_is_conflict(vm, p)) { in acrn_ioeventfd_assign()
129 ret = acrn_ioreq_range_add(vm->ioeventfd_client, p->type, in acrn_ioeventfd_assign()
134 list_add_tail(&p->list, &vm->ioeventfds); in acrn_ioeventfd_assign()
135 mutex_unlock(&vm->ioeventfds_lock); in acrn_ioeventfd_assign()
140 mutex_unlock(&vm->ioeventfds_lock); in acrn_ioeventfd_assign()
147 static int acrn_ioeventfd_deassign(struct acrn_vm *vm, in acrn_ioeventfd_deassign() argument
157 mutex_lock(&vm->ioeventfds_lock); in acrn_ioeventfd_deassign()
158 list_for_each_entry(p, &vm->ioeventfds, list) { in acrn_ioeventfd_deassign()
162 acrn_ioreq_range_del(vm->ioeventfd_client, p->type, in acrn_ioeventfd_deassign()
164 acrn_ioeventfd_shutdown(vm, p); in acrn_ioeventfd_deassign()
167 mutex_unlock(&vm->ioeventfds_lock); in acrn_ioeventfd_deassign()
173 static struct hsm_ioeventfd *hsm_ioeventfd_match(struct acrn_vm *vm, u64 addr, in hsm_ioeventfd_match() argument
178 lockdep_assert_held(&vm->ioeventfds_lock); in hsm_ioeventfd_match()
180 list_for_each_entry(p, &vm->ioeventfds, list) { in hsm_ioeventfd_match()
223 mutex_lock(&client->vm->ioeventfds_lock); in acrn_ioeventfd_handler()
224 p = hsm_ioeventfd_match(client->vm, addr, val, size, req->type); in acrn_ioeventfd_handler()
227 mutex_unlock(&client->vm->ioeventfds_lock); in acrn_ioeventfd_handler()
232 int acrn_ioeventfd_config(struct acrn_vm *vm, struct acrn_ioeventfd *args) in acrn_ioeventfd_config() argument
237 ret = acrn_ioeventfd_deassign(vm, args); in acrn_ioeventfd_config()
239 ret = acrn_ioeventfd_assign(vm, args); in acrn_ioeventfd_config()
244 int acrn_ioeventfd_init(struct acrn_vm *vm) in acrn_ioeventfd_init() argument
248 mutex_init(&vm->ioeventfds_lock); in acrn_ioeventfd_init()
249 INIT_LIST_HEAD(&vm->ioeventfds); in acrn_ioeventfd_init()
250 snprintf(name, sizeof(name), "ioeventfd-%u", vm->vmid); in acrn_ioeventfd_init()
251 vm->ioeventfd_client = acrn_ioreq_client_create(vm, in acrn_ioeventfd_init()
254 if (!vm->ioeventfd_client) { in acrn_ioeventfd_init()
259 dev_dbg(acrn_dev.this_device, "VM %u ioeventfd init.\n", vm->vmid); in acrn_ioeventfd_init()
263 void acrn_ioeventfd_deinit(struct acrn_vm *vm) in acrn_ioeventfd_deinit() argument
267 dev_dbg(acrn_dev.this_device, "VM %u ioeventfd deinit.\n", vm->vmid); in acrn_ioeventfd_deinit()
268 acrn_ioreq_client_destroy(vm->ioeventfd_client); in acrn_ioeventfd_deinit()
269 mutex_lock(&vm->ioeventfds_lock); in acrn_ioeventfd_deinit()
270 list_for_each_entry_safe(p, next, &vm->ioeventfds, list) in acrn_ioeventfd_deinit()
271 acrn_ioeventfd_shutdown(vm, p); in acrn_ioeventfd_deinit()
272 mutex_unlock(&vm->ioeventfds_lock); in acrn_ioeventfd_deinit()