]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/amd/display: fail instead of div by zero/bugcheck
authorAshley Thomas <Ashley.Thomas2@amd.com>
Tue, 13 Oct 2020 04:33:27 +0000 (21:33 -0700)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 2 Nov 2020 20:30:47 +0000 (15:30 -0500)
[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>
drivers/gpu/drm/amd/display/dc/core/dc_debug.c
drivers/gpu/drm/amd/display/dc/core/dc_link.c
drivers/gpu/drm/amd/display/dc/inc/core_status.h

index 7977e283906508a4a3bd1e180111f5733145673b..21be2a684393a625efd6d104731380f212c2068f 100644 (file)
@@ -420,6 +420,8 @@ char *dc_status_to_str(enum dc_status status)
                return "Fail clk below required CFG (hard_min in PPLIB)";
        case DC_NOT_SUPPORTED:
                return "The operation is not supported.";
+       case DC_UNSUPPORTED_VALUE:
+               return "The value specified is not supported.";
        case DC_ERROR_UNEXPECTED:
                return "Unexpected error";
        }
index 3900c81699a0698ab93340a4b887fec4c0ad05cf..6b8bc8dde6ea6ae61abddca802cac4a8aea08fe1 100644 (file)
@@ -2952,6 +2952,10 @@ enum dc_status dc_link_allocate_mst_payload(struct pipe_ctx *pipe_ctx)
 
        /* slot X.Y for only current stream */
        pbn_per_slot = get_pbn_per_slot(stream);
+       if (pbn_per_slot.value == 0) {
+               DC_LOG_ERROR("Failure: pbn_per_slot==0 not allowed. Cannot continue, returning DC_UNSUPPORTED_VALUE.\n");
+               return DC_UNSUPPORTED_VALUE;
+       }
        pbn = get_pbn_from_timing(pipe_ctx);
        avg_time_slots_per_mtp = dc_fixpt_div(pbn, pbn_per_slot);
 
index 714593a155905d034b3ae8bb95e112e50ae6924d..d34b0b0eea655123f56b59109873c216a749f6f1 100644 (file)
@@ -51,6 +51,7 @@ enum dc_status {
        DC_FAIL_CLK_BELOW_CFG_REQUIRED = 23, /*THIS IS hard_min in PPLIB*/
 
        DC_NOT_SUPPORTED = 24,
+       DC_UNSUPPORTED_VALUE = 25,
 
        DC_ERROR_UNEXPECTED = -1
 };