]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
drm/amd/display: fix a divided-by-zero error
authorAlex Hung <alex.hung@amd.com>
Mon, 3 Apr 2023 09:45:41 +0000 (17:45 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 11 May 2023 14:10:53 +0000 (23:10 +0900)
[ Upstream commit 0b5dfe12755f87ec014bb4cc1930485026167430 ]

[Why & How]

timing.dsc_cfg.num_slices_v can be zero and it is necessary to check
before using it.

This fixes the error "divide error: 0000 [#1] PREEMPT SMP NOPTI".

Reviewed-by: Aurabindo Pillai <Aurabindo.Pillai@amd.com>
Acked-by: Qingqing Zhuo <qingqing.zhuo@amd.com>
Signed-off-by: Alex Hung <alex.hung@amd.com>
Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/amd/display/modules/power/power_helpers.c

index cf4fa87c7db60a1b1c4e61eea8a144b9035239ba..e75b443ee95dc231311b408b78ce4bc575356875 100644 (file)
@@ -933,6 +933,10 @@ bool psr_su_set_y_granularity(struct dc *dc, struct dc_link *link,
 
        pic_height = stream->timing.v_addressable +
                stream->timing.v_border_top + stream->timing.v_border_bottom;
+
+       if (stream->timing.dsc_cfg.num_slices_v == 0)
+               return false;
+
        slice_height = pic_height / stream->timing.dsc_cfg.num_slices_v;
 
        if (slice_height) {