From bcdac829f44afc1b08941c507e691866f3a9cb38 Mon Sep 17 00:00:00 2001 From: Nitin Kumbhar Date: Mon, 13 Aug 2018 10:09:04 +0530 Subject: gpu: nvgpu: move therm debugfs to linux Move debugfs related code of therm from common driver to linux specific part of the driver. gp106_therm_debugfs_init() is updated to use nvgpu_os_linux_ops. This also affects gv100 as gp106_therm_debugfs_init is used for gv100 as well. JIRA NVGPU-603 Change-Id: Ia293d14599bc0c91fd1e917b5a430bd8f3d96e56 Signed-off-by: Nitin Kumbhar Reviewed-on: https://git-master.nvidia.com/r/1797906 GVS: Gerrit_Virtual_Submit Reviewed-by: Vijayakumar Subbu Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/Makefile | 1 + drivers/gpu/nvgpu/common/therm/therm_gp106.c | 33 +---------------- drivers/gpu/nvgpu/common/therm/therm_gp106.h | 5 +-- drivers/gpu/nvgpu/gp106/hal_gp106.c | 3 -- drivers/gpu/nvgpu/gv100/hal_gv100.c | 3 -- drivers/gpu/nvgpu/os/linux/debug_therm_gp106.c | 49 ++++++++++++++++++++++++++ drivers/gpu/nvgpu/os/linux/debug_therm_gp106.h | 29 +++++++++++++++ drivers/gpu/nvgpu/os/linux/module.c | 8 +++++ drivers/gpu/nvgpu/os/linux/os_linux.h | 4 +++ drivers/gpu/nvgpu/os/linux/os_ops.c | 9 +++++ drivers/gpu/nvgpu/os/linux/os_ops_gp106.c | 5 +++ drivers/gpu/nvgpu/os/linux/os_ops_gv100.c | 5 +++ 12 files changed, 112 insertions(+), 42 deletions(-) create mode 100644 drivers/gpu/nvgpu/os/linux/debug_therm_gp106.c create mode 100644 drivers/gpu/nvgpu/os/linux/debug_therm_gp106.h (limited to 'drivers/gpu/nvgpu') diff --git a/drivers/gpu/nvgpu/Makefile b/drivers/gpu/nvgpu/Makefile index 24322f82..7edcd63e 100644 --- a/drivers/gpu/nvgpu/Makefile +++ b/drivers/gpu/nvgpu/Makefile @@ -101,6 +101,7 @@ nvgpu-$(CONFIG_DEBUG_FS) += \ os/linux/debug_hal.o \ os/linux/debug_clk_gm20b.o \ os/linux/debug_clk_gp106.o \ + os/linux/debug_therm_gp106.o \ os/linux/debug_bios.o \ os/linux/debug_ltc.o \ os/linux/debug_xve.o diff --git a/drivers/gpu/nvgpu/common/therm/therm_gp106.c b/drivers/gpu/nvgpu/common/therm/therm_gp106.c index 1f82aa7a..cc3127d7 100644 --- a/drivers/gpu/nvgpu/common/therm/therm_gp106.c +++ b/drivers/gpu/nvgpu/common/therm/therm_gp106.c @@ -21,16 +21,12 @@ */ #include + #include "gk20a/gk20a.h" #include "therm_gp106.h" #include "therm/thrmpmu.h" -#ifdef CONFIG_DEBUG_FS -#include -#include "os/linux/os_linux.h" -#endif - #include #include @@ -66,33 +62,6 @@ int gp106_get_internal_sensor_curr_temp(struct gk20a *g, u32 *temp_f24_8) return err; } -#ifdef CONFIG_DEBUG_FS -static int therm_get_internal_sensor_curr_temp(void *data, u64 *val) -{ - struct gk20a *g = (struct gk20a *)data; - u32 readval; - int err; - - err = gp106_get_internal_sensor_curr_temp(g, &readval); - if (!err) - *val = readval; - - return err; -} -DEFINE_SIMPLE_ATTRIBUTE(therm_ctrl_fops, therm_get_internal_sensor_curr_temp, NULL, "%llu\n"); - -void gp106_therm_debugfs_init(struct gk20a *g) -{ - struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g); - struct dentry *dbgentry; - - dbgentry = debugfs_create_file( - "temp", S_IRUGO, l->debugfs, g, &therm_ctrl_fops); - if (!dbgentry) - nvgpu_err(g, "debugfs entry create failed for therm_curr_temp"); -} -#endif - int gp106_elcg_init_idle_filters(struct gk20a *g) { u32 gate_ctrl, idle_filter; diff --git a/drivers/gpu/nvgpu/common/therm/therm_gp106.h b/drivers/gpu/nvgpu/common/therm/therm_gp106.h index a92c2e0f..e29c993f 100644 --- a/drivers/gpu/nvgpu/common/therm/therm_gp106.h +++ b/drivers/gpu/nvgpu/common/therm/therm_gp106.h @@ -1,7 +1,7 @@ /* * general thermal control structures & definitions * - * Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2016-2018, NVIDIA CORPORATION. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -31,9 +31,6 @@ struct gk20a; void gp106_get_internal_sensor_limits(s32 *max_24_8, s32 *min_24_8); int gp106_get_internal_sensor_curr_temp(struct gk20a *g, u32 *temp_f24_8); -#ifdef CONFIG_DEBUG_FS -void gp106_therm_debugfs_init(struct gk20a *g); -#endif int gp106_elcg_init_idle_filters(struct gk20a *g); u32 gp106_configure_therm_alert(struct gk20a *g, s32 curr_warn_temp); diff --git a/drivers/gpu/nvgpu/gp106/hal_gp106.c b/drivers/gpu/nvgpu/gp106/hal_gp106.c index af2d4c00..24c4191d 100644 --- a/drivers/gpu/nvgpu/gp106/hal_gp106.c +++ b/drivers/gpu/nvgpu/gp106/hal_gp106.c @@ -605,9 +605,6 @@ static const struct gpu_ops gp106_ops = { .data032_r = pram_data032_r, }, .therm = { -#ifdef CONFIG_DEBUG_FS - .therm_debugfs_init = gp106_therm_debugfs_init, -#endif /* CONFIG_DEBUG_FS */ .init_elcg_mode = gm20b_therm_init_elcg_mode, .init_blcg_mode = gm20b_therm_init_blcg_mode, .elcg_init_idle_filters = gp106_elcg_init_idle_filters, diff --git a/drivers/gpu/nvgpu/gv100/hal_gv100.c b/drivers/gpu/nvgpu/gv100/hal_gv100.c index 78798196..6a4f874d 100644 --- a/drivers/gpu/nvgpu/gv100/hal_gv100.c +++ b/drivers/gpu/nvgpu/gv100/hal_gv100.c @@ -702,9 +702,6 @@ static const struct gpu_ops gv100_ops = { .data032_r = pram_data032_r, }, .therm = { -#ifdef CONFIG_DEBUG_FS - .therm_debugfs_init = gp106_therm_debugfs_init, -#endif /* CONFIG_DEBUG_FS */ /* PROD values match with H/W INIT values */ .init_elcg_mode = gv11b_therm_init_elcg_mode, .init_blcg_mode = gm20b_therm_init_blcg_mode, diff --git a/drivers/gpu/nvgpu/os/linux/debug_therm_gp106.c b/drivers/gpu/nvgpu/os/linux/debug_therm_gp106.c new file mode 100644 index 00000000..dfe39461 --- /dev/null +++ b/drivers/gpu/nvgpu/os/linux/debug_therm_gp106.c @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2018, 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 "os_linux.h" + +static int therm_get_internal_sensor_curr_temp(void *data, u64 *val) +{ + struct gk20a *g = (struct gk20a *)data; + u32 readval; + int err; + + if (!g->ops.therm.get_internal_sensor_curr_temp) + return -EINVAL; + + err = g->ops.therm.get_internal_sensor_curr_temp(g, &readval); + if (!err) + *val = readval; + + return err; +} +DEFINE_SIMPLE_ATTRIBUTE(therm_ctrl_fops, therm_get_internal_sensor_curr_temp, NULL, "%llu\n"); + +int gp106_therm_init_debugfs(struct gk20a *g) +{ + struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g); + struct dentry *dbgentry; + + dbgentry = debugfs_create_file( + "temp", S_IRUGO, l->debugfs, g, &therm_ctrl_fops); + if (!dbgentry) + nvgpu_err(g, "debugfs entry create failed for therm_curr_temp"); + + return 0; +} diff --git a/drivers/gpu/nvgpu/os/linux/debug_therm_gp106.h b/drivers/gpu/nvgpu/os/linux/debug_therm_gp106.h new file mode 100644 index 00000000..6ebc9f58 --- /dev/null +++ b/drivers/gpu/nvgpu/os/linux/debug_therm_gp106.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2018, 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 . + */ + +#ifndef __DEBUG_THERM_GP106_H +#define __DEBUG_THERM_GP106_H + +#ifdef CONFIG_DEBUG_FS +int gp106_therm_init_debugfs(struct gk20a *g); +#else +inline int gp106_therm_init_debugfs(struct gk20a *g) +{ + return 0; +} +#endif + +#endif diff --git a/drivers/gpu/nvgpu/os/linux/module.c b/drivers/gpu/nvgpu/os/linux/module.c index 02b0ea5c..169baaf4 100644 --- a/drivers/gpu/nvgpu/os/linux/module.c +++ b/drivers/gpu/nvgpu/os/linux/module.c @@ -206,6 +206,14 @@ int nvgpu_finalize_poweron_linux(struct nvgpu_os_linux *l) } } + if (l->ops.therm.init_debugfs) { + err = l->ops.therm.init_debugfs(g); + if (err) { + nvgpu_err(g, "failed to init linux therm debugfs"); + return err; + } + } + l->init_done = true; return 0; diff --git a/drivers/gpu/nvgpu/os/linux/os_linux.h b/drivers/gpu/nvgpu/os/linux/os_linux.h index 96eff12e..ff871fe5 100644 --- a/drivers/gpu/nvgpu/os/linux/os_linux.h +++ b/drivers/gpu/nvgpu/os/linux/os_linux.h @@ -42,6 +42,10 @@ struct nvgpu_os_linux_ops { struct { int (*init_debugfs)(struct gk20a *g); } clk; + + struct { + int (*init_debugfs)(struct gk20a *g); + } therm; }; struct nvgpu_os_linux { diff --git a/drivers/gpu/nvgpu/os/linux/os_ops.c b/drivers/gpu/nvgpu/os/linux/os_ops.c index 5fc5beb4..5c2eb25c 100644 --- a/drivers/gpu/nvgpu/os/linux/os_ops.c +++ b/drivers/gpu/nvgpu/os/linux/os_ops.c @@ -21,6 +21,10 @@ #include "os_ops_gp106.h" #include "os_ops_gv100.h" +#if defined(CONFIG_TEGRA_GPU_NEXT) +#include "nvgpu_gpuid_next.h" +#endif + int nvgpu_init_os_linux_ops(struct nvgpu_os_linux *l) { struct gk20a *g = &l->g; @@ -40,6 +44,11 @@ int nvgpu_init_os_linux_ops(struct nvgpu_os_linux *l) case NVGPU_GPUID_GV100: nvgpu_gv100_init_os_ops(l); break; +#if defined(CONFIG_TEGRA_GPU_NEXT) + case NVGPU_GPUID_NEXT: + NVGPU_NEXT_INIT_OS_OPS(l); + break; +#endif default: break; } diff --git a/drivers/gpu/nvgpu/os/linux/os_ops_gp106.c b/drivers/gpu/nvgpu/os/linux/os_ops_gp106.c index 13ce73e6..662f4551 100644 --- a/drivers/gpu/nvgpu/os/linux/os_ops_gp106.c +++ b/drivers/gpu/nvgpu/os/linux/os_ops_gp106.c @@ -17,14 +17,19 @@ #include "os_linux.h" #include "debug_clk_gp106.h" +#include "debug_therm_gp106.h" static struct nvgpu_os_linux_ops gp106_os_linux_ops = { .clk = { .init_debugfs = gp106_clk_init_debugfs, }, + .therm = { + .init_debugfs = gp106_therm_init_debugfs, + }, }; void nvgpu_gp106_init_os_ops(struct nvgpu_os_linux *l) { l->ops.clk = gp106_os_linux_ops.clk; + l->ops.therm = gp106_os_linux_ops.therm; } diff --git a/drivers/gpu/nvgpu/os/linux/os_ops_gv100.c b/drivers/gpu/nvgpu/os/linux/os_ops_gv100.c index 9236286b..7a5174a4 100644 --- a/drivers/gpu/nvgpu/os/linux/os_ops_gv100.c +++ b/drivers/gpu/nvgpu/os/linux/os_ops_gv100.c @@ -17,14 +17,19 @@ #include "os_linux.h" #include "debug_clk_gp106.h" +#include "debug_therm_gp106.h" static struct nvgpu_os_linux_ops gv100_os_linux_ops = { .clk = { .init_debugfs = gp106_clk_init_debugfs, }, + .therm = { + .init_debugfs = gp106_therm_init_debugfs, + }, }; void nvgpu_gv100_init_os_ops(struct nvgpu_os_linux *l) { l->ops.clk = gv100_os_linux_ops.clk; + l->ops.therm = gv100_os_linux_ops.therm; } -- cgit v1.2.2