Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5E14E606A320 for ; Tue, 1 Dec 2026 19:04:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=E+3S+W1T Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E81E210FC38; Tue, 1 Dec 2026 19:03:54 +0000 (UTC) Received: from CH1PR05CU001.outbound.protection.outlook.com (mail-northcentralusazon11010000.outbound.protection.outlook.com [52.101.193.0]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9A6DE10FC33 for ; Tue, 1 Dec 2026 19:03:49 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=E1peeWL6J7xuOGKaSF2bnpYr0iyOUbT991Q15BF01GwbHVjLsyOTN0TJfbzDwe6zcVZhf+e7NMtrPlTNh8SlhrMbzAGN/DIk6/zLBtaS6KeiPIbk32GWeb7Z98YuACSq89jfZ8TKd6lM/6HByAON2ytz0p/3MzN5Vun9s6DWqsMqwaH3JNu97rP2IKlFpVOFCu3eaVuZK0wyja6p4j/uYJNiPlnrXEqjFFlaKBJYzOhUeL6VG4DDEcSQbWak0MC187StIdsnVrnJ04PjgEBUwOq3fRJ89kfmBa9k0LtaiiEdQlddAqIaLK8ah+iGd8UBLGrgvUMxRLcpSDVdfqcv3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=CpZflFOWDbyoimAXqZerSmbdBUOSZinWK0+y1XQKH40=; b=K0BEo8xFgVo4R3H1wnzd+TyFjasR0qs0+5hqq/clFIrL83aC4qq/lUgeiuHVMd/RSHdO/HM9/GEkYens/EyTT2sMySpnZQfbbFchellWCCFC5DmVeg4g2dL1VMoykiRzuwSOFgPTvnkWdxpVvUZgKOLyK2v2UGipi8I474q+XcnjSnrT3TsB2czSrs1wMX+TefkzU5Xo42Q79/VCQNDw3yVGPupI+04mnTL71SGu+UpZKve1BXd4B09xJx0npt7hQ1CXc0KC3nLpAYAHv+4/5YN/fnC+LQjmPv1sNYwc0rkKPa9+C+Tfhx02/L/sTY+uyzdAyG7mYbMj6HDfrbTb3w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CpZflFOWDbyoimAXqZerSmbdBUOSZinWK0+y1XQKH40=; b=E+3S+W1ToD/GAQqmMwusK+ilXZ0lt2HjG/v9zTYTf7um0VNMuwyxcBd7Rp2L5fF+W1Hz9E1yDMArV17yN/adScAJ7qXKshilBzO6PadYT/+5hFoCWDMHR0I0Zr0CAIr4OCdk7tdoZomePv08h1psPmKX0Vg0SK0c0Ifjy9t4Wbo= Received: from DS0PR17CA0018.namprd17.prod.outlook.com (2603:10b6:8:191::18) by BL3PR12MB6595.namprd12.prod.outlook.com (2603:10b6:208:38e::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.662.13; Tue, 1 Dec 2026 19:03:35 +0000 Received: from DM3PEPF000265B1.namprd02.prod.outlook.com (2603:10b6:8:191:cafe::1f) by DS0PR17CA0018.outlook.office365.com (2603:10b6:8:191::18) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.688.10 via Frontend Transport; Tue, 1 Dec 2026 19:03:35 +0000 X-MS-Exchange-Authentication-Results: mx.microsoft.com 1; spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by DM3PEPF000265B1.mail.protection.outlook.com (10.167.23.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.5 via Frontend Transport; Tue, 1 Dec 2026 19:03:34 +0000 Received: from georzhanmkm.amd.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Tue, 1 Dec 2026 13:03:21 -0600 From: George Zhang To: CC: Harry Wentland , Leo Li , Aurabindo Pillai , Roman Li , Wayne Lin , Tom Chung , "Fangzhi Zuo" , Dan Wheeler , Ray Wu , Ivan Lipski , Alex Hung , James Lin , Chenyu Chen , Alvin Lee , George Zhang Subject: [PATCH 17/30] drm/amd/display: Revoke alternate channel P-State before pipe teardown Date: Tue, 1 Dec 2026 13:57:53 -0500 Message-ID: <20261201190245.360906-18-george.zhang@amd.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261201190245.360906-1-george.zhang@amd.com> References: <20261201190245.360906-1-george.zhang@amd.com> X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-ClientProxiedBy: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM3PEPF000265B1:EE_|BL3PR12MB6595:EE_ X-MS-Office365-Filtering-Correlation-Id: 02d03565-e30f-4c8f-9bb5-08df4fddcc5f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|36860700016|82310400026|1800799024|23010399003|11063799006|6133799003|261009223027099003|18002099003|22082099003|3023799007|10067099003|56012099006|261026140227099003|261102123227099003|261026121527099003|261028144727099003|261022105027099003|261021123027099003|261021121427099003|261022075727099003; X-Microsoft-Antispam-Message-Info: MgCiWhl7RmxAlp43bkZizsxHwEZLp9bvK4MZTjXuBka4YaUi3+e25YvINWwPmAJn7dr0wAQ7wxxCijhaIll17iXpGq3awLxI0/wCgkM21/b1Oepzlr/BklCNg1/iwyjyaj2FQz+bbWfTDt+y/HMt1ybjjX6ihLz/55f2Y9xcQFuRjDjbK/HfHKFkNMBs8+QLjl06EvnOJPOXs1piKhJxDUOn9Ecr+4CbEhQZSNT1BPDvBJ993hheYxpdDnjDKFBmX8eNiwuu9Q1htAMTua9ArZZ71LtXi7N2NU1pP4GCQrz0ZHNtQacwWpdT6kFHWoul/HcAku406DTvpxGXo+iTOvE+fme5+tNdhZF/rdWRjkFQ2/N+nELT+Fx+ifvxauHsX+KCX/0yflXjwUulJFcSdG4ScQiaqco0mHjE3VlFWAaH7IxXhwkzDARGt8RsmoSAfaem7+meXQx0jop/VvgUZcTSxqyMP4FnQHODTwJmX8mGLeAnDUUcN4zpolcQztuSBBdR0oft6t0sfYm6dMF92AWVvBnD906JwO/TcWCtifr/2BoONqqyl3x2kfvh5ypm8Er/KzvmPBgHjD3P5VmJLhflXwbh6rUROl4D+bUQHFbMad/PmDotGij/RWGzCUjADEckSIVJqF559NjBnjVY8b6L3oaNpqgVNRnqF9ohegbXCKFEGwgwDZUyOcZGBTXZBtEIv8IF+s4H30uFo5rxLQ== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:satlexmb07.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(376014)(36860700016)(82310400026)(1800799024)(23010399003)(11063799006)(6133799003)(261009223027099003)(18002099003)(22082099003)(3023799007)(10067099003)(56012099006)(261026140227099003)(261102123227099003)(261026121527099003)(261028144727099003)(261022105027099003)(261021123027099003)(261021121427099003)(261022075727099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ZBhg4AhtvmPjsNQBRnXYo6b1ce4YoXCV8ypVTETMy7YrfHpHb05thMRPVgNAa6vvXpQLyGv+b8tWLIHKq1kJXLkg8G3cCa5JBjlJDs6J0+uVC9c+qHEnybst9AlcXNnKqt9D/ALpX7ZwHxmOxgiWbp2Hls48JpjWPZDAYTYxmgxUvoAkkv0A5vI20Zn0zkDDTUgXIDvNVNTWdhLfxf9HIVHq+0rMYkRI5QJQaa1zEL5u2rdm8vA3e+Mj8Ls7XaPP+IIviQ8OKkJmx43YwljM3RWeGSK8VnA5qBj5FhIo3OgeNaRhC32EEVzyVwM0rbQ9qQgPI9SAtqytC85MnZsF5nYWOwFGaggIpKb3nY0z/RXNtigwvL1HfiPbmeVdyHRlCaFCvo/lxAfFIxuaS2wbFry9vFJGjIuDaEyjBDNyVoamSRyt0zvtN27i9yyTeuZV X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2026 19:03:34.4467 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 02d03565-e30f-4c8f-9bb5-08df4fddcc5f X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM3PEPF000265B1.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR12MB6595 X-BeenThere: amd-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion list for AMD gfx List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "amd-gfx" X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 From: Ivan Lipski [Why] A modeset after stress testing can hang PMFW. The hang only happens when alternate channel P-State switching is in use. Alternate channel P-State permission was sequenced the opposite way to UCLK/FCLK P-State: it could be enabled during prepare_bandwidth, before the new configuration was programmed, and was only disabled during optimize_bandwidth, after the old configuration had been torn down. PMFW could therefore start an alternate channel switch that depended on a display being disabled and never complete it. The IndicatePstateStatus messages also did not follow the computed action. With no active planes, prepare_bandwidth decided to revoke UCLK/FCLK P-State but still told PMFW they were allowed, and the enable message could briefly re-allow a state the action was revoking. [How] Only allow alternate channel P-State when it is safe to lower, and revoke it as soon as the new state does not support it. Only treat zero active planes as UCLK/FCLK P-State support when it is safe to lower, so prepare_bandwidth never grants it for a config that has not been programmed yet. Derive allow_uclk, allow_fclk and alt_ch_enable once from the action and the current clocks. The IndicatePstateStatus messages no longer recount the active planes to allow UCLK/FCLK P-State on their own; the zero plane case is decided only by the action. Cc: Alvin Lee Signed-off-by: Ivan Lipski Signed-off-by: George Zhang --- .../display/dc/clk_mgr/dcn60/dcn60_clk_mgr.c | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn60/dcn60_clk_mgr.c b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn60/dcn60_clk_mgr.c index 9556da79cdce..4b73dd8b5382 100644 --- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn60/dcn60_clk_mgr.c +++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn60/dcn60_clk_mgr.c @@ -1211,10 +1211,10 @@ static void dcn60_make_bandwidth_clocks_update_action( bool dcfclk_dpm_enabled = dcn60_is_ppclk_dpm_enabled(clk_mgr_internal, PPCLK_DCFCLK); bool uclk_pstate_supported = new_clocks->p_state_change_support - || (total_plane_count == 0); + || (total_plane_count == 0 && safe_to_lower); bool fclk_pstate_supported = new_clocks->fclk_p_state_change_support - || (total_plane_count == 0); + || (total_plane_count == 0 && safe_to_lower); memset(action, 0, sizeof(*action)); /* clock actions */ @@ -1282,9 +1282,10 @@ static void dcn60_make_bandwidth_clocks_update_action( } if (new_clocks->alt_ch_pstate_switch != clk_mgr_base->clks.alt_ch_pstate_switch) { - action->alt_ch.enable = new_clocks->alt_ch_pstate_switch; - action->alt_ch.disable = !new_clocks->alt_ch_pstate_switch + /* PMFW hangs if alt-ch is still allowed while pipes are torn down */ + action->alt_ch.enable = new_clocks->alt_ch_pstate_switch && safe_to_lower; + action->alt_ch.disable = !new_clocks->alt_ch_pstate_switch; action->alt_ch.send_message = action->alt_ch.enable || action->alt_ch.disable; } @@ -1296,7 +1297,6 @@ static void dcn60_make_bandwidth_clocks_update_action( * @block_sequence: output array of block sequence steps * @action: action struct populated by dcn60_make_bandwidth_clocks_update_action * @clk_mgr_base: current clock manager state (read-only, used for original values) - * @context: dc state with active plane information * @new_clocks: requested clock values for message parameters * * Return: number of steps written to block_sequence @@ -1305,11 +1305,16 @@ static unsigned int dcn60_build_bandwidth_clocks_block_sequence_with_action( struct dcn60_clk_mgr_block_sequence *block_sequence, struct dcn60_bandwidth_clocks_update_action *action, struct clk_mgr *clk_mgr_base, - struct dc_state *context, struct dc_clocks *new_clocks) { unsigned int num_steps = 0; - bool no_active_planes = clk_mgr_helper_get_active_plane_cnt(clk_mgr_base->ctx->dc, context) == 0; + const struct dc_clocks *cur = &clk_mgr_base->clks; + bool allow_uclk = action->uclk_pstate.enable + || (!action->uclk_pstate.disable && cur->p_state_change_support); + bool allow_fclk = action->fclk_pstate.enable + || (!action->fclk_pstate.disable && cur->fclk_p_state_change_support); + bool alt_ch_enable = action->alt_ch.enable + || (!action->alt_ch.disable && cur->alt_ch_pstate_switch); /* CLK_MGR60_INDICATE_PSTATE_STATUS — enable */ if ((action->uclk_pstate.enable && action->uclk_pstate.send_message) @@ -1317,15 +1322,13 @@ static unsigned int dcn60_build_bandwidth_clocks_block_sequence_with_action( || (action->fams.enable && action->fams.send_message) || (action->alt_ch.enable && action->alt_ch.send_message)) { block_sequence[num_steps].params.indicate_pstate_status_params.allow_uclk = - action->uclk_pstate.enable - || clk_mgr_base->clks.p_state_change_support; + allow_uclk; block_sequence[num_steps].params.indicate_pstate_status_params.allow_fclk = - action->fclk_pstate.enable - || clk_mgr_base->clks.fclk_p_state_change_support; + allow_fclk; block_sequence[num_steps].params.indicate_pstate_status_params.drr_enable = new_clocks->fw_based_mclk_switching; block_sequence[num_steps].params.indicate_pstate_status_params.alt_ch_enable = - new_clocks->alt_ch_pstate_switch; + alt_ch_enable; block_sequence[num_steps].params.indicate_pstate_status_params.wait_resp = new_clocks->fw_based_mclk_switching; block_sequence[num_steps].func = CLK_MGR60_INDICATE_PSTATE_STATUS; @@ -1369,13 +1372,13 @@ static unsigned int dcn60_build_bandwidth_clocks_block_sequence_with_action( || (action->fams.disable && action->fams.send_message) || (action->alt_ch.disable && action->alt_ch.send_message)) { block_sequence[num_steps].params.indicate_pstate_status_params.allow_uclk = - new_clocks->p_state_change_support || no_active_planes; + allow_uclk; block_sequence[num_steps].params.indicate_pstate_status_params.allow_fclk = - new_clocks->fclk_p_state_change_support || no_active_planes; + allow_fclk; block_sequence[num_steps].params.indicate_pstate_status_params.drr_enable = new_clocks->fw_based_mclk_switching; block_sequence[num_steps].params.indicate_pstate_status_params.alt_ch_enable = - new_clocks->alt_ch_pstate_switch; + alt_ch_enable; block_sequence[num_steps].params.indicate_pstate_status_params.wait_resp = new_clocks->fw_based_mclk_switching; block_sequence[num_steps].func = CLK_MGR60_INDICATE_PSTATE_STATUS; @@ -1469,7 +1472,7 @@ static unsigned int dcn60_build_update_bandwidth_clocks_sequence( num_steps = dcn60_build_bandwidth_clocks_block_sequence_with_action( clk_mgr60->block_sequence, &action, - clk_mgr_base, context, new_clocks); + clk_mgr_base, new_clocks); dcn60_update_bandwidth_clocks_state_with_action(clk_mgr_base, &action, new_clocks); -- 2.56.1