mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-22 17:36:20 +03:00
gpu: nvgpu: Debugfs for Volt
Changes: 1. Reading operating voltage and minimum voltage of chip. 2. Added nvgpu_volt_init_debugfs for creating the debugfs interface. 3. Command for reading current voltage: cat /sys/kernel/debug/gpu_pci/volt/current_voltage 4. Command for reading minimum voltage: cat /sys/kernel/debug/gpu_pci/volt/minimum_voltage Jira NVGPU-1731 Change-Id: I76d42fc376235f37c44d259398bd6f125a90413b Signed-off-by: rmylavarapu <rmylavarapu@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1986403 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:
committed by
mobile promotions
parent
9467646a87
commit
d174860854
@@ -205,7 +205,8 @@ nvgpu-$(CONFIG_DEBUG_FS) += \
|
|||||||
os/linux/debug_bios.o \
|
os/linux/debug_bios.o \
|
||||||
os/linux/debug_ltc.o \
|
os/linux/debug_ltc.o \
|
||||||
os/linux/debug_xve.o \
|
os/linux/debug_xve.o \
|
||||||
os/linux/debug_clk_gv100.o
|
os/linux/debug_clk_gv100.o \
|
||||||
|
os/linux/debug_volt.o
|
||||||
|
|
||||||
ifeq ($(CONFIG_NVGPU_TRACK_MEM_USAGE),y)
|
ifeq ($(CONFIG_NVGPU_TRACK_MEM_USAGE),y)
|
||||||
nvgpu-$(CONFIG_DEBUG_FS) += \
|
nvgpu-$(CONFIG_DEBUG_FS) += \
|
||||||
|
|||||||
80
drivers/gpu/nvgpu/os/linux/debug_volt.c
Normal file
80
drivers/gpu/nvgpu/os/linux/debug_volt.c
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019, 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"
|
||||||
|
|
||||||
|
#include <nvgpu/pmu/volt.h>
|
||||||
|
#include <common/pmu/volt/volt_rail.h>
|
||||||
|
|
||||||
|
static int get_curr_voltage(void *data, u64 *val)
|
||||||
|
{
|
||||||
|
struct gk20a *g = (struct gk20a *)data;
|
||||||
|
u32 readval;
|
||||||
|
int err;
|
||||||
|
|
||||||
|
if (!g->ops.pmu_ver.volt.volt_get_voltage)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
err = g->ops.pmu_ver.volt.volt_get_voltage(g,
|
||||||
|
CTRL_VOLT_DOMAIN_LOGIC, &readval);
|
||||||
|
if (!err)
|
||||||
|
*val = readval;
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
DEFINE_SIMPLE_ATTRIBUTE(curr_volt_ctrl_fops, get_curr_voltage, NULL, "%llu\n");
|
||||||
|
|
||||||
|
static int get_min_voltage(void *data, u64 *val)
|
||||||
|
{
|
||||||
|
struct gk20a *g = (struct gk20a *)data;
|
||||||
|
u32 readval;
|
||||||
|
int err;
|
||||||
|
|
||||||
|
if (!g->ops.pmu_ver.volt.volt_get_vmin)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
err = g->ops.pmu_ver.volt.volt_get_vmin(g, &readval);
|
||||||
|
if (!err)
|
||||||
|
*val = readval;
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
DEFINE_SIMPLE_ATTRIBUTE(min_volt_ctrl_fops, get_min_voltage, NULL, "%llu\n");
|
||||||
|
|
||||||
|
int nvgpu_volt_init_debugfs(struct gk20a *g)
|
||||||
|
{
|
||||||
|
struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g);
|
||||||
|
struct dentry *dbgentry, *volt_root;
|
||||||
|
|
||||||
|
volt_root = debugfs_create_dir("volt", l->debugfs);
|
||||||
|
|
||||||
|
dbgentry = debugfs_create_file(
|
||||||
|
"current_voltage", S_IRUGO, volt_root, g, &curr_volt_ctrl_fops);
|
||||||
|
if (!dbgentry) {
|
||||||
|
pr_err("%s: Failed to make debugfs node\n", __func__);
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
dbgentry = debugfs_create_file("minimum_voltage",
|
||||||
|
S_IRUGO, volt_root, g, &min_volt_ctrl_fops);
|
||||||
|
if (!dbgentry) {
|
||||||
|
pr_err("%s: Failed to make debugfs node\n", __func__);
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
29
drivers/gpu/nvgpu/os/linux/debug_volt.h
Normal file
29
drivers/gpu/nvgpu/os/linux/debug_volt.h
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019, 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_VOLT_H
|
||||||
|
#define __DEBUG_VOLT_H
|
||||||
|
|
||||||
|
#ifdef CONFIG_DEBUG_FS
|
||||||
|
int nvgpu_volt_init_debugfs(struct gk20a *g);
|
||||||
|
#else
|
||||||
|
static inline int nvgpu_volt_init_debugfs(struct gk20a *g)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -233,6 +233,14 @@ int nvgpu_finalize_poweron_linux(struct nvgpu_os_linux *l)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (l->ops.volt.init_debugfs) {
|
||||||
|
err = l->ops.volt.init_debugfs(g);
|
||||||
|
if (err) {
|
||||||
|
nvgpu_err(g, "failed to init linux volt debugfs");
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
err = nvgpu_pmgr_init_debugfs_linux(l);
|
err = nvgpu_pmgr_init_debugfs_linux(l);
|
||||||
if (err) {
|
if (err) {
|
||||||
nvgpu_err(g, "failed to init linux pmgr debugfs");
|
nvgpu_err(g, "failed to init linux pmgr debugfs");
|
||||||
|
|||||||
@@ -52,6 +52,10 @@ struct nvgpu_os_linux_ops {
|
|||||||
struct {
|
struct {
|
||||||
int (*init_debugfs)(struct gk20a *g);
|
int (*init_debugfs)(struct gk20a *g);
|
||||||
} fecs_trace;
|
} fecs_trace;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
int (*init_debugfs)(struct gk20a *g);
|
||||||
|
} volt;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct nvgpu_os_linux {
|
struct nvgpu_os_linux {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, NVIDIA Corporation. All rights reserved.
|
* Copyright (c) 2018-2019, NVIDIA Corporation. All rights reserved.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
* under the terms and conditions of the GNU General Public License,
|
* under the terms and conditions of the GNU General Public License,
|
||||||
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include "os/linux/debug_therm_gp106.h"
|
#include "os/linux/debug_therm_gp106.h"
|
||||||
#include "os/linux/debug_clk_gv100.h"
|
#include "os/linux/debug_clk_gv100.h"
|
||||||
|
#include "os/linux/debug_volt.h"
|
||||||
|
|
||||||
static struct nvgpu_os_linux_ops tu104_os_linux_ops = {
|
static struct nvgpu_os_linux_ops tu104_os_linux_ops = {
|
||||||
.therm = {
|
.therm = {
|
||||||
@@ -26,10 +27,14 @@ static struct nvgpu_os_linux_ops tu104_os_linux_ops = {
|
|||||||
.clk = {
|
.clk = {
|
||||||
.init_debugfs = gv100_clk_init_debugfs,
|
.init_debugfs = gv100_clk_init_debugfs,
|
||||||
},
|
},
|
||||||
|
.volt = {
|
||||||
|
.init_debugfs = nvgpu_volt_init_debugfs,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
void nvgpu_tu104_init_os_ops(struct nvgpu_os_linux *l)
|
void nvgpu_tu104_init_os_ops(struct nvgpu_os_linux *l)
|
||||||
{
|
{
|
||||||
l->ops.therm = tu104_os_linux_ops.therm;
|
l->ops.therm = tu104_os_linux_ops.therm;
|
||||||
l->ops.clk = tu104_os_linux_ops.clk;
|
l->ops.clk = tu104_os_linux_ops.clk;
|
||||||
|
l->ops.volt = tu104_os_linux_ops.volt;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user