From b8efd9d04537d6129e2ce8b067417e46b0e7436f Mon Sep 17 00:00:00 2001 From: Terje Bergstrom Date: Thu, 27 Jul 2017 12:58:03 -0700 Subject: gpu: nvgpu: Make LTC disabling common code Refactor the sync_debugfs LTC HAL op so that the logic to enable or disable LTC goes to common code nvgpu_ltc_sync_enabled() and the LTC HAL set_enabled only performs the hardware register access. Create a new common function nvgpu_init_ltc_support() to initialize the LTC software variable, and move hardware initialization of LTC to be called from it. JIRA NVGPU-62 Change-Id: Ib1cf4f5b83ca3dac08407464ed56a732e0a33923 Signed-off-by: Terje Bergstrom Reviewed-on: https://git-master.nvidia.com/r/1528262 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/ltc.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 drivers/gpu/nvgpu/common/ltc.c (limited to 'drivers/gpu/nvgpu/common/ltc.c') diff --git a/drivers/gpu/nvgpu/common/ltc.c b/drivers/gpu/nvgpu/common/ltc.c new file mode 100644 index 00000000..0965caa3 --- /dev/null +++ b/drivers/gpu/nvgpu/common/ltc.c @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2017, 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 . + */ + +#include + +#include "gk20a/gk20a.h" + +int nvgpu_init_ltc_support(struct gk20a *g) +{ + nvgpu_spinlock_init(&g->ltc_enabled_lock); + + g->mm.ltc_enabled_current = true; + g->mm.ltc_enabled_target = true; + + if (g->ops.ltc.init_fs_state) + g->ops.ltc.init_fs_state(g); + + return 0; +} + +void nvgpu_ltc_sync_enabled(struct gk20a *g) +{ + nvgpu_spinlock_acquire(&g->ltc_enabled_lock); + if (g->mm.ltc_enabled_current != g->mm.ltc_enabled_target) { + g->ops.ltc.set_enabled(g, g->mm.ltc_enabled_target); + g->mm.ltc_enabled_current = g->mm.ltc_enabled_target; + } + nvgpu_spinlock_release(&g->ltc_enabled_lock); +} -- cgit v1.2.2