summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/common/priv_ring/priv_ring_gm20b.c
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/priv_ring_gm20b.c
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/priv_ring_gm20b.c')
-rw-r--r--drivers/gpu/nvgpu/common/priv_ring/priv_ring_gm20b.c121
1 files changed, 121 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}