linux/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
/**
 * vmw_kms_helper_resource_prepare - Reserve and validate a resource before
 * command submission.
 *
 * @res: Pointer to the resource. Typically a surface.
 * @interruptible: Whether to perform waits as interruptible.
 *
 * Reserves and validates also the backup buffer if a guest-backed resource.
 * Returns 0 on success, negative error code on failure. -ERESTARTSYS if
 * interrupted by a signal.
 */
Reserve and validate a resource before
command submission.

@res: Pointer to the resource. Typically a surface.
@interruptible: Whether to perform waits as interruptible.

Reserves and validates also the backup buffer if a guest-backed resource.
Returns 0 on success, negative error code on failure. -ERESTARTSYS if
interrupted by a signal.
Reserve and validate a resource before command submission . @res : Pointer to the resource . Typically a surface . @interruptible : Whether to perform waits as interruptible . Reserves and validates also the backup buffer if a guest - backed resource . Returns 0 on success negative error code on failure . - ERESTARTSYS if interrupted by a signal .
int vmw_kms_helper_resource_prepare(struct vmw_resource *res,
				    bool interruptible,
				    struct vmw_validation_ctx *ctx)
{
	int ret = 0;
	ctx->buf = NULL;
	ctx->res = res;
	if (interruptible)
		ret = mutex_lock_interruptible(&res->dev_priv->cmdbuf_mutex);
	else
		mutex_lock(&res->dev_priv->cmdbuf_mutex);
	if (unlikely(ret != 0))
		return -ERESTARTSYS;
	ret = vmw_resource_reserve(res, interruptible, false);
	if (ret)
		goto out_unlock;
	if (res->backup) {
		ret = vmw_kms_helper_buffer_prepare(res->dev_priv, res->backup,
						    interruptible,
						    res->dev_priv->has_mob,
						    false);
		if (ret)
			goto out_unreserve;
		ctx->buf = vmw_bo_reference(res->backup);
	}
	ret = vmw_resource_validate(res);
	if (ret)
		goto out_revert;
	return 0;
out_revert:
	vmw_kms_helper_buffer_revert(ctx->buf);
out_unreserve:
	vmw_resource_unreserve(res, false, NULL, 0);
out_unlock:
	mutex_unlock(&res->dev_priv->cmdbuf_mutex);
	return ret;
}
int vmw_kms_helper_resource_prepare ( struct vmw_resource * res , bool interruptible , struct vmw_validation_ctx * ctx ) { int ret = 0 ; ctx -> buf = NULL ; ctx -> res = res ; if ( interruptible ) ret = mutex_lock_interruptible ( & res -> dev_priv -> cmdbuf_mutex ) ; else mutex_lock ( & res -> dev_priv -> cmdbuf_mutex ) ; if ( unlikely ( ret != 0 ) ) return - ERESTARTSYS ; ret = vmw_resource_reserve ( res , interruptible , false ) ; if ( ret ) goto out_unlock ; if ( res -> backup ) { ret = vmw_kms_helper_buffer_prepare ( res -> dev_priv , res -> backup , interruptible , res -> dev_priv -> has_mob , false ) ; if ( ret ) goto out_unreserve ; ctx -> buf = vmw_bo_reference ( res -> backup ) ; } ret = vmw_resource_validate ( res ) ; if ( ret ) goto out_revert ; return 0 ; out_revert : vmw_kms_helper_buffer_revert ( ctx -> buf ) ; out_unreserve : vmw_resource_unreserve ( res , false , NULL , 0 ) ; out_unlock : mutex_unlock ( & res -> dev_priv -> cmdbuf_mutex ) ; return ret ; }
vmw_kms_helper_resource_prepare - Reserve and validate a resource before
 command submission.
vmw_kms_helper_resource_prepare - Reserve and validate a resource before command submission .