summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gk20a/mc_gk20a.c
diff options
context:
space:
mode:
authorVinod G <vinodg@nvidia.com>2018-05-16 13:43:13 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2018-05-18 17:53:58 -0400
commitac687c95d383c3fb0165e6535893510409559a8e (patch)
tree7a76099c05186ad636704c07c5409bbc8547f20f /drivers/gpu/nvgpu/gk20a/mc_gk20a.c
parentde67fb18fb639b7a605c77eeb2e1c639a8a3d67e (diff)
gpu: nvgpu: Code updates for MISRA violations
Code related to MC module is updated for handling MISRA violations Rule 10.1: Operands shalln't be an inappropriate essential type. Rule 10.3: Value of expression shalln't be assigned to an object with a narrow essential type. Rule 10.4: Both operands in an operator shall have the same essential type. Rule 14.4: Controlling if statement shall have essentially Boolean type. Rule 15.6: Enclose if() sequences with braces. JIRA NVGPU-646 JIRA NVGPU-659 JIRA NVGPU-671 Change-Id: Ia7ada40068eab5c164b8bad99bf8103b37a2fbc9 Signed-off-by: Vinod G <vinodg@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1720926 Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/mc_gk20a.c')
-rw-r--r--drivers/gpu/nvgpu/gk20a/mc_gk20a.c80
1 files changed, 47 insertions, 33 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/mc_gk20a.c b/drivers/gpu/nvgpu/gk20a/mc_gk20a.c
index 9473ad4f..69d165af 100644
--- a/drivers/gpu/nvgpu/gk20a/mc_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/mc_gk20a.c
@@ -45,7 +45,7 @@ void mc_gk20a_isr_stall(struct gk20a *g)
45 for (engine_id_idx = 0; engine_id_idx < g->fifo.num_engines; engine_id_idx++) { 45 for (engine_id_idx = 0; engine_id_idx < g->fifo.num_engines; engine_id_idx++) {
46 active_engine_id = g->fifo.active_engines_list[engine_id_idx]; 46 active_engine_id = g->fifo.active_engines_list[engine_id_idx];
47 47
48 if (mc_intr_0 & g->fifo.engine_info[active_engine_id].intr_mask) { 48 if ((mc_intr_0 & g->fifo.engine_info[active_engine_id].intr_mask) != 0U) {
49 engine_enum = g->fifo.engine_info[active_engine_id].engine_enum; 49 engine_enum = g->fifo.engine_info[active_engine_id].engine_enum;
50 /* GR Engine */ 50 /* GR Engine */
51 if (engine_enum == ENGINE_GR_GK20A) { 51 if (engine_enum == ENGINE_GR_GK20A) {
@@ -55,28 +55,33 @@ void mc_gk20a_isr_stall(struct gk20a *g)
55 /* CE Engine */ 55 /* CE Engine */
56 if (((engine_enum == ENGINE_GRCE_GK20A) || 56 if (((engine_enum == ENGINE_GRCE_GK20A) ||
57 (engine_enum == ENGINE_ASYNC_CE_GK20A)) && 57 (engine_enum == ENGINE_ASYNC_CE_GK20A)) &&
58 g->ops.ce2.isr_stall){ 58 (g->ops.ce2.isr_stall != NULL)) {
59 g->ops.ce2.isr_stall(g, 59 g->ops.ce2.isr_stall(g,
60 g->fifo.engine_info[active_engine_id].inst_id, 60 g->fifo.engine_info[active_engine_id].inst_id,
61 g->fifo.engine_info[active_engine_id].pri_base); 61 g->fifo.engine_info[active_engine_id].pri_base);
62 } 62 }
63 } 63 }
64 } 64 }
65 if (mc_intr_0 & mc_intr_0_pfifo_pending_f()) 65 if ((mc_intr_0 & mc_intr_0_pfifo_pending_f()) != 0U) {
66 gk20a_fifo_isr(g); 66 gk20a_fifo_isr(g);
67 if (mc_intr_0 & mc_intr_0_pmu_pending_f()) 67 }
68 if ((mc_intr_0 & mc_intr_0_pmu_pending_f()) != 0U) {
68 gk20a_pmu_isr(g); 69 gk20a_pmu_isr(g);
69 if (mc_intr_0 & mc_intr_0_priv_ring_pending_f()) 70 }
71 if ((mc_intr_0 & mc_intr_0_priv_ring_pending_f()) != 0U) {
70 g->ops.priv_ring.isr(g); 72 g->ops.priv_ring.isr(g);
71 if (mc_intr_0 & mc_intr_0_ltc_pending_f()) 73 }
74 if ((mc_intr_0 & mc_intr_0_ltc_pending_f()) != 0U) {
72 g->ops.ltc.isr(g); 75 g->ops.ltc.isr(g);
73 if (mc_intr_0 & mc_intr_0_pbus_pending_f()) 76 }
77 if ((mc_intr_0 & mc_intr_0_pbus_pending_f()) != 0U) {
74 g->ops.bus.isr(g); 78 g->ops.bus.isr(g);
79 }
75} 80}
76 81
77int mc_gk20a_isr_nonstall(struct gk20a *g) 82u32 mc_gk20a_isr_nonstall(struct gk20a *g)
78{ 83{
79 int ops = 0; 84 u32 ops = 0;
80 u32 mc_intr_1; 85 u32 mc_intr_1;
81 u32 engine_id_idx; 86 u32 engine_id_idx;
82 u32 active_engine_id = 0; 87 u32 active_engine_id = 0;
@@ -84,8 +89,9 @@ int mc_gk20a_isr_nonstall(struct gk20a *g)
84 89
85 mc_intr_1 = g->ops.mc.intr_nonstall(g); 90 mc_intr_1 = g->ops.mc.intr_nonstall(g);
86 91
87 if (g->ops.mc.is_intr1_pending(g, NVGPU_UNIT_FIFO, mc_intr_1)) 92 if (g->ops.mc.is_intr1_pending(g, NVGPU_UNIT_FIFO, mc_intr_1) != 0U) {
88 ops |= gk20a_fifo_nonstall_isr(g); 93 ops |= gk20a_fifo_nonstall_isr(g);
94 }
89 95
90 for (engine_id_idx = 0; engine_id_idx < g->fifo.num_engines; 96 for (engine_id_idx = 0; engine_id_idx < g->fifo.num_engines;
91 engine_id_idx++) { 97 engine_id_idx++) {
@@ -94,19 +100,20 @@ int mc_gk20a_isr_nonstall(struct gk20a *g)
94 active_engine_id = g->fifo.active_engines_list[engine_id_idx]; 100 active_engine_id = g->fifo.active_engines_list[engine_id_idx];
95 engine_info = &g->fifo.engine_info[active_engine_id]; 101 engine_info = &g->fifo.engine_info[active_engine_id];
96 102
97 if (mc_intr_1 & engine_info->intr_mask) { 103 if ((mc_intr_1 & engine_info->intr_mask) != 0U) {
98 engine_enum = engine_info->engine_enum; 104 engine_enum = engine_info->engine_enum;
99 /* GR Engine */ 105 /* GR Engine */
100 if (engine_enum == ENGINE_GR_GK20A) 106 if (engine_enum == ENGINE_GR_GK20A) {
101 ops |= gk20a_gr_nonstall_isr(g); 107 ops |= gk20a_gr_nonstall_isr(g);
102 108 }
103 /* CE Engine */ 109 /* CE Engine */
104 if (((engine_enum == ENGINE_GRCE_GK20A) || 110 if (((engine_enum == ENGINE_GRCE_GK20A) ||
105 (engine_enum == ENGINE_ASYNC_CE_GK20A)) && 111 (engine_enum == ENGINE_ASYNC_CE_GK20A)) &&
106 g->ops.ce2.isr_nonstall) 112 (g->ops.ce2.isr_nonstall != NULL)) {
107 ops |= g->ops.ce2.isr_nonstall(g, 113 ops |= g->ops.ce2.isr_nonstall(g,
108 engine_info->inst_id, 114 engine_info->inst_id,
109 engine_info->pri_base); 115 engine_info->pri_base);
116 }
110 } 117 }
111 } 118 }
112 119
@@ -219,7 +226,7 @@ void gk20a_mc_enable(struct gk20a *g, u32 units)
219 pmc = gk20a_readl(g, mc_enable_r()); 226 pmc = gk20a_readl(g, mc_enable_r());
220 pmc |= units; 227 pmc |= units;
221 gk20a_writel(g, mc_enable_r(), pmc); 228 gk20a_writel(g, mc_enable_r(), pmc);
222 gk20a_readl(g, mc_enable_r()); 229 pmc = gk20a_readl(g, mc_enable_r());
223 nvgpu_spinlock_release(&g->mc_enable_lock); 230 nvgpu_spinlock_release(&g->mc_enable_lock);
224 231
225 nvgpu_udelay(20); 232 nvgpu_udelay(20);
@@ -228,10 +235,11 @@ void gk20a_mc_enable(struct gk20a *g, u32 units)
228void gk20a_mc_reset(struct gk20a *g, u32 units) 235void gk20a_mc_reset(struct gk20a *g, u32 units)
229{ 236{
230 g->ops.mc.disable(g, units); 237 g->ops.mc.disable(g, units);
231 if (units & gk20a_fifo_get_all_ce_engine_reset_mask(g)) 238 if ((units & gk20a_fifo_get_all_ce_engine_reset_mask(g)) != 0U) {
232 nvgpu_udelay(500); 239 nvgpu_udelay(500);
233 else 240 } else {
234 nvgpu_udelay(20); 241 nvgpu_udelay(20);
242 }
235 g->ops.mc.enable(g, units); 243 g->ops.mc.enable(g, units);
236} 244}
237 245
@@ -239,19 +247,22 @@ u32 gk20a_mc_boot_0(struct gk20a *g, u32 *arch, u32 *impl, u32 *rev)
239{ 247{
240 u32 val = __nvgpu_readl(g, mc_boot_0_r()); 248 u32 val = __nvgpu_readl(g, mc_boot_0_r());
241 249
242 if (val == 0xffffffff) 250 if (val != 0xffffffffU) {
243 return val;
244 251
245 if (arch) 252 if (arch != NULL) {
246 *arch = mc_boot_0_architecture_v(val) << 253 *arch = mc_boot_0_architecture_v(val) <<
247 NVGPU_GPU_ARCHITECTURE_SHIFT; 254 NVGPU_GPU_ARCHITECTURE_SHIFT;
255 }
248 256
249 if (impl) 257 if (impl != NULL) {
250 *impl = mc_boot_0_implementation_v(val); 258 *impl = mc_boot_0_implementation_v(val);
259 }
251 260
252 if (rev) 261 if (rev != NULL) {
253 *rev = (mc_boot_0_major_revision_v(val) << 4) | 262 *rev = (mc_boot_0_major_revision_v(val) << 4) |
254 mc_boot_0_minor_revision_v(val); 263 mc_boot_0_minor_revision_v(val);
264 }
265 }
255 266
256 return val; 267 return val;
257} 268}
@@ -259,7 +270,7 @@ u32 gk20a_mc_boot_0(struct gk20a *g, u32 *arch, u32 *impl, u32 *rev)
259bool mc_gk20a_is_intr1_pending(struct gk20a *g, 270bool mc_gk20a_is_intr1_pending(struct gk20a *g,
260 enum nvgpu_unit unit, u32 mc_intr_1) 271 enum nvgpu_unit unit, u32 mc_intr_1)
261{ 272{
262 u32 mask = 0; 273 u32 mask = 0U;
263 bool is_pending; 274 bool is_pending;
264 275
265 switch (unit) { 276 switch (unit) {
@@ -270,11 +281,11 @@ bool mc_gk20a_is_intr1_pending(struct gk20a *g,
270 break; 281 break;
271 } 282 }
272 283
273 if (mask == 0) { 284 if (mask == 0U) {
274 nvgpu_err(g, "unknown unit %d", unit); 285 nvgpu_err(g, "unknown unit %d", unit);
275 is_pending = false; 286 is_pending = false;
276 } else { 287 } else {
277 is_pending = (mc_intr_1 & mask) ? true : false; 288 is_pending = ((mc_intr_1 & mask) != 0U) ? true : false;
278 } 289 }
279 290
280 return is_pending; 291 return is_pending;
@@ -284,9 +295,12 @@ void mc_gk20a_handle_intr_nonstall(struct gk20a *g, u32 ops)
284{ 295{
285 bool semaphore_wakeup, post_events; 296 bool semaphore_wakeup, post_events;
286 297
287 semaphore_wakeup = ops & gk20a_nonstall_ops_wakeup_semaphore; 298 semaphore_wakeup = (((ops & (u32)gk20a_nonstall_ops_wakeup_semaphore) != 0U) ?
288 post_events = ops & gk20a_nonstall_ops_post_events; 299 true : false);
300 post_events = (((ops & (u32)gk20a_nonstall_ops_post_events) != 0U) ?
301 true: false);
289 302
290 if (semaphore_wakeup) 303 if (semaphore_wakeup) {
291 g->ops.semaphore_wakeup(g, post_events); 304 g->ops.semaphore_wakeup(g, post_events);
305 }
292} 306}