From: Iago Toral Quiroga Date: Mon, 16 Dec 2019 08:05:07 +0000 (+0100) Subject: v3dv: make the command buffer own the command list BOs X-Git-Tag: upstream/21.0.0~4256 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bab28ab1e8ba926ca9a16d232e80365f66ab1c6a;p=platform%2Fupstream%2Fmesa.git v3dv: make the command buffer own the command list BOs Part-of: --- diff --git a/src/broadcom/vulkan/v3dv_cl.c b/src/broadcom/vulkan/v3dv_cl.c index 62b04f0..4debcd3 100644 --- a/src/broadcom/vulkan/v3dv_cl.c +++ b/src/broadcom/vulkan/v3dv_cl.c @@ -48,18 +48,16 @@ v3dv_cl_reset(struct v3dv_cl *cl) /* FIXME: consider keeping the BO when the command buffer is reset with * flag VK_COMMAND_BUFFER_RESET_RELEASE_RESOURCES_BIT. */ - v3dv_cl_destroy(cl); v3dv_cl_init(cl->cmd_buffer, cl); } void v3dv_cl_destroy(struct v3dv_cl *cl) { - assert(cl); - if (cl->bo) { - assert(cl->cmd_buffer && cl->cmd_buffer->device); - v3dv_bo_free(cl->cmd_buffer->device, cl->bo); - } + /* The CL's BO is owned by the command buffer, so don't free it here */ + + /* Leave the CL in a reset state to catch use after destroy instances */ + v3dv_cl_init(NULL, cl); } void @@ -81,6 +79,7 @@ v3dv_cl_ensure_space_with_branch(struct v3dv_cl *cl, uint32_t space) } } + /* The command buffer takes ownership of the BO */ v3dv_cmd_buffer_add_bo(cl->cmd_buffer, bo); bool ok = v3dv_bo_map(cl->cmd_buffer->device, bo, bo->size); diff --git a/src/broadcom/vulkan/v3dv_cmd_buffer.c b/src/broadcom/vulkan/v3dv_cmd_buffer.c index 640f60f..a255c9b 100644 --- a/src/broadcom/vulkan/v3dv_cmd_buffer.c +++ b/src/broadcom/vulkan/v3dv_cmd_buffer.c @@ -105,10 +105,6 @@ cmd_buffer_destroy(struct v3dv_cmd_buffer *cmd_buffer) { list_del(&cmd_buffer->pool_link); - /* FIXME: we are probably double-freeing these BOs in the loop below. - * either have a refcount system for BOs like in v3d or don't free the - * BO when we destroy a CL. - */ v3dv_cl_destroy(&cmd_buffer->bcl); v3dv_cl_destroy(&cmd_buffer->rcl); v3dv_cl_destroy(&cmd_buffer->indirect);