habanalabs: add enum mmu_op_flags
The enum vm_type was abused, used once as a value (indication memory type for map) and once as a flag (for cache invalidation). This makes it hard to add new and still keep it meaningful, hence it is better to split into one enum for values and one for flags. Signed-off-by: Yuri Nudelman <ynudelman@habana.ai> Reviewed-by: Oded Gabbay <ogabbay@kernel.org> Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
This commit is contained in:
parent
89d6decdb7
commit
82e5169e8a
|
@ -80,7 +80,7 @@ static int cb_map_mem(struct hl_ctx *ctx, struct hl_cb *cb)
|
|||
offset += va_block->size;
|
||||
}
|
||||
|
||||
hdev->asic_funcs->mmu_invalidate_cache(hdev, false, VM_TYPE_USERPTR);
|
||||
hdev->asic_funcs->mmu_invalidate_cache(hdev, false, MMU_OP_USERPTR);
|
||||
|
||||
mutex_unlock(&ctx->mmu_lock);
|
||||
|
||||
|
@ -97,7 +97,7 @@ err_va_umap:
|
|||
offset -= va_block->size;
|
||||
}
|
||||
|
||||
hdev->asic_funcs->mmu_invalidate_cache(hdev, true, VM_TYPE_USERPTR);
|
||||
hdev->asic_funcs->mmu_invalidate_cache(hdev, true, MMU_OP_USERPTR);
|
||||
|
||||
mutex_unlock(&ctx->mmu_lock);
|
||||
|
||||
|
@ -126,7 +126,7 @@ static void cb_unmap_mem(struct hl_ctx *ctx, struct hl_cb *cb)
|
|||
"Failed to unmap CB's va 0x%llx\n",
|
||||
va_block->start);
|
||||
|
||||
hdev->asic_funcs->mmu_invalidate_cache(hdev, true, VM_TYPE_USERPTR);
|
||||
hdev->asic_funcs->mmu_invalidate_cache(hdev, true, MMU_OP_USERPTR);
|
||||
|
||||
mutex_unlock(&ctx->mmu_lock);
|
||||
|
||||
|
|
|
@ -352,6 +352,17 @@ enum vm_type {
|
|||
VM_TYPE_PHYS_PACK = 0x2
|
||||
};
|
||||
|
||||
/**
|
||||
* enum mmu_op_flags - mmu operation relevant information.
|
||||
* @MMU_OP_USERPTR: operation on user memory (host resident).
|
||||
* @MMU_OP_PHYS_PACK: operation on DRAM (device resident).
|
||||
*/
|
||||
enum mmu_op_flags {
|
||||
MMU_OP_USERPTR = 0x1,
|
||||
MMU_OP_PHYS_PACK = 0x2
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* enum hl_device_hw_state - H/W device state. use this to understand whether
|
||||
* to do reset before hw_init or not
|
||||
|
|
|
@ -2639,8 +2639,8 @@ void hl_vm_ctx_fini(struct hl_ctx *ctx)
|
|||
mutex_lock(&ctx->mmu_lock);
|
||||
|
||||
/* invalidate the cache once after the unmapping loop */
|
||||
hdev->asic_funcs->mmu_invalidate_cache(hdev, true, VM_TYPE_USERPTR);
|
||||
hdev->asic_funcs->mmu_invalidate_cache(hdev, true, VM_TYPE_PHYS_PACK);
|
||||
hdev->asic_funcs->mmu_invalidate_cache(hdev, true, MMU_OP_USERPTR);
|
||||
hdev->asic_funcs->mmu_invalidate_cache(hdev, true, MMU_OP_PHYS_PACK);
|
||||
|
||||
mutex_unlock(&ctx->mmu_lock);
|
||||
|
||||
|
|
|
@ -8688,7 +8688,7 @@ static int gaudi_internal_cb_pool_init(struct hl_device *hdev,
|
|||
hdev->internal_cb_pool_dma_addr,
|
||||
HOST_SPACE_INTERNAL_CB_SZ);
|
||||
|
||||
hdev->asic_funcs->mmu_invalidate_cache(hdev, false, VM_TYPE_USERPTR);
|
||||
hdev->asic_funcs->mmu_invalidate_cache(hdev, false, MMU_OP_USERPTR);
|
||||
mutex_unlock(&ctx->mmu_lock);
|
||||
|
||||
if (rc)
|
||||
|
@ -8723,7 +8723,7 @@ static void gaudi_internal_cb_pool_fini(struct hl_device *hdev,
|
|||
HOST_SPACE_INTERNAL_CB_SZ);
|
||||
hl_unreserve_va_block(hdev, ctx, hdev->internal_cb_va_base,
|
||||
HOST_SPACE_INTERNAL_CB_SZ);
|
||||
hdev->asic_funcs->mmu_invalidate_cache(hdev, true, VM_TYPE_USERPTR);
|
||||
hdev->asic_funcs->mmu_invalidate_cache(hdev, true, MMU_OP_USERPTR);
|
||||
mutex_unlock(&ctx->mmu_lock);
|
||||
|
||||
gen_pool_destroy(hdev->internal_cb_pool);
|
||||
|
|
|
@ -2621,7 +2621,7 @@ int goya_mmu_init(struct hl_device *hdev)
|
|||
(~STLB_STLB_FEATURE_EN_FOLLOWER_EN_MASK));
|
||||
|
||||
hdev->asic_funcs->mmu_invalidate_cache(hdev, true,
|
||||
VM_TYPE_USERPTR | VM_TYPE_PHYS_PACK);
|
||||
MMU_OP_USERPTR | MMU_OP_PHYS_PACK);
|
||||
|
||||
WREG32(mmMMU_MMU_ENABLE, 1);
|
||||
WREG32(mmMMU_SPI_MASK, 0xF);
|
||||
|
|
Loading…
Reference in New Issue