habanalabs: correct an error message
PATCH 1/4 habanalabs: correct an error message
We don't try to allocate huge pages here so remove the huge word.
--- drivers/misc/habanalabs/common/memory.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/misc/habanalabs/common/memory.c +2 -2
@@ -77,8 +77,8 @@ static int alloc_device_memory(struct hl_ctx *ctx, struct hl_mem_in *args, paddr = (u64 )gen_pool_alloc (vm->dram_pg_pool, total_size);if (!paddr) {dev_err (hdev->dev, -"failed to allocate %llu huge contiguous pages\n" , - num_pgs); +"failed to allocate %llu contiguous pages with total size of %llu\n" , + num_pgs, total_size);return -ENOMEM ; } }
Signature · 1 line
2.17.1
PATCH 2/4 habanalabs: release kernel context after hw_fini
Some engines use resources that belong to the kernel context (e.g. MMU mappings). In case the halt-engines doesn't work properly due to H/W restriction, we need to make sure the kernel context lives on until after the hw_fini. The hw_fini resets the ASIC after that no engine is alive and we can safely close the kernel context.
--- drivers/misc/habanalabs/common/device.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/misc/habanalabs/common/device.c +6 -7
@@ -967,14 +967,13 @@ int hl_device_reset(struct hl_device *hdev, bool hard_reset,flush_workqueue (hdev->eq_wq); } -/* Release kernel context */ -if ((hard_reset) && (hl_ctx_put (hdev->kernel_ctx) ==1 )) - hdev->kernel_ctx =NULL ; -/* Reset the H/W. It will be in idle state after this returns */ hdev->asic_funcs->hw_fini (hdev, hard_reset);if (hard_reset) { +/* Release kernel context */ +if (hl_ctx_put (hdev->kernel_ctx) ==1 ) + hdev->kernel_ctx =NULL ;hl_vm_fini (hdev);hl_mmu_fini (hdev);hl_eq_reset (hdev, &hdev->event_queue);
@@ -1465,13 +1464,13 @@ void hl_device_fini(struct hl_device *hdev)hl_cb_pool_fini (hdev); +/* Reset the H/W. It will be in idle state after this returns */ + hdev->asic_funcs->hw_fini (hdev, true); +/* Release kernel context */ if ((hdev->kernel_ctx) && (hl_ctx_put (hdev->kernel_ctx) !=1 ))dev_err (hdev->dev,"kernel ctx is still alive\n" ); -/* Reset the H/W. It will be in idle state after this returns */ - hdev->asic_funcs->hw_fini (hdev, true); -hl_vm_fini (hdev);hl_mmu_fini (hdev);
Signature · 1 line
2.17.1
PATCH 3/4 habanalabs: add debug messages for opening/closing context
In reply to Oded GabbayDuring debugging of error we sometimes need to know whether the error happened when a user context was open. Add debug prints when opening and closing user contexts.
--- drivers/misc/habanalabs/common/context.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/misc/habanalabs/common/context.c +5 -0
@@ -28,6 +28,8 @@ static void hl_ctx_fini(struct hl_ctx *ctx)kfree (ctx->cs_pending);if (ctx->asid !=HL_KERNEL_ASID_ID ) { +dev_dbg (hdev->dev,"closing user context %d\n" , ctx->asid); +/* The engines are stopped as there is no executing CS, but the * Coresight might be still working by accessing addresses * related to the stopped engines. Hence stop it explicitly.
@@ -41,6 +43,7 @@ static void hl_ctx_fini(struct hl_ctx *ctx)hl_vm_ctx_fini (ctx);hl_asid_free (hdev, ctx->asid); }else { +dev_dbg (hdev->dev,"closing kernel context\n" );hl_mmu_ctx_fini (ctx); } }
@@ -168,6 +171,8 @@ int hl_ctx_init(struct hl_device *hdev, struct hl_ctx *ctx, bool is_kernel_ctx)dev_err (hdev->dev,"ctx_init failed\n" ); goto err_cb_va_pool_fini; } + +dev_dbg (hdev->dev,"create user context %d\n" , ctx->asid); }return 0 ;
Signature · 1 line
2.17.1
PATCH 4/4 habanalabs: add notice of device not idle
In reply to Oded GabbayThe device should be idle after a context is closed. If not, print a notice.
--- drivers/misc/habanalabs/common/context.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/misc/habanalabs/common/context.c +8 -0
@@ -12,6 +12,7 @@static void hl_ctx_fini (struct hl_ctx *ctx) {struct hl_device *hdev = ctx->hdev; +u64 idle_mask =0 ;int i;/*
@@ -42,6 +43,13 @@ static void hl_ctx_fini(struct hl_ctx *ctx)hl_cb_va_pool_fini (ctx);hl_vm_ctx_fini (ctx);hl_asid_free (hdev, ctx->asid); + +if ((!hdev->pldm) && (hdev->pdev) && + (!hdev->asic_funcs->is_device_idle (hdev, + &idle_mask,NULL ))) +dev_notice (hdev->dev, +"device not idle after user context is closed (0x%llx)\n" , + idle_mask); }else {dev_dbg (hdev->dev,"closing kernel context\n" );hl_mmu_ctx_fini (ctx);
Signature · 1 line
2.17.1
RE: [PATCH 4/4] habanalabs: add notice of device not idle
Quoted 4 lines · Oded Gabbay
The device should be idle after a context is closed. If not, print a notice.
Signed-off-by Oded Gabbay <[email protected]>
This patch-set is: