diff options
author | Thomas Hellstrom <thellstrom@vmware.com> | 2015-06-26 00:25:37 -0700 |
---|---|---|
committer | Thomas Hellstrom <thellstrom@vmware.com> | 2015-08-05 14:01:08 +0200 |
commit | 459d0fa7359654e5e076e84fc58512f00f70fee9 (patch) | |
tree | 506a294671a2406db1530c60d5df92b1a675b875 /drivers/gpu/drm/vmwgfx/vmwgfx_resource.c | |
parent | f89c6c321c4a7c0188922f331b70d83af01ab53e (diff) | |
download | lwn-459d0fa7359654e5e076e84fc58512f00f70fee9.tar.gz lwn-459d0fa7359654e5e076e84fc58512f00f70fee9.zip |
drm/vmwgfx: Introduce a pin count to allow for recursive pinning v2
v2: Fix dma buffer validation on resource pinning.
Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: Sinclair Yeh <syeh@vmware.com>
Diffstat (limited to 'drivers/gpu/drm/vmwgfx/vmwgfx_resource.c')
-rw-r--r-- | drivers/gpu/drm/vmwgfx/vmwgfx_resource.c | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c index 9dcbe8ba08ea..271bc900d83a 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c @@ -1596,25 +1596,29 @@ int vmw_resource_pin(struct vmw_resource *res) goto out_no_reserve; if (res->pin_count == 0) { - struct ttm_buffer_object *bo = NULL; + struct vmw_dma_buffer *vbo = NULL; if (res->backup) { - bo = &res->backup->base; - - ttm_bo_reserve(bo, false, false, false, NULL); - ret = ttm_bo_validate(bo, res->func->backup_placement, - false, false); - if (ret) { - ttm_bo_unreserve(bo); - goto out_no_validate; + vbo = res->backup; + + ttm_bo_reserve(&vbo->base, false, false, false, NULL); + if (!vbo->pin_count) { + ret = ttm_bo_validate + (&vbo->base, + res->func->backup_placement, + false, false); + if (ret) { + ttm_bo_unreserve(&vbo->base); + goto out_no_validate; + } } /* Do we really need to pin the MOB as well? */ - vmw_bo_pin(bo, true); + vmw_bo_pin_reserved(vbo, true); } ret = vmw_resource_validate(res); - if (bo) - ttm_bo_unreserve(bo); + if (vbo) + ttm_bo_unreserve(&vbo->base); if (ret) goto out_no_validate; } @@ -1650,11 +1654,11 @@ void vmw_resource_unpin(struct vmw_resource *res) WARN_ON(res->pin_count == 0); if (--res->pin_count == 0 && res->backup) { - struct ttm_buffer_object *bo = &res->backup->base; + struct vmw_dma_buffer *vbo = res->backup; - ttm_bo_reserve(bo, false, false, false, NULL); - vmw_bo_pin(bo, false); - ttm_bo_unreserve(bo); + ttm_bo_reserve(&vbo->base, false, false, false, NULL); + vmw_bo_pin_reserved(vbo, false); + ttm_bo_unreserve(&vbo->base); } vmw_resource_unreserve(res, NULL, 0UL); |