diff options
author | Kyle Guo <kyleg@nvidia.com> | 2018-07-12 20:51:42 -0400 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2018-08-15 00:24:53 -0400 |
commit | 2a25d03f2b7ad0700f14640282abd72ff587d800 (patch) | |
tree | 990b2f40d4625df7d5a9106d3c98dc0ccddf90ac /drivers/gpu/nvgpu/vgpu/ecc_vgpu.c | |
parent | 91390d857f6302f9c2923ec4188ea7e24ee537a2 (diff) |
gpu: nvgpu: vgpu: ecc sysfs support for vgpu
- fetch ecc info from RM server and create sysfs nodes
- new file ecc_vgpu.c for platform-independent code
- add 2 new commands: GET_ECC_INFO and GET_ECC_COUNTER_VALUE
JIRA EVLR-2590
Change-Id: I040a9fcd23326e432ca93e9a028319f9c1c570f0
Signed-off-by: Kyle Guo <kyleg@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1777428
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/vgpu/ecc_vgpu.c')
-rw-r--r-- | drivers/gpu/nvgpu/vgpu/ecc_vgpu.c | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/vgpu/ecc_vgpu.c b/drivers/gpu/nvgpu/vgpu/ecc_vgpu.c new file mode 100644 index 00000000..fa44e58f --- /dev/null +++ b/drivers/gpu/nvgpu/vgpu/ecc_vgpu.c | |||
@@ -0,0 +1,92 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. | ||
3 | * | ||
4 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | * copy of this software and associated documentation files (the "Software"), | ||
6 | * to deal in the Software without restriction, including without limitation | ||
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | * and/or sell copies of the Software, and to permit persons to whom the | ||
9 | * Software is furnished to do so, subject to the following conditions: | ||
10 | * | ||
11 | * The above copyright notice and this permission notice shall be included in | ||
12 | * all copies or substantial portions of the Software. | ||
13 | * | ||
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
20 | * DEALINGS IN THE SOFTWARE. | ||
21 | */ | ||
22 | |||
23 | #include <nvgpu/kmem.h> | ||
24 | #include <nvgpu/vgpu/vgpu_ivc.h> | ||
25 | #include <nvgpu/vgpu/vgpu.h> | ||
26 | #include <nvgpu/errno.h> | ||
27 | |||
28 | #include "vgpu/ecc_vgpu.h" | ||
29 | |||
30 | int vgpu_ecc_get_info(struct gk20a *g) | ||
31 | { | ||
32 | struct vgpu_priv_data *priv = vgpu_get_priv_data(g); | ||
33 | struct tegra_vgpu_cmd_msg msg = {0}; | ||
34 | struct tegra_vgpu_ecc_info_params *p = &msg.params.ecc_info; | ||
35 | struct tegra_vgpu_ecc_info_entry *entry; | ||
36 | struct vgpu_ecc_stat *stats; | ||
37 | void *handle; | ||
38 | int err, i, count; | ||
39 | size_t oob_size; | ||
40 | |||
41 | msg.cmd = TEGRA_VGPU_CMD_GET_ECC_INFO; | ||
42 | msg.handle = vgpu_get_handle(g); | ||
43 | err = vgpu_comm_sendrecv(&msg, sizeof(msg), sizeof(msg)); | ||
44 | err = err ? err : msg.ret; | ||
45 | if (unlikely(err)) { | ||
46 | nvgpu_err(g, "vgpu get_ecc_info failed, err=%d", err); | ||
47 | return err; | ||
48 | } | ||
49 | |||
50 | count = p->ecc_stats_count; | ||
51 | |||
52 | handle = vgpu_ivc_oob_get_ptr(vgpu_ivc_get_server_vmid(), | ||
53 | TEGRA_VGPU_QUEUE_CMD, | ||
54 | (void **)&entry, &oob_size); | ||
55 | if (unlikely(!handle)) | ||
56 | return -EINVAL; | ||
57 | |||
58 | if (unlikely(oob_size < count * sizeof(*entry))) { | ||
59 | err = -E2BIG; | ||
60 | goto out; | ||
61 | } | ||
62 | |||
63 | stats = nvgpu_kzalloc(g, count * sizeof(*stats)); | ||
64 | if (unlikely(!stats)) { | ||
65 | err = -ENOMEM; | ||
66 | goto out; | ||
67 | } | ||
68 | |||
69 | for (i = 0; i < count; i++) { | ||
70 | stats[i].ecc_id = entry[i].ecc_id; | ||
71 | strncpy(stats[i].name, entry[i].name, | ||
72 | NVGPU_ECC_STAT_NAME_MAX_SIZE); | ||
73 | } | ||
74 | |||
75 | priv->ecc_stats = stats; | ||
76 | priv->ecc_stats_count = count; | ||
77 | out: | ||
78 | vgpu_ivc_oob_put_ptr(handle); | ||
79 | return err; | ||
80 | } | ||
81 | |||
82 | void vgpu_ecc_remove_info(struct gk20a *g) | ||
83 | { | ||
84 | struct vgpu_priv_data *priv = vgpu_get_priv_data(g); | ||
85 | |||
86 | priv->ecc_stats_count = 0; | ||
87 | |||
88 | if (priv->ecc_stats) { | ||
89 | nvgpu_kfree(g, priv->ecc_stats); | ||
90 | priv->ecc_stats = NULL; | ||
91 | } | ||
92 | } | ||