From 145ed9bde2c43b40d788db312a46913bff67b5e5 Mon Sep 17 00:00:00 2001 From: Kai Song Date: Wed, 13 Feb 2019 10:12:39 +0800 Subject: [PATCH] codec_mm: Fix cma clear and rebuild map for codec_mm. [1/1] PD#172483 Problem: To avoid A73 core speculative data loading from protected memory, which triggers SError fault, the mapping of the protected region should be cleared. In codec_mm driver, the page structure pointer used to clear the mapping is wrong. Although the memory is allocated from CMA, because we are using CMA_res mode the address from CMA_res_pool is actually a physical address, similar as reserved memory case. As a result, the mapping to protected address is not cleared. Solution: 1.Add "mem->from_flags == AMPORTS_MEM_FLAGS_FROM_GET_FROM_CMA_RES" case processing. Verify: Run YTTV and there is no SError crash after the fix. Change-Id: Ia912337c1d7d5a55800fc55ad1d61016f9710f4d Signed-off-by: Kai Song --- drivers/amlogic/media/common/codec_mm/codec_mm.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/amlogic/media/common/codec_mm/codec_mm.c b/drivers/amlogic/media/common/codec_mm/codec_mm.c index c6dabed..17dc594 100644 --- a/drivers/amlogic/media/common/codec_mm/codec_mm.c +++ b/drivers/amlogic/media/common/codec_mm/codec_mm.c @@ -1099,8 +1099,14 @@ int codec_mm_extpool_pool_alloc( CODEC_MM_FLAGS_FOR_LOCAL_MGR | CODEC_MM_FLAGS_CMA); if (mem) { + struct page *mm = mem->mem_handle; + + if (mem->from_flags == + AMPORTS_MEM_FLAGS_FROM_GET_FROM_CMA_RES) + mm = phys_to_page( + (unsigned long)mm); if (for_tvp) { - cma_mmu_op(mem->mem_handle, + cma_mmu_op(mm, mem->page_count, 0); } @@ -1109,7 +1115,7 @@ int codec_mm_extpool_pool_alloc( mem); if (ret < 0) { if (for_tvp) { - cma_mmu_op(mem->mem_handle, + cma_mmu_op(mm, mem->page_count, 1); } @@ -1160,7 +1166,13 @@ static int codec_mm_extpool_pool_release(struct extpool_mgt_s *tvp_pool) slot_mem_size = gen_pool_size(gpool); gen_pool_destroy(tvp_pool->gen_pool[i]); if (tvp_pool->mm[i]) { - cma_mmu_op(tvp_pool->mm[i]->mem_handle, + struct page *mm = tvp_pool->mm[i]->mem_handle; + + if (tvp_pool->mm[i]->from_flags == + AMPORTS_MEM_FLAGS_FROM_GET_FROM_CMA_RES) + mm = phys_to_page( + (unsigned long)mm); + cma_mmu_op(mm, tvp_pool->mm[i]->page_count, 1); codec_mm_release(tvp_pool->mm[i], -- 2.7.4