Lines Matching refs:ved
45 struct vm_event_domain **ved, in vm_event_enable() argument
53 if ( !*ved ) in vm_event_enable()
54 *ved = xzalloc(struct vm_event_domain); in vm_event_enable()
55 if ( !*ved ) in vm_event_enable()
61 if ( (*ved)->ring_page ) in vm_event_enable()
69 vm_event_ring_lock_init(*ved); in vm_event_enable()
70 vm_event_ring_lock(*ved); in vm_event_enable()
77 rc = prepare_ring_for_helper(d, ring_gfn, &(*ved)->ring_pg_struct, in vm_event_enable()
78 &(*ved)->ring_page); in vm_event_enable()
83 (*ved)->blocked = 0; in vm_event_enable()
91 (*ved)->xen_port = vec->port = rc; in vm_event_enable()
94 FRONT_RING_INIT(&(*ved)->front_ring, in vm_event_enable()
95 (vm_event_sring_t *)(*ved)->ring_page, in vm_event_enable()
99 (*ved)->pause_flag = pause_flag; in vm_event_enable()
102 init_waitqueue_head(&(*ved)->wq); in vm_event_enable()
104 vm_event_ring_unlock(*ved); in vm_event_enable()
108 destroy_ring_for_helper(&(*ved)->ring_page, in vm_event_enable()
109 (*ved)->ring_pg_struct); in vm_event_enable()
110 vm_event_ring_unlock(*ved); in vm_event_enable()
111 xfree(*ved); in vm_event_enable()
112 *ved = NULL; in vm_event_enable()
117 static unsigned int vm_event_ring_available(struct vm_event_domain *ved) in vm_event_ring_available() argument
119 int avail_req = RING_FREE_REQUESTS(&ved->front_ring); in vm_event_ring_available()
120 avail_req -= ved->target_producers; in vm_event_ring_available()
121 avail_req -= ved->foreign_producers; in vm_event_ring_available()
134 static void vm_event_wake_blocked(struct domain *d, struct vm_event_domain *ved) in vm_event_wake_blocked() argument
137 unsigned int avail_req = vm_event_ring_available(ved); in vm_event_wake_blocked()
139 if ( avail_req == 0 || ved->blocked == 0 ) in vm_event_wake_blocked()
148 for (i = ved->last_vcpu_wake_up + 1, j = 0; j < d->max_vcpus; i++, j++) in vm_event_wake_blocked()
155 if ( !(ved->blocked) || avail_req == 0 ) in vm_event_wake_blocked()
158 if ( test_and_clear_bit(ved->pause_flag, &v->pause_flags) ) in vm_event_wake_blocked()
162 ved->blocked--; in vm_event_wake_blocked()
163 ved->last_vcpu_wake_up = k; in vm_event_wake_blocked()
174 static void vm_event_wake_queued(struct domain *d, struct vm_event_domain *ved) in vm_event_wake_queued() argument
176 unsigned int avail_req = vm_event_ring_available(ved); in vm_event_wake_queued()
179 wake_up_nr(&ved->wq, avail_req); in vm_event_wake_queued()
189 void vm_event_wake(struct domain *d, struct vm_event_domain *ved) in vm_event_wake() argument
191 if (!list_empty(&ved->wq.list)) in vm_event_wake()
192 vm_event_wake_queued(d, ved); in vm_event_wake()
194 vm_event_wake_blocked(d, ved); in vm_event_wake()
197 static int vm_event_disable(struct domain *d, struct vm_event_domain **ved) in vm_event_disable() argument
199 if ( vm_event_check_ring(*ved) ) in vm_event_disable()
203 vm_event_ring_lock(*ved); in vm_event_disable()
205 if ( !list_empty(&(*ved)->wq.list) ) in vm_event_disable()
207 vm_event_ring_unlock(*ved); in vm_event_disable()
212 free_xen_event_channel(d, (*ved)->xen_port); in vm_event_disable()
217 if ( test_and_clear_bit((*ved)->pause_flag, &v->pause_flags) ) in vm_event_disable()
220 (*ved)->blocked--; in vm_event_disable()
224 destroy_ring_for_helper(&(*ved)->ring_page, in vm_event_disable()
225 (*ved)->ring_pg_struct); in vm_event_disable()
229 vm_event_ring_unlock(*ved); in vm_event_disable()
232 xfree(*ved); in vm_event_disable()
233 *ved = NULL; in vm_event_disable()
239 struct vm_event_domain *ved) in vm_event_release_slot() argument
243 ved->target_producers--; in vm_event_release_slot()
245 ved->foreign_producers--; in vm_event_release_slot()
248 vm_event_wake(d, ved); in vm_event_release_slot()
255 void vm_event_mark_and_pause(struct vcpu *v, struct vm_event_domain *ved) in vm_event_mark_and_pause() argument
257 if ( !test_and_set_bit(ved->pause_flag, &v->pause_flags) ) in vm_event_mark_and_pause()
260 ved->blocked++; in vm_event_mark_and_pause()
271 struct vm_event_domain *ved, in vm_event_put_request() argument
280 if( !vm_event_check_ring(ved)) in vm_event_put_request()
295 vm_event_ring_lock(ved); in vm_event_put_request()
298 front_ring = &ved->front_ring; in vm_event_put_request()
312 vm_event_release_slot(d, ved); in vm_event_put_request()
317 avail_req = vm_event_ring_available(ved); in vm_event_put_request()
320 vm_event_mark_and_pause(curr, ved); in vm_event_put_request()
322 vm_event_ring_unlock(ved); in vm_event_put_request()
324 notify_via_xen_event_channel(d, ved->xen_port); in vm_event_put_request()
327 int vm_event_get_response(struct domain *d, struct vm_event_domain *ved, in vm_event_get_response() argument
333 vm_event_ring_lock(ved); in vm_event_get_response()
335 front_ring = &ved->front_ring; in vm_event_get_response()
340 vm_event_ring_unlock(ved); in vm_event_get_response()
354 vm_event_wake(d, ved); in vm_event_get_response()
356 vm_event_ring_unlock(ved); in vm_event_get_response()
369 void vm_event_resume(struct domain *d, struct vm_event_domain *ved) in vm_event_resume() argument
384 while ( vm_event_get_response(d, ved, &rsp) ) in vm_event_resume()
448 void vm_event_cancel_slot(struct domain *d, struct vm_event_domain *ved) in vm_event_cancel_slot() argument
450 if( !vm_event_check_ring(ved) ) in vm_event_cancel_slot()
453 vm_event_ring_lock(ved); in vm_event_cancel_slot()
454 vm_event_release_slot(d, ved); in vm_event_cancel_slot()
455 vm_event_ring_unlock(ved); in vm_event_cancel_slot()
458 static int vm_event_grab_slot(struct vm_event_domain *ved, int foreign) in vm_event_grab_slot() argument
462 if ( !ved->ring_page ) in vm_event_grab_slot()
465 vm_event_ring_lock(ved); in vm_event_grab_slot()
467 avail_req = vm_event_ring_available(ved); in vm_event_grab_slot()
470 vm_event_ring_unlock(ved); in vm_event_grab_slot()
475 ved->target_producers++; in vm_event_grab_slot()
477 ved->foreign_producers++; in vm_event_grab_slot()
479 vm_event_ring_unlock(ved); in vm_event_grab_slot()
485 static int vm_event_wait_try_grab(struct vm_event_domain *ved, int *rc) in vm_event_wait_try_grab() argument
487 *rc = vm_event_grab_slot(ved, 0); in vm_event_wait_try_grab()
492 static int vm_event_wait_slot(struct vm_event_domain *ved) in vm_event_wait_slot() argument
495 wait_event(ved->wq, vm_event_wait_try_grab(ved, &rc) != -EBUSY); in vm_event_wait_slot()
499 bool_t vm_event_check_ring(struct vm_event_domain *ved) in vm_event_check_ring() argument
501 return (ved && ved->ring_page); in vm_event_check_ring()
516 int __vm_event_claim_slot(struct domain *d, struct vm_event_domain *ved, in __vm_event_claim_slot() argument
519 if ( !vm_event_check_ring(ved) ) in __vm_event_claim_slot()
523 return vm_event_wait_slot(ved); in __vm_event_claim_slot()
525 return vm_event_grab_slot(ved, (current->domain != d)); in __vm_event_claim_slot()