aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
authorThomas Hellstrom <thellstrom@vmware.com>2018-09-26 10:29:49 -0400
committerThomas Hellstrom <thellstrom@vmware.com>2018-09-28 02:57:08 -0400
commit1b9a01d62cb1bed2bc98f8b4e31d5b9daf0a446b (patch)
treee26303fbb82b5c14f7fe502926ffb52befb02a5c /drivers/gpu
parent508108ea274788888408f4245438e40c90d821da (diff)
drm/vmwgfx: Don't refcount cotable lookups during command buffer validation
The typical pattern of these lookups are -Lookup -Put on validate list if not already there. -Unreference And since we are the exclusive user of the context during lookup time, we can be sure that the resource will stay alive during the sequence. So avoid taking a reference during lookup, and also avoid unreferencing when done. There are two users outside of command buffer validation and those are refcounted explicitly. Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com> Reviewed-by: Sinclair Yeh <syeh@vmware.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_context.c5
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c5
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_shader.c3
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_so.c3
4 files changed, 6 insertions, 10 deletions
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_context.c b/drivers/gpu/drm/vmwgfx/vmwgfx_context.c
index 24d7c81081ae..14bd760a62fd 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_context.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_context.c
@@ -861,9 +861,8 @@ struct vmw_resource *vmw_context_cotable(struct vmw_resource *ctx,
861 if (cotable_type >= SVGA_COTABLE_DX10_MAX) 861 if (cotable_type >= SVGA_COTABLE_DX10_MAX)
862 return ERR_PTR(-EINVAL); 862 return ERR_PTR(-EINVAL);
863 863
864 return vmw_resource_reference 864 return container_of(ctx, struct vmw_user_context, res)->
865 (container_of(ctx, struct vmw_user_context, res)-> 865 cotables[cotable_type];
866 cotables[cotable_type]);
867} 866}
868 867
869/** 868/**
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
index 13db7efcb89c..dfa2d19274d5 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
@@ -372,7 +372,6 @@ static int vmw_resource_context_res_add(struct vmw_private *dev_priv,
372 continue; 372 continue;
373 373
374 ret = vmw_resource_val_add(sw_context, res); 374 ret = vmw_resource_val_add(sw_context, res);
375 vmw_resource_unreference(&res);
376 if (unlikely(ret != 0)) 375 if (unlikely(ret != 0))
377 return ret; 376 return ret;
378 } 377 }
@@ -1266,7 +1265,6 @@ static int vmw_cmd_dx_define_query(struct vmw_private *dev_priv,
1266 1265
1267 cotable_res = vmw_context_cotable(ctx_node->ctx, SVGA_COTABLE_DXQUERY); 1266 cotable_res = vmw_context_cotable(ctx_node->ctx, SVGA_COTABLE_DXQUERY);
1268 ret = vmw_cotable_notify(cotable_res, cmd->q.queryId); 1267 ret = vmw_cotable_notify(cotable_res, cmd->q.queryId);
1269 vmw_resource_unreference(&cotable_res);
1270 1268
1271 return ret; 1269 return ret;
1272} 1270}
@@ -2578,7 +2576,6 @@ static int vmw_cmd_dx_view_define(struct vmw_private *dev_priv,
2578 2576
2579 res = vmw_context_cotable(ctx_node->ctx, vmw_view_cotables[view_type]); 2577 res = vmw_context_cotable(ctx_node->ctx, vmw_view_cotables[view_type]);
2580 ret = vmw_cotable_notify(res, cmd->defined_id); 2578 ret = vmw_cotable_notify(res, cmd->defined_id);
2581 vmw_resource_unreference(&res);
2582 if (unlikely(ret != 0)) 2579 if (unlikely(ret != 0))
2583 return ret; 2580 return ret;
2584 2581
@@ -2675,7 +2672,6 @@ static int vmw_cmd_dx_so_define(struct vmw_private *dev_priv,
2675 res = vmw_context_cotable(ctx_node->ctx, vmw_so_cotables[so_type]); 2672 res = vmw_context_cotable(ctx_node->ctx, vmw_so_cotables[so_type]);
2676 cmd = container_of(header, typeof(*cmd), header); 2673 cmd = container_of(header, typeof(*cmd), header);
2677 ret = vmw_cotable_notify(res, cmd->defined_id); 2674 ret = vmw_cotable_notify(res, cmd->defined_id);
2678 vmw_resource_unreference(&res);
2679 2675
2680 return ret; 2676 return ret;
2681} 2677}
@@ -2806,7 +2802,6 @@ static int vmw_cmd_dx_define_shader(struct vmw_private *dev_priv,
2806 2802
2807 res = vmw_context_cotable(ctx_node->ctx, SVGA_COTABLE_DXSHADER); 2803 res = vmw_context_cotable(ctx_node->ctx, SVGA_COTABLE_DXSHADER);
2808 ret = vmw_cotable_notify(res, cmd->body.shaderId); 2804 ret = vmw_cotable_notify(res, cmd->body.shaderId);
2809 vmw_resource_unreference(&res);
2810 if (ret) 2805 if (ret)
2811 return ret; 2806 return ret;
2812 2807
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_shader.c b/drivers/gpu/drm/vmwgfx/vmwgfx_shader.c
index 6915c8258e6b..bf32fe446219 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_shader.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_shader.c
@@ -636,7 +636,8 @@ int vmw_dx_shader_add(struct vmw_cmdbuf_res_manager *man,
636 636
637 res = &shader->res; 637 res = &shader->res;
638 shader->ctx = ctx; 638 shader->ctx = ctx;
639 shader->cotable = vmw_context_cotable(ctx, SVGA_COTABLE_DXSHADER); 639 shader->cotable = vmw_resource_reference
640 (vmw_context_cotable(ctx, SVGA_COTABLE_DXSHADER));
640 shader->id = user_key; 641 shader->id = user_key;
641 shader->committed = false; 642 shader->committed = false;
642 INIT_LIST_HEAD(&shader->cotable_head); 643 INIT_LIST_HEAD(&shader->cotable_head);
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_so.c b/drivers/gpu/drm/vmwgfx/vmwgfx_so.c
index aaabb87ac3af..bc8bb690f1ea 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_so.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_so.c
@@ -366,7 +366,8 @@ int vmw_view_add(struct vmw_cmdbuf_res_manager *man,
366 res = &view->res; 366 res = &view->res;
367 view->ctx = ctx; 367 view->ctx = ctx;
368 view->srf = vmw_resource_reference(srf); 368 view->srf = vmw_resource_reference(srf);
369 view->cotable = vmw_context_cotable(ctx, vmw_view_cotables[view_type]); 369 view->cotable = vmw_resource_reference
370 (vmw_context_cotable(ctx, vmw_view_cotables[view_type]));
370 view->view_type = view_type; 371 view->view_type = view_type;
371 view->view_id = user_key; 372 view->view_id = user_key;
372 view->cmd_size = cmd_size; 373 view->cmd_size = cmd_size;