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 <nkumbhar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1797906
GVS: Gerrit_Virtual_Submit
Reviewed-by: Vijayakumar Subbu <vsubbu@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Nitin Kumbhar
2018-08-13 10:09:04 +05:30
committed by mobile promotions
parent 0406900ca9
commit bcdac829f4
12 changed files with 112 additions and 42 deletions

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#include <linux/debugfs.h>
#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;
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
#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

View File

@@ -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;

View File

@@ -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 {

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}