From nobody Sun Sep 7 12:17:40 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EA066C54EE9 for ; Fri, 2 Sep 2022 12:51:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237864AbiIBMvp (ORCPT ); Fri, 2 Sep 2022 08:51:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237793AbiIBMup (ORCPT ); Fri, 2 Sep 2022 08:50:45 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5179F7B34; Fri, 2 Sep 2022 05:36:45 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 48906B82AC5; Fri, 2 Sep 2022 12:29:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 89EC0C433D7; Fri, 2 Sep 2022 12:29:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1662121786; bh=hyX6Zt3IU6MpFRjst+F6f9W4NLmMoAVAbz38sQFz9OE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KW/LoE49bIJliGodYzvVANdym1m/RqpyWs7rrtE9dcUcoTciXKnDRfFBN6Ru9OwJJ AkqWJ5ZswRMVSPDLEcGX+LrTe0OqEaS2iJxWXvNrHNOTN96ZrQaz2/Yzl7azR6m7Ua UsbLfLwpt7yrLSVSnyCLdSP/Y7GPOG0ki9SpC/34= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Josip Pavic , Jun Lei , Alex Hung , Aric Cyr , Daniel Wheeler , Alex Deucher , Sasha Levin Subject: [PATCH 5.4 65/77] drm/amd/display: Avoid MPC infinite loop Date: Fri, 2 Sep 2022 14:19:14 +0200 Message-Id: <20220902121405.847824457@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220902121403.569927325@linuxfoundation.org> References: <20220902121403.569927325@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Josip Pavic [ Upstream commit 8de297dc046c180651c0500f8611663ae1c3828a ] [why] In some cases MPC tree bottom pipe ends up point to itself. This causes iterating from top to bottom to hang the system in an infinite loop. [how] When looping to next MPC bottom pipe, check that the pointer is not same as current to avoid infinite loop. Reviewed-by: Josip Pavic Reviewed-by: Jun Lei Acked-by: Alex Hung Signed-off-by: Aric Cyr Tested-by: Daniel Wheeler Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/display/dc/dcn10/dcn10_mpc.c | 6 ++++++ drivers/gpu/drm/amd/display/dc/dcn20/dcn20_mpc.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_mpc.c b/drivers/gpu= /drm/amd/display/dc/dcn10/dcn10_mpc.c index 8b2f29f6dabd2..068e79fa3490d 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_mpc.c +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_mpc.c @@ -118,6 +118,12 @@ struct mpcc *mpc1_get_mpcc_for_dpp(struct mpc_tree *tr= ee, int dpp_id) while (tmp_mpcc !=3D NULL) { if (tmp_mpcc->dpp_id =3D=3D dpp_id) return tmp_mpcc; + + /* avoid circular linked list */ + ASSERT(tmp_mpcc !=3D tmp_mpcc->mpcc_bot); + if (tmp_mpcc =3D=3D tmp_mpcc->mpcc_bot) + break; + tmp_mpcc =3D tmp_mpcc->mpcc_bot; } return NULL; diff --git a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_mpc.c b/drivers/gpu= /drm/amd/display/dc/dcn20/dcn20_mpc.c index 5a188b2bc033c..0a00bd8e00abc 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_mpc.c +++ b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_mpc.c @@ -488,6 +488,12 @@ struct mpcc *mpc2_get_mpcc_for_dpp(struct mpc_tree *tr= ee, int dpp_id) while (tmp_mpcc !=3D NULL) { if (tmp_mpcc->dpp_id =3D=3D 0xf || tmp_mpcc->dpp_id =3D=3D dpp_id) return tmp_mpcc; + + /* avoid circular linked list */ + ASSERT(tmp_mpcc !=3D tmp_mpcc->mpcc_bot); + if (tmp_mpcc =3D=3D tmp_mpcc->mpcc_bot) + break; + tmp_mpcc =3D tmp_mpcc->mpcc_bot; } return NULL; --=20 2.35.1