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

drm/amd/display: Fix compiler warnings on high compiler warning levels

[why]
Enabling higher compiler warning levels results in many issues that can
be trivially resolved as well as some potentially critical issues.

[how]
Fix all compiler warnings found with various compilers and higher
warning levels. Primarily, potentially uninitialized variables and
unreachable code.

Reviewed-by: Leo Li <sunpeng.li@amd.com>
Acked-by: Roman Li <roman.li@amd.com>
Signed-off-by: Aric Cyr <aric.cyr@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Aric Cyr and committed by
Alex Deucher
aece2094 cc520964

+44 -55
-2
drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c
··· 1594 1594 return (le16_to_cpu(bp->object_info_tbl.v1_5->supporteddevices) & mask) != 0; 1595 1595 break; 1596 1596 } 1597 - 1598 - return false; 1599 1597 } 1600 1598 1601 1599 static uint32_t bios_parser_get_ss_entry_number(
+2 -1
drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c
··· 642 642 643 643 j = -1; 644 644 645 - ASSERT(PP_SMU_NUM_FCLK_DPM_LEVELS <= MAX_NUM_DPM_LVL); 645 + static_assert(PP_SMU_NUM_FCLK_DPM_LEVELS <= MAX_NUM_DPM_LVL, 646 + "number of reported FCLK DPM levels exceed maximum"); 646 647 647 648 /* Find lowest DPM, FCLK is filled in reverse order*/ 648 649
+2 -1
drivers/gpu/drm/amd/display/dc/clk_mgr/dcn301/vg_clk_mgr.c
··· 566 566 567 567 j = -1; 568 568 569 - ASSERT(VG_NUM_FCLK_DPM_LEVELS <= MAX_NUM_DPM_LVL); 569 + static_assert(VG_NUM_FCLK_DPM_LEVELS <= MAX_NUM_DPM_LVL, 570 + "number of reported FCLK DPM levels exceeds maximum"); 570 571 571 572 /* Find lowest DPM, FCLK is filled in reverse order*/ 572 573
+2 -1
drivers/gpu/drm/amd/display/dc/clk_mgr/dcn31/dcn31_clk_mgr.c
··· 562 562 563 563 j = -1; 564 564 565 - ASSERT(NUM_DF_PSTATE_LEVELS <= MAX_NUM_DPM_LVL); 565 + static_assert(NUM_DF_PSTATE_LEVELS <= MAX_NUM_DPM_LVL, 566 + "number of reported pstate levels exceeds maximum"); 566 567 567 568 /* Find lowest DPM, FCLK is filled in reverse order*/ 568 569
+2 -1
drivers/gpu/drm/amd/display/dc/clk_mgr/dcn316/dcn316_clk_mgr.c
··· 480 480 481 481 j = -1; 482 482 483 - ASSERT(NUM_DF_PSTATE_LEVELS <= MAX_NUM_DPM_LVL); 483 + static_assert(NUM_DF_PSTATE_LEVELS <= MAX_NUM_DPM_LVL, 484 + "number of reported pstate levels exceeds maximum"); 484 485 485 486 /* Find lowest DPM, FCLK is filled in reverse order*/ 486 487
+1 -1
drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c
··· 558 558 struct dc_dmub_cmd *dc_dmub_cmd, 559 559 unsigned int dmub_cmd_count, 560 560 struct block_sequence block_sequence[], 561 - int *num_steps, 561 + unsigned int *num_steps, 562 562 struct pipe_ctx *pipe_ctx, 563 563 struct dc_stream_status *stream_status) 564 564 {
+1 -1
drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c
··· 1316 1316 static void dc_dmub_srv_exit_low_power_state(const struct dc *dc) 1317 1317 { 1318 1318 struct dc_dmub_srv *dc_dmub_srv; 1319 - uint32_t rcg_exit_count, ips1_exit_count, ips2_exit_count; 1319 + uint32_t rcg_exit_count = 0, ips1_exit_count = 0, ips2_exit_count = 0; 1320 1320 1321 1321 if (dc->debug.dmcub_emulation) 1322 1322 return;
+1 -1
drivers/gpu/drm/amd/display/dc/dce/dce_transform.c
··· 1408 1408 static void program_pwl(struct dce_transform *xfm_dce, 1409 1409 const struct pwl_params *params) 1410 1410 { 1411 - int retval; 1411 + uint32_t retval; 1412 1412 uint8_t max_tries = 10; 1413 1413 uint8_t counter = 0; 1414 1414 uint32_t i = 0;
+1 -1
drivers/gpu/drm/amd/display/dc/dcn32/dcn32_resource_helpers.c
··· 382 382 { 383 383 int i, pipe_cnt; 384 384 struct resource_context *res_ctx = &context->res_ctx; 385 - struct pipe_ctx *pipe; 385 + struct pipe_ctx *pipe = 0; 386 386 bool disable_unbounded_requesting = dc->debug.disable_z9_mpc || dc->debug.disable_unbounded_requesting; 387 387 388 388 for (i = 0, pipe_cnt = 0; i < dc->res_pool->pipe_count; i++) {
-2
drivers/gpu/drm/amd/display/dc/dml/dcn20/dcn20_fpu.c
··· 1102 1102 } else { 1103 1103 return DCN_ZSTATE_SUPPORT_DISALLOW; 1104 1104 } 1105 - 1106 - return DCN_ZSTATE_SUPPORT_DISALLOW; 1107 1105 } 1108 1106 1109 1107 static void dcn20_adjust_freesync_v_startup(
-1
drivers/gpu/drm/amd/display/dc/dml/dcn30/display_mode_vba_30.c
··· 3535 3535 return DesiredBPP; 3536 3536 } 3537 3537 } 3538 - return BPP_INVALID; 3539 3538 } 3540 3539 3541 3540 void dml30_ModeSupportAndSystemConfigurationFull(struct display_mode_lib *mode_lib)
-1
drivers/gpu/drm/amd/display/dc/dml/dcn31/display_mode_vba_31.c
··· 3679 3679 return DesiredBPP; 3680 3680 } 3681 3681 } 3682 - return BPP_INVALID; 3683 3682 } 3684 3683 3685 3684 static noinline void CalculatePrefetchSchedulePerPlane(
+1 -1
drivers/gpu/drm/amd/display/dc/dml/dcn314/dcn314_fpu.c
··· 310 310 { 311 311 int i, pipe_cnt; 312 312 struct resource_context *res_ctx = &context->res_ctx; 313 - struct pipe_ctx *pipe; 313 + struct pipe_ctx *pipe = 0; 314 314 bool upscaled = false; 315 315 const unsigned int max_allowed_vblank_nom = 1023; 316 316
-1
drivers/gpu/drm/amd/display/dc/dml/dcn314/display_mode_vba_314.c
··· 3788 3788 return DesiredBPP; 3789 3789 } 3790 3790 } 3791 - return BPP_INVALID; 3792 3791 } 3793 3792 3794 3793 static noinline void CalculatePrefetchSchedulePerPlane(
+6 -8
drivers/gpu/drm/amd/display/dc/dml/dcn32/display_mode_vba_util_32.c
··· 1650 1650 MaxLinkBPP = 2 * MaxLinkBPP; 1651 1651 } 1652 1652 1653 + *RequiredSlots = dml_ceil(DesiredBPP / MaxLinkBPP * 64, 1); 1654 + 1653 1655 if (DesiredBPP == 0) { 1654 1656 if (DSCEnable) { 1655 1657 if (MaxLinkBPP < MinDSCBPP) ··· 1678 1676 else 1679 1677 return DesiredBPP; 1680 1678 } 1681 - 1682 - *RequiredSlots = dml_ceil(DesiredBPP / MaxLinkBPP * 64, 1); 1683 - 1684 - return BPP_INVALID; 1685 1679 } // TruncToValidBPP 1686 1680 1687 1681 double dml32_RequiredDTBCLK( ··· 4289 4291 unsigned int i, j, k; 4290 4292 unsigned int SurfaceWithMinActiveFCLKChangeMargin = 0; 4291 4293 unsigned int DRAMClockChangeSupportNumber = 0; 4292 - unsigned int LastSurfaceWithoutMargin; 4294 + unsigned int LastSurfaceWithoutMargin = 0; 4293 4295 unsigned int DRAMClockChangeMethod = 0; 4294 4296 bool FoundFirstSurfaceWithMinActiveFCLKChangeMargin = false; 4295 4297 double MinActiveFCLKChangeMargin = 0.; ··· 5654 5656 double LastZ8StutterPeriod = 0.0; 5655 5657 double LastStutterPeriod = 0.0; 5656 5658 unsigned int TotalNumberOfActiveOTG = 0; 5657 - double doublePixelClock; 5658 - unsigned int doubleHTotal; 5659 - unsigned int doubleVTotal; 5659 + double doublePixelClock = 0; 5660 + unsigned int doubleHTotal = 0; 5661 + unsigned int doubleVTotal = 0; 5660 5662 bool SameTiming = true; 5661 5663 double DETBufferingTimeY; 5662 5664 double SwathWidthYCriticalSurface = 0.0;
+1 -1
drivers/gpu/drm/amd/display/dc/dml/dcn35/dcn35_fpu.c
··· 439 439 { 440 440 int i, pipe_cnt; 441 441 struct resource_context *res_ctx = &context->res_ctx; 442 - struct pipe_ctx *pipe; 442 + struct pipe_ctx *pipe = 0; 443 443 bool upscaled = false; 444 444 const unsigned int max_allowed_vblank_nom = 1023; 445 445
+1 -1
drivers/gpu/drm/amd/display/dc/dml/dcn351/dcn351_fpu.c
··· 474 474 { 475 475 int i, pipe_cnt; 476 476 struct resource_context *res_ctx = &context->res_ctx; 477 - struct pipe_ctx *pipe; 477 + struct pipe_ctx *pipe = 0; 478 478 bool upscaled = false; 479 479 const unsigned int max_allowed_vblank_nom = 1023; 480 480
+5 -7
drivers/gpu/drm/amd/display/dc/dml2/display_mode_core.c
··· 2784 2784 } 2785 2785 } 2786 2786 2787 + *RequiredSlots = (dml_uint_t)(dml_ceil(DesiredBPP / MaxLinkBPP * 64, 1)); 2788 + 2787 2789 if (DesiredBPP == 0) { 2788 2790 if (DSCEnable) { 2789 2791 if (MaxLinkBPP < MinDSCBPP) { ··· 2814 2812 return DesiredBPP; 2815 2813 } 2816 2814 } 2817 - 2818 - *RequiredSlots = (dml_uint_t)(dml_ceil(DesiredBPP / MaxLinkBPP * 64, 1)); 2819 - 2820 - return __DML_DPP_INVALID__; 2821 2815 } // TruncToValidBPP 2822 2816 2823 2817 static void CalculateWatermarksMALLUseAndDRAMSpeedChangeSupport( ··· 3790 3792 dml_bool_t FoundCriticalSurface = false; 3791 3793 3792 3794 dml_uint_t TotalNumberOfActiveOTG = 0; 3793 - dml_float_t SinglePixelClock; 3794 - dml_uint_t SingleHTotal; 3795 - dml_uint_t SingleVTotal; 3795 + dml_float_t SinglePixelClock = 0; 3796 + dml_uint_t SingleHTotal = 0; 3797 + dml_uint_t SingleVTotal = 0; 3796 3798 dml_bool_t SameTiming = true; 3797 3799 3798 3800 dml_float_t LastStutterPeriod = 0.0;
+1 -1
drivers/gpu/drm/amd/display/dc/dml2/dml2_utils.c
··· 224 224 static bool get_plane_id(struct dml2_context *dml2, const struct dc_state *state, const struct dc_plane_state *plane, 225 225 unsigned int stream_id, unsigned int plane_index, unsigned int *plane_id) 226 226 { 227 - int i, j; 227 + unsigned int i, j; 228 228 bool is_plane_duplicate = dml2->v20.scratch.plane_duplicate_exists; 229 229 230 230 if (!plane_id)
+4 -4
drivers/gpu/drm/amd/display/dc/dsc/dc_dsc.c
··· 458 458 bool is_dsc_possible = false; 459 459 struct dsc_enc_caps dsc_enc_caps; 460 460 struct dsc_enc_caps dsc_common_caps; 461 - struct dc_dsc_config config; 461 + struct dc_dsc_config config = {0}; 462 462 struct dc_dsc_config_options options = {0}; 463 463 464 464 options.dsc_min_slice_height_override = dsc_min_slice_height_override; ··· 868 868 struct dc_dsc_config *dsc_cfg) 869 869 { 870 870 struct dsc_enc_caps dsc_common_caps; 871 - int max_slices_h; 872 - int min_slices_h; 873 - int num_slices_h; 871 + int max_slices_h = 0; 872 + int min_slices_h = 0; 873 + int num_slices_h = 0; 874 874 int pic_width; 875 875 int slice_width; 876 876 int target_bpp;
+1 -1
drivers/gpu/drm/amd/display/dc/hwss/dce110/dce110_hwseq.c
··· 2188 2188 struct dc *dc, 2189 2189 struct dc_state *context) 2190 2190 { 2191 - int i; 2191 + unsigned int i; 2192 2192 2193 2193 /* program audio wall clock. use HDMI as clock source if HDMI 2194 2194 * audio active. Otherwise, use DP as clock source
+1 -1
drivers/gpu/drm/amd/display/dc/hwss/dcn30/dcn30_hwseq.c
··· 885 885 { 886 886 union dmub_rb_cmd cmd; 887 887 uint32_t tmr_delay = 0, tmr_scale = 0; 888 - struct dc_cursor_attributes cursor_attr; 888 + struct dc_cursor_attributes cursor_attr = {0}; 889 889 bool cursor_cache_enable = false; 890 890 struct dc_stream_state *stream = NULL; 891 891 struct dc_plane_state *plane = NULL;
+1 -1
drivers/gpu/drm/amd/display/dc/hwss/hw_sequencer.h
··· 480 480 struct dc_dmub_cmd *dc_dmub_cmd, 481 481 unsigned int dmub_cmd_count, 482 482 struct block_sequence block_sequence[], 483 - int *num_steps, 483 + unsigned int *num_steps, 484 484 struct pipe_ctx *pipe_ctx, 485 485 struct dc_stream_status *stream_status); 486 486
-2
drivers/gpu/drm/amd/display/dc/resource/dce112/dce112_resource.c
··· 864 864 default: 865 865 return NULL; 866 866 } 867 - 868 - return NULL; 869 867 } 870 868 871 869 static enum dc_status build_mapped_resource(
+1 -1
drivers/gpu/drm/amd/display/dc/resource/dce120/dce120_resource.c
··· 1060 1060 struct irq_service_init_data irq_init_data; 1061 1061 static const struct resource_create_funcs *res_funcs; 1062 1062 bool is_vg20 = ASICREV_IS_VEGA20_P(ctx->asic_id.hw_internal_rev); 1063 - uint32_t pipe_fuses; 1063 + uint32_t pipe_fuses = 0; 1064 1064 1065 1065 ctx->dc_bios->regs = &bios_regs; 1066 1066
+1 -1
drivers/gpu/drm/amd/display/dc/resource/dcn30/dcn30_resource.c
··· 1639 1639 int split[MAX_PIPES] = { 0 }; 1640 1640 bool merge[MAX_PIPES] = { false }; 1641 1641 bool newly_split[MAX_PIPES] = { false }; 1642 - int pipe_cnt, i, pipe_idx, vlevel; 1642 + int pipe_cnt, i, pipe_idx, vlevel = 0; 1643 1643 struct vba_vars_st *vba = &context->bw_ctx.dml.vba; 1644 1644 1645 1645 ASSERT(pipes);
+1 -1
drivers/gpu/drm/amd/display/dc/resource/dcn31/dcn31_resource.c
··· 1644 1644 { 1645 1645 int i, pipe_cnt; 1646 1646 struct resource_context *res_ctx = &context->res_ctx; 1647 - struct pipe_ctx *pipe; 1647 + struct pipe_ctx *pipe = 0; 1648 1648 bool upscaled = false; 1649 1649 1650 1650 DC_FP_START();
+1 -1
drivers/gpu/drm/amd/display/dc/resource/dcn316/dcn316_resource.c
··· 1613 1613 { 1614 1614 int i, pipe_cnt; 1615 1615 struct resource_context *res_ctx = &context->res_ctx; 1616 - struct pipe_ctx *pipe; 1616 + struct pipe_ctx *pipe = 0; 1617 1617 const int max_usable_det = context->bw_ctx.dml.ip.config_return_buffer_size_in_kbytes - DCN3_16_MIN_COMPBUF_SIZE_KB; 1618 1618 1619 1619 DC_FP_START();
+1 -1
drivers/gpu/drm/amd/display/modules/color/color_gamma.c
··· 1059 1059 struct fixed31_32 min_display; 1060 1060 struct fixed31_32 max_content; 1061 1061 struct fixed31_32 clip = dc_fixpt_one; 1062 - struct fixed31_32 output; 1062 + struct fixed31_32 output = dc_fixpt_zero; 1063 1063 bool use_eetf = false; 1064 1064 bool is_clipped = false; 1065 1065 struct fixed31_32 sdr_white_level;
+1 -1
drivers/gpu/drm/amd/display/modules/hdcp/hdcp2_execution.c
··· 151 151 152 152 static enum mod_hdcp_status poll_l_prime_available(struct mod_hdcp *hdcp) 153 153 { 154 - enum mod_hdcp_status status; 154 + enum mod_hdcp_status status = MOD_HDCP_STATUS_FAILURE; 155 155 uint8_t size; 156 156 uint16_t max_wait = 20; // units of ms 157 157 uint16_t num_polls = 5;