From patchwork Fri Jan 10 08:48:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Ying X-Patchwork-Id: 13933988 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 90B71E7719C for ; Fri, 10 Jan 2025 08:47:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1561410E4FC; Fri, 10 Jan 2025 08:47:49 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=nxp.com header.i=@nxp.com header.b="OSg00vQd"; dkim-atps=neutral Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2054.outbound.protection.outlook.com [40.107.249.54]) by gabe.freedesktop.org (Postfix) with ESMTPS id EA2E310E4FC for ; Fri, 10 Jan 2025 08:47:47 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=FpwaKhdLx56zM/LAbYXjdYlL2Mr5aPuAK6SdL7fPj6bCbB+vIHYUVA1uuzeL/vGySDEwdq0XY3mammkc3GTBGwUbeJ+n7qufKxIu6W3YdeBWfH6e3b/ZhJ5G+RSvhcGY9MyzVjC022JTfYaQ0+NrUe2XW43zZsD3UsCdtJusnNpdlqqJcDhx14JXOPXO/ONM4ZQutYCUf04JYe7zdqkMFZhMv2fy5z9GtAfdXOripyOLunj5zrTTtAGs+YBGu4diSZelSFZEuyzNCmvutBN1J/27luLr+ozONIndqmUcGOKl0QxfvkYfC7P8lwhuUTrF4UGDdmPDpVqARdtzsw/4Mg== 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=VW4dGaT0v5IoxjWe15+w5qtcWgWmgfapMXw1w3m8Rc0=; b=GvSqijwpBSr7NMwRWTVawUsuCifqhCSlbeeBFHM3apbAvWcdQwdVqHitBXUoUFmcmQkMRoeq8POHo7kF1PhOcl3/xMJ3sf2G+HkEVAy0ZfTdmVOQ+/wkhFBmKkLsJSnrmlRfvquMeHTEKZesBGni5p3f1ETxzsILkcUwv7XOH/q7krVKCVjALDHhpnMsy9lKbcyLoQtOxmM8EUuFiF0PXhlq0uqZCFeT4/AqLlMgCBvQ2ubbvBKA3aOyrgScyQ5UKXiIiobtvrPBEdoksJTQWlJMeiqYzhotTI/+GgbqgHcpLmXLF0MXDmM4ZCUeUR7Q4K/FJNkvvsVQmRoILePvkA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VW4dGaT0v5IoxjWe15+w5qtcWgWmgfapMXw1w3m8Rc0=; b=OSg00vQdYJZ0z6lDFcB6q1vGoBekUNoI+Iy9zLpo6VaswJeGTiut+rR+l2z9cAT4ENmj45z+hwtvZn0gYIfj4kiPA0GWnx1irKH4U9hmwaqFaosrotOfRwEwi1Nk79psvzbtTRuDaMqst03o+dW2fuHypDP9Ldlhr6ER7m6CU6FM83n0UJTCmiEUJBO+4eYtNaHhAQ96eTFao+n7AGuEnhxydHNmDEBJFuwK1/5pDKdrxS+/RMFE/SEc2Om1ZT2+ZnTrhsm++pK8JZbsooKHZQNIGqyF7qg8Uxx0r8bn1Fuhj4r57mDqC+zzOtCgjgIZcPk33q0kb+U4LU/kJVGDwA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM7PR04MB7046.eurprd04.prod.outlook.com (2603:10a6:20b:113::22) by AS5PR04MB9770.eurprd04.prod.outlook.com (2603:10a6:20b:654::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8335.11; Fri, 10 Jan 2025 08:47:45 +0000 Received: from AM7PR04MB7046.eurprd04.prod.outlook.com ([fe80::d1ce:ea15:6648:6f90]) by AM7PR04MB7046.eurprd04.prod.outlook.com ([fe80::d1ce:ea15:6648:6f90%4]) with mapi id 15.20.8335.012; Fri, 10 Jan 2025 08:47:45 +0000 From: Liu Ying To: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: andrzej.hajda@intel.com, neil.armstrong@linaro.org, rfoss@kernel.org, Laurent.pinchart@ideasonboard.com, jonas@kwiboo.se, jernej.skrabec@gmail.com, maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com, simona@ffwll.ch, dmitry.baryshkov@linaro.org Subject: [PATCH v2 1/2] drm/connector: hdmi: Do atomic check when necessary Date: Fri, 10 Jan 2025 16:48:20 +0800 Message-Id: <20250110084821.3239518-2-victor.liu@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250110084821.3239518-1-victor.liu@nxp.com> References: <20250110084821.3239518-1-victor.liu@nxp.com> X-ClientProxiedBy: JH0PR01CA0186.apcprd01.prod.exchangelabs.com (2603:1096:990:75::11) To AM7PR04MB7046.eurprd04.prod.outlook.com (2603:10a6:20b:113::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM7PR04MB7046:EE_|AS5PR04MB9770:EE_ X-MS-Office365-Filtering-Correlation-Id: b119083d-76b3-4fad-3552-08dd315373b0 X-LD-Processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|366016|376014|52116014|1800799024|7416014|38350700014; X-Microsoft-Antispam-Message-Info: boe2jpJs+SBGO7ND/l30ms7oRvGfPOZPOx9ImrpETADRDzHKOfkJsCa2NS8Iy4esz7GLHCmb5yBwt3+2iJwTXPANeBV2+6sZ/CmcolKdiAFwA8z+7xy6LTnBn6gLIZY7Gb2LTRmIXS7IZSoojcyoKDHxD3J0fvlOTx7D57vcX4TrJH5yJlDLTGA6d68HW5NB1iMcmgRP9OPv66jx6Q8oIyM1MdEzY8sAJelUdMUZ3ejEm/cz8+L0cEZwaVZMXi0++4noqIE6TlSOrpp7GCgMlzPaBeu0iB2vfhBkQmR5bh5mN7UdooHa/1GftXKRmuboq0zHDpzMiZNfFgNsdkNK2OuHD3R74GGsA7ZlOxdMxeH1UMlveU0xZLh7YwhwwlNl3ZSGeG6DfSbyzuId+p8S5/R2PzallbxzWmnNd3wIJFiJbjir7VZs17jhiPXvcvnGhdw1J6TtjeKOvdqvO1RFGmTba21C3+JCBtdkHSJqaVYXWmCVKJtfPtVCP6dNhe2/mGT+IMcjzKHMx+Ww78kng4iqdgQoQ3sikqQvDmAdwe73AG/eRnjOUTWwm/aJBOXb0qqyQN9kJrjWl8K5okJReaB2wc9bLR3mTvdx5RImC2nDzskvDevLJg2LvVczEBnywvAnsjd4YYvV2xttT/sGbP5+gHfzUkEF2ogKhs/lzg6y5W3EB8bnQ/jrJRYzGu9MbCsWLiL6gAJqjB/viIZpBRLKVLeX1Sntm2gqzgZjtzPO+4Zs3898llYlrLEhmJHnUB2s/sBxnd+fdgUjAAhkiRN8G8V1M8MFDj+4hIE9bz31nqmZD0tfmHq71gxbsFHpMq19l/OdmUdG5vHyBxKp301HgMbTdKgnEJTIQosgs44vzkTRk8aQP6iPjHcbqOGy2S6f3zdBvBoj1+68jBJn3GdBZk/iJx5wmpjiI1ciLUY/ODDim4ycBHCjojjDTUKGYBMGagc67xR1Dq1wpWgYXRb/LF3MlIypvujQcdwDV1hkXaaTJXDw22Rwdkc4torfJTPGNibXxZgxQL8Wu9gvlOq0b1xA+WvXlpmr01aGXNSsGZniTmS6PFS/SnxLqRpQRx8Gj9X00yyhCylpbkF4p091pgVaGw70dkts0xfIHQ3lhSfYbrLQFLc7h2Q+mf1dpM/Kr+hroDxN0BKvyoopyob1qlz3LnrR33+BmqYnMRQkv+O5EFAgsMcFV0J0XQI3Er3UXOc5eGj5sq2gc5OOY48D+LJm8KJqym4ncvfSt1538LhqSQqLVCqsTtSnU04C9ZCM4djSYLi1KYnMJMZo/5ZnQTwydPct13UhjhmX9u825EVMtuQWpKsRlQNRTElh9Nw2TAHqnDnjizaHDPpji7FezyWjI7m58Dmt3yg/1rDSbG7owLHGRIE0zY4S2AzMworj4xYAYf6ONs1w7pdi+mMaWBiDellL9Syrd61xZTvw05V8yPwCk70NpXOXQFdG X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR04MB7046.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(376014)(52116014)(1800799024)(7416014)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: c6PtHofq43AOiObIFTAQdtYFrPA5/G0Wrxv9J2PXDQ6AvLw3l0n04ad8RfaoNXKwimhL/t1uaDL4fxrhs0VOqm79QNuNJwrUNaUI+TkIqLMfI8INNSAqMzU6oiSmzfz2+x/CbmhSTRgI5vTB9jw32rMudCkndkMRIir+e+VbCrCOl38y0t6TYjApqi2ECe/yZrPwrx/uyuONxrrBaD6piHRbuMsc2S93uSldH53nwMsepwZQP7Q7O8+Ad4XslPk0+IfNxqjCJi3xn3xuVY0i7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LxquZ7575tDICuANxJ+uoStNY2WNJxFjByCS/rn16vrmC2/C5Gdm2B6PwJs2KdBg5YWDEXWcDL8il+ujFvhPB6rQU/6bZi3gCAR55Sv9JMBdlcfivCF0FsdbOZNP0W26MIyLqTwAJcuMv3atHHc0GHolU1cw9fcJvqBxpz/ZiTmHKjxeBzpNuyThhwyBflTE82e1YhmLLmdAKRaFdfJX1jum9YXOJgo9LKsFpmIKmsHa X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b119083d-76b3-4fad-3552-08dd315373b0 X-MS-Exchange-CrossTenant-AuthSource: AM7PR04MB7046.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jan 2025 08:47:45.2545 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: VTL+9G1XrVxczdB7396tOX4gYDthCsZ5J7I8iadsUNdKwX9UcUBjuYKfcADYqimY/svOYQfJ133x5/LIi3YcyA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS5PR04MB9770 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" It's ok to pass atomic check successfully if an atomic commit tries to disable the display pipeline which the connector belongs to. That is, when the crtc or the best_encoder pointers in struct drm_connector_state are NULL, drm_atomic_helper_connector_hdmi_check() should return 0. Without the check against the NULL pointers, drm_default_rgb_quant_range() called by drm_atomic_helper_connector_hdmi_check() would dereference the NULL pointer to_match in drm_match_cea_mode(). Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000 Call trace: drm_default_rgb_quant_range+0x0/0x4c (P) drm_bridge_connector_atomic_check+0x20/0x2c drm_atomic_helper_check_modeset+0x488/0xc78 drm_atomic_helper_check+0x20/0xa4 drm_atomic_check_only+0x4b8/0x984 drm_atomic_commit+0x48/0xc4 drm_framebuffer_remove+0x44c/0x530 drm_mode_rmfb_work_fn+0x7c/0xa0 process_one_work+0x150/0x294 worker_thread+0x2dc/0x3dc kthread+0x130/0x204 ret_from_fork+0x10/0x20 Fixes: 8ec116ff21a9 ("drm/display: bridge_connector: provide atomic_check for HDMI bridges") Fixes: 84e541b1e58e ("drm/sun4i: use drm_atomic_helper_connector_hdmi_check()") Fixes: 65548c8ff0ab ("drm/rockchip: inno_hdmi: Switch to HDMI connector") Signed-off-by: Liu Ying Reviewed-by: Dmitry Baryshkov --- Tested with i.MX8MP imx-lcdif. sun4i and rockchip are not tested due to no HW access. v2: * Trim backtrace in commit message. (Dmitry) * Drop timestamps from backtrace commit message. (Dmitry) * Move the necessary checks from drm_bridge_connector_atomic_check() to drm_atomic_helper_connector_hdmi_check(). (Dmitry) drivers/gpu/drm/display/drm_hdmi_state_helper.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/display/drm_hdmi_state_helper.c b/drivers/gpu/drm/display/drm_hdmi_state_helper.c index cfc2aaee1da0..daaf68b80e5f 100644 --- a/drivers/gpu/drm/display/drm_hdmi_state_helper.c +++ b/drivers/gpu/drm/display/drm_hdmi_state_helper.c @@ -503,6 +503,9 @@ int drm_atomic_helper_connector_hdmi_check(struct drm_connector *connector, connector_state_get_mode(new_conn_state); int ret; + if (!new_conn_state->crtc || !new_conn_state->best_encoder) + return 0; + new_conn_state->hdmi.is_limited_range = hdmi_is_limited_range(connector, new_conn_state); ret = hdmi_compute_config(connector, new_conn_state, mode); From patchwork Fri Jan 10 08:48:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Ying X-Patchwork-Id: 13933989 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0A04AE7719C for ; Fri, 10 Jan 2025 08:47:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8E9DA10F017; Fri, 10 Jan 2025 08:47:53 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=nxp.com header.i=@nxp.com header.b="Q6BxD4HG"; dkim-atps=neutral Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2077.outbound.protection.outlook.com [40.107.22.77]) by gabe.freedesktop.org (Postfix) with ESMTPS id 61BB110F017 for ; Fri, 10 Jan 2025 08:47:52 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=uceAWkAPOqTOSxwHtE1lC6Gn3zWHYHPy7GtA6s894Jfhf7IWou+bTbHYLxsVOvop5z9ySKk+tMlyocBqB9bzbDxkxn4nQuYWATsaqeYNKXYq5lnQrD8vUpQjkcYYlxNVdX/WKPAw+P/A9YHs+CDdHdYgtsrvzEP8YqHMDTCc24veKMc0Xz9f1J7o4d1qMJB5PiFqVciiAl/bjbZzPfSLDYIBxSkCHrltl+wVcF4VWblLVuYAUBCRihsCpwIPyoo9uWkPv/Wb5BdRHAjpxTqH8qsApKSDhDdjJ6JCg6PRGSRnV7DNBkC+4Y5TdPXNQ/Hyh7IYBN2GAEoDuQ0/OLCDSQ== 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=W+0aRxD9HX/5wghIEq45OBGh06i64y3li6G9yGCQfTQ=; b=ewd27kJNOmQG3/CTmkHdMBLBzrgPrHIyLpE7QYS66FFXQBLwfMvNwcchc1QzRC36TIdZq7LqGh1wuJngNMM6peggkKTJ1wMzCcROjCQsUaPIQsdyQlLMpKpnh0Zx5X1nOlMhTMuc++Xb1W66i29GPIENBNLvEWk29XxfqlnrAoFkDCNfdHRDQ6Z4sGstshyPzcQOIM5mgxWAy50Nh5Ss7cVKghLcfQZhDRQAMQWf6HN2tRLPiOiajk/8WuhaHq3ktbpwtfLrFyn6ElJGqUxj1ywyISuazciUqwokEJlhcPEbW6z5P8/tjEGuvjsL+Cf8l1wQNm/wbgv12q38VoezuQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=W+0aRxD9HX/5wghIEq45OBGh06i64y3li6G9yGCQfTQ=; b=Q6BxD4HGDyNJH7ItK6jhmhah4wGH3BwclpahTwwCyDuEM8Bi5LqkiEScA6apgbGkVejdMbFZILc/zGHU+d6QEe1VWfPCsZBv2P1XEkcn7i3a3zoXTBjP9Il5XzbBGY3Hmjg7jEXFLtaJno7KrMnxGkFEXJ0HKib7JdyuQRW9JsjV81l2KzLQzLyOJug2V91SP2sfZDBzVuWuCdI9Bn2xIYPlt7E/7fUTotrH2/7yvOqQ0Ai0sBF29Pn7Ap5ml06tE0/obPvXRC3Ksi6nzMuF7N2LFOzxxeNERlsQmrOSzN8P0yXOWmtHE5ymAvZGQvj3+2FUGz/ifsNepmsyWKuTBg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM7PR04MB7046.eurprd04.prod.outlook.com (2603:10a6:20b:113::22) by AS5PR04MB9770.eurprd04.prod.outlook.com (2603:10a6:20b:654::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8335.11; Fri, 10 Jan 2025 08:47:50 +0000 Received: from AM7PR04MB7046.eurprd04.prod.outlook.com ([fe80::d1ce:ea15:6648:6f90]) by AM7PR04MB7046.eurprd04.prod.outlook.com ([fe80::d1ce:ea15:6648:6f90%4]) with mapi id 15.20.8335.012; Fri, 10 Jan 2025 08:47:50 +0000 From: Liu Ying To: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: andrzej.hajda@intel.com, neil.armstrong@linaro.org, rfoss@kernel.org, Laurent.pinchart@ideasonboard.com, jonas@kwiboo.se, jernej.skrabec@gmail.com, maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com, simona@ffwll.ch, dmitry.baryshkov@linaro.org Subject: [PATCH v2 2/2] drm/tests: hdmi: Add connector disablement test Date: Fri, 10 Jan 2025 16:48:21 +0800 Message-Id: <20250110084821.3239518-3-victor.liu@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250110084821.3239518-1-victor.liu@nxp.com> References: <20250110084821.3239518-1-victor.liu@nxp.com> X-ClientProxiedBy: JH0PR01CA0186.apcprd01.prod.exchangelabs.com (2603:1096:990:75::11) To AM7PR04MB7046.eurprd04.prod.outlook.com (2603:10a6:20b:113::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM7PR04MB7046:EE_|AS5PR04MB9770:EE_ X-MS-Office365-Filtering-Correlation-Id: 8256447d-dad7-4aef-d5f7-08dd31537682 X-LD-Processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|366016|376014|52116014|1800799024|7416014|38350700014; X-Microsoft-Antispam-Message-Info: YZg5x1dKxeotAc66J1HuMxxGVu/Q7oH8dwAOm8wgZF8nsSffJBXvhhMvKlRmR/1+OBksrlqrQy2fnLxo6DtGS9C5dLkXQnuDoWKDq0+5UVHZn0FI4Jul+aFTI/HIZ2ksmGPZIzqwNmLXgqed31aJKZIUvN4bZvDpn2pBH84jZiFptcBUVbDR56qUykNeRFzuzXvMEwWvG7VSm/vADY86epSCI9WfIbzIBzMNoj8DA9ZAElAgrNKCTMWTa9iK3KLBnOjLXjbjJGWw+c2KZMOPW//Jrq4U8U8fWEMiAWU+Gmzbl8ZtRqL6SxumqTTU87in0K0RclBAR3QY+96d6Eey9e3025/aBw0F7CAlug+yzoGk5shV9HZQzKXFT/ejBThAbP6EPDZrywCwqkNEofXgzAWq4ZS9KRBVFsDrqxmPytif0S4W6X6VbeUbGLOyK9quFv7BZGW9r2whok7xLaP6Y4mLj/uOX1VJusk2cdxhOMytgV+S9MQnI0OnpbEP1DuOe1kv9LfpE5uRoNIfjAitt0Snf8tqNLmr4JecDo2dF8MpjFu4L63EwiqbN7/PtbkT5oR+Kgc9FFn8EbfpKrCKlFhuJ7RlyvEWTiM/oCSG0GMp0SnzpdF309lcBSTzRGqWZFvYHnSN6O3C0HxZWl6koMpd+FDXQ2ZelGKH4OC5RpwmxpFh7bjB4LmwSvNlEdg1c2dr4Izjn27X/0VtPFobP2ekIcanHAG5eqtnS6c45lYHrgipuVR2fJvpBVcBgwO2ISxbKxZr70OLufzEcwTq+z+WsquAzwShuRvHb5PGdoQgy73/zsf0ok3+8PwAVL7yWNEB2ktNUigDlP1V73NQdEQIKCZMy5snTcS2JfUXXlnNO809BcMcWCD5WEp6/CZsJqCdQk+wadVR+1hWMVHKHB/VmIaFV1yosXzlzvB10Cca9vFbGEVCzC1WiAsVUZxVas9G9crrtmXPfxbZ5+gz1T6E5pQndOorLExQ6DK/g+O/v/9Eh8CY/Rk4aLXT+8d9fR5cNqof7JXG64aPHNkIveGrXEIv/9olh0vFCu9Kc6vUGmVDU9AZHN82Aj8df8eY5e/Pd3ysFPmaOiNY5SNc8i5oUzRIokxcPxKitQWPC/KZIdVr+qC2+ne9yIwhvfyB4CKeSKPNgSOvfitMKMfW5zes0VfgddIqjwv3Pj7K8FSytPjrZOCUzzOL1TUnEkfwYmoVWmWSVlx3BZ36wt2w9FhbbqYj15eUrUGHhuePonwOc+1mWshj++yQvLXpVSI31dAp0VHjZXC5J4FyWeOVAQYltsJ0w0dbWnjJJZQjFBIQq4NjoZGFzGlfyjErnrwTEja4MK/t3FTYin1qTVSXcH7/uBlJoy/gNLpNK/EqjN2+hsRNx7yovBaXdD5vVd46A+ke0c7lFcTop7FnqwWyPS7vBQ86weLyhFum/z62IB5V9Tlf1xNppVi63yyDPlYJ X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM7PR04MB7046.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(376014)(52116014)(1800799024)(7416014)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ngoqXJ47kWsiOarpvTWtTaXkVzWUmYi23T9RpzYo4NWoA9bmv6ALuzciC+Poo9lsv41SdaMamOIfwspFzEHWHijBGKA5u/RLZJgw4vZpSWm7Q8iTPcG0L4LNwbFwERAM85qUdlvFqFgCh2uNc4XD+16+VMyzp972R/R5nV5tT8nFVTPWBF3hV6IVSp2X9WOuITPvBJhzPil4MLgm0SB8fBH+iEptMtn8wNRXtwRyPPtFGL6OO7g2CzbBqS4SOqluL7NUVo6MESPAhPKDfyG/WdqdswM62L3eVVtjhp+cBc9j6tHLGqUW83HuqvPZ3cTfRXkNAJ2nNEJ6+C73G8Wvfn4pX+K6MWHAd7h81YRlUsnqMeqo/TxE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ESAiQVZvCK4s7Fb/AXugI7RJrpJowSbncQzrKGpRqgg9k5wMQ156mOdI1EubDK8y0i9lBwu6LIw39JDswnyTxZTlsb1jaZ2tzwS8IRHPNYx4NDBnRFWAdUsw5sCkrnohPqjQKE X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8256447d-dad7-4aef-d5f7-08dd31537682 X-MS-Exchange-CrossTenant-AuthSource: AM7PR04MB7046.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jan 2025 08:47:49.9475 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: lULyVqKivg4clVF8Aji4VLZ5mwqDNcef9o6YYS7HenL1a6utfng0ivhUHUaMKzM5K15afnjxI5YBVp3efcVtsw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS5PR04MB9770 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Atomic check should succeed when disabling a connector. Add a test case drm_test_check_disabling_connector() to make sure of this. Suggested-by: Dmitry Baryshkov Signed-off-by: Liu Ying --- v2: * New patch to add the test case. (Dmitry) .../drm/tests/drm_hdmi_state_helper_test.c | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/drivers/gpu/drm/tests/drm_hdmi_state_helper_test.c b/drivers/gpu/drm/tests/drm_hdmi_state_helper_test.c index c3b693bb966f..8f7a39c9a1bb 100644 --- a/drivers/gpu/drm/tests/drm_hdmi_state_helper_test.c +++ b/drivers/gpu/drm/tests/drm_hdmi_state_helper_test.c @@ -1568,6 +1568,57 @@ static void drm_test_check_output_bpc_format_display_8bpc_only(struct kunit *tes KUNIT_EXPECT_EQ(test, conn_state->hdmi.output_format, HDMI_COLORSPACE_RGB); } +/* Test that atomic check succeeds when disabling a connector. */ +static void drm_test_check_disabling_connector(struct kunit *test) +{ + struct drm_atomic_helper_connector_hdmi_priv *priv; + struct drm_modeset_acquire_ctx *ctx; + struct drm_connector_state *conn_state; + struct drm_crtc_state *crtc_state; + struct drm_atomic_state *state; + struct drm_display_mode *preferred; + struct drm_connector *conn; + struct drm_device *drm; + struct drm_crtc *crtc; + int ret; + + priv = drm_kunit_helper_connector_hdmi_init(test, + BIT(HDMI_COLORSPACE_RGB), + 8); + KUNIT_ASSERT_NOT_NULL(test, priv); + + ctx = drm_kunit_helper_acquire_ctx_alloc(test); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); + + conn = &priv->connector; + preferred = find_preferred_mode(conn); + KUNIT_ASSERT_NOT_NULL(test, preferred); + + drm = &priv->drm; + crtc = priv->crtc; + ret = light_up_connector(test, drm, crtc, conn, preferred, ctx); + KUNIT_ASSERT_EQ(test, ret, 0); + + state = drm_kunit_helper_atomic_state_alloc(test, drm, ctx); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state); + + crtc_state = drm_atomic_get_crtc_state(state, crtc); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, crtc_state); + + crtc_state->active = false; + ret = drm_atomic_set_mode_for_crtc(crtc_state, NULL); + KUNIT_EXPECT_EQ(test, ret, 0); + + conn_state = drm_atomic_get_connector_state(state, conn); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, conn_state); + + ret = drm_atomic_set_crtc_for_connector(conn_state, NULL); + KUNIT_EXPECT_EQ(test, ret, 0); + + ret = drm_atomic_check_only(state); + KUNIT_ASSERT_EQ(test, ret, 0); +} + static struct kunit_case drm_atomic_helper_connector_hdmi_check_tests[] = { KUNIT_CASE(drm_test_check_broadcast_rgb_auto_cea_mode), KUNIT_CASE(drm_test_check_broadcast_rgb_auto_cea_mode_vic_1), @@ -1605,6 +1656,7 @@ static struct kunit_case drm_atomic_helper_connector_hdmi_check_tests[] = { * picked up aside from changing the BPC or mode which would * already trigger a mode change. */ + KUNIT_CASE(drm_test_check_disabling_connector), { } };