summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/common/priv_ring
diff options
context:
space:
mode:
authorTerje Bergstrom <tbergstrom@nvidia.com>2018-08-10 11:28:23 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2018-08-13 17:06:17 -0400
commite62785190f74cfbf9003a190a768e9077373bf6f (patch)
treebe7bf93828c948d3b9bc84ec31f3f21cec35cf9e /drivers/gpu/nvgpu/common/priv_ring
parent0706e94c9204becdee6a32391a319cad690d1bc3 (diff)
gpu: nvgpu: Move priv_ring HAL to common
Move implementation of priv_ring HAL to common/priv_ring. Implement two new HAL APIs to remove illegal dependencies: enable_priv_ring and enum_ltc. As enum_ltc can be implemented only gm20b onwards, bump gk20a implementation to base on gm20b. JIRA NVGPU-964 Change-Id: I160c2216132aadbcd98bb4a688aeeb2c520a9bc0 Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1797025 Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/common/priv_ring')
-rw-r--r--drivers/gpu/nvgpu/common/priv_ring/priv_ring_gm20b.c121
-rw-r--r--drivers/gpu/nvgpu/common/priv_ring/priv_ring_gm20b.h32
-rw-r--r--drivers/gpu/nvgpu/common/priv_ring/priv_ring_gp10b.c198
-rw-r--r--drivers/gpu/nvgpu/common/priv_ring/priv_ring_gp10b.h33
4 files changed, 384 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/common/priv_ring/priv_ring_gm20b.c b/drivers/gpu/nvgpu/common/priv_ring/priv_ring_gm20b.c
new file mode 100644
index 00000000..1445473a
--- /dev/null
+++ b/drivers/gpu/nvgpu/common/priv_ring/priv_ring_gm20b.c
@@ -0,0 +1,121 @@
1/*
2 * Copyright (c) 2011-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 "gk20a/gk20a.h"
24
25#include <nvgpu/log.h>
26#include <nvgpu/timers.h>
27#include <nvgpu/enabled.h>
28#include <nvgpu/io.h>
29#include <nvgpu/utils.h>
30
31#include "priv_ring_gm20b.h"
32
33#include <nvgpu/hw/gm20b/hw_pri_ringmaster_gm20b.h>
34#include <nvgpu/hw/gm20b/hw_pri_ringstation_sys_gm20b.h>
35#include <nvgpu/hw/gm20b/hw_pri_ringstation_gpc_gm20b.h>
36
37void gm20b_priv_ring_enable(struct gk20a *g)
38{
39 if (nvgpu_is_enabled(g, NVGPU_IS_FMODEL))
40 return;
41
42 nvgpu_log(g, gpu_dbg_info, "enabling priv ring");
43
44 if (g->ops.clock_gating.slcg_priring_load_gating_prod)
45 g->ops.clock_gating.slcg_priring_load_gating_prod(g,
46 g->slcg_enabled);
47
48 gk20a_writel(g,pri_ringmaster_command_r(),
49 0x4);
50
51 gk20a_writel(g, pri_ringstation_sys_decode_config_r(),
52 0x2);
53 gk20a_readl(g, pri_ringstation_sys_decode_config_r());
54}
55
56void gm20b_priv_ring_isr(struct gk20a *g)
57{
58 u32 status0, status1;
59 u32 cmd;
60 s32 retry = 100;
61 u32 gpc;
62 u32 gpc_priv_stride = nvgpu_get_litter_value(g, GPU_LIT_GPC_PRIV_STRIDE);
63
64 if (nvgpu_is_enabled(g, NVGPU_IS_FMODEL))
65 return;
66
67 status0 = gk20a_readl(g, pri_ringmaster_intr_status0_r());
68 status1 = gk20a_readl(g, pri_ringmaster_intr_status1_r());
69
70 nvgpu_log(g, gpu_dbg_intr, "ringmaster intr status0: 0x%08x,"
71 "status1: 0x%08x", status0, status1);
72
73 if (pri_ringmaster_intr_status0_gbl_write_error_sys_v(status0) != 0) {
74 nvgpu_log(g, gpu_dbg_intr, "SYS write error. ADR %08x WRDAT %08x INFO %08x, CODE %08x",
75 gk20a_readl(g, pri_ringstation_sys_priv_error_adr_r()),
76 gk20a_readl(g, pri_ringstation_sys_priv_error_wrdat_r()),
77 gk20a_readl(g, pri_ringstation_sys_priv_error_info_r()),
78 gk20a_readl(g, pri_ringstation_sys_priv_error_code_r()));
79 }
80
81 for (gpc = 0; gpc < g->gr.gpc_count; gpc++) {
82 if (status1 & BIT(gpc)) {
83 nvgpu_log(g, gpu_dbg_intr, "GPC%u write error. ADR %08x WRDAT %08x INFO %08x, CODE %08x", gpc,
84 gk20a_readl(g, pri_ringstation_gpc_gpc0_priv_error_adr_r() + gpc * gpc_priv_stride),
85 gk20a_readl(g, pri_ringstation_gpc_gpc0_priv_error_wrdat_r() + gpc * gpc_priv_stride),
86 gk20a_readl(g, pri_ringstation_gpc_gpc0_priv_error_info_r() + gpc * gpc_priv_stride),
87 gk20a_readl(g, pri_ringstation_gpc_gpc0_priv_error_code_r() + gpc * gpc_priv_stride));
88 }
89 }
90 /* clear interrupt */
91 cmd = gk20a_readl(g, pri_ringmaster_command_r());
92 cmd = set_field(cmd, pri_ringmaster_command_cmd_m(),
93 pri_ringmaster_command_cmd_ack_interrupt_f());
94 gk20a_writel(g, pri_ringmaster_command_r(), cmd);
95 /* poll for clear interrupt done */
96 cmd = pri_ringmaster_command_cmd_v(
97 gk20a_readl(g, pri_ringmaster_command_r()));
98 while (cmd != pri_ringmaster_command_cmd_no_cmd_v() && retry) {
99 nvgpu_udelay(20);
100 retry--;
101 cmd = pri_ringmaster_command_cmd_v(
102 gk20a_readl(g, pri_ringmaster_command_r()));
103 }
104 if (retry == 0 && cmd != pri_ringmaster_command_cmd_no_cmd_v())
105 nvgpu_warn(g, "priv ringmaster intr ack too many retries");
106}
107
108void gm20b_priv_set_timeout_settings(struct gk20a *g)
109{
110 /*
111 * Bug 1340570: increase the clock timeout to avoid potential
112 * operation failure at high gpcclk rate. Default values are 0x400.
113 */
114 nvgpu_writel(g, pri_ringstation_sys_master_config_r(0x15), 0x800);
115 nvgpu_writel(g, pri_ringstation_gpc_master_config_r(0xa), 0x800);
116}
117
118u32 gm20b_priv_ring_enum_ltc(struct gk20a *g)
119{
120 return gk20a_readl(g, pri_ringmaster_enum_ltc_r());
121}
diff --git a/drivers/gpu/nvgpu/common/priv_ring/priv_ring_gm20b.h b/drivers/gpu/nvgpu/common/priv_ring/priv_ring_gm20b.h
new file mode 100644
index 00000000..02f20515
--- /dev/null
+++ b/drivers/gpu/nvgpu/common/priv_ring/priv_ring_gm20b.h
@@ -0,0 +1,32 @@
1/*
2 * Copyright (c) 2011-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#ifndef __PRIV_RING_GM20B_H__
23#define __PRIV_RING_GM20B_H__
24
25struct gk20a;
26
27void gm20b_priv_ring_isr(struct gk20a *g);
28void gm20b_priv_ring_enable(struct gk20a *g);
29void gm20b_priv_set_timeout_settings(struct gk20a *g);
30u32 gm20b_priv_ring_enum_ltc(struct gk20a *g);
31
32#endif /*__PRIV_RING_GM20B_H__*/
diff --git a/drivers/gpu/nvgpu/common/priv_ring/priv_ring_gp10b.c b/drivers/gpu/nvgpu/common/priv_ring/priv_ring_gp10b.c
new file mode 100644
index 00000000..04525375
--- /dev/null
+++ b/drivers/gpu/nvgpu/common/priv_ring/priv_ring_gp10b.c
@@ -0,0 +1,198 @@
1/*
2 * GP10B priv ring
3 *
4 * Copyright (c) 2017-2018, NVIDIA CORPORATION. All rights reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 */
24
25#include "gk20a/gk20a.h"
26
27#include <nvgpu/log.h>
28#include <nvgpu/timers.h>
29#include <nvgpu/enabled.h>
30#include <nvgpu/io.h>
31#include <nvgpu/utils.h>
32
33#include <nvgpu/hw/gp10b/hw_pri_ringmaster_gp10b.h>
34#include <nvgpu/hw/gp10b/hw_pri_ringstation_sys_gp10b.h>
35#include <nvgpu/hw/gp10b/hw_pri_ringstation_gpc_gp10b.h>
36
37#include "priv_ring_gp10b.h"
38
39static const char *const error_type_badf1xyy[] = {
40 "client timeout",
41 "decode error",
42 "client in reset",
43 "client floorswept",
44 "client stuck ack",
45 "client expected ack",
46 "fence error",
47 "subid error",
48 "byte access unsupported",
49};
50
51static const char *const error_type_badf2xyy[] = {
52 "orphan gpc/fbp"
53};
54
55static const char *const error_type_badf3xyy[] = {
56 "priv ring dead"
57};
58
59static const char *const error_type_badf5xyy[] = {
60 "client error",
61 "priv level violation",
62 "indirect priv level violation",
63 "local local ring error",
64 "falcon mem access priv level violation",
65 "pri route error"
66};
67
68void gp10b_priv_ring_decode_error_code(struct gk20a *g,
69 u32 error_code)
70{
71 u32 error_type_index;
72
73 error_type_index = (error_code & 0x00000f00) >> 16;
74 error_code = error_code & 0xBADFf000;
75
76 if (error_code == 0xBADF1000) {
77 if (error_type_index <
78 ARRAY_SIZE(error_type_badf1xyy))
79 nvgpu_err(g, "%s",
80 error_type_badf1xyy[error_type_index]);
81 } else if (error_code == 0xBADF2000) {
82 if (error_type_index <
83 ARRAY_SIZE(error_type_badf2xyy))
84 nvgpu_err(g, "%s",
85 error_type_badf2xyy[error_type_index]);
86 } else if (error_code == 0xBADF3000) {
87 if (error_type_index <
88 ARRAY_SIZE(error_type_badf3xyy))
89 nvgpu_err(g, "%s",
90 error_type_badf3xyy[error_type_index]);
91 } else if (error_code == 0xBADF5000) {
92 if (error_type_index <
93 ARRAY_SIZE(error_type_badf5xyy))
94 nvgpu_err(g, "%s",
95 error_type_badf5xyy[error_type_index]);
96 }
97}
98
99void gp10b_priv_ring_isr(struct gk20a *g)
100{
101 u32 status0, status1;
102 u32 cmd;
103 s32 retry = 100;
104 u32 gpc;
105 u32 gpc_stride, offset;
106 u32 error_info;
107 u32 error_code;
108
109 if (nvgpu_is_enabled(g, NVGPU_IS_FMODEL)) {
110 nvgpu_info(g, "unhandled priv ring intr");
111 return;
112 }
113
114 status0 = gk20a_readl(g, pri_ringmaster_intr_status0_r());
115 status1 = gk20a_readl(g, pri_ringmaster_intr_status1_r());
116
117 nvgpu_err(g, "ringmaster intr status0: 0x%08x,"
118 "status1: 0x%08x", status0, status1);
119
120 if (pri_ringmaster_intr_status0_ring_start_conn_fault_v(status0) != 0)
121 nvgpu_err(g,
122 "BUG: connectivity problem on the startup sequence");
123
124 if (pri_ringmaster_intr_status0_disconnect_fault_v(status0) != 0)
125 nvgpu_err(g, "ring disconnected");
126
127 if (pri_ringmaster_intr_status0_overflow_fault_v(status0) != 0)
128 nvgpu_err(g, "ring overflowed");
129
130 if (pri_ringmaster_intr_status0_gbl_write_error_sys_v(status0) != 0) {
131 error_info =
132 gk20a_readl(g, pri_ringstation_sys_priv_error_info_r());
133 error_code =
134 gk20a_readl(g, pri_ringstation_sys_priv_error_code_r());
135 nvgpu_err(g, "SYS write error. ADR 0x%08x WRDAT 0x%08x "
136 "INFO 0x%08x (subid 0x%08x priv level %d), "
137 "CODE 0x%08x",
138 gk20a_readl(g, pri_ringstation_sys_priv_error_adr_r()),
139 gk20a_readl(g, pri_ringstation_sys_priv_error_wrdat_r()),
140 error_info,
141 pri_ringstation_sys_priv_error_info_subid_v(error_info),
142 pri_ringstation_sys_priv_error_info_priv_level_v(error_info),
143 error_code);
144 if (g->ops.priv_ring.decode_error_code)
145 g->ops.priv_ring.decode_error_code(g, error_code);
146 }
147
148 if (status1) {
149 gpc_stride = nvgpu_get_litter_value(g, GPU_LIT_GPC_PRIV_STRIDE);
150 for (gpc = 0; gpc < g->gr.gpc_count; gpc++) {
151 offset = gpc * gpc_stride;
152 if (status1 & BIT(gpc)) {
153 error_info = gk20a_readl(g,
154 pri_ringstation_gpc_gpc0_priv_error_info_r() + offset);
155 error_code = gk20a_readl(g,
156 pri_ringstation_gpc_gpc0_priv_error_code_r() + offset);
157 nvgpu_err(g, "GPC%u write error. ADR 0x%08x "
158 "WRDAT 0x%08x "
159 "INFO 0x%08x (subid 0x%08x priv level %d), "
160 "CODE 0x%08x", gpc,
161 gk20a_readl(g,
162 pri_ringstation_gpc_gpc0_priv_error_adr_r() + offset),
163 gk20a_readl(g,
164 pri_ringstation_gpc_gpc0_priv_error_wrdat_r() + offset),
165 error_info,
166 pri_ringstation_gpc_gpc0_priv_error_info_subid_v(error_info),
167 pri_ringstation_gpc_gpc0_priv_error_info_priv_level_v(error_info),
168 error_code);
169
170 if (g->ops.priv_ring.decode_error_code)
171 g->ops.priv_ring.decode_error_code(g,
172 error_code);
173
174 status1 = status1 & (~(BIT(gpc)));
175 if (!status1)
176 break;
177 }
178 }
179 }
180 /* clear interrupt */
181 cmd = gk20a_readl(g, pri_ringmaster_command_r());
182 cmd = set_field(cmd, pri_ringmaster_command_cmd_m(),
183 pri_ringmaster_command_cmd_ack_interrupt_f());
184 gk20a_writel(g, pri_ringmaster_command_r(), cmd);
185
186 /* poll for clear interrupt done */
187 cmd = pri_ringmaster_command_cmd_v(
188 gk20a_readl(g, pri_ringmaster_command_r()));
189 while (cmd != pri_ringmaster_command_cmd_no_cmd_v() && retry) {
190 nvgpu_udelay(20);
191 cmd = pri_ringmaster_command_cmd_v(
192 gk20a_readl(g, pri_ringmaster_command_r()));
193 retry--;
194 }
195
196 if (retry == 0)
197 nvgpu_err(g, "priv ringmaster intr ack failed");
198}
diff --git a/drivers/gpu/nvgpu/common/priv_ring/priv_ring_gp10b.h b/drivers/gpu/nvgpu/common/priv_ring/priv_ring_gp10b.h
new file mode 100644
index 00000000..dd418e5b
--- /dev/null
+++ b/drivers/gpu/nvgpu/common/priv_ring/priv_ring_gp10b.h
@@ -0,0 +1,33 @@
1/*
2 * GP10B PRIV ringmaster
3 *
4 * Copyright (c) 2011-2018, NVIDIA CORPORATION. All rights reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 */
24#ifndef __PRIV_RING_GP10B_H__
25#define __PRIV_RING_GP10B_H__
26
27struct gk20a;
28
29void gp10b_priv_ring_isr(struct gk20a *g);
30void gp10b_priv_ring_decode_error_code(struct gk20a *g,
31 u32 error_code);
32
33#endif /*__PRIV_RING_GP10B_H__*/