From 88c774e5d1e3cba697060295aa821b14554dfafc Mon Sep 17 00:00:00 2001 From: Thomas Fleury Date: Tue, 24 Mar 2020 12:23:24 -0400 Subject: [PATCH] gpu: nvgpu: enable clk_arb for dGPU safety Enable CONFIG_NVGPU_CLK_ARB for dGPU safety build. Use CONFIG_NVGPU_NON_FUSA for invocation of non-safe functions: - nvgpu_hr_timestamp - nvgpu_hr_timestamp_us Jira NVGPU-4661 Jira NVGPU-5235 (for addressing usage of above functions). Change-Id: I271fdbc45c1e4d01cb70d50dcf63d15b9df33c76 Signed-off-by: Thomas Fleury Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2317842 Reviewed-by: automaticguardword Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-misra Reviewed-by: svc-mobile-cert Reviewed-by: Deepak Nibade Reviewed-by: mobile promotions Tested-by: mobile promotions GVS: Gerrit_Virtual_Submit --- drivers/gpu/nvgpu/Makefile.shared.configs | 3 +++ drivers/gpu/nvgpu/common/clk_arb/clk_arb.c | 5 ++++- drivers/gpu/nvgpu/hal/clk/clk_tu104.c | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/nvgpu/Makefile.shared.configs b/drivers/gpu/nvgpu/Makefile.shared.configs index 791bf1951..e50895a33 100644 --- a/drivers/gpu/nvgpu/Makefile.shared.configs +++ b/drivers/gpu/nvgpu/Makefile.shared.configs @@ -120,6 +120,9 @@ NVGPU_COMMON_CFLAGS += -DCONFIG_NVGPU_USE_3LSS_ERR_INJECTION CONFIG_NVGPU_LS_PMU := 1 NVGPU_COMMON_CFLAGS += -DCONFIG_NVGPU_LS_PMU + +CONFIG_NVGPU_CLK_ARB := 1 +NVGPU_COMMON_CFLAGS += -DCONFIG_NVGPU_CLK_ARB endif endif diff --git a/drivers/gpu/nvgpu/common/clk_arb/clk_arb.c b/drivers/gpu/nvgpu/common/clk_arb/clk_arb.c index 435a5aeeb..0da723938 100644 --- a/drivers/gpu/nvgpu/common/clk_arb/clk_arb.c +++ b/drivers/gpu/nvgpu/common/clk_arb/clk_arb.c @@ -72,11 +72,14 @@ static void nvgpu_clk_arb_queue_notification(struct gk20a *g, u32 alarm_mask) { u32 queue_index; - u64 timestamp; + u64 timestamp = 0U; queue_index = U32(nvgpu_atomic_inc_return(&queue->tail)) % queue->size; + +#ifdef CONFIG_NVGPU_NON_FUSA /* get current timestamp */ timestamp = (u64) nvgpu_hr_timestamp(); +#endif queue->clk_q_notifications[queue_index].timestamp = timestamp; queue->clk_q_notifications[queue_index].clk_notification = alarm_mask; diff --git a/drivers/gpu/nvgpu/hal/clk/clk_tu104.c b/drivers/gpu/nvgpu/hal/clk/clk_tu104.c index 71722617b..16a320b74 100644 --- a/drivers/gpu/nvgpu/hal/clk/clk_tu104.c +++ b/drivers/gpu/nvgpu/hal/clk/clk_tu104.c @@ -262,6 +262,7 @@ int tu104_init_clk_support(struct gk20a *g) } u32 tu104_get_rate_cntr(struct gk20a *g, struct namemap_cfg *c) { +#ifdef CONFIG_NVGPU_NON_FUSA u32 cntr = 0; u64 cntr_start = 0; u64 cntr_stop = 0; @@ -310,6 +311,7 @@ u32 tu104_get_rate_cntr(struct gk20a *g, struct namemap_cfg *c) { } nvgpu_mutex_release(&clk->clk_mutex); +#endif /* too many iterations, bail out */ nvgpu_err(g, "failed to get clk rate"); return -EBUSY;