summaryrefslogtreecommitdiffstats
path: root/drivers/misc/habanalabs/common/mmu.c
diff options
context:
space:
mode:
authorMoti Haimovski <mhaimovski@habana.ai>2020-10-27 11:03:32 +0200
committerOded Gabbay <ogabbay@kernel.org>2020-11-30 10:47:35 +0200
commitfe2bc2d249539c117cc887dc1f960ffcbba52d1e (patch)
treea27d616e6eef737982da9682e930d62d690803a6 /drivers/misc/habanalabs/common/mmu.c
parent412c41fcd526b239472a24974591a05227bf5225 (diff)
downloadlinux-fe2bc2d249539c117cc887dc1f960ffcbba52d1e.tar.bz2
habanalabs: share a single ctx-mutex between all MMUs
Multiple locks are usually a source of problems, which in the MMU case can be avoided since it is relatively rare that both MMU tables are updated at the same time. Therefore, use a single shared lock instead of two separate ones. Signed-off-by: Moti Haimovski <mhaimovski@habana.ai> Reviewed-by: Oded Gabbay <ogabbay@kernel.org> Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
Diffstat (limited to 'drivers/misc/habanalabs/common/mmu.c')
-rw-r--r--drivers/misc/habanalabs/common/mmu.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/misc/habanalabs/common/mmu.c b/drivers/misc/habanalabs/common/mmu.c
index 6f535c81478d..f4b3d02fe0d8 100644
--- a/drivers/misc/habanalabs/common/mmu.c
+++ b/drivers/misc/habanalabs/common/mmu.c
@@ -81,6 +81,8 @@ int hl_mmu_ctx_init(struct hl_ctx *ctx)
if (!hdev->mmu_enable)
return 0;
+ mutex_init(&ctx->mmu_lock);
+
if (hdev->mmu_func[MMU_DR_PGT].ctx_init != NULL) {
rc = hdev->mmu_func[MMU_DR_PGT].ctx_init(ctx);
if (rc)
@@ -115,6 +117,8 @@ void hl_mmu_ctx_fini(struct hl_ctx *ctx)
if (hdev->mmu_func[MMU_HR_PGT].ctx_fini != NULL)
hdev->mmu_func[MMU_HR_PGT].ctx_fini(ctx);
+
+ mutex_destroy(&ctx->mmu_lock);
}
/*