Skip to content

Commit b7d4062

Browse files
en4bzzackr
authored andcommitted
drm/vmwgfx: Add new keep_resv BO param
Adds a new BO param that keeps the reservation locked after creation. This removes the need to re-reserve the BO after creation which is a waste of cycles. This also fixes a bug in vmw_prime_import_sg_table where the imported reservation is unlocked twice. Signed-off-by: Ian Forbes <[email protected]> Fixes: b32233a ("drm/vmwgfx: Fix prime import/export") Reviewed-by: Zack Rusin <[email protected]> Signed-off-by: Zack Rusin <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 9cdebfa commit b7d4062

File tree

6 files changed

+11
-15
lines changed

6 files changed

+11
-15
lines changed

drivers/gpu/drm/vmwgfx/vmwgfx_bo.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,8 @@ static int vmw_bo_init(struct vmw_private *dev_priv,
442442

443443
if (params->pin)
444444
ttm_bo_pin(&vmw_bo->tbo);
445-
ttm_bo_unreserve(&vmw_bo->tbo);
445+
if (!params->keep_resv)
446+
ttm_bo_unreserve(&vmw_bo->tbo);
446447

447448
return 0;
448449
}

drivers/gpu/drm/vmwgfx/vmwgfx_bo.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,9 @@ struct vmw_bo_params {
5656
u32 domain;
5757
u32 busy_domain;
5858
enum ttm_bo_type bo_type;
59-
size_t size;
6059
bool pin;
60+
bool keep_resv;
61+
size_t size;
6162
struct dma_resv *resv;
6263
struct sg_table *sg;
6364
};

drivers/gpu/drm/vmwgfx/vmwgfx_drv.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,8 @@ static int vmw_dummy_query_bo_create(struct vmw_private *dev_priv)
403403
.busy_domain = VMW_BO_DOMAIN_SYS,
404404
.bo_type = ttm_bo_type_kernel,
405405
.size = PAGE_SIZE,
406-
.pin = true
406+
.pin = true,
407+
.keep_resv = true,
407408
};
408409

409410
/*
@@ -415,10 +416,6 @@ static int vmw_dummy_query_bo_create(struct vmw_private *dev_priv)
415416
if (unlikely(ret != 0))
416417
return ret;
417418

418-
ret = ttm_bo_reserve(&vbo->tbo, false, true, NULL);
419-
BUG_ON(ret != 0);
420-
vmw_bo_pin_reserved(vbo, true);
421-
422419
ret = ttm_bo_kmap(&vbo->tbo, 0, 1, &map);
423420
if (likely(ret == 0)) {
424421
result = ttm_kmap_obj_virtual(&map, &dummy);

drivers/gpu/drm/vmwgfx/vmwgfx_gem.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ struct drm_gem_object *vmw_prime_import_sg_table(struct drm_device *dev,
206206
.bo_type = ttm_bo_type_sg,
207207
.size = attach->dmabuf->size,
208208
.pin = false,
209+
.keep_resv = true,
209210
.resv = attach->dmabuf->resv,
210211
.sg = table,
211212

drivers/gpu/drm/vmwgfx/vmwgfx_shader.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -896,7 +896,8 @@ int vmw_compat_shader_add(struct vmw_private *dev_priv,
896896
.busy_domain = VMW_BO_DOMAIN_SYS,
897897
.bo_type = ttm_bo_type_device,
898898
.size = size,
899-
.pin = true
899+
.pin = true,
900+
.keep_resv = true,
900901
};
901902

902903
if (!vmw_shader_id_ok(user_key, shader_type))
@@ -906,10 +907,6 @@ int vmw_compat_shader_add(struct vmw_private *dev_priv,
906907
if (unlikely(ret != 0))
907908
goto out;
908909

909-
ret = ttm_bo_reserve(&buf->tbo, false, true, NULL);
910-
if (unlikely(ret != 0))
911-
goto no_reserve;
912-
913910
/* Map and copy shader bytecode. */
914911
ret = ttm_bo_kmap(&buf->tbo, 0, PFN_UP(size), &map);
915912
if (unlikely(ret != 0)) {

drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -572,15 +572,14 @@ int vmw_bo_create_and_populate(struct vmw_private *dev_priv,
572572
.busy_domain = domain,
573573
.bo_type = ttm_bo_type_kernel,
574574
.size = bo_size,
575-
.pin = true
575+
.pin = true,
576+
.keep_resv = true,
576577
};
577578

578579
ret = vmw_bo_create(dev_priv, &bo_params, &vbo);
579580
if (unlikely(ret != 0))
580581
return ret;
581582

582-
ret = ttm_bo_reserve(&vbo->tbo, false, true, NULL);
583-
BUG_ON(ret != 0);
584583
ret = vmw_ttm_populate(vbo->tbo.bdev, vbo->tbo.ttm, &ctx);
585584
if (likely(ret == 0)) {
586585
struct vmw_ttm_tt *vmw_tt =

0 commit comments

Comments
 (0)