From 848305ff419af69b2a88f2da081b603f19eb2c09 Mon Sep 17 00:00:00 2001 From: Suman Anna Date: Mon, 19 Apr 2021 17:02:09 -0500 Subject: cmemk: Fix usage of mmap_sem for 5.8+ kernels The mmap_sem locking semantics were abstracted out in preparation for some scalability work in v5.8 kernel. The mmap_sem field is no longer defined (renamed), and is abstracted out through newly introduced mmap_read_{lock,unlock} wrappers in a new mmap_lock.h file in commit 9740ca4e95b4 ("mmap locking API: initial implementation as rwsem wrappers"). Adopt to these new wrappers to fix the CMEM kernel module build against these newer kernels. Signed-off-by: Suman Anna --- src/cmem/module/cmemk.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/cmem/module/cmemk.c b/src/cmem/module/cmemk.c index 7e3042b..6295a9e 100644 --- a/src/cmem/module/cmemk.c +++ b/src/cmem/module/cmemk.c @@ -625,12 +625,20 @@ void HeapMem_free(int bi, phys_addr_t block, size_t size) static inline void cmem_mmap_read_lock(struct mm_struct *mm) { +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0)) down_read(&mm->mmap_sem); +#else + mmap_read_lock(mm); +#endif } static inline void cmem_mmap_read_unlock(struct mm_struct *mm) { +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0)) up_read(&mm->mmap_sem); +#else + mmap_read_unlock(mm); +#endif } /* Traverses the page tables and translates a virtual address to a physical. */ -- cgit v1.2.3