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