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 <kai.song@amlogic.com>
This commit is contained in:
Kai Song
2019-02-13 10:12:39 +08:00
committed by Luan Yuan
parent 687f715cd1
commit 92417948de

View File

@@ -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],