From 3fdada39ff0559357a4145306ca08ee0c8153ba2 Mon Sep 17 00:00:00 2001 From: Laxman Dewangan Date: Tue, 31 Oct 2023 11:14:38 +0000 Subject: [PATCH] nvgpu: linux: ioctl: Avoid call of mmap_write_{trylock,unlock} The API mmap_write_trylock() is deleted from core kernel with following change in Linux 6.6 --- commit cf95e337cb63cfbf5c9ea1a1f64f9818b979e3b3 Author: Hugh Dickins Date: Tue Jul 11 21:48:48 2023 -0700 mm: delete mmap_write_trylock() and vma_try_start_write() ---- Replace the mmap_write_trylock() call with down_write_trylock with appropriate argument. Bug 4346767 Change-Id: I076ad51b012c706a4bada3bd303db1802cca34dd Signed-off-by: Laxman Dewangan Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/3007342 (cherry picked from commit 344c682a2077eb95c7d24ef1c0bf40eda70e524e) Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/3036796 Reviewed-by: Jonathan Hunter Tested-by: Jonathan Hunter GVS: Gerrit_Virtual_Submit --- drivers/gpu/nvgpu/os/linux/ioctl_ctrl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/nvgpu/os/linux/ioctl_ctrl.c b/drivers/gpu/nvgpu/os/linux/ioctl_ctrl.c index 2951633d9..45d34aa20 100644 --- a/drivers/gpu/nvgpu/os/linux/ioctl_ctrl.c +++ b/drivers/gpu/nvgpu/os/linux/ioctl_ctrl.c @@ -2915,7 +2915,7 @@ static int alter_usermode_mapping(struct gk20a *g, * does it in reverse order. Trylock is a way to avoid deadlock. */ #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0) - if (!mmap_write_trylock(vma->vm_mm)) { + if (!down_write_trylock(&vma->vm_mm->mmap_lock)) { #else if (!down_write_trylock(&vma->vm_mm->mmap_sem)) { #endif @@ -2947,7 +2947,7 @@ static int alter_usermode_mapping(struct gk20a *g, } #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0) - mmap_write_unlock(vma->vm_mm); + up_write(&vma->vm_mm->mmap_lock); #else up_write(&vma->vm_mm->mmap_sem); #endif