diff options
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/priv_ring_gk20a.c')
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/priv_ring_gk20a.c | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/priv_ring_gk20a.c b/drivers/gpu/nvgpu/gk20a/priv_ring_gk20a.c new file mode 100644 index 00000000..1d764ad2 --- /dev/null +++ b/drivers/gpu/nvgpu/gk20a/priv_ring_gk20a.c | |||
@@ -0,0 +1,105 @@ | |||
1 | /* | ||
2 | * GK20A priv ring | ||
3 | * | ||
4 | * Copyright (c) 2011-2017, 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.h" | ||
26 | |||
27 | #include <nvgpu/log.h> | ||
28 | #include <nvgpu/timers.h> | ||
29 | #include <nvgpu/enabled.h> | ||
30 | |||
31 | #include <nvgpu/hw/gk20a/hw_mc_gk20a.h> | ||
32 | #include <nvgpu/hw/gk20a/hw_pri_ringmaster_gk20a.h> | ||
33 | #include <nvgpu/hw/gk20a/hw_pri_ringstation_sys_gk20a.h> | ||
34 | #include <nvgpu/hw/gk20a/hw_pri_ringstation_gpc_gk20a.h> | ||
35 | |||
36 | void gk20a_enable_priv_ring(struct gk20a *g) | ||
37 | { | ||
38 | if (nvgpu_is_enabled(g, NVGPU_IS_FMODEL)) | ||
39 | return; | ||
40 | |||
41 | nvgpu_log(g, gpu_dbg_info, "enabling priv ring"); | ||
42 | |||
43 | if (g->ops.clock_gating.slcg_priring_load_gating_prod) | ||
44 | g->ops.clock_gating.slcg_priring_load_gating_prod(g, | ||
45 | g->slcg_enabled); | ||
46 | |||
47 | gk20a_writel(g,pri_ringmaster_command_r(), | ||
48 | 0x4); | ||
49 | |||
50 | gk20a_writel(g, pri_ringstation_sys_decode_config_r(), | ||
51 | 0x2); | ||
52 | gk20a_readl(g, pri_ringstation_sys_decode_config_r()); | ||
53 | } | ||
54 | |||
55 | void gk20a_priv_ring_isr(struct gk20a *g) | ||
56 | { | ||
57 | u32 status0, status1; | ||
58 | u32 cmd; | ||
59 | s32 retry = 100; | ||
60 | u32 gpc; | ||
61 | u32 gpc_stride = nvgpu_get_litter_value(g, GPU_LIT_GPC_STRIDE); | ||
62 | |||
63 | if (nvgpu_is_enabled(g, NVGPU_IS_FMODEL)) | ||
64 | return; | ||
65 | |||
66 | status0 = gk20a_readl(g, pri_ringmaster_intr_status0_r()); | ||
67 | status1 = gk20a_readl(g, pri_ringmaster_intr_status1_r()); | ||
68 | |||
69 | gk20a_dbg(gpu_dbg_intr, "ringmaster intr status0: 0x%08x," | ||
70 | "status1: 0x%08x", status0, status1); | ||
71 | |||
72 | if (pri_ringmaster_intr_status0_gbl_write_error_sys_v(status0) != 0) { | ||
73 | gk20a_dbg(gpu_dbg_intr, "SYS write error. ADR %08x WRDAT %08x INFO %08x, CODE %08x", | ||
74 | gk20a_readl(g, pri_ringstation_sys_priv_error_adr_r()), | ||
75 | gk20a_readl(g, pri_ringstation_sys_priv_error_wrdat_r()), | ||
76 | gk20a_readl(g, pri_ringstation_sys_priv_error_info_r()), | ||
77 | gk20a_readl(g, pri_ringstation_sys_priv_error_code_r())); | ||
78 | } | ||
79 | |||
80 | for (gpc = 0; gpc < g->gr.gpc_count; gpc++) { | ||
81 | if (status1 & BIT(gpc)) { | ||
82 | gk20a_dbg(gpu_dbg_intr, "GPC%u write error. ADR %08x WRDAT %08x INFO %08x, CODE %08x", gpc, | ||
83 | gk20a_readl(g, pri_ringstation_gpc_gpc0_priv_error_adr_r() + gpc * gpc_stride), | ||
84 | gk20a_readl(g, pri_ringstation_gpc_gpc0_priv_error_wrdat_r() + gpc * gpc_stride), | ||
85 | gk20a_readl(g, pri_ringstation_gpc_gpc0_priv_error_info_r() + gpc * gpc_stride), | ||
86 | gk20a_readl(g, pri_ringstation_gpc_gpc0_priv_error_code_r() + gpc * gpc_stride)); | ||
87 | } | ||
88 | } | ||
89 | /* clear interrupt */ | ||
90 | cmd = gk20a_readl(g, pri_ringmaster_command_r()); | ||
91 | cmd = set_field(cmd, pri_ringmaster_command_cmd_m(), | ||
92 | pri_ringmaster_command_cmd_ack_interrupt_f()); | ||
93 | gk20a_writel(g, pri_ringmaster_command_r(), cmd); | ||
94 | /* poll for clear interrupt done */ | ||
95 | cmd = pri_ringmaster_command_cmd_v( | ||
96 | gk20a_readl(g, pri_ringmaster_command_r())); | ||
97 | while (cmd != pri_ringmaster_command_cmd_no_cmd_v() && retry) { | ||
98 | nvgpu_udelay(20); | ||
99 | retry--; | ||
100 | cmd = pri_ringmaster_command_cmd_v( | ||
101 | gk20a_readl(g, pri_ringmaster_command_r())); | ||
102 | } | ||
103 | if (retry == 0 && cmd != pri_ringmaster_command_cmd_no_cmd_v()) | ||
104 | nvgpu_warn(g, "priv ringmaster intr ack too many retries"); | ||
105 | } | ||