]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
drm/amd/display: Fix crash during MPO + ODM combine mode recalculation
authorAric Cyr <aric.cyr@amd.com>
Tue, 25 May 2021 19:33:51 +0000 (15:33 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 19 Jul 2021 08:00:57 +0000 (10:00 +0200)
[ Upstream commit 665f28507a2a3d8d72ed9afa9a2b9b17fd43add1 ]

[Why]
When calculating recout width for an MPO plane on a mode that's using
ODM combine, driver can calculate a negative value, resulting in a
crash.

[How]
For negative widths, use zero such that validation will prune the
configuration correctly and disallow MPO.

Signed-off-by: Aric Cyr <aric.cyr@amd.com>
Reviewed-by: Krunoslav Kovac <Krunoslav.Kovac@amd.com>
Acked-by: Stylon Wang <stylon.wang@amd.com>
Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/amd/display/dc/core/dc_resource.c

index 325e0d656d6a0da1081028fc78776b756cab1f16..749189eb20babab82ef348acfa61aa73c8e5d84e 100644 (file)
@@ -733,6 +733,11 @@ static void calculate_recout(struct pipe_ctx *pipe_ctx)
                        if (split_idx == split_count) {
                                /* rightmost pipe is the remainder recout */
                                data->recout.width -= data->h_active * split_count - data->recout.x;
+
+                               /* ODM combine cases with MPO we can get negative widths */
+                               if (data->recout.width < 0)
+                                       data->recout.width = 0;
+
                                data->recout.x = 0;
                        } else
                                data->recout.width = data->h_active - data->recout.x;