diff options
author | Suman Anna <s-anna@ti.com> | 2021-04-19 16:49:33 -0500 |
---|---|---|
committer | Suman Anna <s-anna@ti.com> | 2021-04-20 15:49:01 -0500 |
commit | ebe913b4124e7fcfc20481257e32feb686d3a1b4 (patch) | |
tree | d5c293aa225863fcf424b06a4f8bf76c7c1095dd | |
parent | 7af77b4db8a779316ae4ff237050e8931adbe5f6 (diff) | |
download | linuxutils-ebe913b4124e7fcfc20481257e32feb686d3a1b4.tar.gz |
cmemk: Introduce cmem_mmap_read_{lock,unlock} wrappers
Introduce small inline wrapper functions around down_read() and
up_read() in preparation for scaling the CMEM kernel module for
changes in v5.8 kernel around the mmap lock semantics.
Signed-off-by: Suman Anna <s-anna@ti.com>
-rw-r--r-- | src/cmem/module/cmemk.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/cmem/module/cmemk.c b/src/cmem/module/cmemk.c index b578db0..7e3042b 100644 --- a/src/cmem/module/cmemk.c +++ b/src/cmem/module/cmemk.c @@ -623,6 +623,16 @@ void HeapMem_free(int bi, phys_addr_t block, size_t size) unmap_header(newHeader); } +static inline void cmem_mmap_read_lock(struct mm_struct *mm) +{ + down_read(&mm->mmap_sem); +} + +static inline void cmem_mmap_read_unlock(struct mm_struct *mm) +{ + up_read(&mm->mmap_sem); +} + /* Traverses the page tables and translates a virtual address to a physical. */ static phys_addr_t get_phys(void *virtp) { @@ -639,7 +649,7 @@ static phys_addr_t get_phys(void *virtp) return(physp); } - down_read(¤t->mm->mmap_sem); + cmem_mmap_read_lock(current->mm); vma = find_vma(mm, virt); /* this will catch, kernel-allocated, mmaped-to-usermode addresses */ if (vma && @@ -647,7 +657,7 @@ static phys_addr_t get_phys(void *virtp) (vma->vm_pgoff)) { physp = (((phys_addr_t)vma->vm_pgoff) << PAGE_SHIFT) + (virt - vma->vm_start); - up_read(¤t->mm->mmap_sem); + cmem_mmap_read_unlock(current->mm); __D("get_phys: find_vma translated user %#lx to %pa\n", virt, &physp); return(physp); @@ -671,7 +681,7 @@ static phys_addr_t get_phys(void *virtp) res = get_user_pages(current, current->mm, virt, nr_pages, 1, 0, &pages, NULL); #endif - up_read(¤t->mm->mmap_sem); + cmem_mmap_read_unlock(current->mm); if (res == nr_pages) { physp = __pa(page_address(&pages[0]) + (virt & ~PAGE_MASK)); |