From 75d98f55d71c8e37d854ef2002c5ea420702824d Mon Sep 17 00:00:00 2001 From: scottl Date: Sun, 28 Feb 2021 12:50:46 -0800 Subject: [PATCH] gpu: nvgpu: add SUPPORT_MAPPING_MODIFY flags Add new NVGPU_SUPPORT_MAPPING_MODIFY enable flag that is used to control the value of the exported NVGPU_GPU_FLAGS_SUPPORT_MAPPING_MODIFY flag. These flags are currently only enabled on linux in non-virtualized environments. Jira NVGPU-6374 Change-Id: Ia85c353b767b4f7d0aebc04838f44996bc38c61f Signed-off-by: scottl Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2490986 Reviewed-by: Alex Waterman Reviewed-by: mobile promotions GVS: Gerrit_Virtual_Submit Tested-by: mobile promotions --- drivers/gpu/nvgpu/include/nvgpu/enabled.h | 2 ++ drivers/gpu/nvgpu/os/linux/ioctl_as.c | 4 ++++ drivers/gpu/nvgpu/os/linux/ioctl_ctrl.c | 2 ++ drivers/gpu/nvgpu/os/linux/module.c | 8 +++++++- include/uapi/linux/nvgpu-ctrl.h | 2 ++ 5 files changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/nvgpu/include/nvgpu/enabled.h b/drivers/gpu/nvgpu/include/nvgpu/enabled.h index e0fdecd92..6413d5585 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/enabled.h +++ b/drivers/gpu/nvgpu/include/nvgpu/enabled.h @@ -80,6 +80,8 @@ struct gk20a; "Direct PTE kind control is supported (map_buffer_ex)"),\ DEFINE_FLAG(NVGPU_SUPPORT_MAP_BUFFER_BATCH, \ "Support batch mapping"), \ + DEFINE_FLAG(NVGPU_SUPPORT_MAPPING_MODIFY, \ + "Support mapping modify"), \ DEFINE_FLAG(NVGPU_USE_COHERENT_SYSMEM, \ "Use coherent aperture for sysmem"), \ DEFINE_FLAG(NVGPU_MM_USE_PHYSICAL_SG, \ diff --git a/drivers/gpu/nvgpu/os/linux/ioctl_as.c b/drivers/gpu/nvgpu/os/linux/ioctl_as.c index 69be9f398..0b0b69bce 100644 --- a/drivers/gpu/nvgpu/os/linux/ioctl_as.c +++ b/drivers/gpu/nvgpu/os/linux/ioctl_as.c @@ -310,6 +310,10 @@ static int nvgpu_as_ioctl_mapping_modify( nvgpu_log_fn(g, " "); + if (!nvgpu_is_enabled(g, NVGPU_SUPPORT_MAPPING_MODIFY)) { + return -ENOTTY; + } + return nvgpu_vm_mapping_modify(as_share->vm, args->compr_kind, args->incompr_kind, diff --git a/drivers/gpu/nvgpu/os/linux/ioctl_ctrl.c b/drivers/gpu/nvgpu/os/linux/ioctl_ctrl.c index 748ac0016..38fcc3a43 100644 --- a/drivers/gpu/nvgpu/os/linux/ioctl_ctrl.c +++ b/drivers/gpu/nvgpu/os/linux/ioctl_ctrl.c @@ -265,6 +265,8 @@ static struct nvgpu_flags_mapping flags_mapping[] = { NVGPU_SUPPORT_SET_CTX_MMU_DEBUG_MODE}, {NVGPU_GPU_FLAGS_SUPPORT_FAULT_RECOVERY, NVGPU_SUPPORT_FAULT_RECOVERY}, + {NVGPU_GPU_FLAGS_SUPPORT_MAPPING_MODIFY, + NVGPU_SUPPORT_MAPPING_MODIFY}, {NVGPU_GPU_FLAGS_SUPPORT_COMPRESSION, NVGPU_SUPPORT_COMPRESSION}, {NVGPU_GPU_FLAGS_SUPPORT_SM_TTU, diff --git a/drivers/gpu/nvgpu/os/linux/module.c b/drivers/gpu/nvgpu/os/linux/module.c index 5fa058bf2..846f3dbf1 100644 --- a/drivers/gpu/nvgpu/os/linux/module.c +++ b/drivers/gpu/nvgpu/os/linux/module.c @@ -1,7 +1,7 @@ /* * GK20A Graphics * - * Copyright (c) 2011-2020, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2011-2021, 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, @@ -314,6 +314,8 @@ int nvgpu_finalize_poweron_linux(struct nvgpu_os_linux *l) void gk20a_init_linux_characteristics(struct gk20a *g) { + struct device *dev = dev_from_gk20a(g); + nvgpu_set_enabled(g, NVGPU_SUPPORT_PARTIAL_MAPPINGS, true); nvgpu_set_enabled(g, NVGPU_SUPPORT_DETERMINISTIC_OPTS, true); nvgpu_set_enabled(g, NVGPU_SUPPORT_USERSPACE_MANAGED_AS, true); @@ -322,6 +324,10 @@ void gk20a_init_linux_characteristics(struct gk20a *g) if (!IS_ENABLED(CONFIG_NVGPU_SYNCFD_NONE)) { nvgpu_set_enabled(g, NVGPU_SUPPORT_SYNC_FENCE_FDS, true); } + + if (!gk20a_gpu_is_virtual(dev)) { + nvgpu_set_enabled(g, NVGPU_SUPPORT_MAPPING_MODIFY, true); + } } #ifdef CONFIG_NVGPU_DGPU diff --git a/include/uapi/linux/nvgpu-ctrl.h b/include/uapi/linux/nvgpu-ctrl.h index 90f7c62af..becbc6716 100644 --- a/include/uapi/linux/nvgpu-ctrl.h +++ b/include/uapi/linux/nvgpu-ctrl.h @@ -156,6 +156,8 @@ struct nvgpu_gpu_zbc_query_table_args { #define NVGPU_GPU_FLAGS_SUPPORT_SET_CTX_MMU_DEBUG_MODE (1ULL << 32) /* Fault recovery is enabled */ #define NVGPU_GPU_FLAGS_SUPPORT_FAULT_RECOVERY (1ULL << 33) +/* Mapping modify is enabled */ +#define NVGPU_GPU_FLAGS_SUPPORT_MAPPING_MODIFY (1ULL << 34) /* Compression is enabled */ #define NVGPU_GPU_FLAGS_SUPPORT_COMPRESSION (1ULL << 36) /* SM TTU is enabled */