Lines Matching refs:vm
39 static int ioreq_complete_request(struct acrn_vm *vm, u16 vcpu, in ioreq_complete_request() argument
64 ret = hcall_notify_req_finish(vm->vmid, vcpu); in ioreq_complete_request()
79 if (vcpu >= client->vm->vcpu_num) in acrn_ioreq_complete_request()
84 acrn_req = (struct acrn_io_request *)client->vm->ioreq_buf; in acrn_ioreq_complete_request()
88 ret = ioreq_complete_request(client->vm, vcpu, acrn_req); in acrn_ioreq_complete_request()
93 int acrn_ioreq_request_default_complete(struct acrn_vm *vm, u16 vcpu) in acrn_ioreq_request_default_complete() argument
97 spin_lock_bh(&vm->ioreq_clients_lock); in acrn_ioreq_request_default_complete()
98 if (vm->default_client) in acrn_ioreq_request_default_complete()
99 ret = acrn_ioreq_complete_request(vm->default_client, in acrn_ioreq_request_default_complete()
101 spin_unlock_bh(&vm->ioreq_clients_lock); in acrn_ioreq_request_default_complete()
191 vcpu = find_first_bit(ioreqs_map, client->vm->vcpu_num); in ioreq_task()
192 req = client->vm->ioreq_buf->req_slot + vcpu; in ioreq_task()
212 void acrn_ioreq_request_clear(struct acrn_vm *vm) in acrn_ioreq_request_clear() argument
223 set_bit(ACRN_VM_FLAG_CLEARING_IOREQ, &vm->flags); in acrn_ioreq_request_clear()
230 spin_lock_bh(&vm->ioreq_clients_lock); in acrn_ioreq_request_clear()
231 list_for_each_entry(client, &vm->ioreq_clients, list) { in acrn_ioreq_request_clear()
236 spin_unlock_bh(&vm->ioreq_clients_lock); in acrn_ioreq_request_clear()
246 spin_lock_bh(&vm->ioreq_clients_lock); in acrn_ioreq_request_clear()
247 client = vm->default_client; in acrn_ioreq_request_clear()
252 spin_unlock_bh(&vm->ioreq_clients_lock); in acrn_ioreq_request_clear()
255 clear_bit(ACRN_VM_FLAG_CLEARING_IOREQ, &vm->flags); in acrn_ioreq_request_clear()
312 static bool handle_cf8cfc(struct acrn_vm *vm, in handle_cf8cfc() argument
321 vm->pci_conf_addr = req->reqs.pio_request.value; in handle_cf8cfc()
323 req->reqs.pio_request.value = vm->pci_conf_addr; in handle_cf8cfc()
326 if (!(vm->pci_conf_addr & CONF1_ENABLE)) { in handle_cf8cfc()
335 pci_cfg_addr = vm->pci_conf_addr; in handle_cf8cfc()
349 ioreq_complete_request(vm, vcpu, req); in handle_cf8cfc()
381 static struct acrn_ioreq_client *find_ioreq_client(struct acrn_vm *vm, in find_ioreq_client() argument
387 lockdep_assert_held(&vm->ioreq_clients_lock); in find_ioreq_client()
389 list_for_each_entry(client, &vm->ioreq_clients, list) { in find_ioreq_client()
401 return found ? found : vm->default_client; in find_ioreq_client()
415 struct acrn_ioreq_client *acrn_ioreq_client_create(struct acrn_vm *vm, in acrn_ioreq_client_create() argument
432 client->vm = vm; in acrn_ioreq_client_create()
443 client->vm->vmid, client->name); in acrn_ioreq_client_create()
450 spin_lock_bh(&vm->ioreq_clients_lock); in acrn_ioreq_client_create()
452 vm->default_client = client; in acrn_ioreq_client_create()
454 list_add(&client->list, &vm->ioreq_clients); in acrn_ioreq_client_create()
455 spin_unlock_bh(&vm->ioreq_clients_lock); in acrn_ioreq_client_create()
468 struct acrn_vm *vm = client->vm; in acrn_ioreq_client_destroy() local
479 spin_lock_bh(&vm->ioreq_clients_lock); in acrn_ioreq_client_destroy()
481 vm->default_client = NULL; in acrn_ioreq_client_destroy()
484 spin_unlock_bh(&vm->ioreq_clients_lock); in acrn_ioreq_client_destroy()
497 static int acrn_ioreq_dispatch(struct acrn_vm *vm) in acrn_ioreq_dispatch() argument
503 for (i = 0; i < vm->vcpu_num; i++) { in acrn_ioreq_dispatch()
504 req = vm->ioreq_buf->req_slot + i; in acrn_ioreq_dispatch()
510 if (test_bit(ACRN_VM_FLAG_CLEARING_IOREQ, &vm->flags)) { in acrn_ioreq_dispatch()
511 ioreq_complete_request(vm, i, req); in acrn_ioreq_dispatch()
514 if (handle_cf8cfc(vm, req, i)) in acrn_ioreq_dispatch()
517 spin_lock_bh(&vm->ioreq_clients_lock); in acrn_ioreq_dispatch()
518 client = find_ioreq_client(vm, req); in acrn_ioreq_dispatch()
522 spin_unlock_bh(&vm->ioreq_clients_lock); in acrn_ioreq_dispatch()
537 spin_unlock_bh(&vm->ioreq_clients_lock); in acrn_ioreq_dispatch()
546 struct acrn_vm *vm; in ioreq_dispatcher() local
549 list_for_each_entry(vm, &acrn_vm_list, list) { in ioreq_dispatcher()
550 if (!vm->ioreq_buf) in ioreq_dispatcher()
552 acrn_ioreq_dispatch(vm); in ioreq_dispatcher()
596 int acrn_ioreq_init(struct acrn_vm *vm, u64 buf_vma) in acrn_ioreq_init() argument
602 if (vm->ioreq_buf) in acrn_ioreq_init()
617 vm->ioreq_buf = page_address(page); in acrn_ioreq_init()
618 vm->ioreq_page = page; in acrn_ioreq_init()
620 ret = hcall_set_ioreq_buffer(vm->vmid, virt_to_phys(set_buffer)); in acrn_ioreq_init()
624 vm->ioreq_buf = NULL; in acrn_ioreq_init()
629 "Init ioreq buffer %pK!\n", vm->ioreq_buf); in acrn_ioreq_init()
636 void acrn_ioreq_deinit(struct acrn_vm *vm) in acrn_ioreq_deinit() argument
641 "Deinit ioreq buffer %pK!\n", vm->ioreq_buf); in acrn_ioreq_deinit()
643 list_for_each_entry_safe(client, next, &vm->ioreq_clients, list) in acrn_ioreq_deinit()
645 if (vm->default_client) in acrn_ioreq_deinit()
646 acrn_ioreq_client_destroy(vm->default_client); in acrn_ioreq_deinit()
648 if (vm->ioreq_buf && vm->ioreq_page) { in acrn_ioreq_deinit()
649 unpin_user_page(vm->ioreq_page); in acrn_ioreq_deinit()
650 vm->ioreq_buf = NULL; in acrn_ioreq_deinit()