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 7A562606A320 for ; Tue, 1 Dec 2026 20:27:16 +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=K6RUPhN8 Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F3A3C10FCDD; Tue, 1 Dec 2026 20:27:10 +0000 (UTC) Received: from BN1PR04CU002.outbound.protection.outlook.com (mail-eastus2azon11010035.outbound.protection.outlook.com [52.101.56.35]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0670210FCDE for ; Tue, 1 Dec 2026 20:26:54 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=AdNewW7wFFCs9pEKwUxZe6FYjPsoz6lgW4sPrLQuicFzRVT5gRgKvBJZhO9ScN2AQSV1ApDIqRyJv+FkOMKqKonZlcfQehT9VZYbb8fUllVHDYreZ7ZVfuLQsiK7UHFP2ji7Hc+iuoDbByWhnHf8rBxewhZ0j0Nc9mARdo2/rBE6TPO2Dutlq4gvfao4/Gi2yZbPIDeB2zZ3AOK9FmNIWBn2lL1/HVriqad1leyxnwk3EUUOiOdv5Gtz2YwY+3OjlsOVpTkHJkmFwVvSIFoLjJQNwAh2nNtfKlUaCFG9annlTa67cpQ6iI0htsRHbYRPGoMipOJoE98x/J/ceqYHyA== 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=Vt7APyafe2+s7ijV0L9fsAOFcmsUwgNKx0A3TO54KwW7MC9ozy19nU2yoxAEGtiqSyd4iF09VRH4FTNrd5Yqb5CDKFtIS66/kXS7hdyCTNHhOstpoGLC1DmfJWJonVx41jrmXXBC0Qcm+P3fsPfTtHcwPHX7m9Q6h0KYUXg9JIjDh/xfWpcav2ICxB9M7wmhtClwFVqJG7uKH4DVAyZgXu6WWl7Yfbqivn5FcTPffrP6eflMPu0FH7mldu6KpoK0ZeB+Bh3iMpcecYqIFzerxdpf37HxtGBVpVJllvnMeP4J7gEeR1JHsWr3+YY30xUZC6bDG0E93b9z2H0EVUMd2A== 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=K6RUPhN8Yn2EgbJvi7ftIGAltTQlQyX9gZtomdn1bg7fNtwMjwkyoW+GYjWHf29F0VG+3Pwcg+ioC+WvFFv9xiZkyXcb2yO1yWgtsKEWfytkTnQjkF+5tEK1WcBDgPGuo7I2tU4H0iz5HaYys+FWnTleibrZUgX762brngdtZX8= Received: from CH0PR04CA0023.namprd04.prod.outlook.com (2603:10b6:610:76::28) by DS0PR12MB7825.namprd12.prod.outlook.com (2603:10b6:8:14d::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.10; Tue, 1 Dec 2026 20:26:49 +0000 Received: from DSM2EPF0000000C.namprd02.prod.outlook.com (2603:10b6:610:76:cafe::77) by CH0PR04CA0023.outlook.office365.com (2603:10b6:610:76::28) 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 20:26:49 +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 DSM2EPF0000000C.mail.protection.outlook.com (10.167.23.6) 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 20:26:48 +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 14:26:32 -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 v2 17/30] drm/amd/display: Revoke alternate channel P-State before pipe teardown Date: Tue, 1 Dec 2026 15:22:51 -0500 Message-ID: <20261201202451.463794-19-george.zhang@amd.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261201202451.463794-2-george.zhang@amd.com> References: <20261201202451.463794-2-george.zhang@amd.com> X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DSM2EPF0000000C:EE_|DS0PR12MB7825:EE_ X-MS-Office365-Filtering-Correlation-Id: 11427320-0f66-4e91-8a91-08df4fe96d28 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700016|376014|1800799024|23010399003|82310400026|261102123227099003|10067099003|56012099006|261026121527099003|261026140227099003|261028144727099003|261022105027099003|261022075727099003|261021123027099003|261021121427099003|261009223027099003|18002099003|22082099003|11063799006|6133799003|3023799007; X-Microsoft-Antispam-Message-Info: nlJScct13URZdwASJzE2jhNrEjPQ0XFUV7nUftIgjeoppIY4dz1Pp8axADtAwUpI208rtHiJOWdxVprP7bqwJxrjJNTJ3e/u5nrD/je2Cje3Km0nmV2O9VBv1jArxCXeDqUn9B4UgTXHklcpsfrxS/bThvBcKM97D7MlSGvQ6tQNS89OrT9+CBvrjiKwQIpceLWb/8ZWyaE+cmib7kHF1NASTc1d0Wv8fF2SknLAQpmadsS4MKtUVEuZUwYQIL4fM6lavYyBDoIihPURU0UvnGKzRe0y2m7WR4AYx2c/T3Dh3HeXkH9DvHfOU3f5QwGQbLtKztcvC6d+ijE0NjLA1tjDbRN9nHGJuPT+dd75Ivj1Mdi7R0YkDEPoKO5S4Gbr9QwEZfe269cDiHuw6ERHjVMpQeJgyyI8E+T3MP5cikWbKDmLpVmDSdGKxfDrPZHqWMGcSF8CkZ4Wp90P6W2lWuLe8Mg0v75pLXnivdPaMqR2X/D7tkWWebd6vSk9eAN+XZRUo24CwpDJwJUdYFKngBzyp6lVgmqXKfnqPejKQwmWsiMKck4rp31ikUrpN0etLr7rmAw9nWyyKHO5k/dEpH3LepG1eyXNQVAl+Q6ojrflmmCLwp8Dkz3fKLja+o/ltNH4GqQZfU1PojlmTowjhK51rhPh6Xm9OCOzWocCj63gHPchpNrGiqTcO2N7/7/aaSfKeprZAMSQZ8V+z1UmiA== 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)(36860700016)(376014)(1800799024)(23010399003)(82310400026)(261102123227099003)(10067099003)(56012099006)(261026121527099003)(261026140227099003)(261028144727099003)(261022105027099003)(261022075727099003)(261021123027099003)(261021121427099003)(261009223027099003)(18002099003)(22082099003)(11063799006)(6133799003)(3023799007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: RipJzp/Q5KlrovuKd1nBEzpIUeulWR1QKM1TgF7pzMMfwjMiYZh7SufcyMXaYISac2ny1nwA16eMwnSF4Awb0ie3INahkcOORTUUb4abXVkUUVIcSaJQyjhbOMbkI+RmEcJN+sutbSrQjRIbm+cKwKhUs5GcS+/+qec94WsVp+1fHs+PImRt07koCUwtt2CsjdpZM1mPhfSyIpzedwu06X1e4LuZnCi+3jj3UShQFfLOYDWfJFulJupRc1lnr7R8bqY0WD1wUEJMLaaoI+KCxbhDNuiNtsJVt7xbmi2cujd7w2h9Cak8unCktc8mttPHj31S9n/3+6fgeBGv/QTc5wGRiTBf66nsFrmEeNHH6wVR65/Q4DkAe8YcurdACOCYZxuUSZkdLTrCVisCbD3r7Nca+An/nKjYh2cWoIv6u9E8+TqjkCURXpmoafVVxm9L X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2026 20:26:48.6439 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 11427320-0f66-4e91-8a91-08df4fe96d28 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: DSM2EPF0000000C.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7825 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