gpu: nvgpu: Use conftest for VM flags

Using kernel version for detecting kernel changes does not work for some
3rd party Linux distributions that back port kernel changes to their
kernel. The conftest script has a test for detecting if the 'vm_flags'
variable can be set directly or if the appropriate helper functions must
be used. Update the NVGPU driver to use the definition provided by
conftest to determine if the 'vm_flags' variable can set set directly or
not.

Bug 4014315

Change-Id: I6ebfbfa622259e15560152bf70315451a52fba81
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/3164870
(cherry picked from commit 2c9097363d29a235eb5c41530cdd3896694599d2)
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/3172302
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
Reviewed-by: Sagar Kamble <skamble@nvidia.com>
This commit is contained in:
Jon Hunter
2024-05-23 11:43:24 +01:00
committed by mobile promotions
parent 6d8106348a
commit 10b813a25d
3 changed files with 20 additions and 34 deletions

View File

@@ -1,18 +1,9 @@
/*
* Copyright (c) 2017-2023, NVIDIA CORPORATION. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// SPDX-License-Identifier: GPL-2.0-only
// SPDX-FileCopyrightText: Copyright (c) 2017-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#if defined(CONFIG_NVIDIA_CONFTEST)
#include <nvidia/conftest.h>
#endif
#include <nvgpu/gk20a.h>
#include <nvgpu/gr/ctx.h>
@@ -250,7 +241,7 @@ static int cbc_ctrl_debug_mmap_cbc_store(struct file *f, struct vm_area_struct *
err = -EINVAL;
goto done;
}
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)
#if defined(NV_VM_AREA_STRUCT_HAS_CONST_VM_FLAGS) /* Linux v6.3 */
vm_flags_set(vma, VM_DONTCOPY | VM_DONTEXPAND | VM_NORESERVE |
VM_DONTDUMP | VM_PFNMAP);
vm_flags_clear(vma, VM_MAYWRITE);