summaryrefslogtreecommitdiff
path: root/drivers/mxc
diff options
context:
space:
mode:
authorXianzhong <xianzhong.li@nxp.com>2020-10-22 13:37:35 +0800
committerXianzhong <xianzhong.li@nxp.com>2020-10-22 14:39:27 +0800
commit54e7aa7ca3bae5fc672d5a83f1711ecee104c8d4 (patch)
tree0ed2a8b2088b62a9906da375c18ee76eb245687b /drivers/mxc
parent0fef6d7f6778f72cde9da11b306e8a6a51edeba9 (diff)
MGS-6012-6 [#imx-2337] refine mmap_sem fix for L5.10 kernel
avoid the duplicated kernel version check and messy copy Signed-off-by: Xianzhong <xianzhong.li@nxp.com>
Diffstat (limited to 'drivers/mxc')
-rw-r--r--drivers/mxc/gpu-viv/hal/os/linux/kernel/allocator/default/gc_hal_kernel_allocator_dma.c20
-rw-r--r--drivers/mxc/gpu-viv/hal/os/linux/kernel/allocator/default/gc_hal_kernel_allocator_gfp.c20
-rw-r--r--drivers/mxc/gpu-viv/hal/os/linux/kernel/allocator/default/gc_hal_kernel_allocator_reserved_mem.c20
-rw-r--r--drivers/mxc/gpu-viv/hal/os/linux/kernel/allocator/default/gc_hal_kernel_allocator_user_memory.c22
-rw-r--r--drivers/mxc/gpu-viv/hal/os/linux/kernel/allocator/freescale/gc_hal_kernel_allocator_cma.c20
-rw-r--r--drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_os.c10
6 files changed, 30 insertions, 82 deletions
diff --git a/drivers/mxc/gpu-viv/hal/os/linux/kernel/allocator/default/gc_hal_kernel_allocator_dma.c b/drivers/mxc/gpu-viv/hal/os/linux/kernel/allocator/default/gc_hal_kernel_allocator_dma.c
index 823e712c3679..080a5cf3a4dc 100644
--- a/drivers/mxc/gpu-viv/hal/os/linux/kernel/allocator/default/gc_hal_kernel_allocator_dma.c
+++ b/drivers/mxc/gpu-viv/hal/os/linux/kernel/allocator/default/gc_hal_kernel_allocator_dma.c
@@ -395,7 +395,7 @@ _DmaUnmapUser(
);
}
#else
- down_write(&current->mm->mmap_sem);
+ down_write(&current_mm_mmap_sem);
if (do_munmap(current->mm, (unsigned long)MdlMap->vmaAddr, Size) < 0)
{
gcmkTRACE_ZONE(
@@ -404,7 +404,7 @@ _DmaUnmapUser(
__FUNCTION__, __LINE__
);
}
- up_write(&current->mm->mmap_sem);
+ up_write(&current_mm_mmap_sem);
#endif
}
@@ -429,14 +429,14 @@ _DmaMapUser(
MAP_SHARED | MAP_NORESERVE,
0);
#else
- down_write(&current->mm->mmap_sem);
+ down_write(&current_mm_mmap_sem);
userLogical = (gctPOINTER)do_mmap_pgoff(gcvNULL,
0L,
Mdl->numPages * PAGE_SIZE,
PROT_READ | PROT_WRITE,
MAP_SHARED,
0);
- up_write(&current->mm->mmap_sem);
+ up_write(&current_mm_mmap_sem);
#endif
gcmkTRACE_ZONE(
@@ -456,11 +456,7 @@ _DmaMapUser(
gcmkONERROR(gcvSTATUS_OUT_OF_MEMORY);
}
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0)
- down_write(&current->mm->mmap_lock);
-#else
- down_write(&current->mm->mmap_sem);
-#endif
+ down_write(&current_mm_mmap_sem);
do
{
@@ -484,11 +480,7 @@ _DmaMapUser(
}
while (gcvFALSE);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0)
- up_write(&current->mm->mmap_lock);
-#else
- up_write(&current->mm->mmap_sem);
-#endif
+ up_write(&current_mm_mmap_sem);
OnError:
if (gcmIS_ERROR(status) && userLogical)
diff --git a/drivers/mxc/gpu-viv/hal/os/linux/kernel/allocator/default/gc_hal_kernel_allocator_gfp.c b/drivers/mxc/gpu-viv/hal/os/linux/kernel/allocator/default/gc_hal_kernel_allocator_gfp.c
index 2f18712918fb..86dc819b8758 100644
--- a/drivers/mxc/gpu-viv/hal/os/linux/kernel/allocator/default/gc_hal_kernel_allocator_gfp.c
+++ b/drivers/mxc/gpu-viv/hal/os/linux/kernel/allocator/default/gc_hal_kernel_allocator_gfp.c
@@ -1001,7 +1001,7 @@ _GFPUnmapUser(
);
}
#else
- down_write(&current->mm->mmap_sem);
+ down_write(&current_mm_mmap_sem);
if (do_munmap(current->mm, (unsigned long)MdlMap->vmaAddr, Size) < 0)
{
gcmkTRACE_ZONE(
@@ -1010,7 +1010,7 @@ _GFPUnmapUser(
__FUNCTION__, __LINE__
);
}
- up_write(&current->mm->mmap_sem);
+ up_write(&current_mm_mmap_sem);
#endif
MdlMap->vma = NULL;
@@ -1037,14 +1037,14 @@ _GFPMapUser(
MAP_SHARED | MAP_NORESERVE,
0);
#else
- down_write(&current->mm->mmap_sem);
+ down_write(&current_mm_mmap_sem);
userLogical = (gctPOINTER)do_mmap_pgoff(NULL,
0L,
Mdl->numPages * PAGE_SIZE,
PROT_READ | PROT_WRITE,
MAP_SHARED,
0);
- up_write(&current->mm->mmap_sem);
+ up_write(&current_mm_mmap_sem);
#endif
gcmkTRACE_ZONE(
@@ -1068,11 +1068,7 @@ _GFPMapUser(
gcmkONERROR(gcvSTATUS_OUT_OF_MEMORY);
}
-#if LINUX_VERSION_CODE >= KERNEL_VERSION (5,8,0)
- down_write(&current->mm->mmap_lock);
-#else
- down_write(&current->mm->mmap_sem);
-#endif
+ down_write(&current_mm_mmap_sem);
do
{
@@ -1094,11 +1090,7 @@ _GFPMapUser(
}
while (gcvFALSE);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION (5,8,0)
- up_write(&current->mm->mmap_lock);
-#else
- up_write(&current->mm->mmap_sem);
-#endif
+ up_write(&current_mm_mmap_sem);
if (gcmIS_SUCCESS(status))
{
diff --git a/drivers/mxc/gpu-viv/hal/os/linux/kernel/allocator/default/gc_hal_kernel_allocator_reserved_mem.c b/drivers/mxc/gpu-viv/hal/os/linux/kernel/allocator/default/gc_hal_kernel_allocator_reserved_mem.c
index bbb9096331a7..e222e6b7157b 100644
--- a/drivers/mxc/gpu-viv/hal/os/linux/kernel/allocator/default/gc_hal_kernel_allocator_reserved_mem.c
+++ b/drivers/mxc/gpu-viv/hal/os/linux/kernel/allocator/default/gc_hal_kernel_allocator_reserved_mem.c
@@ -298,12 +298,12 @@ reserved_mem_unmap_user(
printk("%s: vm_munmap failed\n", __func__);
}
#else
- down_write(&current->mm->mmap_sem);
+ down_write(&current_mm_mmap_sem);
if (do_munmap(current->mm, (unsigned long)MdlMap->vmaAddr - res->offset_in_page, res->size) < 0)
{
printk("%s: do_munmap failed\n", __func__);
}
- up_write(&current->mm->mmap_sem);
+ up_write(&current_mm_mmap_sem);
#endif
}
@@ -325,10 +325,10 @@ reserved_mem_map_user(
userLogical = (gctPOINTER)vm_mmap(NULL, 0L, res->size,
PROT_READ | PROT_WRITE, MAP_SHARED | MAP_NORESERVE, 0);
#else
- down_write(&current->mm->mmap_sem);
+ down_write(&current_mm_mmap_sem);
userLogical = (gctPOINTER)do_mmap_pgoff(NULL, 0L, res->size,
PROT_READ | PROT_WRITE, MAP_SHARED, 0);
- up_write(&current->mm->mmap_sem);
+ up_write(&current_mm_mmap_sem);
#endif
gcmkTRACE_ZONE(
@@ -348,11 +348,7 @@ reserved_mem_map_user(
gcmkONERROR(gcvSTATUS_OUT_OF_MEMORY);
}
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0)
- down_write(&current->mm->mmap_lock);
-#else
- down_write(&current->mm->mmap_sem);
-#endif
+ down_write(&current_mm_mmap_sem);
do
{
@@ -376,11 +372,7 @@ reserved_mem_map_user(
}
while (gcvFALSE);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0)
- up_write(&current->mm->mmap_lock);
-#else
- up_write(&current->mm->mmap_sem);
-#endif
+ up_write(&current_mm_mmap_sem);
OnError:
if (gcmIS_ERROR(status) && userLogical)
diff --git a/drivers/mxc/gpu-viv/hal/os/linux/kernel/allocator/default/gc_hal_kernel_allocator_user_memory.c b/drivers/mxc/gpu-viv/hal/os/linux/kernel/allocator/default/gc_hal_kernel_allocator_user_memory.c
index d66066d2c547..c98da15cfb0d 100644
--- a/drivers/mxc/gpu-viv/hal/os/linux/kernel/allocator/default/gc_hal_kernel_allocator_user_memory.c
+++ b/drivers/mxc/gpu-viv/hal/os/linux/kernel/allocator/default/gc_hal_kernel_allocator_user_memory.c
@@ -141,11 +141,7 @@ static int import_page_map(struct um_desc *um,
if (!pages)
return -ENOMEM;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0)
- down_read(&current->mm->mmap_lock);
-#else
- down_read(&current->mm->mmap_sem);
-#endif
+ down_read(&current_mm_mmap_sem);
result = get_user_pages(
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0)
@@ -163,11 +159,7 @@ static int import_page_map(struct um_desc *um,
pages,
NULL);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0)
- up_read(&current->mm->mmap_lock);
-#else
- up_read(&current->mm->mmap_sem);
-#endif
+ up_read(&current_mm_mmap_sem);
if (result < page_count)
{
@@ -248,15 +240,9 @@ static int import_pfn_map(struct um_desc *um,
if (!current->mm)
return -ENOTTY;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION (5,8,0)
- down_read(&current->mm->mmap_lock);
+ down_read(&current_mm_mmap_sem);
vma = find_vma(current->mm, addr);
- up_read(&current->mm->mmap_lock);
-#else
- down_read(&current->mm->mmap_sem);
- vma = find_vma(current->mm, addr);
- up_read(&current->mm->mmap_sem);
-#endif
+ up_read(&current_mm_mmap_sem);
if (!vma)
return -ENOTTY;
diff --git a/drivers/mxc/gpu-viv/hal/os/linux/kernel/allocator/freescale/gc_hal_kernel_allocator_cma.c b/drivers/mxc/gpu-viv/hal/os/linux/kernel/allocator/freescale/gc_hal_kernel_allocator_cma.c
index f1e87be26ea7..7d4d2240f72b 100644
--- a/drivers/mxc/gpu-viv/hal/os/linux/kernel/allocator/freescale/gc_hal_kernel_allocator_cma.c
+++ b/drivers/mxc/gpu-viv/hal/os/linux/kernel/allocator/freescale/gc_hal_kernel_allocator_cma.c
@@ -383,7 +383,7 @@ _CMAFSLUnmapUser(
);
}
#else
- down_write(&current->mm->mmap_sem);
+ down_write(&current_mm_mmap_sem);
if (do_munmap(current->mm, (unsigned long)MdlMap->vmaAddr, Size) < 0)
{
gcmkTRACE_ZONE(
@@ -392,7 +392,7 @@ _CMAFSLUnmapUser(
__FUNCTION__, __LINE__
);
}
- up_write(&current->mm->mmap_sem);
+ up_write(&current_mm_mmap_sem);
#endif
}
@@ -417,14 +417,14 @@ _CMAFSLMapUser(
MAP_SHARED | MAP_NORESERVE,
0);
#else
- down_write(&current->mm->mmap_sem);
+ down_write(&current_mm_mmap_sem);
userLogical = (gctPOINTER)do_mmap_pgoff(gcvNULL,
0L,
Mdl->numPages * PAGE_SIZE,
PROT_READ | PROT_WRITE,
MAP_SHARED,
0);
- up_write(&current->mm->mmap_sem);
+ up_write(&current_mm_mmap_sem);
#endif
gcmkTRACE_ZONE(
@@ -444,11 +444,7 @@ _CMAFSLMapUser(
gcmkONERROR(gcvSTATUS_OUT_OF_MEMORY);
}
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0)
- down_write(&current->mm->mmap_lock);
-#else
- down_write(&current->mm->mmap_sem);
-#endif
+ down_write(&current_mm_mmap_sem);
do
{
@@ -471,11 +467,7 @@ _CMAFSLMapUser(
}
while (gcvFALSE);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0)
- up_write(&current->mm->mmap_lock);
-#else
- up_write(&current->mm->mmap_sem);
-#endif
+ up_write(&current_mm_mmap_sem);
OnError:
if (gcmIS_ERROR(status) && userLogical && !IS_ERR(userLogical))
diff --git a/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_os.c b/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_os.c
index edc279c60c02..6efb2f23f4d7 100644
--- a/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_os.c
+++ b/drivers/mxc/gpu-viv/hal/os/linux/kernel/gc_hal_kernel_os.c
@@ -451,15 +451,9 @@ _QueryProcessPageTable(
if (!current->mm)
return gcvSTATUS_NOT_FOUND;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION (5,8,0)
- down_read(&current->mm->mmap_lock);
+ down_read(&current_mm_mmap_sem);
vma = find_vma(current->mm, logical);
- up_read(&current->mm->mmap_lock);
-#else
- down_read(&current->mm->mmap_sem);
- vma = find_vma(current->mm, logical);
- up_read(&current->mm->mmap_sem);
-#endif
+ up_read(&current_mm_mmap_sem);
/* To check if mapped to user. */
if (!vma)