summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/common/linux/vgpu/sysfs_vgpu.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/nvgpu/common/linux/vgpu/sysfs_vgpu.c')
-rw-r--r--drivers/gpu/nvgpu/common/linux/vgpu/sysfs_vgpu.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/vgpu/sysfs_vgpu.c b/drivers/gpu/nvgpu/common/linux/vgpu/sysfs_vgpu.c
new file mode 100644
index 00000000..4025aabd
--- /dev/null
+++ b/drivers/gpu/nvgpu/common/linux/vgpu/sysfs_vgpu.c
@@ -0,0 +1,49 @@
1/*
2 * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include <linux/device.h>
18
19#include "vgpu.h"
20
21static ssize_t vgpu_load_show(struct device *dev,
22 struct device_attribute *attr,
23 char *buf)
24{
25 struct gk20a *g = get_gk20a(dev);
26 struct tegra_vgpu_cmd_msg msg = {0};
27 struct tegra_vgpu_gpu_load_params *p = &msg.params.gpu_load;
28 int err;
29
30 msg.cmd = TEGRA_VGPU_CMD_GET_GPU_LOAD;
31 msg.handle = vgpu_get_handle(g);
32 err = vgpu_comm_sendrecv(&msg, sizeof(msg), sizeof(msg));
33 if (err)
34 return err;
35
36 return snprintf(buf, PAGE_SIZE, "%u\n", p->load);
37}
38static DEVICE_ATTR(load, S_IRUGO, vgpu_load_show, NULL);
39
40void vgpu_create_sysfs(struct device *dev)
41{
42 if (device_create_file(dev, &dev_attr_load))
43 dev_err(dev, "Failed to create vgpu sysfs attributes!\n");
44}
45
46void vgpu_remove_sysfs(struct device *dev)
47{
48 device_remove_file(dev, &dev_attr_load);
49}