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

drm/amd/display: fail instead of div by zero/bugcheck

[why]
If pbn_per_slot is 0, fail instead of dividing by zero and
bugchecking.

[how]
Check for zero divisor before division operation.

Signed-off-by: Ashley Thomas <Ashley.Thomas2@amd.com>
Reviewed-by: Wyatt Wood <Wyatt.Wood@amd.com>
Acked-by: Qingqing Zhuo <qingqing.zhuo@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Ashley Thomas and committed by
Alex Deucher
7dd4f4df 81e8da71

+7
+2
drivers/gpu/drm/amd/display/dc/core/dc_debug.c
··· 420 420 return "Fail clk below required CFG (hard_min in PPLIB)"; 421 421 case DC_NOT_SUPPORTED: 422 422 return "The operation is not supported."; 423 + case DC_UNSUPPORTED_VALUE: 424 + return "The value specified is not supported."; 423 425 case DC_ERROR_UNEXPECTED: 424 426 return "Unexpected error"; 425 427 }
+4
drivers/gpu/drm/amd/display/dc/core/dc_link.c
··· 2952 2952 2953 2953 /* slot X.Y for only current stream */ 2954 2954 pbn_per_slot = get_pbn_per_slot(stream); 2955 + if (pbn_per_slot.value == 0) { 2956 + DC_LOG_ERROR("Failure: pbn_per_slot==0 not allowed. Cannot continue, returning DC_UNSUPPORTED_VALUE.\n"); 2957 + return DC_UNSUPPORTED_VALUE; 2958 + } 2955 2959 pbn = get_pbn_from_timing(pipe_ctx); 2956 2960 avg_time_slots_per_mtp = dc_fixpt_div(pbn, pbn_per_slot); 2957 2961
+1
drivers/gpu/drm/amd/display/dc/inc/core_status.h
··· 51 51 DC_FAIL_CLK_BELOW_CFG_REQUIRED = 23, /*THIS IS hard_min in PPLIB*/ 52 52 53 53 DC_NOT_SUPPORTED = 24, 54 + DC_UNSUPPORTED_VALUE = 25, 54 55 55 56 DC_ERROR_UNEXPECTED = -1 56 57 };