summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gp106/mclk_gp106.c
diff options
context:
space:
mode:
authorPhilip Elcan <pelcan@nvidia.com>2018-08-27 12:45:27 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2018-09-10 18:23:45 -0400
commitd2be65315a9ebfc88e77489571a31c48b3d21284 (patch)
treeff4a2d2d90ad1b6f3768bcb8e67176202ccfe97c /drivers/gpu/nvgpu/gp106/mclk_gp106.c
parentc86f185d1022de18a1a1073aa91d2b06aa59e2fc (diff)
gpu: nvgpu: fix some MISRA 10.3 violations
Fix MISRA 10.3 violations in mclk_gp106.c. Cleanup cases where values were being assigned to narrower types. Changes in mclk_gp106.c required updates to other files to resolve errors and prevent introducing new violations. JIRA NVGPU-647 Change-Id: Ifdb03ad41d9dbf05dbcf79494ae8565fff6ee083 Signed-off-by: Philip Elcan <pelcan@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1809366 Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/gp106/mclk_gp106.c')
-rw-r--r--drivers/gpu/nvgpu/gp106/mclk_gp106.c61
1 files changed, 32 insertions, 29 deletions
diff --git a/drivers/gpu/nvgpu/gp106/mclk_gp106.c b/drivers/gpu/nvgpu/gp106/mclk_gp106.c
index 6a49e83b..b4f553ec 100644
--- a/drivers/gpu/nvgpu/gp106/mclk_gp106.c
+++ b/drivers/gpu/nvgpu/gp106/mclk_gp106.c
@@ -39,14 +39,9 @@
39 39
40#define VREG_COUNT 24 40#define VREG_COUNT 24
41 41
42#define GP106_MCLK_LOW_SPEED 0 42#define GP106_MEM_CONFIG_GDDR5_PG418 0U
43#define GP106_MCLK_MID_SPEED 1 43#define GP106_MEM_CONFIG_GDDR5_PG419 1U
44#define GP106_MCLK_HIGH_SPEED 2 44#define GP106_MEM_CONFIG_GDDR5_PG419_8606580012 2U
45#define GP106_MCLK_NUM_SPEED 3
46
47#define GP106_MEM_CONFIG_GDDR5_PG418 0
48#define GP106_MEM_CONFIG_GDDR5_PG419 1
49#define GP106_MEM_CONFIG_GDDR5_PG419_8606580012 2
50 45
51struct memory_link_training_pattern { 46struct memory_link_training_pattern {
52 u32 regaddr; 47 u32 regaddr;
@@ -2939,7 +2934,7 @@ static int mclk_debugfs_init(struct gk20a *g);
2939 2934
2940struct memory_config { 2935struct memory_config {
2941 struct memory_link_training_pattern *pattern_ptr; 2936 struct memory_link_training_pattern *pattern_ptr;
2942 u32 pattern_size; 2937 size_t pattern_size;
2943 struct { 2938 struct {
2944 u8 *addr; 2939 u8 *addr;
2945 u32 size; 2940 u32 size;
@@ -2949,7 +2944,7 @@ struct memory_config {
2949#undef S 2944#undef S
2950#define S(from, to, script) \ 2945#define S(from, to, script) \
2951 [GP106_MCLK_##from##_SPEED][GP106_MCLK_##to##_SPEED] = \ 2946 [GP106_MCLK_##from##_SPEED][GP106_MCLK_##to##_SPEED] = \
2952 { script, sizeof(script) } 2947 { script, (u32)sizeof(script) }
2953 2948
2954static struct memory_config mem_config[] = { 2949static struct memory_config mem_config[] = {
2955 [GP106_MEM_CONFIG_GDDR5_PG418] = { 2950 [GP106_MEM_CONFIG_GDDR5_PG418] = {
@@ -2998,7 +2993,8 @@ static void mclk_seq_pmucmdhandler(struct gk20a *g, struct pmu_msg *_msg,
2998{ 2993{
2999 struct nv_pmu_seq_msg *msg = (struct nv_pmu_seq_msg *)_msg; 2994 struct nv_pmu_seq_msg *msg = (struct nv_pmu_seq_msg *)_msg;
3000 struct nv_pmu_seq_msg_run_script *seq_msg; 2995 struct nv_pmu_seq_msg_run_script *seq_msg;
3001 u32 msg_status = 0; 2996 int msg_status = 0;
2997 bool *seq_running = (bool *)param; /* to report back completion */
3002 2998
3003 nvgpu_log_info(g, " "); 2999 nvgpu_log_info(g, " ");
3004 3000
@@ -3021,7 +3017,7 @@ static void mclk_seq_pmucmdhandler(struct gk20a *g, struct pmu_msg *_msg,
3021 } 3017 }
3022 3018
3023status_update: 3019status_update:
3024 *((u32 *)param) = msg_status; 3020 *seq_running = (msg_status != 0);
3025} 3021}
3026 3022
3027static int mclk_get_memclk_table(struct gk20a *g) 3023static int mclk_get_memclk_table(struct gk20a *g)
@@ -3087,8 +3083,8 @@ static int mclk_get_memclk_table(struct gk20a *g)
3087 VBIOS_MEMORY_CLOCK_BASE_ENTRY_11_FLAGS1_SCRIPT_INDEX); 3083 VBIOS_MEMORY_CLOCK_BASE_ENTRY_11_FLAGS1_SCRIPT_INDEX);
3088 3084
3089 script_ptr = nvgpu_bios_read_u32(g, 3085 script_ptr = nvgpu_bios_read_u32(g,
3090 memclock_table_header.script_list_ptr + 3086 (u32)(memclock_table_header.script_list_ptr +
3091 script_index * sizeof(u32)); 3087 script_index * sizeof(u32)));
3092 3088
3093 if (!script_ptr) { 3089 if (!script_ptr) {
3094 continue; 3090 continue;
@@ -3142,8 +3138,8 @@ static int mclk_get_memclk_table(struct gk20a *g)
3142 VBIOS_MEMORY_CLOCK_BASE_ENTRY_12_FLAGS2_CMD_SCRIPT_INDEX); 3138 VBIOS_MEMORY_CLOCK_BASE_ENTRY_12_FLAGS2_CMD_SCRIPT_INDEX);
3143 3139
3144 cmd_script_ptr = nvgpu_bios_read_u32(g, 3140 cmd_script_ptr = nvgpu_bios_read_u32(g,
3145 memclock_table_header.cmd_script_list_ptr + 3141 (u32)(memclock_table_header.cmd_script_list_ptr +
3146 cmd_script_index * sizeof(u32)); 3142 cmd_script_index * sizeof(u32)));
3147 3143
3148 if (!cmd_script_ptr) { 3144 if (!cmd_script_ptr) {
3149 continue; 3145 continue;
@@ -3268,14 +3264,14 @@ int gp106_mclk_init(struct gk20a *g)
3268 3264
3269 p5_info = pstate_get_clk_set_info(g, 3265 p5_info = pstate_get_clk_set_info(g,
3270 CTRL_PERF_PSTATE_P5, clkwhich_mclk); 3266 CTRL_PERF_PSTATE_P5, clkwhich_mclk);
3271 if (!p5_info) { 3267 if (p5_info == NULL) {
3272 err = -EINVAL; 3268 err = -EINVAL;
3273 goto fail_data_mutex; 3269 goto fail_data_mutex;
3274 } 3270 }
3275 3271
3276 p0_info = pstate_get_clk_set_info(g, 3272 p0_info = pstate_get_clk_set_info(g,
3277 CTRL_PERF_PSTATE_P0, clkwhich_mclk); 3273 CTRL_PERF_PSTATE_P0, clkwhich_mclk);
3278 if (!p0_info) { 3274 if (p0_info == NULL) {
3279 err = -EINVAL; 3275 err = -EINVAL;
3280 goto fail_data_mutex; 3276 goto fail_data_mutex;
3281 } 3277 }
@@ -3284,7 +3280,7 @@ int gp106_mclk_init(struct gk20a *g)
3284 mclk->p0_min = p0_info->min_mhz; 3280 mclk->p0_min = p0_info->min_mhz;
3285 3281
3286 mclk->vreg_buf = nvgpu_kcalloc(g, VREG_COUNT, sizeof(u32)); 3282 mclk->vreg_buf = nvgpu_kcalloc(g, VREG_COUNT, sizeof(u32));
3287 if (!mclk->vreg_buf) { 3283 if (mclk->vreg_buf == NULL) {
3288 nvgpu_err(g, "unable to allocate memory for VREG"); 3284 nvgpu_err(g, "unable to allocate memory for VREG");
3289 err = -ENOMEM; 3285 err = -ENOMEM;
3290 goto fail_data_mutex; 3286 goto fail_data_mutex;
@@ -3318,13 +3314,14 @@ int gp106_mclk_change(struct gk20a *g, u16 val)
3318 int status = 0; 3314 int status = 0;
3319 struct memory_config *m = &mem_config[g->mem_config_idx]; 3315 struct memory_config *m = &mem_config[g->mem_config_idx];
3320 3316
3321 u32 seq_completion_status = ~0x0; 3317 bool seq_running = true;
3322 u8 *seq_script_ptr = NULL; 3318 u8 *seq_script_ptr = NULL;
3323 size_t seq_script_size = 0; 3319 u32 seq_script_size = 0;
3324#ifdef CONFIG_DEBUG_FS 3320#ifdef CONFIG_DEBUG_FS
3325 u64 t0, t1; 3321 u64 t0, t1;
3326#endif 3322#endif
3327 u32 speed; 3323 u32 speed;
3324 u64 cmd_hdr_size;
3328 3325
3329 nvgpu_log_info(g, " "); 3326 nvgpu_log_info(g, " ");
3330 3327
@@ -3357,8 +3354,14 @@ int gp106_mclk_change(struct gk20a *g, u16 val)
3357 /* Fill command header with SEQ ID & size */ 3354 /* Fill command header with SEQ ID & size */
3358 memset(&cmd, 0, sizeof(cmd)); 3355 memset(&cmd, 0, sizeof(cmd));
3359 cmd.hdr.unit_id = PMU_UNIT_SEQ; 3356 cmd.hdr.unit_id = PMU_UNIT_SEQ;
3360 cmd.hdr.size = sizeof(struct nv_pmu_seq_cmd_run_script) + 3357 cmd_hdr_size = sizeof(struct nv_pmu_seq_cmd_run_script) +
3361 sizeof(struct pmu_hdr); 3358 sizeof(struct pmu_hdr);
3359 if (cmd_hdr_size > U8_MAX) {
3360 nvgpu_err(g, "Invalid command header size");
3361 status = -EINVAL;
3362 goto exit_status;
3363 }
3364 cmd.hdr.size = (u8)cmd_hdr_size;
3362 3365
3363 /* Fill RM_PMU_SEQ_CMD_RUN_SCRIPT struct */ 3366 /* Fill RM_PMU_SEQ_CMD_RUN_SCRIPT struct */
3364 pseq_cmd = &cmd.run_script; 3367 pseq_cmd = &cmd.run_script;
@@ -3379,24 +3382,24 @@ int gp106_mclk_change(struct gk20a *g, u16 val)
3379 3382
3380 /* Read sequencer binary*/ 3383 /* Read sequencer binary*/
3381 payload.in.buf = seq_script_ptr; 3384 payload.in.buf = seq_script_ptr;
3382 payload.in.size = seq_script_size; 3385 payload.in.size = (u32)seq_script_size;
3383 payload.in.fb_size = PMU_CMD_SUBMIT_PAYLOAD_PARAMS_FB_SIZE_UNUSED; 3386 payload.in.fb_size = PMU_CMD_SUBMIT_PAYLOAD_PARAMS_FB_SIZE_UNUSED;
3384 payload.in.offset = offsetof(struct nv_pmu_seq_cmd_run_script, 3387 payload.in.offset = (u32)offsetof(struct nv_pmu_seq_cmd_run_script,
3385 script_alloc); 3388 script_alloc);
3386 3389
3387 memset(mclk->vreg_buf, 0, (sizeof(u32) * VREG_COUNT)); 3390 memset(mclk->vreg_buf, 0, (sizeof(u32) * VREG_COUNT));
3388 3391
3389 payload.out.buf = mclk->vreg_buf; 3392 payload.out.buf = mclk->vreg_buf;
3390 payload.out.size = (VREG_COUNT * sizeof(u32)); 3393 payload.out.size = (VREG_COUNT * (u32)sizeof(u32));
3391 payload.out.fb_size = PMU_CMD_SUBMIT_PAYLOAD_PARAMS_FB_SIZE_UNUSED; 3394 payload.out.fb_size = PMU_CMD_SUBMIT_PAYLOAD_PARAMS_FB_SIZE_UNUSED;
3392 payload.out.offset = offsetof(struct nv_pmu_seq_cmd_run_script, 3395 payload.out.offset = (u32)offsetof(struct nv_pmu_seq_cmd_run_script,
3393 reg_alloc); 3396 reg_alloc);
3394 3397
3395 /* Send command to PMU to execute sequencer script */ 3398 /* Send command to PMU to execute sequencer script */
3396 status = nvgpu_pmu_cmd_post(g, (struct pmu_cmd *)&cmd, NULL, &payload, 3399 status = nvgpu_pmu_cmd_post(g, (struct pmu_cmd *)&cmd, NULL, &payload,
3397 PMU_COMMAND_QUEUE_LPQ, 3400 PMU_COMMAND_QUEUE_LPQ,
3398 mclk_seq_pmucmdhandler, 3401 mclk_seq_pmucmdhandler,
3399 &seq_completion_status, &seqdesc, ~0); 3402 &seq_running, &seqdesc, ~0UL);
3400 if (status) { 3403 if (status) {
3401 nvgpu_err(g, "unable to post seq script exec cmd for unit %x", 3404 nvgpu_err(g, "unable to post seq script exec cmd for unit %x",
3402 cmd.hdr.unit_id); 3405 cmd.hdr.unit_id);
@@ -3404,8 +3407,8 @@ int gp106_mclk_change(struct gk20a *g, u16 val)
3404 } 3407 }
3405 /* wait till sequencer script complete */ 3408 /* wait till sequencer script complete */
3406 pmu_wait_message_cond(&g->pmu, (gk20a_get_gr_idle_timeout(g)), 3409 pmu_wait_message_cond(&g->pmu, (gk20a_get_gr_idle_timeout(g)),
3407 &seq_completion_status, 0); 3410 &seq_running, (u8)false);
3408 if (seq_completion_status != 0) { 3411 if (seq_running) {
3409 nvgpu_err(g, "seq_script update failed"); 3412 nvgpu_err(g, "seq_script update failed");
3410 status = -EBUSY; 3413 status = -EBUSY;
3411 goto exit_status; 3414 goto exit_status;