diff options
author | Thomas Hellstrom <thellstrom@vmware.com> | 2018-09-18 16:51:22 +0200 |
---|---|---|
committer | Thomas Hellstrom <thellstrom@vmware.com> | 2018-09-25 11:28:03 +0200 |
commit | 539bfff3a67e65e18f62dbbac2dda205b28d63dd (patch) | |
tree | d99872b65b01d0032be31a63a010f70d2c23b7a6 | |
parent | 33792d721104f2872c6599d858e63a0f9d0cf9ef (diff) |
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>
-rw-r--r-- | vmwgfx_context.c | 5 | ||||
-rw-r--r-- | vmwgfx_execbuf.c | 5 | ||||
-rw-r--r-- | vmwgfx_shader.c | 3 | ||||
-rw-r--r-- | vmwgfx_so.c | 3 |
4 files changed, 6 insertions, 10 deletions
diff --git a/vmwgfx_context.c b/vmwgfx_context.c index f07cd58..cbab2c9 100644 --- a/vmwgfx_context.c +++ b/vmwgfx_context.c @@ -856,9 +856,8 @@ struct vmw_resource *vmw_context_cotable(struct vmw_resource *ctx, if (cotable_type >= SVGA_COTABLE_DX10_MAX) return ERR_PTR(-EINVAL); - return vmw_resource_reference - (container_of(ctx, struct vmw_user_context, res)-> - cotables[cotable_type]); + return container_of(ctx, struct vmw_user_context, res)-> + cotables[cotable_type]; } /** diff --git a/vmwgfx_execbuf.c b/vmwgfx_execbuf.c index d7a1f00..fa47926 100644 --- a/vmwgfx_execbuf.c +++ b/vmwgfx_execbuf.c @@ -372,7 +372,6 @@ static int vmw_resource_context_res_add(struct vmw_private *dev_priv, continue; ret = vmw_resource_val_add(sw_context, res); - vmw_resource_unreference(&res); if (unlikely(ret != 0)) return ret; } @@ -1266,7 +1265,6 @@ static int vmw_cmd_dx_define_query(struct vmw_private *dev_priv, cotable_res = vmw_context_cotable(ctx_node->ctx, SVGA_COTABLE_DXQUERY); ret = vmw_cotable_notify(cotable_res, cmd->q.queryId); - vmw_resource_unreference(&cotable_res); return ret; } @@ -2578,7 +2576,6 @@ static int vmw_cmd_dx_view_define(struct vmw_private *dev_priv, res = vmw_context_cotable(ctx_node->ctx, vmw_view_cotables[view_type]); ret = vmw_cotable_notify(res, cmd->defined_id); - vmw_resource_unreference(&res); if (unlikely(ret != 0)) return ret; @@ -2675,7 +2672,6 @@ static int vmw_cmd_dx_so_define(struct vmw_private *dev_priv, res = vmw_context_cotable(ctx_node->ctx, vmw_so_cotables[so_type]); cmd = container_of(header, typeof(*cmd), header); ret = vmw_cotable_notify(res, cmd->defined_id); - vmw_resource_unreference(&res); return ret; } @@ -2806,7 +2802,6 @@ static int vmw_cmd_dx_define_shader(struct vmw_private *dev_priv, res = vmw_context_cotable(ctx_node->ctx, SVGA_COTABLE_DXSHADER); ret = vmw_cotable_notify(res, cmd->body.shaderId); - vmw_resource_unreference(&res); if (ret) return ret; diff --git a/vmwgfx_shader.c b/vmwgfx_shader.c index 286ba8c..91d370a 100644 --- a/vmwgfx_shader.c +++ b/vmwgfx_shader.c @@ -631,7 +631,8 @@ int vmw_dx_shader_add(struct vmw_cmdbuf_res_manager *man, res = &shader->res; shader->ctx = ctx; - shader->cotable = vmw_context_cotable(ctx, SVGA_COTABLE_DXSHADER); + shader->cotable = vmw_resource_reference + (vmw_context_cotable(ctx, SVGA_COTABLE_DXSHADER)); shader->id = user_key; shader->committed = false; INIT_LIST_HEAD(&shader->cotable_head); diff --git a/vmwgfx_so.c b/vmwgfx_so.c index edd9737..04a9f36 100644 --- a/vmwgfx_so.c +++ b/vmwgfx_so.c @@ -362,7 +362,8 @@ int vmw_view_add(struct vmw_cmdbuf_res_manager *man, res = &view->res; view->ctx = ctx; view->srf = vmw_resource_reference(srf); - view->cotable = vmw_context_cotable(ctx, vmw_view_cotables[view_type]); + view->cotable = vmw_resource_reference + (vmw_context_cotable(ctx, vmw_view_cotables[view_type])); view->view_type = view_type; view->view_id = user_key; view->cmd_size = cmd_size; |