drm/vmwgfx: Modify the resource validation interface
authorThomas Hellstrom <thellstrom@vmware.com>
Wed, 26 Sep 2018 13:22:54 +0000 (15:22 +0200)
committerThomas Hellstrom <thellstrom@vmware.com>
Thu, 27 Sep 2018 13:21:36 +0000 (15:21 +0200)
Allow selecting interruptible or uninterruptible waits to match
expectations of callers.

Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: Deepak Rawat <drawat@vmware.com>
Reviewed-by: Sinclair Yeh <syeh@vmware.com>
drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
drivers/gpu/drm/vmwgfx/vmwgfx_validation.c

index 1aa11c39f07f724e3697da3349299b7eadcad1e2..ca46e4075a26b023f5a6510a6a672d150e45571e 100644 (file)
@@ -628,7 +628,7 @@ extern void vmw_resource_unreference(struct vmw_resource **p_res);
 extern struct vmw_resource *vmw_resource_reference(struct vmw_resource *res);
 extern struct vmw_resource *
 vmw_resource_reference_unless_doomed(struct vmw_resource *res);
-extern int vmw_resource_validate(struct vmw_resource *res);
+extern int vmw_resource_validate(struct vmw_resource *res, bool intr);
 extern int vmw_resource_reserve(struct vmw_resource *res, bool interruptible,
                                bool no_backup);
 extern bool vmw_resource_needs_backup(const struct vmw_resource *res);
index 1f134570b7599483e2768cfcbe785409f2b7ba04..cfc87313a431d181f246baad449e368a909c01ad 100644 (file)
@@ -659,7 +659,7 @@ static int vmw_resources_validate(struct vmw_sw_context *sw_context)
                struct vmw_resource *res = val->res;
                struct vmw_buffer_object *backup = res->backup;
 
-               ret = vmw_resource_validate(res);
+               ret = vmw_resource_validate(res, true);
                if (unlikely(ret != 0)) {
                        if (ret != -ERESTARTSYS)
                                DRM_ERROR("Failed to validate resource.\n");
index 0c25bb8faf80d6ef0527b8f8c60767e4e4cea5b9..e5659bf28ee1a7ce440abbab86031ee93b86b318 100644 (file)
@@ -2713,7 +2713,7 @@ int vmw_kms_helper_resource_prepare(struct vmw_resource *res,
 
                ctx->buf = vmw_bo_reference(res->backup);
        }
-       ret = vmw_resource_validate(res);
+       ret = vmw_resource_validate(res, interruptible);
        if (ret)
                goto out_revert;
        return 0;
index 92003ea5a2196a6cbcac38a9e9b4add15a4e6bcb..315b3d60567d4676c0856f1b0e43a63a8974e559 100644 (file)
@@ -587,15 +587,18 @@ out_no_unbind:
 /**
  * vmw_resource_validate - Make a resource up-to-date and visible
  *                         to the device.
- *
- * @res:            The resource to make visible to the device.
+ * @res: The resource to make visible to the device.
+ * @intr: Perform waits interruptible if possible.
  *
  * On succesful return, any backup DMA buffer pointed to by @res->backup will
  * be reserved and validated.
  * On hardware resource shortage, this function will repeatedly evict
  * resources of the same type until the validation succeeds.
+ *
+ * Return: Zero on success, -ERESTARTSYS if interrupted, negative error code
+ * on failure.
  */
-int vmw_resource_validate(struct vmw_resource *res)
+int vmw_resource_validate(struct vmw_resource *res, bool intr)
 {
        int ret;
        struct vmw_resource *evict_res;
@@ -633,7 +636,7 @@ int vmw_resource_validate(struct vmw_resource *res)
                write_unlock(&dev_priv->resource_lock);
 
                /* Trylock backup buffers with a NULL ticket. */
-               ret = vmw_resource_do_evict(NULL, evict_res, true);
+               ret = vmw_resource_do_evict(NULL, evict_res, intr);
                if (unlikely(ret != 0)) {
                        write_lock(&dev_priv->resource_lock);
                        list_add_tail(&evict_res->lru_head, lru_list);
@@ -914,7 +917,7 @@ int vmw_resource_pin(struct vmw_resource *res, bool interruptible)
                        /* Do we really need to pin the MOB as well? */
                        vmw_bo_pin_reserved(vbo, true);
                }
-               ret = vmw_resource_validate(res);
+               ret = vmw_resource_validate(res, interruptible);
                if (vbo)
                        ttm_bo_unreserve(&vbo->base);
                if (ret)
index 5bc00eafe381ef2c65c5beb85e7f69bab08cd03d..dbb58cce098786abf286eb369bcf2d0710c4d829 100644 (file)
@@ -479,7 +479,7 @@ int vmw_validation_res_validate(struct vmw_validation_context *ctx, bool intr)
                struct vmw_resource *res = val->res;
                struct vmw_buffer_object *backup = res->backup;
 
-               ret = vmw_resource_validate(res);
+               ret = vmw_resource_validate(res, intr);
                if (ret) {
                        if (ret != -ERESTARTSYS)
                                DRM_ERROR("Failed to validate resource.\n");