Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/amd: Fix set but not used warnings

There are many set but not used warnings under drivers/gpu/drm/amd when
compiling with the latest upstream mainline GCC:

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c:305:18: warning: variable ‘p’ set but not used [-Wunused-but-set-variable=]
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h:103:26: warning: variable ‘internal_reg_offset’ set but not used [-Wunused-but-set-variable=]
...
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h:164:26: warning: variable ‘internal_reg_offset’ set but not used [-Wunused-but-set-variable=]
...
drivers/gpu/drm/amd/amdgpu/../display/dc/dc_dmub_srv.c:445:13: warning: variable ‘pipe_idx’ set but not used [-Wunused-but-set-variable=]
drivers/gpu/drm/amd/amdgpu/../display/dc/dc_dmub_srv.c:875:21: warning: variable ‘pipe_idx’ set but not used [-Wunused-but-set-variable=]

Remove the variables actually not used or add __maybe_unused attribute for
the variables actually used to fix them, compile tested only.

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Tiezhu Yang and committed by
Alex Deucher
46791d14 7169e706

+8 -11
+1 -3
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
··· 302 302 int pages) 303 303 { 304 304 unsigned t; 305 - unsigned p; 306 305 int i, j; 307 306 u64 page_base; 308 307 /* Starting from VEGA10, system bit must be 0 to mean invalid. */ ··· 315 316 return; 316 317 317 318 t = offset / AMDGPU_GPU_PAGE_SIZE; 318 - p = t / AMDGPU_GPU_PAGES_IN_CPU_PAGE; 319 - for (i = 0; i < pages; i++, p++) { 319 + for (i = 0; i < pages; i++) { 320 320 page_base = adev->dummy_page_addr; 321 321 if (!adev->gart.ptr) 322 322 continue;
+4 -2
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h
··· 100 100 101 101 #define SOC15_DPG_MODE_OFFSET(ip, inst_idx, reg) \ 102 102 ({ \ 103 - uint32_t internal_reg_offset, addr; \ 103 + /* To avoid a -Wunused-but-set-variable warning. */ \ 104 + uint32_t internal_reg_offset __maybe_unused, addr; \ 104 105 bool video_range, video1_range, aon_range, aon1_range; \ 105 106 \ 106 107 addr = (adev->reg_offset[ip##_HWIP][inst_idx][reg##_BASE_IDX] + reg); \ ··· 162 161 163 162 #define SOC24_DPG_MODE_OFFSET(ip, inst_idx, reg) \ 164 163 ({ \ 165 - uint32_t internal_reg_offset, addr; \ 164 + /* To avoid a -Wunused-but-set-variable warning. */ \ 165 + uint32_t internal_reg_offset __maybe_unused, addr; \ 166 166 bool video_range, video1_range, aon_range, aon1_range; \ 167 167 \ 168 168 addr = (adev->reg_offset[ip##_HWIP][inst_idx][reg##_BASE_IDX] + reg); \
+3 -6
drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c
··· 442 442 int i = 0, k = 0; 443 443 int ramp_up_num_steps = 1; // TODO: Ramp is currently disabled. Reenable it. 444 444 uint8_t visual_confirm_enabled; 445 - int pipe_idx = 0; 446 445 struct dc_stream_status *stream_status = NULL; 447 446 448 447 if (dc == NULL) ··· 456 457 cmd.fw_assisted_mclk_switch.config_data.visual_confirm_enabled = visual_confirm_enabled; 457 458 458 459 if (should_manage_pstate) { 459 - for (i = 0, pipe_idx = 0; i < dc->res_pool->pipe_count; i++) { 460 + for (i = 0; i < dc->res_pool->pipe_count; i++) { 460 461 struct pipe_ctx *pipe = &context->res_ctx.pipe_ctx[i]; 461 462 462 463 if (!pipe->stream) ··· 471 472 cmd.fw_assisted_mclk_switch.config_data.vactive_stretch_margin_us = dc->debug.fpo_vactive_margin_us; 472 473 break; 473 474 } 474 - pipe_idx++; 475 475 } 476 476 } 477 477 ··· 870 872 bool enable) 871 873 { 872 874 uint8_t cmd_pipe_index = 0; 873 - uint32_t i, pipe_idx; 875 + uint32_t i; 874 876 uint8_t subvp_count = 0; 875 877 union dmub_rb_cmd cmd; 876 878 struct pipe_ctx *subvp_pipes[2]; ··· 897 899 898 900 if (enable) { 899 901 // For each pipe that is a "main" SUBVP pipe, fill in pipe data for DMUB SUBVP cmd 900 - for (i = 0, pipe_idx = 0; i < dc->res_pool->pipe_count; i++) { 902 + for (i = 0; i < dc->res_pool->pipe_count; i++) { 901 903 struct pipe_ctx *pipe = &context->res_ctx.pipe_ctx[i]; 902 904 pipe_mall_type = dc_state_get_pipe_subvp_type(context, pipe); 903 905 ··· 920 922 populate_subvp_cmd_vblank_pipe_info(dc, context, &cmd, pipe, cmd_pipe_index++); 921 923 922 924 } 923 - pipe_idx++; 924 925 } 925 926 if (subvp_count == 2) { 926 927 update_subvp_prefetch_end_to_mall_start(dc, context, &cmd, subvp_pipes);