diff options
Diffstat (limited to 'drivers/misc/habanalabs/common/context.c')
| -rw-r--r-- | drivers/misc/habanalabs/common/context.c | 14 | 
1 files changed, 11 insertions, 3 deletions
| diff --git a/drivers/misc/habanalabs/common/context.c b/drivers/misc/habanalabs/common/context.c index cda871afb8f4..62d705889ca8 100644 --- a/drivers/misc/habanalabs/common/context.c +++ b/drivers/misc/habanalabs/common/context.c @@ -20,6 +20,11 @@ static void hl_ctx_fini(struct hl_ctx *ctx)  	 */  	hl_pending_cb_list_flush(ctx); +	/* Release all allocated HW block mapped list entries and destroy +	 * the mutex. +	 */ +	hl_hw_block_mem_fini(ctx); +  	/*  	 * If we arrived here, there are no jobs waiting for this context  	 * on its queues so we can safely remove it. @@ -160,13 +165,15 @@ int hl_ctx_init(struct hl_device *hdev, struct hl_ctx *ctx, bool is_kernel_ctx)  	if (!ctx->cs_pending)  		return -ENOMEM; +	hl_hw_block_mem_init(ctx); +  	if (is_kernel_ctx) {  		ctx->asid = HL_KERNEL_ASID_ID; /* Kernel driver gets ASID 0 */  		rc = hl_vm_ctx_init(ctx);  		if (rc) {  			dev_err(hdev->dev, "Failed to init mem ctx module\n");  			rc = -ENOMEM; -			goto err_free_cs_pending; +			goto err_hw_block_mem_fini;  		}  		rc = hdev->asic_funcs->ctx_init(ctx); @@ -179,7 +186,7 @@ int hl_ctx_init(struct hl_device *hdev, struct hl_ctx *ctx, bool is_kernel_ctx)  		if (!ctx->asid) {  			dev_err(hdev->dev, "No free ASID, failed to create context\n");  			rc = -ENOMEM; -			goto err_free_cs_pending; +			goto err_hw_block_mem_fini;  		}  		rc = hl_vm_ctx_init(ctx); @@ -214,7 +221,8 @@ err_vm_ctx_fini:  err_asid_free:  	if (ctx->asid != HL_KERNEL_ASID_ID)  		hl_asid_free(hdev, ctx->asid); -err_free_cs_pending: +err_hw_block_mem_fini: +	hl_hw_block_mem_fini(ctx);  	kfree(ctx->cs_pending);  	return rc; | 
