mirror of https://gitee.com/openkylin/linux.git
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>
This commit is contained in:
parent
412c41fcd5
commit
fe2bc2d249
|
@ -81,6 +81,8 @@ int hl_mmu_ctx_init(struct hl_ctx *ctx)
|
||||||
if (!hdev->mmu_enable)
|
if (!hdev->mmu_enable)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
mutex_init(&ctx->mmu_lock);
|
||||||
|
|
||||||
if (hdev->mmu_func[MMU_DR_PGT].ctx_init != NULL) {
|
if (hdev->mmu_func[MMU_DR_PGT].ctx_init != NULL) {
|
||||||
rc = hdev->mmu_func[MMU_DR_PGT].ctx_init(ctx);
|
rc = hdev->mmu_func[MMU_DR_PGT].ctx_init(ctx);
|
||||||
if (rc)
|
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)
|
if (hdev->mmu_func[MMU_HR_PGT].ctx_fini != NULL)
|
||||||
hdev->mmu_func[MMU_HR_PGT].ctx_fini(ctx);
|
hdev->mmu_func[MMU_HR_PGT].ctx_fini(ctx);
|
||||||
|
|
||||||
|
mutex_destroy(&ctx->mmu_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -481,9 +481,7 @@ static void hl_mmu_v1_fini(struct hl_device *hdev)
|
||||||
*/
|
*/
|
||||||
static int hl_mmu_v1_ctx_init(struct hl_ctx *ctx)
|
static int hl_mmu_v1_ctx_init(struct hl_ctx *ctx)
|
||||||
{
|
{
|
||||||
mutex_init(&ctx->mmu_lock);
|
|
||||||
hash_init(ctx->mmu_shadow_hash);
|
hash_init(ctx->mmu_shadow_hash);
|
||||||
|
|
||||||
return dram_default_mapping_init(ctx);
|
return dram_default_mapping_init(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -516,8 +514,6 @@ static void hl_mmu_v1_ctx_fini(struct hl_ctx *ctx)
|
||||||
pgt_info->phys_addr, ctx->asid, pgt_info->num_of_ptes);
|
pgt_info->phys_addr, ctx->asid, pgt_info->num_of_ptes);
|
||||||
_free_hop(ctx, pgt_info);
|
_free_hop(ctx, pgt_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_destroy(&ctx->mmu_lock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _hl_mmu_v1_unmap(struct hl_ctx *ctx,
|
static int _hl_mmu_v1_unmap(struct hl_ctx *ctx,
|
||||||
|
|
Loading…
Reference in New Issue