diff options
-rw-r--r-- | drivers/gpu/nvgpu/Makefile.nvgpu | 3 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/vgpu/sysfs_vgpu.c | 48 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/vgpu/vgpu.c | 2 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/vgpu/vgpu.h | 3 | ||||
-rw-r--r-- | include/linux/tegra_vgpu.h | 6 |
5 files changed, 61 insertions, 1 deletions
diff --git a/drivers/gpu/nvgpu/Makefile.nvgpu b/drivers/gpu/nvgpu/Makefile.nvgpu index 30e2bdeb..c3c5fa8c 100644 --- a/drivers/gpu/nvgpu/Makefile.nvgpu +++ b/drivers/gpu/nvgpu/Makefile.nvgpu | |||
@@ -115,7 +115,8 @@ nvgpu-$(CONFIG_TEGRA_GR_VIRTUALIZATION) += \ | |||
115 | vgpu/gk20a/vgpu_hal_gk20a.o \ | 115 | vgpu/gk20a/vgpu_hal_gk20a.o \ |
116 | vgpu/gk20a/vgpu_gr_gk20a.o \ | 116 | vgpu/gk20a/vgpu_gr_gk20a.o \ |
117 | vgpu/gm20b/vgpu_hal_gm20b.o \ | 117 | vgpu/gm20b/vgpu_hal_gm20b.o \ |
118 | vgpu/gm20b/vgpu_gr_gm20b.o | 118 | vgpu/gm20b/vgpu_gr_gm20b.o \ |
119 | vgpu/sysfs_vgpu.o | ||
119 | 120 | ||
120 | nvgpu-$(CONFIG_TEGRA_CLK_FRAMEWORK) += gk20a/clk_gk20a.o | 121 | nvgpu-$(CONFIG_TEGRA_CLK_FRAMEWORK) += gk20a/clk_gk20a.o |
121 | ifneq (,$filter y,$(CONFIG_TEGRA_CLK_FRAMEWORK),$(CONFIG_COMMON_CLK)) | 122 | ifneq (,$filter y,$(CONFIG_TEGRA_CLK_FRAMEWORK),$(CONFIG_COMMON_CLK)) |
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 | } | ||
diff --git a/drivers/gpu/nvgpu/vgpu/vgpu.c b/drivers/gpu/nvgpu/vgpu/vgpu.c index 0ac79345..ba387de9 100644 --- a/drivers/gpu/nvgpu/vgpu/vgpu.c +++ b/drivers/gpu/nvgpu/vgpu/vgpu.c | |||
@@ -632,6 +632,7 @@ int vgpu_probe(struct platform_device *pdev) | |||
632 | CONFIG_GK20A_DEFAULT_TIMEOUT; | 632 | CONFIG_GK20A_DEFAULT_TIMEOUT; |
633 | gk20a->timeouts_enabled = true; | 633 | gk20a->timeouts_enabled = true; |
634 | 634 | ||
635 | vgpu_create_sysfs(dev); | ||
635 | gk20a_init_gr(gk20a); | 636 | gk20a_init_gr(gk20a); |
636 | 637 | ||
637 | return 0; | 638 | return 0; |
@@ -650,6 +651,7 @@ int vgpu_remove(struct platform_device *pdev) | |||
650 | vgpu_comm_deinit(); | 651 | vgpu_comm_deinit(); |
651 | gk20a_sched_ctrl_cleanup(g); | 652 | gk20a_sched_ctrl_cleanup(g); |
652 | gk20a_user_deinit(dev, &nvgpu_class); | 653 | gk20a_user_deinit(dev, &nvgpu_class); |
654 | vgpu_remove_sysfs(dev); | ||
653 | gk20a_get_platform(dev)->g = NULL; | 655 | gk20a_get_platform(dev)->g = NULL; |
654 | kfree(g); | 656 | kfree(g); |
655 | return 0; | 657 | return 0; |
diff --git a/drivers/gpu/nvgpu/vgpu/vgpu.h b/drivers/gpu/nvgpu/vgpu/vgpu.h index e64b31b4..098c7dbd 100644 --- a/drivers/gpu/nvgpu/vgpu/vgpu.h +++ b/drivers/gpu/nvgpu/vgpu/vgpu.h | |||
@@ -103,6 +103,9 @@ int vgpu_gk20a_init_hal(struct gk20a *g); | |||
103 | int vgpu_gm20b_init_hal(struct gk20a *g); | 103 | int vgpu_gm20b_init_hal(struct gk20a *g); |
104 | 104 | ||
105 | void vgpu_init_dbg_session_ops(struct gpu_ops *gops); | 105 | void vgpu_init_dbg_session_ops(struct gpu_ops *gops); |
106 | |||
107 | void vgpu_create_sysfs(struct device *dev); | ||
108 | void vgpu_remove_sysfs(struct device *dev); | ||
106 | #else | 109 | #else |
107 | static inline int vgpu_pm_prepare_poweroff(struct device *dev) | 110 | static inline int vgpu_pm_prepare_poweroff(struct device *dev) |
108 | { | 111 | { |
diff --git a/include/linux/tegra_vgpu.h b/include/linux/tegra_vgpu.h index 14449242..b83b9669 100644 --- a/include/linux/tegra_vgpu.h +++ b/include/linux/tegra_vgpu.h | |||
@@ -99,6 +99,7 @@ enum { | |||
99 | TEGRA_VGPU_CMD_GET_CONSTANTS = 62, | 99 | TEGRA_VGPU_CMD_GET_CONSTANTS = 62, |
100 | TEGRA_VGPU_CMD_CHANNEL_CYCLESTATS_SNAPSHOT = 63, | 100 | TEGRA_VGPU_CMD_CHANNEL_CYCLESTATS_SNAPSHOT = 63, |
101 | TEGRA_VGPU_CMD_TSG_OPEN = 64, | 101 | TEGRA_VGPU_CMD_TSG_OPEN = 64, |
102 | TEGRA_VGPU_CMD_GET_GPU_LOAD = 65, | ||
102 | }; | 103 | }; |
103 | 104 | ||
104 | struct tegra_vgpu_connect_params { | 105 | struct tegra_vgpu_connect_params { |
@@ -454,6 +455,10 @@ struct tegra_vgpu_channel_cyclestats_snapshot_params { | |||
454 | u8 hw_overflow; | 455 | u8 hw_overflow; |
455 | }; | 456 | }; |
456 | 457 | ||
458 | struct tegra_vgpu_gpu_load_params { | ||
459 | u32 load; | ||
460 | }; | ||
461 | |||
457 | struct tegra_vgpu_cmd_msg { | 462 | struct tegra_vgpu_cmd_msg { |
458 | u32 cmd; | 463 | u32 cmd; |
459 | int ret; | 464 | int ret; |
@@ -500,6 +505,7 @@ struct tegra_vgpu_cmd_msg { | |||
500 | struct tegra_vgpu_gpu_clk_rate_params gpu_clk_rate; | 505 | struct tegra_vgpu_gpu_clk_rate_params gpu_clk_rate; |
501 | struct tegra_vgpu_constants_params constants; | 506 | struct tegra_vgpu_constants_params constants; |
502 | struct tegra_vgpu_channel_cyclestats_snapshot_params cyclestats_snapshot; | 507 | struct tegra_vgpu_channel_cyclestats_snapshot_params cyclestats_snapshot; |
508 | struct tegra_vgpu_gpu_load_params gpu_load; | ||
503 | char padding[192]; | 509 | char padding[192]; |
504 | } params; | 510 | } params; |
505 | }; | 511 | }; |