From patchwork Thu Jun 6 02:04:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13687769 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 20BD2C25B76 for ; Thu, 6 Jun 2024 02:04:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3274710E821; Thu, 6 Jun 2024 02:04:35 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="l3HekZtX"; dkim-atps=neutral Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2081.outbound.protection.outlook.com [40.107.236.81]) by gabe.freedesktop.org (Postfix) with ESMTPS id CEBF310E821; Thu, 6 Jun 2024 02:04:33 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=K4H/JnhcSUVfga0NccXX/pgqGqExEyXAKPzoB6W91zDLxVUo8bPDrvFsV6zqJ9C2oLO1AiQ7XzF51w1hXJKw/v8RKG9NdJDeEM9NsoFMJqsscC5hvbXWLQmIzU1RjKV2LnARz1SeGecAh5HD313kRj0ElposcaHCCLlDpvg7Beq03fvz8dfnaldO/8d6BLC5G1tA+q/Njza7GL7UzI6GC0QIId8O4Zw0zb20UXyD5yT0pB3liDnhLWgybaEVNgsycGcXGmmQgbfFNpHZEmlopdOHyS+ussBTx3UgTBldQk1QEyr0FsQPvphtUSL5bkrdK18B/E6Bh8DPIF0pcfGTiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=vqVbZds0SYN7rV/3MiTdSMP1NuVBe4NmYonJY7yl1fM=; b=bsUMEjCdqCCz/TvSTJUuXiT9O6uJM9QpCsz/UxW27+u1pY0HTxJf6yFxnMYBkDq/laQh9icTdBgk1UXPlgdWcxgOGjGkG2AyxO1Nfr5ofjZKaygarzMd9ynLHGthRKqqjLvihQv+MQhb4MI++A89tIACpBjM9JdIJvFmHWGRVews0jVI7Q9H5I1cb+/F2FqRLAuSlN0xZ+2rK+CX6BDI9+XdszhKZuzhJ25nsaGviOiD3hHO6KcJdGlbZGp92PaNsbdWF73jNYPLDHzd2eDPK6Y9rcKr/Zp3Sjtcc6a3wTeMgOBGGxU8Xp3gv5IyNLayD4Z4/ulWySnF34RcCU3UCQ== 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=vqVbZds0SYN7rV/3MiTdSMP1NuVBe4NmYonJY7yl1fM=; b=l3HekZtXCkds7G+WiXqTum9NJkuKVUYGjZOXXWXnFzHw/qauYBwNLmIVbi6wtR5b+nBJW3xlPSUQNOb0hZciCmf9QE08nW8nNxmtW/8kcBB6Oj7BMfW3pRuIHFCDwTaSW/1Wb2FVed1xivLyaq7xm0pmdwn+JQVx127ts6Z5wyk= Received: from CH5P221CA0020.NAMP221.PROD.OUTLOOK.COM (2603:10b6:610:1f2::11) by CY5PR12MB9055.namprd12.prod.outlook.com (2603:10b6:930:35::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.17; Thu, 6 Jun 2024 02:04:30 +0000 Received: from CH1PEPF0000AD7C.namprd04.prod.outlook.com (2603:10b6:610:1f2:cafe::cc) by CH5P221CA0020.outlook.office365.com (2603:10b6:610:1f2::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7656.17 via Frontend Transport; Thu, 6 Jun 2024 02:04:30 +0000 X-MS-Exchange-Authentication-Results: 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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH1PEPF0000AD7C.mail.protection.outlook.com (10.167.244.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7452.22 via Frontend Transport; Thu, 6 Jun 2024 02:04:30 +0000 Received: from SITE-L-T34-2.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Wed, 5 Jun 2024 21:04:27 -0500 From: Mario Limonciello To: , Simon Ser CC: Harry Wentland , Xaver Hugl , , Leo Li , Sean Paul , Mario Limonciello Subject: [PATCH v3 1/2] drm: Introduce 'power saving policy' drm property Date: Wed, 5 Jun 2024 21:04:03 -0500 Message-ID: <20240606020404.210989-2-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240606020404.210989-1-mario.limonciello@amd.com> References: <20240606020404.210989-1-mario.limonciello@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000AD7C:EE_|CY5PR12MB9055:EE_ X-MS-Office365-Filtering-Correlation-Id: b55985f8-607d-436a-8834-08dc85cd0083 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230031|376005|36860700004|82310400017|1800799015; X-Microsoft-Antispam-Message-Info: DZFgstq3+9VadGOxb+3AG/E3fuKwl/l9GdnY7p53/daXlrsYbpUAtp94o35OdUyowhvUmJ9ROdi59o2VMlC9Ev1qbgBjPsJWxaFpFtT7RSZWVfikKD+7pWpBV1YZ4tOBsaKYgAK9cYBzFf5a1Vwp17Tjlkm04nNUOBgTCdFV9/MKCiKWhdGST45mT8z2JgBzA5XNWtS/ucQwns2MgBIfZBuhn7t2lEGkd1ymsQI/vwhd+9WWvsH2w1ubCFn7yo3QyVb8Fl9ZqbjPGM5yunYNvh0odkxoJBuocNmJUemteQC86r+UD99CBxm2zBL9TjQOP7jim0UwA48V7VC56ywhIuB0uX7fdQ2vmQb+N1vKXIXoixnPPbKulhMcnvlB7QV8vyej44FAWuoxMNCs7dwQGUXZsZuXc/8ny/nnZin/JlV0FOzAV8f7W60sXDnWeMmwrptBvXEbIinAxR17SMzH9xW7ddtcp0jpM3+XaPceubv5yN2adgd5VlfAI3GY3O0UlzEMXegsSSBnDSpOc6SbQtnP+buOYZRizgsvS9FNjyDEMMda/v5JJMDJpL1lwGq73QpcivyioiOzDNjv6C6NjymVGQMUSBNbD3IYCLTO2YdGkLA0pAhpK3+OXRyH7c08Lpf6w2RqX14bf9mFOwV7OtLsdVH/dru+dPT58pJK2wrIxy92W68UV/j9fMpx36aiHDzqRYOTFLmOehNr+rpUOfK9CvPp37J0hPYLR+/E1wFb7xrxPesgJ81CSJyokqWugV3dXxXmadWie9AB5W21MiH5gTF1Eyokcy3kPDPEfo3D8KzdhwU6+5293fkqyMStGTdovTCH4OPKIk/5uI9Nw5aqNICMYbOH2iKs+YY7D2bSMJSwXYTj3j0btoKixq6y9utImM2lZA2y6QxBvAPTsebBR/9sOL0M70Q8EALWCpkSC0iX3Xf9R170mA6nImfgCFfcBdKcZscZ4KibG/IOTphBuis16JKZ3RB0g52BxR8XnJDwh8Dli8dtWKoL4CFljlzSTZR7OEAUbkpcm+5K7GePkbO1DO6TYRSvsiDEputu+oFLJ70/iAQN25qKD7WxjREzXLFcL4tVHm+WMtfHLhOoFUmXhwk7WD7K87lgjW1MNKEe8/vfi1jlDarjhREl/mKMqCTU0N9j9n0U/KbU4lnlK6iqka4iLUH0b5jxzfLB+1zOvatkzveHtabWMU5YvkWGCLS0oNJfbFKyxglLdvTBi0O9uvlVxA8VfSqRbZjV3WMLFUhjwlrwgx+iJnB7hRReEc4z/rafMAd9IPhokBeyUCC1WR1ahrSM3eNRVK5pRjwWAmzlu/9hIpoav04ITo17mQuY2ba/6sO0ASQhDaXkQnHT3BDMiwVIZZDTlZ0ZR/ve2mWhMCEZaowBfbBV X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(376005)(36860700004)(82310400017)(1800799015); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jun 2024 02:04:30.2396 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b55985f8-607d-436a-8834-08dc85cd0083 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000AD7C.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB9055 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" The `power saving policy` DRM property is an optional property that can be added to a connector by a driver. This property is for compositors to indicate intent of policy of whether a driver can use power saving features that may compromise the experience intended by the compositor. Acked-by: Leo Li Signed-off-by: Mario Limonciello --- v2->v3: * Add tag --- drivers/gpu/drm/drm_connector.c | 46 +++++++++++++++++++++++++++++++++ include/drm/drm_connector.h | 2 ++ include/drm/drm_mode_config.h | 5 ++++ include/uapi/drm/drm_mode.h | 7 +++++ 4 files changed, 60 insertions(+) diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c index 4d2df7f64dc5..088a5874c7a4 100644 --- a/drivers/gpu/drm/drm_connector.c +++ b/drivers/gpu/drm/drm_connector.c @@ -961,6 +961,11 @@ static const struct drm_prop_enum_list drm_scaling_mode_enum_list[] = { { DRM_MODE_SCALE_ASPECT, "Full aspect" }, }; +static const struct drm_prop_enum_list drm_power_saving_policy_enum_list[] = { + { __builtin_ffs(DRM_MODE_REQUIRE_COLOR_ACCURACY) - 1, "Require color accuracy" }, + { __builtin_ffs(DRM_MODE_REQUIRE_LOW_LATENCY) - 1, "Require low latency" }, +}; + static const struct drm_prop_enum_list drm_aspect_ratio_enum_list[] = { { DRM_MODE_PICTURE_ASPECT_NONE, "Automatic" }, { DRM_MODE_PICTURE_ASPECT_4_3, "4:3" }, @@ -1499,6 +1504,16 @@ static const u32 dp_colorspaces = * * Drivers can set up these properties by calling * drm_mode_create_tv_margin_properties(). + * power saving policy: + * This property is used to set the power saving policy for the connector. + * This property is populated with a bitmask of optional requirements set + * by the drm master for the drm driver to respect: + * - "Require color accuracy": Disable power saving features that will + * affect color fidelity. + * For example: Hardware assisted backlight modulation. + * - "Require low latency": Disable power saving features that will + * affect latency. + * For example: Panel self refresh (PSR) */ int drm_connector_create_standard_properties(struct drm_device *dev) @@ -1963,6 +1978,37 @@ int drm_mode_create_scaling_mode_property(struct drm_device *dev) } EXPORT_SYMBOL(drm_mode_create_scaling_mode_property); +/** + * drm_mode_create_power_saving_policy_property - create power saving policy property + * @dev: DRM device + * @supported_policies: bitmask of supported power saving policies + * + * Called by a driver the first time it's needed, must be attached to desired + * connectors. + * + * Returns: %0 + */ +int drm_mode_create_power_saving_policy_property(struct drm_device *dev, + uint64_t supported_policies) +{ + struct drm_property *power_saving; + + if (dev->mode_config.power_saving_policy) + return 0; + WARN_ON((supported_policies & DRM_MODE_POWER_SAVING_POLICY_ALL) == 0); + + power_saving = + drm_property_create_bitmask(dev, 0, "power saving policy", + drm_power_saving_policy_enum_list, + ARRAY_SIZE(drm_power_saving_policy_enum_list), + supported_policies); + + dev->mode_config.power_saving_policy = power_saving; + + return 0; +} +EXPORT_SYMBOL(drm_mode_create_power_saving_policy_property); + /** * DOC: Variable refresh properties * diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index fe88d7fc6b8f..b0ec2ec48de7 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -2025,6 +2025,8 @@ int drm_mode_create_dp_colorspace_property(struct drm_connector *connector, u32 supported_colorspaces); int drm_mode_create_content_type_property(struct drm_device *dev); int drm_mode_create_suggested_offset_properties(struct drm_device *dev); +int drm_mode_create_power_saving_policy_property(struct drm_device *dev, + uint64_t supported_policies); int drm_connector_set_path_property(struct drm_connector *connector, const char *path); diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h index 8de3c9a5f61b..eefcbf6c5377 100644 --- a/include/drm/drm_mode_config.h +++ b/include/drm/drm_mode_config.h @@ -969,6 +969,11 @@ struct drm_mode_config { */ struct drm_atomic_state *suspend_state; + /** + * @power_saving_policy: bitmask for power saving policy requests. + */ + struct drm_property *power_saving_policy; + const struct drm_mode_config_helper_funcs *helper_private; }; diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h index 1ca5c7e418fd..558a306a23a7 100644 --- a/include/uapi/drm/drm_mode.h +++ b/include/uapi/drm/drm_mode.h @@ -152,6 +152,13 @@ extern "C" { #define DRM_MODE_SCALE_CENTER 2 /* Centered, no scaling */ #define DRM_MODE_SCALE_ASPECT 3 /* Full screen, preserve aspect */ +/* power saving policy options */ +#define DRM_MODE_REQUIRE_COLOR_ACCURACY BIT(0) /* Compositor requires color accuracy */ +#define DRM_MODE_REQUIRE_LOW_LATENCY BIT(1) /* Compositor requires low latency */ + +#define DRM_MODE_POWER_SAVING_POLICY_ALL (DRM_MODE_REQUIRE_COLOR_ACCURACY |\ + DRM_MODE_REQUIRE_LOW_LATENCY) + /* Dithering mode options */ #define DRM_MODE_DITHERING_OFF 0 #define DRM_MODE_DITHERING_ON 1 From patchwork Thu Jun 6 02:04:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13687771 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 AE91CC25B76 for ; Thu, 6 Jun 2024 02:04:45 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id ED39B10E832; Thu, 6 Jun 2024 02:04:38 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="QO+2HBQx"; dkim-atps=neutral Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2050.outbound.protection.outlook.com [40.107.237.50]) by gabe.freedesktop.org (Postfix) with ESMTPS id CAB3010E832; Thu, 6 Jun 2024 02:04:36 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QRZjtODQL5C/PIs4cawDTU32PwY+QIXYgnWA3p1j7tDCC1q/qoJ39I0MLCimqnBLrWqmL0Hp7BY/8KwoF1D7DGVYkHcFiFme1zK99IKnGsKi1KDzmSDvPq4HJPx8GT8jjW1xBs6bjxgjamsdII58rICfHAjAc1r1ZuIeOWEMEz+FxdGuSqsbmL6b21a0Eg9Yd/C4DqI/5ySTPV35HczeOTlW/MajOXUJvBC6IsqjqH0iraqkhYaKxetOPGvE6IdJk+KULg+NtxDkclAaRhRr3PcgCDSjS59yvucdAxlZxH9A1tXAhTziYIyKFdvtNDw/0DyBmfEy9pk7xmyTpi9R3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=OFfrD3VZ/pK39SFn8HivHTbLysNB2wiHluJDbemggo4=; b=RUWk0HUd79lzFkvV0lf82oMvOv3tHMfL/6FoRyYXZtGwcUvdVMzsyIvj4canF7ioHBzpPGk5ZqD1LQh55rNgWT67Jh7VCUBJ0rELusJ3WPiW3NPDPcC4ZP46HUzz8fpfNUPzlqdntKplj0KfwzCyM+N8ZtwynK18YQqGj+AtSW8NQxi8wycnghNgK4EsWt6LrhW1es2BbPDnPSPpCfkL/V3HJ4ymSx2vmvRphj8rojb3XLSTNn5omU3JY6TC/wcVhhqds9fcpspBZccFvPvS5qj3GXarBmIXwikCJv8oUlR8rA3Mq16wFWtx5P+c9h/bxqhIcpIA/xy0WIWym1t4RA== 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=OFfrD3VZ/pK39SFn8HivHTbLysNB2wiHluJDbemggo4=; b=QO+2HBQx4YaMIN9ykeE86AnNCASXQpEfyqfL5QwV1nvKXcwpIX3i896LtiVu+DUoIspeu92MxNCkNoDsY/gjv1fBe0BlTMhjaOR1OJu9e6ClLTKIzN2nd5mYjlXftBzZ3kwDGQdIjFtCIadw6ndrR53txXLyG0+QCQ3HXk8FN0k= Received: from CH0P221CA0020.NAMP221.PROD.OUTLOOK.COM (2603:10b6:610:11c::21) by SA3PR12MB9105.namprd12.prod.outlook.com (2603:10b6:806:382::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.31; Thu, 6 Jun 2024 02:04:31 +0000 Received: from CH1PEPF0000AD81.namprd04.prod.outlook.com (2603:10b6:610:11c:cafe::70) by CH0P221CA0020.outlook.office365.com (2603:10b6:610:11c::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7656.18 via Frontend Transport; Thu, 6 Jun 2024 02:04:31 +0000 X-MS-Exchange-Authentication-Results: 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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CH1PEPF0000AD81.mail.protection.outlook.com (10.167.244.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7452.22 via Frontend Transport; Thu, 6 Jun 2024 02:04:31 +0000 Received: from SITE-L-T34-2.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Wed, 5 Jun 2024 21:04:29 -0500 From: Mario Limonciello To: , Simon Ser CC: Harry Wentland , Xaver Hugl , , Leo Li , Sean Paul , Mario Limonciello Subject: [PATCH v3 2/2] drm/amd: Add power_saving_policy drm property to eDP connectors Date: Wed, 5 Jun 2024 21:04:04 -0500 Message-ID: <20240606020404.210989-3-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240606020404.210989-1-mario.limonciello@amd.com> References: <20240606020404.210989-1-mario.limonciello@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH1PEPF0000AD81:EE_|SA3PR12MB9105:EE_ X-MS-Office365-Filtering-Correlation-Id: d2cdc1cd-2333-4353-5205-08dc85cd0158 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230031|1800799015|36860700004|376005|82310400017; X-Microsoft-Antispam-Message-Info: y+TkpjFRUaFJgnyTVvAcCivXJtlfN8bWEakklygTRhWx6jgnxmkfFC0Wxgt+FUMJi02mGFqokNbPqIF5TTkABGCbYXCfjWvI27VNONzqoEJCvYXKfqPFJSmYWG6lxki90zZu5RsjsOu0ueQXlhkqEpjda1ADay3Jt7cRLdATC4BdKhe1to7NTUHbPQGomuvlRp+IN7dQNj9gK9rMrR5kmsG9BJf1sfUopFDoqJatnGzsohUi+YZOuST4L18vBZYC/W5IPT8BAC5iXZclg2Nw7uEFAQcp/+UuoQDOjQvKNSe8mRINQiApdZkA5m+IH5Xa8dfmxSWIAuU9lv9xOgIuQUPfcTYb9f4SnfOgkDyg0XrA24psyIdKPq8ZhbYcfLRT4IoEnBKWaqF4mieBPPqGoUDJ+LQKfMVjVR7K7pu0e3QkbqEa1RYDhy1MMP5RHPsvKqSHoy2Bkgveb0Dj//fLV1PvSiLzNlHXF6QfywuT+dN2HqDL/Zi7S3leGtU47d6V+A8pRrLGZUsuCw8LkLkG5lVkk+r2fDv+neSZ5j9RTe4/tafgessmztqrgyZGlBi0FVNvUz8CDZntWyJKUOYYjwYravhwCT9/P6adZqpq3K2zGutMrM+x/rMxIz9YPMiKVZZK/OIup474Urh/OMknNdfaHqysuqLX7zcBq5qGktsox+077bXD16+TJOAPazzBsg1IfWDQYRIYTyUCpW6LMR+eSTvSGmt3WvUKgfwLv8GZ7XsiyxZ2KmdzGmwbln9ny3sHZ+0zzSeOwSusizGBPtrmNoWEW8NJFplGJh9BDdTBP3FQKXM/qlWlP4ScoqZMtJxTlpV03RMPBg87tbmg3V6wlUXG76zTF6rF1yb1Ws/yFwFj1VPxKkUY8i/XxdAQHw+7/qgc+JUkgKVRcYplh0egy2npZcR1c0FSxdjQRLBgidCtsXfQA2oWAKhk8vWXcCCmN1KSYuN0PLCWCe5SW+4ijuSaRcsTbrIecIecspzoENk6OqyzJ9/tjr767mC6CvQSrq0aOVEgizRZF3qCKhpK0/sI5EQutkzH17oZC7oF05SfgPIYCmI5xYBtZ1Pi4RXg3iYdz1VDvyBvfDe5vvY/Rf8x7+kozvDhfGzBC1ge1CU1A9xiQ81bmE4zea6c7lNaeJMQb9jmdudzGS6e/4rGd5J67hi3FkOJ7UBIol3mdaKOnecGVPPIg+TAQ1Ty3kqL35z0VjNpDoroOmuXZm9B8XePniPp/wvRHlXOCLkrXs+O6Xrx0JJUSyvPC497u8f2vs2F8R6DDK0zNUxzKWGsxAKVoqjIIUcLabZuIA8KpltLDhcgBM/RGNReMYuYcXw+Mgz2SC3pFsc5F2IsQ6WfMePCNByABfuhnCbfb0s/BcclYuf+NIZCIeqeuWwM4zD+IbKfCSHN6Dc4w0qI0Q== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(1800799015)(36860700004)(376005)(82310400017); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jun 2024 02:04:31.6185 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d2cdc1cd-2333-4353-5205-08dc85cd0158 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000AD81.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB9105 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" When the `power_saving_policy` property is set to bit mask "Require color accuracy" ABM should be disabled immediately and any requests by sysfs to update will return an -EBUSY error. When the `power_saving_policy` property is set to bit mask "Require low latency" PSR should be disabled. When the property is restored to an empty bit mask the previous value of ABM and pSR will be restored. Signed-off-by: Mario Limonciello Reviewed-by: Leo Li --- v2->v3: * Use `disallow_edp_enter_psr` instead * Drop case in dm_update_crtc_state() --- drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 4 ++ .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 50 +++++++++++++++++-- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h | 2 + 3 files changed, 51 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c index 3ecc7ef95172..cfb5220cf182 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c @@ -1350,6 +1350,10 @@ int amdgpu_display_modeset_create_props(struct amdgpu_device *adev) "dither", amdgpu_dither_enum_list, sz); + if (adev->dc_enabled) + drm_mode_create_power_saving_policy_property(adev_to_drm(adev), + DRM_MODE_POWER_SAVING_POLICY_ALL); + return 0; } diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c index f1d67c6f4b98..5fd7210b2479 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -6436,6 +6436,13 @@ int amdgpu_dm_connector_atomic_set_property(struct drm_connector *connector, } else if (property == adev->mode_info.underscan_property) { dm_new_state->underscan_enable = val; ret = 0; + } else if (property == dev->mode_config.power_saving_policy) { + dm_new_state->abm_forbidden = val & DRM_MODE_REQUIRE_COLOR_ACCURACY; + dm_new_state->abm_level = (dm_new_state->abm_forbidden || !amdgpu_dm_abm_level) ? + ABM_LEVEL_IMMEDIATE_DISABLE : + amdgpu_dm_abm_level; + dm_new_state->psr_forbidden = val & DRM_MODE_REQUIRE_LOW_LATENCY; + ret = 0; } return ret; @@ -6478,6 +6485,13 @@ int amdgpu_dm_connector_atomic_get_property(struct drm_connector *connector, } else if (property == adev->mode_info.underscan_property) { *val = dm_state->underscan_enable; ret = 0; + } else if (property == dev->mode_config.power_saving_policy) { + *val = 0; + if (dm_state->psr_forbidden) + *val |= DRM_MODE_REQUIRE_LOW_LATENCY; + if (dm_state->abm_forbidden) + *val |= DRM_MODE_REQUIRE_COLOR_ACCURACY; + ret = 0; } return ret; @@ -6504,9 +6518,12 @@ static ssize_t panel_power_savings_show(struct device *device, u8 val; drm_modeset_lock(&dev->mode_config.connection_mutex, NULL); - val = to_dm_connector_state(connector->state)->abm_level == - ABM_LEVEL_IMMEDIATE_DISABLE ? 0 : - to_dm_connector_state(connector->state)->abm_level; + if (to_dm_connector_state(connector->state)->abm_forbidden) + val = 0; + else + val = to_dm_connector_state(connector->state)->abm_level == + ABM_LEVEL_IMMEDIATE_DISABLE ? 0 : + to_dm_connector_state(connector->state)->abm_level; drm_modeset_unlock(&dev->mode_config.connection_mutex); return sysfs_emit(buf, "%u\n", val); @@ -6530,10 +6547,16 @@ static ssize_t panel_power_savings_store(struct device *device, return -EINVAL; drm_modeset_lock(&dev->mode_config.connection_mutex, NULL); - to_dm_connector_state(connector->state)->abm_level = val ?: - ABM_LEVEL_IMMEDIATE_DISABLE; + if (to_dm_connector_state(connector->state)->abm_forbidden) + ret = -EBUSY; + else + to_dm_connector_state(connector->state)->abm_level = val ?: + ABM_LEVEL_IMMEDIATE_DISABLE; drm_modeset_unlock(&dev->mode_config.connection_mutex); + if (ret) + return ret; + drm_kms_helper_hotplug_event(dev); return count; @@ -7704,6 +7727,13 @@ void amdgpu_dm_connector_init_helper(struct amdgpu_display_manager *dm, aconnector->base.state->max_bpc = 16; aconnector->base.state->max_requested_bpc = aconnector->base.state->max_bpc; + if (connector_type == DRM_MODE_CONNECTOR_eDP && + (dc_is_dmcu_initialized(adev->dm.dc) || + adev->dm.dc->ctx->dmub_srv)) { + drm_object_attach_property(&aconnector->base.base, + dm->ddev->mode_config.power_saving_policy, 0); + } + if (connector_type == DRM_MODE_CONNECTOR_HDMIA) { /* Content Type is currently only implemented for HDMI. */ drm_connector_attach_content_type_property(&aconnector->base); @@ -9307,6 +9337,7 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state) for_each_oldnew_connector_in_state(state, connector, old_con_state, new_con_state, i) { struct dm_connector_state *dm_new_con_state = to_dm_connector_state(new_con_state); struct dm_connector_state *dm_old_con_state = to_dm_connector_state(old_con_state); + struct amdgpu_dm_connector *aconnector = to_amdgpu_dm_connector(connector); struct amdgpu_crtc *acrtc = to_amdgpu_crtc(dm_new_con_state->base.crtc); struct dc_surface_update *dummy_updates; struct dc_stream_update stream_update; @@ -9360,6 +9391,15 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state) stream_update.hdr_static_metadata = &hdr_packet; } + aconnector->disallow_edp_enter_psr = dm_new_con_state->psr_forbidden; + + /* immediately disable PSR if disallowed */ + if (aconnector->disallow_edp_enter_psr) { + mutex_lock(&dm->dc_lock); + amdgpu_dm_psr_disable(dm_new_crtc_state->stream); + mutex_unlock(&dm->dc_lock); + } + status = dc_stream_get_status(dm_new_crtc_state->stream); if (WARN_ON(!status)) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h index 09519b7abf67..b246e82f5b0d 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h @@ -873,6 +873,8 @@ struct dm_connector_state { bool underscan_enable; bool freesync_capable; bool update_hdcp; + bool abm_forbidden; + bool psr_forbidden; uint8_t abm_level; int vcpi_slots; uint64_t pbn;