habanalabs: add notice of device not idle
authorOded Gabbay <oded.gabbay@gmail.com>
Wed, 23 Sep 2020 20:56:18 +0000 (23:56 +0300)
committerOded Gabbay <oded.gabbay@gmail.com>
Fri, 25 Sep 2020 11:44:21 +0000 (14:44 +0300)
The device should be idle after a context is closed. If not, print a
notice.

Reviewed-by: Tomer Tayar <ttayar@habana.ai>
Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
drivers/misc/habanalabs/common/context.c

index bd03ef074eed1a31f7b7ca2bb134f48e9c3f105b..7a59dd7c6450b1869945565f3ecfe0e6003fa5bb 100644 (file)
@@ -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);