Skip to content

Commit 84e1bf0

Browse files
committed
drm/vmwgfx: Modify the resource validation interface
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>
1 parent 038ecc5 commit 84e1bf0

File tree

5 files changed

+12
-9
lines changed

5 files changed

+12
-9
lines changed

drivers/gpu/drm/vmwgfx/vmwgfx_drv.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ extern void vmw_resource_unreference(struct vmw_resource **p_res);
628628
extern struct vmw_resource *vmw_resource_reference(struct vmw_resource *res);
629629
extern struct vmw_resource *
630630
vmw_resource_reference_unless_doomed(struct vmw_resource *res);
631-
extern int vmw_resource_validate(struct vmw_resource *res);
631+
extern int vmw_resource_validate(struct vmw_resource *res, bool intr);
632632
extern int vmw_resource_reserve(struct vmw_resource *res, bool interruptible,
633633
bool no_backup);
634634
extern bool vmw_resource_needs_backup(const struct vmw_resource *res);

drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ static int vmw_resources_validate(struct vmw_sw_context *sw_context)
659659
struct vmw_resource *res = val->res;
660660
struct vmw_buffer_object *backup = res->backup;
661661

662-
ret = vmw_resource_validate(res);
662+
ret = vmw_resource_validate(res, true);
663663
if (unlikely(ret != 0)) {
664664
if (ret != -ERESTARTSYS)
665665
DRM_ERROR("Failed to validate resource.\n");

drivers/gpu/drm/vmwgfx/vmwgfx_kms.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2713,7 +2713,7 @@ int vmw_kms_helper_resource_prepare(struct vmw_resource *res,
27132713

27142714
ctx->buf = vmw_bo_reference(res->backup);
27152715
}
2716-
ret = vmw_resource_validate(res);
2716+
ret = vmw_resource_validate(res, interruptible);
27172717
if (ret)
27182718
goto out_revert;
27192719
return 0;

drivers/gpu/drm/vmwgfx/vmwgfx_resource.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -587,15 +587,18 @@ static int vmw_resource_do_evict(struct ww_acquire_ctx *ticket,
587587
/**
588588
* vmw_resource_validate - Make a resource up-to-date and visible
589589
* to the device.
590-
*
591-
* @res: The resource to make visible to the device.
590+
* @res: The resource to make visible to the device.
591+
* @intr: Perform waits interruptible if possible.
592592
*
593593
* On succesful return, any backup DMA buffer pointed to by @res->backup will
594594
* be reserved and validated.
595595
* On hardware resource shortage, this function will repeatedly evict
596596
* resources of the same type until the validation succeeds.
597+
*
598+
* Return: Zero on success, -ERESTARTSYS if interrupted, negative error code
599+
* on failure.
597600
*/
598-
int vmw_resource_validate(struct vmw_resource *res)
601+
int vmw_resource_validate(struct vmw_resource *res, bool intr)
599602
{
600603
int ret;
601604
struct vmw_resource *evict_res;
@@ -633,7 +636,7 @@ int vmw_resource_validate(struct vmw_resource *res)
633636
write_unlock(&dev_priv->resource_lock);
634637

635638
/* Trylock backup buffers with a NULL ticket. */
636-
ret = vmw_resource_do_evict(NULL, evict_res, true);
639+
ret = vmw_resource_do_evict(NULL, evict_res, intr);
637640
if (unlikely(ret != 0)) {
638641
write_lock(&dev_priv->resource_lock);
639642
list_add_tail(&evict_res->lru_head, lru_list);
@@ -914,7 +917,7 @@ int vmw_resource_pin(struct vmw_resource *res, bool interruptible)
914917
/* Do we really need to pin the MOB as well? */
915918
vmw_bo_pin_reserved(vbo, true);
916919
}
917-
ret = vmw_resource_validate(res);
920+
ret = vmw_resource_validate(res, interruptible);
918921
if (vbo)
919922
ttm_bo_unreserve(&vbo->base);
920923
if (ret)

drivers/gpu/drm/vmwgfx/vmwgfx_validation.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ int vmw_validation_res_validate(struct vmw_validation_context *ctx, bool intr)
479479
struct vmw_resource *res = val->res;
480480
struct vmw_buffer_object *backup = res->backup;
481481

482-
ret = vmw_resource_validate(res);
482+
ret = vmw_resource_validate(res, intr);
483483
if (ret) {
484484
if (ret != -ERESTARTSYS)
485485
DRM_ERROR("Failed to validate resource.\n");

0 commit comments

Comments
 (0)