From 40231858a59ec96a470b2f102e5ac913f19af44a Mon Sep 17 00:00:00 2001 From: Antony Clince Alex Date: Tue, 15 Mar 2022 03:03:59 +0000 Subject: [PATCH] gpu: nvgpu: add enable flag for gpu emulate mode Introduce enable flag NVGPU_SUPPORT_EMULATE_MODE, and bring emulate mode feature under this flag. At present, gpu emulate mode is only support on ga10b. Jira NVGPU-8120 Change-Id: I85269992926c3cf8f2d1dd70882979e1c4656984 Signed-off-by: Antony Clince Alex Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2681613 Tested-by: mobile promotions Reviewed-by: mobile promotions --- drivers/gpu/nvgpu/hal/init/hal_ga10b.c | 1 + drivers/gpu/nvgpu/include/nvgpu/enabled.h | 2 ++ drivers/gpu/nvgpu/os/linux/sysfs.c | 5 +++++ 3 files changed, 8 insertions(+) diff --git a/drivers/gpu/nvgpu/hal/init/hal_ga10b.c b/drivers/gpu/nvgpu/hal/init/hal_ga10b.c index 3113e0977..02c8575c7 100644 --- a/drivers/gpu/nvgpu/hal/init/hal_ga10b.c +++ b/drivers/gpu/nvgpu/hal/init/hal_ga10b.c @@ -1994,6 +1994,7 @@ int ga10b_init_hal(struct gk20a *g) #ifdef CONFIG_NVGPU_HAL_NON_FUSA gops->mssnvlink = ga10b_ops_mssnvlink; #endif + nvgpu_set_enabled(g, NVGPU_SUPPORT_EMULATE_MODE, true); g->name = "ga10b"; return 0; diff --git a/drivers/gpu/nvgpu/include/nvgpu/enabled.h b/drivers/gpu/nvgpu/include/nvgpu/enabled.h index 97c01922c..8e5b46ded 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/enabled.h +++ b/drivers/gpu/nvgpu/include/nvgpu/enabled.h @@ -221,6 +221,8 @@ struct gk20a; DEFINE_FLAG(NVGPU_SUPPORT_NVS, "Domain scheduler support"), \ DEFINE_FLAG(NVGPU_SUPPORT_TEGRA_RAW, \ "TEGRA_RAW format support"), \ + DEFINE_FLAG(NVGPU_SUPPORT_EMULATE_MODE, \ + "Emulate mode support"), \ DEFINE_FLAG(NVGPU_MAX_ENABLED_BITS, "Marks max number of flags"), /** diff --git a/drivers/gpu/nvgpu/os/linux/sysfs.c b/drivers/gpu/nvgpu/os/linux/sysfs.c index 0f330432b..c6d055126 100644 --- a/drivers/gpu/nvgpu/os/linux/sysfs.c +++ b/drivers/gpu/nvgpu/os/linux/sysfs.c @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -1302,6 +1303,10 @@ static ssize_t emulate_mode_store(struct device *dev, if (kstrtoul(buf, 10, &val) < 0) return -EINVAL; + if (!nvgpu_is_enabled(g, NVGPU_SUPPORT_EMULATE_MODE)) { + nvgpu_err(g, "Emulate mode not supported"); + return -EINVAL; + } if (nvgpu_is_powered_on(g)) { nvgpu_err(g, "GPU is powered on already, emulate mode " "cannot be enabled");