drm/vmwgfx: Add new keep_resv BO param
Subsystems (3)
PATCH 1/1 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 b32233acceff ("drm/vmwgfx: Fix prime import/export")
--- drivers/gpu/drm/vmwgfx/vmwgfx_bo.c | 3 ++- drivers/gpu/drm/vmwgfx/vmwgfx_bo.h | 3 ++- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 7 ++----- drivers/gpu/drm/vmwgfx/vmwgfx_gem.c | 1 + drivers/gpu/drm/vmwgfx/vmwgfx_shader.c | 7 ++----- drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c | 5 ++--- 6 files changed, 11 insertions(+), 15 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_bo.c +2 -1
@@ -442,7 +442,8 @@ static int vmw_bo_init(struct vmw_private *dev_priv,if (params->pin)ttm_bo_pin (&vmw_bo->tbo); -ttm_bo_unreserve (&vmw_bo->tbo); +if (!params->keep_resv) +ttm_bo_unreserve (&vmw_bo->tbo);return 0 ; }
drivers/gpu/drm/vmwgfx/vmwgfx_bo.h +2 -1
@@ -56,8 +56,9 @@ struct vmw_bo_params {u32 domain;u32 busy_domain;enum ttm_bo_type bo_type; -size_t size;bool pin; +bool keep_resv; +size_t size;struct dma_resv *resv;struct sg_table *sg; };
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +2 -5
@@ -403,7 +403,8 @@ static int vmw_dummy_query_bo_create(struct vmw_private *dev_priv) .busy_domain = VMW_BO_DOMAIN_SYS, .bo_type = ttm_bo_type_kernel, .size = PAGE_SIZE, - .pin = true + .pin = true, + .keep_resv = true, };/*
@@ -415,10 +416,6 @@ static int vmw_dummy_query_bo_create(struct vmw_private *dev_priv)if (unlikely (ret !=0 ))return ret; - ret =ttm_bo_reserve (&vbo->tbo, false, true,NULL ); -BUG_ON (ret !=0 ); -vmw_bo_pin_reserved (vbo, true); - ret =ttm_bo_kmap (&vbo->tbo,0 ,1 , &map);if (likely (ret ==0 )) { result =ttm_kmap_obj_virtual (&map, &dummy);
drivers/gpu/drm/vmwgfx/vmwgfx_gem.c +1 -0
@@ -206,6 +206,7 @@ struct drm_gem_object *vmw_prime_import_sg_table(struct drm_device *dev, .bo_type = ttm_bo_type_sg, .size = attach->dmabuf->size, .pin = false, + .keep_resv = true, .resv = attach->dmabuf->resv, .sg = table,
drivers/gpu/drm/vmwgfx/vmwgfx_shader.c +2 -5
@@ -896,7 +896,8 @@ int vmw_compat_shader_add(struct vmw_private *dev_priv, .busy_domain = VMW_BO_DOMAIN_SYS, .bo_type = ttm_bo_type_device, .size = size, - .pin = true + .pin = true, + .keep_resv = true, };if (!vmw_shader_id_ok (user_key, shader_type))
@@ -906,10 +907,6 @@ int vmw_compat_shader_add(struct vmw_private *dev_priv,if (unlikely (ret !=0 )) goto out; - ret =ttm_bo_reserve (&buf->tbo, false, true,NULL ); -if (unlikely (ret !=0 )) - goto no_reserve; -/* Map and copy shader bytecode. */ ret =ttm_bo_kmap (&buf->tbo,0 ,PFN_UP (size), &map);if (unlikely (ret !=0 )) {
drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c +2 -3
@@ -572,15 +572,14 @@ int vmw_bo_create_and_populate(struct vmw_private *dev_priv, .busy_domain = domain, .bo_type = ttm_bo_type_kernel, .size = bo_size, - .pin = true + .pin = true, + .keep_resv = true, }; ret =vmw_bo_create (dev_priv, &bo_params, &vbo);if (unlikely (ret !=0 ))return ret; - ret =ttm_bo_reserve (&vbo->tbo, false, true,NULL ); -BUG_ON (ret !=0 ); ret =vmw_ttm_populate (vbo->tbo.bdev, vbo->tbo.ttm, &ctx);if (likely (ret ==0 )) { struct vmw_ttm_tt *vmw_tt =
Signature · 1 line
2.34.1
Quoted 133 lines · Ian Forbes
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_tablewhere the imported reservation is unlocked twice.Signed-off-by Ian Forbes <[email protected]>Fixes b32233acceff ("drm/vmwgfx: Fix prime import/export")--- drivers/gpu/drm/vmwgfx/vmwgfx_bo.c | 3 ++- drivers/gpu/drm/vmwgfx/vmwgfx_bo.h | 3 ++- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 7 ++----- drivers/gpu/drm/vmwgfx/vmwgfx_gem.c | 1 + drivers/gpu/drm/vmwgfx/vmwgfx_shader.c | 7 ++----- drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c | 5 ++--- 6 files changed, 11 insertions(+), 15 deletions(-)drivers/gpu/drm/vmwgfx/vmwgfx_bo.c +2
-1@@ -442,7 +442,8 @@ static int vmw_bo_init(struct vmw_private *dev_priv,if (params->pin)ttm_bo_pin (&vmw_bo->tbo); -ttm_bo_unreserve (&vmw_bo->tbo); +if (!params->keep_resv) +ttm_bo_unreserve (&vmw_bo->tbo);return 0 ; }drivers/gpu/drm/vmwgfx/vmwgfx_bo.h +2
-1@@ -56,8 +56,9 @@ struct vmw_bo_params {u32 domain;u32 busy_domain;enum ttm_bo_type bo_type; -size_t size;bool pin; +bool keep_resv; +size_t size;struct dma_resv *resv;struct sg_table *sg; };drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +2
-5@@ -403,7 +403,8 @@ static int vmw_dummy_query_bo_create(struct vmw_private *dev_priv) .busy_domain = VMW_BO_DOMAIN_SYS, .bo_type = ttm_bo_type_kernel, .size = PAGE_SIZE, - .pin = true + .pin = true, + .keep_resv = true, };/* @@ -415,10 +416,6 @@ static int vmw_dummy_query_bo_create(struct vmw_private *dev_priv)if (unlikely (ret !=0 ))return ret; - ret =ttm_bo_reserve (&vbo->tbo, false, true,NULL ); -BUG_ON (ret !=0 ); -vmw_bo_pin_reserved (vbo, true); - ret =ttm_bo_kmap (&vbo->tbo,0 ,1 , &map);if (likely (ret ==0 )) { result =ttm_kmap_obj_virtual (&map, &dummy);drivers/gpu/drm/vmwgfx/vmwgfx_gem.c +1
-0@@ -206,6 +206,7 @@ struct drm_gem_object *vmw_prime_import_sg_table(struct drm_device *dev, .bo_type = ttm_bo_type_sg, .size = attach->dmabuf->size, .pin = false, + .keep_resv = true, .resv = attach->dmabuf->resv, .sg = table,drivers/gpu/drm/vmwgfx/vmwgfx_shader.c +2
-5@@ -896,7 +896,8 @@ int vmw_compat_shader_add(struct vmw_private *dev_priv, .busy_domain = VMW_BO_DOMAIN_SYS, .bo_type = ttm_bo_type_device, .size = size, - .pin = true + .pin = true, + .keep_resv = true, };if (!vmw_shader_id_ok (user_key, shader_type))@@ -906,10 +907,6 @@ int vmw_compat_shader_add(struct vmw_private *dev_priv,if (unlikely (ret !=0 )) goto out; - ret =ttm_bo_reserve (&buf->tbo, false, true,NULL ); -if (unlikely (ret !=0 )) - goto no_reserve; -/* Map and copy shader bytecode. */ ret =ttm_bo_kmap (&buf->tbo,0 ,PFN_UP (size), &map);if (unlikely (ret !=0 )) {drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c +2
-4@@ -572,15 +572,14 @@ int vmw_bo_create_and_populate(struct vmw_private *dev_priv, .busy_domain = domain, .bo_type = ttm_bo_type_kernel, .size = bo_size, - .pin = true + .pin = true, + .keep_resv = true, }; ret =vmw_bo_create (dev_priv, &bo_params, &vbo);if (unlikely (ret !=0 ))return ret; - ret =ttm_bo_reserve (&vbo->tbo, false, true,NULL ); -BUG_ON (ret !=0 ); ret =vmw_ttm_populate (vbo->tbo.bdev, vbo->tbo.ttm, &ctx);if (likely (ret ==0 )) { struct vmw_ttm_tt *vmw_tt = --
Quoted 2 lines
2.34.1
That's a pretty nice cleanup and a fix.
Reviewed-by Zack Rusin <[email protected]>
z