Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp1974628rwe; Fri, 2 Sep 2022 06:51:13 -0700 (PDT) X-Google-Smtp-Source: AA6agR5yUl6XlKyhZX6POsDMXXF3sHILsR7Ts48GNGm65aK4JD/nF/Y9vXqNPJqtNvnZhrjHpjxe X-Received: by 2002:a17:902:d512:b0:175:a556:c8ac with SMTP id b18-20020a170902d51200b00175a556c8acmr5181489plg.17.1662126673594; Fri, 02 Sep 2022 06:51:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662126673; cv=none; d=google.com; s=arc-20160816; b=FIAgwOcgKdaZVlRicrlAJmfVBWkFtfzAardOGn8zew5QIcJ963A8c2GhaYbfMFXjeC YdkLy7lF9/rS75hZu66EwNBcpih6p5hsATkx76/T1jIY9EsSnv1sxvmOt3zmQZUYUVrw J0WHoNfYILdSQXQiGkXGu7M7LoQ5b5jG2t0DU1w7fE/SdA1acBHWP4BjJzGY4AFUU5Uc EvDOY9jPXwyIMdEelFkmQ3OeyhZCTh1j542yavTb2aUcph8HMn0KYOUKv87sKstHHptJ KmOOlH3vKMs7OJwMbRpIiWY1V9/jzwjahfmSKwvp9CI84KSa9x/F1GKtqXeY8hQqUKsy hYJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9tpHBrNVr6lOMjQltyZu6OKoKQAVhHGeon9WGVQItYU=; b=0u2rMPoMpFE5vZoQXiqBMUBx/ziCJyhl+DkuRqmsu9qaynW9UWMI4MfgP3coEyEpGG jC18TmGqQb9oImDUAPLIyiWYP0I/5vh4dHCHPtZ6iIhN72aW61hdYh8To4UccmiFj1ix YQADbN/MaOb3TxJcEisdoXP1Vy3pHm5sVMCfrkC6r2Dqqw90YsboucZTSUWK141HmgLN hq/H84CRGBk0IigccQDlU6gFnV7MVQ310w78JDcV5GOSWE3Jd0ht4b8ol6U/Qrmnq9lA DUJzYaFccGA9y+FZO70W4ZUhvpHRxmHJN6lEuvLbQ0QG1z6A5cTTzZcwOALUcMRM/qWA 9X7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OsdJUfyo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d10-20020a056a00198a00b0052ece684368si2249858pfl.240.2022.09.02.06.50.55; Fri, 02 Sep 2022 06:51:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OsdJUfyo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237996AbiIBMxS (ORCPT + 99 others); Fri, 2 Sep 2022 08:53:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236398AbiIBMwc (ORCPT ); Fri, 2 Sep 2022 08:52:32 -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 EB5A75C9CE; Fri, 2 Sep 2022 05:37:22 -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 3622FB82A71; Fri, 2 Sep 2022 12:36:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 68DCBC433C1; Fri, 2 Sep 2022 12:36:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1662122179; bh=V3FkCwM9i+GoSL/R/1gavDi9ac9+8/zlCT8RN7PV1BA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OsdJUfyo17IzaeVidKDeFfptxkMNu3tgtx6KSL6bjTUZvA2LHYA5y6LpKj91OX79H K4e+b9AGmGhHHllZIlPKRdQcnu2L5XwvS3rotqBCV60fRDCfnd/H+uDEzb730oMwfH HFX5d8EhxqdoxkMYqpB8Y+zAFsFz6hrU5Ygd1Cs8= 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.19 38/72] drm/amd/display: Avoid MPC infinite loop Date: Fri, 2 Sep 2022 14:19:14 +0200 Message-Id: <20220902121406.033457164@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220902121404.772492078@linuxfoundation.org> References: <20220902121404.772492078@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 11019c2c62ccb..8192f1967e924 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_mpc.c +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_mpc.c @@ -126,6 +126,12 @@ struct mpcc *mpc1_get_mpcc_for_dpp(struct mpc_tree *tree, int dpp_id) while (tmp_mpcc != NULL) { if (tmp_mpcc->dpp_id == dpp_id) return tmp_mpcc; + + /* avoid circular linked list */ + ASSERT(tmp_mpcc != tmp_mpcc->mpcc_bot); + if (tmp_mpcc == tmp_mpcc->mpcc_bot) + break; + tmp_mpcc = 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 15734db0cdea4..f3c311d093197 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_mpc.c +++ b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_mpc.c @@ -531,6 +531,12 @@ static struct mpcc *mpc2_get_mpcc_for_dpp(struct mpc_tree *tree, int dpp_id) while (tmp_mpcc != NULL) { if (tmp_mpcc->dpp_id == 0xf || tmp_mpcc->dpp_id == dpp_id) return tmp_mpcc; + + /* avoid circular linked list */ + ASSERT(tmp_mpcc != tmp_mpcc->mpcc_bot); + if (tmp_mpcc == tmp_mpcc->mpcc_bot) + break; + tmp_mpcc = tmp_mpcc->mpcc_bot; } return NULL; -- 2.35.1