Lines Matching full:client

29 static inline bool has_pending_request(struct acrn_ioreq_client *client)  in has_pending_request()  argument
31 return !bitmap_empty(client->ioreqs_map, ACRN_IO_REQUEST_MAX); in has_pending_request()
34 static inline bool is_destroying(struct acrn_ioreq_client *client) in is_destroying() argument
36 return test_bit(ACRN_IOREQ_CLIENT_DESTROYING, &client->flags); in is_destroying()
73 static int acrn_ioreq_complete_request(struct acrn_ioreq_client *client, in acrn_ioreq_complete_request() argument
79 if (vcpu >= client->vm->vcpu_num) in acrn_ioreq_complete_request()
82 clear_bit(vcpu, client->ioreqs_map); 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()
107 * acrn_ioreq_range_add() - Add an iorange monitored by an ioreq client
108 * @client: The ioreq client
115 int acrn_ioreq_range_add(struct acrn_ioreq_client *client, in acrn_ioreq_range_add() argument
134 write_lock_bh(&client->range_lock); in acrn_ioreq_range_add()
135 list_add(&range->list, &client->range_list); in acrn_ioreq_range_add()
136 write_unlock_bh(&client->range_lock); in acrn_ioreq_range_add()
142 * acrn_ioreq_range_del() - Del an iorange monitored by an ioreq client
143 * @client: The ioreq client
148 void acrn_ioreq_range_del(struct acrn_ioreq_client *client, in acrn_ioreq_range_del() argument
153 write_lock_bh(&client->range_lock); in acrn_ioreq_range_del()
154 list_for_each_entry(range, &client->range_list, list) { in acrn_ioreq_range_del()
163 write_unlock_bh(&client->range_lock); in acrn_ioreq_range_del()
167 * ioreq_task() is the execution entity of handler thread of an I/O client.
168 * The handler callback of the I/O client is called within the handler thread.
172 struct acrn_ioreq_client *client = data; in ioreq_task() local
187 ioreqs_map = client->ioreqs_map; in ioreq_task()
189 acrn_ioreq_client_wait(client); in ioreq_task()
190 while (has_pending_request(client)) { in ioreq_task()
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()
193 ret = client->handler(client, req); in ioreq_task()
199 acrn_ioreq_complete_request(client, vcpu, req); in ioreq_task()
208 * I/O requests if there are any. For the default I/O client, it is safe to
214 struct acrn_ioreq_client *client; in acrn_ioreq_request_clear() local
231 list_for_each_entry(client, &vm->ioreq_clients, list) { in acrn_ioreq_request_clear()
232 has_pending = has_pending_request(client); in acrn_ioreq_request_clear()
243 "%s cannot flush pending request!\n", client->name); in acrn_ioreq_request_clear()
245 /* Clear all ioreqs belonging to the default client */ in acrn_ioreq_request_clear()
247 client = vm->default_client; in acrn_ioreq_request_clear()
248 if (client) { in acrn_ioreq_request_clear()
249 for_each_set_bit(vcpu, client->ioreqs_map, ACRN_IO_REQUEST_MAX) in acrn_ioreq_request_clear()
250 acrn_ioreq_complete_request(client, vcpu, NULL); in acrn_ioreq_request_clear()
258 int acrn_ioreq_client_wait(struct acrn_ioreq_client *client) in acrn_ioreq_client_wait() argument
260 if (client->is_default) { in acrn_ioreq_client_wait()
262 * In the default client, a user space thread waits on the in acrn_ioreq_client_wait()
264 * space the client is going to be destroyed. in acrn_ioreq_client_wait()
266 wait_event_interruptible(client->wq, in acrn_ioreq_client_wait()
267 has_pending_request(client) || in acrn_ioreq_client_wait()
268 is_destroying(client)); in acrn_ioreq_client_wait()
269 if (is_destroying(client)) in acrn_ioreq_client_wait()
272 wait_event_interruptible(client->wq, in acrn_ioreq_client_wait()
273 has_pending_request(client) || in acrn_ioreq_client_wait()
384 struct acrn_ioreq_client *client, *found = NULL; in find_ioreq_client() local
389 list_for_each_entry(client, &vm->ioreq_clients, list) { in find_ioreq_client()
390 read_lock_bh(&client->range_lock); in find_ioreq_client()
391 list_for_each_entry(range, &client->range_list, list) { in find_ioreq_client()
393 found = client; in find_ioreq_client()
397 read_unlock_bh(&client->range_lock); in find_ioreq_client()
405 * acrn_ioreq_client_create() - Create an ioreq client
406 * @vm: The VM that this client belongs to
407 * @handler: The ioreq_handler of ioreq client acrn_hsm will create a kernel
410 * @is_default: If it is the default client
411 * @name: The name of ioreq client
420 struct acrn_ioreq_client *client; in acrn_ioreq_client_create() local
424 "Cannot create non-default client w/o handler!\n"); in acrn_ioreq_client_create()
427 client = kzalloc(sizeof(*client), GFP_KERNEL); in acrn_ioreq_client_create()
428 if (!client) in acrn_ioreq_client_create()
431 client->handler = handler; in acrn_ioreq_client_create()
432 client->vm = vm; in acrn_ioreq_client_create()
433 client->priv = priv; in acrn_ioreq_client_create()
434 client->is_default = is_default; in acrn_ioreq_client_create()
436 strscpy(client->name, name); in acrn_ioreq_client_create()
437 rwlock_init(&client->range_lock); in acrn_ioreq_client_create()
438 INIT_LIST_HEAD(&client->range_list); in acrn_ioreq_client_create()
439 init_waitqueue_head(&client->wq); in acrn_ioreq_client_create()
441 if (client->handler) { in acrn_ioreq_client_create()
442 client->thread = kthread_run(ioreq_task, client, "VM%u-%s", in acrn_ioreq_client_create()
443 client->vm->vmid, client->name); in acrn_ioreq_client_create()
444 if (IS_ERR(client->thread)) { in acrn_ioreq_client_create()
445 kfree(client); 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()
457 dev_dbg(acrn_dev.this_device, "Created ioreq client %s.\n", name); in acrn_ioreq_client_create()
458 return client; in acrn_ioreq_client_create()
462 * acrn_ioreq_client_destroy() - Destroy an ioreq client
463 * @client: The ioreq client
465 void acrn_ioreq_client_destroy(struct acrn_ioreq_client *client) in acrn_ioreq_client_destroy() argument
468 struct acrn_vm *vm = client->vm; in acrn_ioreq_client_destroy()
471 "Destroy ioreq client %s.\n", client->name); in acrn_ioreq_client_destroy()
473 set_bit(ACRN_IOREQ_CLIENT_DESTROYING, &client->flags); in acrn_ioreq_client_destroy()
474 if (client->is_default) in acrn_ioreq_client_destroy()
475 wake_up_interruptible(&client->wq); in acrn_ioreq_client_destroy()
477 kthread_stop(client->thread); in acrn_ioreq_client_destroy()
480 if (client->is_default) in acrn_ioreq_client_destroy()
483 list_del(&client->list); in acrn_ioreq_client_destroy()
486 write_lock_bh(&client->range_lock); in acrn_ioreq_client_destroy()
487 list_for_each_entry_safe(range, next, &client->range_list, list) { in acrn_ioreq_client_destroy()
491 write_unlock_bh(&client->range_lock); in acrn_ioreq_client_destroy()
492 kfree(client); in acrn_ioreq_client_destroy()
499 struct acrn_ioreq_client *client; in acrn_ioreq_dispatch() local
518 client = find_ioreq_client(vm, req); in acrn_ioreq_dispatch()
519 if (!client) { in acrn_ioreq_dispatch()
521 "Failed to find ioreq client!\n"); in acrn_ioreq_dispatch()
525 if (!client->is_default) in acrn_ioreq_dispatch()
535 set_bit(i, client->ioreqs_map); in acrn_ioreq_dispatch()
536 wake_up_interruptible(&client->wq); in acrn_ioreq_dispatch()
638 struct acrn_ioreq_client *client, *next; in acrn_ioreq_deinit() local
643 list_for_each_entry_safe(client, next, &vm->ioreq_clients, list) in acrn_ioreq_deinit()
644 acrn_ioreq_client_destroy(client); in acrn_ioreq_deinit()