int vmm_mutex_unlock(struct vmm_mutex *mut) { int rc = VMM_EINVALID; irq_flags_t flags; struct vmm_vcpu *current_vcpu = vmm_scheduler_current_vcpu(); BUG_ON(!mut); BUG_ON(!vmm_scheduler_orphan_context()); vmm_spin_lock_irqsave(&mut->wq.lock, flags); if (mut->lock && mut->owner == current_vcpu) { mut->lock--; if (!mut->lock) { mut->owner = NULL; vmm_manager_vcpu_resource_remove(current_vcpu, &mut->res); rc = __vmm_waitqueue_wakeall(&mut->wq); if (rc == VMM_ENOENT) { rc = VMM_OK; } } else { rc = VMM_OK; } } vmm_spin_unlock_irqrestore(&mut->wq.lock, flags); return rc; }
int vmm_completion_complete_all(struct vmm_completion *cmpl) { int rc = VMM_OK; irq_flags_t flags; BUG_ON(!cmpl); vmm_spin_lock_irqsave(&cmpl->wq.lock, flags); cmpl->done += 0xFFFFFFFFUL / 2; rc = __vmm_waitqueue_wakeall(&cmpl->wq); vmm_spin_unlock_irqrestore(&cmpl->wq.lock, flags); return rc; }
void __vmm_mutex_cleanup(struct vmm_vcpu *vcpu, struct vmm_vcpu_resource *vcpu_res) { irq_flags_t flags; struct vmm_mutex *mut = container_of(vcpu_res, struct vmm_mutex, res); if (!vcpu || !vcpu_res) { return; } vmm_spin_lock_irqsave(&mut->wq.lock, flags); if (mut->lock && mut->owner == vcpu) { mut->lock = 0; mut->owner = NULL; __vmm_waitqueue_wakeall(&mut->wq); } vmm_spin_unlock_irqrestore(&mut->wq.lock, flags); }
int vmm_mutex_unlock(struct vmm_mutex *mut) { int rc = VMM_OK; irq_flags_t flags; BUG_ON(!mut); BUG_ON(!vmm_scheduler_orphan_context()); vmm_spin_lock_irqsave(&mut->wq.lock, flags); if (mut->lock && mut->owner == vmm_scheduler_current_vcpu()) { mut->lock = 0; mut->owner = NULL; rc = __vmm_waitqueue_wakeall(&mut->wq); } vmm_spin_unlock_irqrestore(&mut->wq.lock, flags); return rc; }