Commit 9e2e8fc7 authored by Oded Gabbay's avatar Oded Gabbay

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.
Reviewed-by: default avatarTomer Tayar <ttayar@habana.ai>
Signed-off-by: default avatarOded Gabbay <oded.gabbay@gmail.com>
parent fc6121e9
...@@ -967,14 +967,13 @@ int hl_device_reset(struct hl_device *hdev, bool hard_reset, ...@@ -967,14 +967,13 @@ int hl_device_reset(struct hl_device *hdev, bool hard_reset,
flush_workqueue(hdev->eq_wq); 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 */ /* Reset the H/W. It will be in idle state after this returns */
hdev->asic_funcs->hw_fini(hdev, hard_reset); hdev->asic_funcs->hw_fini(hdev, hard_reset);
if (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_vm_fini(hdev);
hl_mmu_fini(hdev); hl_mmu_fini(hdev);
hl_eq_reset(hdev, &hdev->event_queue); hl_eq_reset(hdev, &hdev->event_queue);
...@@ -1465,13 +1464,13 @@ void hl_device_fini(struct hl_device *hdev) ...@@ -1465,13 +1464,13 @@ void hl_device_fini(struct hl_device *hdev)
hl_cb_pool_fini(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 */ /* Release kernel context */
if ((hdev->kernel_ctx) && (hl_ctx_put(hdev->kernel_ctx) != 1)) if ((hdev->kernel_ctx) && (hl_ctx_put(hdev->kernel_ctx) != 1))
dev_err(hdev->dev, "kernel ctx is still alive\n"); 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_vm_fini(hdev);
hl_mmu_fini(hdev); hl_mmu_fini(hdev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment