diff options
author | Aparna Das <aparnad@nvidia.com> | 2016-12-21 15:35:08 -0500 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2017-01-24 19:24:12 -0500 |
commit | bad0572cb1144ba08659aed88c311ae02c72c21c (patch) | |
tree | af05a5541dcff9cfd0c4b2a3a0b4e05f6f935575 /drivers/gpu/nvgpu/vgpu/sysfs_vgpu.c | |
parent | 4feb078717fe7986bc0dfdfbfc3f10e5d1d1fa63 (diff) |
gpu: nvgpu: vgpu: retrieve gpu load
Add support to send command to RM server to retrieve
GPU load.
Bug 200261903
Change-Id: Ie3d0ba7ec91317e9a2911f71613ad78d20f9c1fb
Signed-off-by: Aparna Das <aparnad@nvidia.com>
Reviewed-on: http://git-master/r/1275045
(cherry picked from commit 5a6c1de1e6997bfd803b4b95b3e44e282ba32f67)
Reviewed-on: http://git-master/r/1283279
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/vgpu/sysfs_vgpu.c')
-rw-r--r-- | drivers/gpu/nvgpu/vgpu/sysfs_vgpu.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/vgpu/sysfs_vgpu.c b/drivers/gpu/nvgpu/vgpu/sysfs_vgpu.c new file mode 100644 index 00000000..d43a34aa --- /dev/null +++ b/drivers/gpu/nvgpu/vgpu/sysfs_vgpu.c | |||
@@ -0,0 +1,48 @@ | |||
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 | |||
14 | #include <linux/device.h> | ||
15 | #include <linux/kernel.h> | ||
16 | #include <linux/gk20a.h> | ||
17 | |||
18 | #include "vgpu/vgpu.h" | ||
19 | |||
20 | static ssize_t vgpu_load_show(struct device *dev, | ||
21 | struct device_attribute *attr, | ||
22 | char *buf) | ||
23 | { | ||
24 | struct gk20a *g = get_gk20a(dev); | ||
25 | struct tegra_vgpu_cmd_msg msg = {0}; | ||
26 | struct tegra_vgpu_gpu_load_params *p = &msg.params.gpu_load; | ||
27 | int err; | ||
28 | |||
29 | msg.cmd = TEGRA_VGPU_CMD_GET_GPU_LOAD; | ||
30 | msg.handle = vgpu_get_handle(g); | ||
31 | err = vgpu_comm_sendrecv(&msg, sizeof(msg), sizeof(msg)); | ||
32 | if (err) | ||
33 | return err; | ||
34 | |||
35 | return snprintf(buf, PAGE_SIZE, "%u\n", p->load); | ||
36 | } | ||
37 | static DEVICE_ATTR(load, S_IRUGO, vgpu_load_show, NULL); | ||
38 | |||
39 | void vgpu_create_sysfs(struct device *dev) | ||
40 | { | ||
41 | if (device_create_file(dev, &dev_attr_load)) | ||
42 | dev_err(dev, "Failed to create vgpu sysfs attributes!\n"); | ||
43 | } | ||
44 | |||
45 | void vgpu_remove_sysfs(struct device *dev) | ||
46 | { | ||
47 | device_remove_file(dev, &dev_attr_load); | ||
48 | } | ||