author | Tao Zeng <tao.zeng@amlogic.com> | 2020-10-02 08:06:37 (GMT) |
---|---|---|
committer | Shen Liu <shen.liu@amlogic.com> | 2020-11-05 05:35:13 (GMT) |
commit | a18eb9a7ed2f77184eefbed7f8b22106a2de5019 (patch) | |
tree | 32954d388c364a00f1ab73a6d29e10d38cb168ee | |
parent | 17361ee0748197520114e081eb5f0f68e33b05f6 (diff) | |
download | common-a18eb9a7ed2f77184eefbed7f8b22106a2de5019.zip common-a18eb9a7ed2f77184eefbed7f8b22106a2de5019.tar.gz common-a18eb9a7ed2f77184eefbed7f8b22106a2de5019.tar.bz2 |
cma: fix serror caused by clear cma mmu [1/1]
PD#SWPL-34583
Problem:
tvp pool call cma_mmu_op without check "clear-map" property
from dts, which caused SError.
Solution:
Check if this pool have clear map before set mmu table
Verify:
SM1
Signed-off-by: Tao Zeng <tao.zeng@amlogic.com>
Change-Id: Ice3235305228e6b62e587c4115728f38b926f734
-rw-r--r-- | mm/cma.c | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -119,6 +119,21 @@ int setup_cma_full_pagemap(struct cma *cma) #endif } +static struct cma *find_cma(struct page *page) +{ + unsigned long pfn; + struct cma *cma; + int i; + + pfn = page_to_pfn(page); + for (i = 0; i < cma_area_count; i++) { + cma = &cma_areas[i]; + if (cma->base_pfn <= pfn && pfn < cma->base_pfn + cma->count) + return cma; + } + return NULL; +} + int cma_mmu_op(struct page *page, int count, bool set) { pgd_t *pgd; @@ -127,10 +142,18 @@ int cma_mmu_op(struct page *page, int count, bool set) pte_t *pte; unsigned long addr, end; struct mm_struct *mm; + struct cma *cma; if (!page || PageHighMem(page)) return -EINVAL; + cma = find_cma(page); + if (!cma || !cma->clear_map) { + pr_debug("%s, page:%lx is not cma or no clear-map, cma:%px\n", + __func__, page_to_pfn(page), cma); + return -EINVAL; + } + addr = (unsigned long)page_address(page); end = addr + count * PAGE_SIZE; mm = &init_mm; |