From patchwork Mon Jul 8 20:29:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hamza Mahfooz X-Patchwork-Id: 13727024 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 BA085C3DA42 for ; Mon, 8 Jul 2024 20:29:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5405C10E408; Mon, 8 Jul 2024 20:29:41 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="1RFt6xzX"; dkim-atps=neutral Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2049.outbound.protection.outlook.com [40.107.220.49]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8AE2410E3FC; Mon, 8 Jul 2024 20:29:40 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LPg97p5hSYvkydgm9am2+M3mqpA9D9Bi+TR9u6/CykYSonAJh3KJ4SsOo4vikHDG4KFOTJltUeCrLPHfIr8pXf8hBTghiYuIGLAsssNAbTD5IveL2L8/wMo3a+1ln1lAd0Lh8Q2H4r8TcVAvojG1+dcTkL4F0YtbSDG0hu83BshlbtWvMv3NtRhHFkF3/1zt4Ux1Pa3OWAmIGlzkBi2vvF0eJBaEtE0myWhB4TK70ZeSrgU61kNk9WNKoKzKdxcA4FOEBh1zfqO8bGi9gU1qmPRDRZ95LUlystvmWCmZv6/C1U/RyXVmel9tgkmnbfQO9Qkq7gxFgaa2ezLekUZu6A== 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=wOn7OGUFtmR3yQYfZeCPz87TVtKGjgQWgsqjmz6YvK4=; b=EAlCPGnKeinDy3ld64ADTzY4xu77CsHMpSlwEpMV2pUiM3h8cbfyfaWZqB+hPXvHXY9NW06wYfNi5KUiabQuDCm9TB9422WdFioOVyOWOFL4OPnz3fNnjcUu2lgqtXZdYlVk0F9VnYUyM5BzxbJCnDZyk3HaOtQ13A5DoUthNVC70Efv548E/oWLvgSFf7q1U/SyGdUZqzOOfED60/vQ3e0Hz6HRxNAAe4SPYpbXNPgEYymQl47/amofvVfefiQE699SHodulfuM2NwS0LRygQMavobJ25g29B5HN/a+qeecHQflvZcJkfjShprvvFkpb7tbeA4noIxFzM3H5QeWRw== 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=wOn7OGUFtmR3yQYfZeCPz87TVtKGjgQWgsqjmz6YvK4=; b=1RFt6xzX2FQBV0CCcF9QuwPZdR5FqWl4JIyYln6NKM8vNlP22U6mwIXlUR91RHbHujIh2zGuqaQX+kbXa2Kwt9e+0v1XY//SWFPZju29mA6YR8JyrlznJw0IK+ODwvTG7e85upgPsidk+4dR5PXIPgh4+TepPy2qx/pxraF1aoY= Received: from BN0PR04CA0040.namprd04.prod.outlook.com (2603:10b6:408:e8::15) by CH3PR12MB8657.namprd12.prod.outlook.com (2603:10b6:610:172::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.35; Mon, 8 Jul 2024 20:29:35 +0000 Received: from BN3PEPF0000B077.namprd04.prod.outlook.com (2603:10b6:408:e8:cafe::c1) by BN0PR04CA0040.outlook.office365.com (2603:10b6:408:e8::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.36 via Frontend Transport; Mon, 8 Jul 2024 20:29:35 +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 BN3PEPF0000B077.mail.protection.outlook.com (10.167.243.122) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7762.17 via Frontend Transport; Mon, 8 Jul 2024 20:29:34 +0000 Received: from hamza-pc.localhost (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.39; Mon, 8 Jul 2024 15:29:32 -0500 From: Hamza Mahfooz To: CC: Harry Wentland , Leo Li , Rodrigo Siqueira , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , Maxime Ripard , "Thomas Zimmermann" , Alex Hung , Wayne Lin , Mario Limonciello , , Hamza Mahfooz Subject: [PATCH 1/2] drm/vblank: allow dynamic per-crtc vblank off delay Date: Mon, 8 Jul 2024 16:29:06 -0400 Message-ID: <20240708202907.383917-1-hamza.mahfooz@amd.com> X-Mailer: git-send-email 2.45.1 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: BN3PEPF0000B077:EE_|CH3PR12MB8657:EE_ X-MS-Office365-Filtering-Correlation-Id: 3a77c423-fd92-4514-a183-08dc9f8cae64 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|376014|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: +WXuojlIl3VM5J61XCNjNp3fvvJgKT8+zkwH0J2ps1UM8T0c+TI/9stPNAS6EUdWfk4CwDARPKv7UL/jF6sJfKAoTCL5u9CfIFuxkwRtIBfajkKW66zIWSyjjBRCntx+r+8bQk2CVMJ/qhZF0dbSqAi/DUSSGzgeFrMhu4O6ulnXHbmWKM8hzslLQuYgDdWzXDYsXdODZZ64gC+AuKeEG9SN55Yv6boW3uJQ0XIxCJDVtjridcTz0xVvH4xiXANTY9IM9Xn5KLGtWd2V0zT0CFESeL688ajzvkBioSkE3Fi+ZIKaK6jsIxkoKRNDfkCnSVPfckzenA/iLThVdclEvhqBP7XJ3baYJk1xVPZSmYvgVIv5YQ1qyOpwSuO4recbFFgT67vxBbMnfaWg05YkCfBg+LHqac+mzofbYY3qpU/U+sS3m0RLoddTzdm8LVXWdgiUoKCNBY9i/grZkns9kehg1qus3zqSlFFGToTOr5hNQ6HsHzXGAQZukZtUbJsevLqkWULnr05oadRO1z8uf+tB6urZxHwMCBCd+6AWMVzJdlvjURW42Wyquch9BgR4dMvuvz9axzCHxksewYLPwm9x1YD/e1WH/NNa6sRA6QTh/y1MA1aITIFH15SibV39PbAENbLtxQNuH51JXr3Km0w4sXjSukTLjwqJ6VvonQeOY9mJcQnlthprLFUp9ojdVL6G0qS/d+wh/E065z5qxs2O2mC6Sydga6IDyx2qR1fpdvkjo7uWk/vRsZ7JFV7S4Cg1hzU8ODdlII9ktmityN/FWrPWe9yueaI+a3AEBaLtqIsQAw/8DBRfny0505bTTmlqGKquGls5ou41GkLL8IMW7tGtvGN3br+pKSKnlqYCOqkwDfOOv5Q0i5/VwsfTgAmHiAT2geVDRLoCPZD5DhVPljkqr+B2tesgHj8S7eWjE8OJFvGdizGG5exIioljFc6EwCj68mA3Snj/y8hhsnU6QAqjA7dwGvHuAAIqKor8i/AeuXbuE3I+2zfoplcbY9hjYiNhmxzdHouKc7MKsXo3Ny/VwXvHB2SWb6d9K7sF2ye27FixpZ2upLBnVCpM/3QkEhfSThgrReioAhJXEzQ4mBvHgXNZxkfpg+Al7ythesK4g08k22x4gsMukP3dDzK0gWsPOvUVaP8b41nwpbajxHM5NNDOmeUh+aqwIXR1Nm4/1j51tLEihIfGX9VAtvcXq+Jl2XrsB90R2F3zI/dPU2eDOZIe9jVVkTV5JFkQy9k7yjLdircPx45+wbapXWu4LxFUec1MIVZ8kb31hiYTOZtebQeQpqDPu+vlhA+ePkPeuj7635wljicHT7P3nfhHrYGQQwnXZ4qpI3OOSLamfIT/VjINdS8I4tWKLIKUSTahQO3OL4L10XqcvTSTAr2teyntc/9tFriXiWNlczxG4/vOLLFf1jW4GktxCQqzuxFticcXioMDFjMn/HNy 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:(13230040)(36860700013)(376014)(1800799024)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jul 2024 20:29:34.7961 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3a77c423-fd92-4514-a183-08dc9f8cae64 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: BN3PEPF0000B077.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8657 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" We would like to be able to adjust the vblank off delay dynamically for a given CRTC. Since, it will allow drivers to apply static screen optimizations more quickly and consequently allow users to benefit more so from the power savings afforded by the aforementioned optimizations. Signed-off-by: Hamza Mahfooz --- drivers/gpu/drm/drm_vblank.c | 31 ++++++++++++++++++++++++++----- include/drm/drm_vblank.h | 7 +++++++ 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c index 702a12bc93bd..4f475131a092 100644 --- a/drivers/gpu/drm/drm_vblank.c +++ b/drivers/gpu/drm/drm_vblank.c @@ -529,6 +529,7 @@ int drm_vblank_init(struct drm_device *dev, unsigned int num_crtcs) vblank->dev = dev; vblank->pipe = i; + vblank->offdelay_ms = drm_vblank_offdelay; init_waitqueue_head(&vblank->queue); timer_setup(&vblank->disable_timer, vblank_disable_fn, 0); seqlock_init(&vblank->seqlock); @@ -1229,6 +1230,7 @@ EXPORT_SYMBOL(drm_crtc_vblank_get); void drm_vblank_put(struct drm_device *dev, unsigned int pipe) { struct drm_vblank_crtc *vblank = &dev->vblank[pipe]; + int vblank_offdelay = vblank->offdelay_ms; if (drm_WARN_ON(dev, pipe >= dev->num_crtcs)) return; @@ -1238,13 +1240,13 @@ void drm_vblank_put(struct drm_device *dev, unsigned int pipe) /* Last user schedules interrupt disable */ if (atomic_dec_and_test(&vblank->refcount)) { - if (drm_vblank_offdelay == 0) + if (!vblank_offdelay) return; - else if (drm_vblank_offdelay < 0) + else if (vblank_offdelay < 0) vblank_disable_fn(&vblank->disable_timer); else if (!dev->vblank_disable_immediate) mod_timer(&vblank->disable_timer, - jiffies + ((drm_vblank_offdelay * HZ)/1000)); + jiffies + ((vblank_offdelay * HZ) / 1000)); } } @@ -1455,6 +1457,25 @@ void drm_crtc_set_max_vblank_count(struct drm_crtc *crtc, } EXPORT_SYMBOL(drm_crtc_set_max_vblank_count); +/** + * drm_crtc_set_vblank_offdelay - configure the vblank off delay value + * @crtc: CRTC in question + * @offdelay: off delay value + * + * If used, must be called before drm_vblank_on(). + */ +void drm_crtc_set_vblank_offdelay(struct drm_crtc *crtc, int offdelay) +{ + struct drm_device *dev = crtc->dev; + unsigned int pipe = drm_crtc_index(crtc); + struct drm_vblank_crtc *vblank = &dev->vblank[pipe]; + + drm_WARN_ON(dev, dev->vblank_disable_immediate); + + vblank->offdelay_ms = offdelay; +} +EXPORT_SYMBOL(drm_crtc_set_vblank_offdelay); + /** * drm_crtc_vblank_on - enable vblank events on a CRTC * @crtc: CRTC in question @@ -1490,7 +1511,7 @@ void drm_crtc_vblank_on(struct drm_crtc *crtc) * re-enable interrupts if there are users left, or the * user wishes vblank interrupts to be enabled all the time. */ - if (atomic_read(&vblank->refcount) != 0 || drm_vblank_offdelay == 0) + if (atomic_read(&vblank->refcount) != 0 || !vblank->offdelay_ms) drm_WARN_ON(dev, drm_vblank_enable(dev, pipe)); spin_unlock_irq(&dev->vbl_lock); } @@ -1909,7 +1930,7 @@ bool drm_handle_vblank(struct drm_device *dev, unsigned int pipe) * drm_handle_vblank_events) so that the timestamp is always accurate. */ disable_irq = (dev->vblank_disable_immediate && - drm_vblank_offdelay > 0 && + vblank->offdelay_ms > 0 && !atomic_read(&vblank->refcount)); drm_handle_vblank_events(dev, pipe); diff --git a/include/drm/drm_vblank.h b/include/drm/drm_vblank.h index 7f3957943dd1..f92f28b816af 100644 --- a/include/drm/drm_vblank.h +++ b/include/drm/drm_vblank.h @@ -187,6 +187,12 @@ struct drm_vblank_crtc { */ int linedur_ns; + /** + * @offdelay_ms: Vblank off delay in ms, used to determine how long + * @disable_timer waits before disabling. + */ + int offdelay_ms; + /** * @hwmode: * @@ -255,6 +261,7 @@ void drm_calc_timestamping_constants(struct drm_crtc *crtc, wait_queue_head_t *drm_crtc_vblank_waitqueue(struct drm_crtc *crtc); void drm_crtc_set_max_vblank_count(struct drm_crtc *crtc, u32 max_vblank_count); +void drm_crtc_set_vblank_offdelay(struct drm_crtc *crtc, int offdelay); /* * Helpers for struct drm_crtc_funcs From patchwork Mon Jul 8 20:29:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hamza Mahfooz X-Patchwork-Id: 13727025 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 F011AC3DA41 for ; Mon, 8 Jul 2024 20:29:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 43DE410E40F; Mon, 8 Jul 2024 20:29:42 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="nvM6vIwG"; dkim-atps=neutral Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2080.outbound.protection.outlook.com [40.107.237.80]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8987710E40C; Mon, 8 Jul 2024 20:29:41 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NqViuHdvZjrS25I84XL2NKN+XDCc553JOeBtfVBjjdB0UMW3fM9JMcil+HeICUcDQb2pjDBcYgd/OxGl7FOqExoNcuCxgKguj6dV1OtK3h6aOPDV4+0+UgDSY8E6vdHUkGoyKhCb7nUxbVyAVTYz15MR3NkooocX3/RUKSZ9Hk2b5dplUHzKMl0U8h/sNtKYufsfl9CGuuFuuURpoCqr7MKNXo9UI5Iizzz4oTqeUW0rYoO17bs6maqnVuFKJUrK77eIk9/WmW0PMffLQ38gGoGhNGGHWLmbCF0HYSQwsObH+EfjE7Bs7cqfMV5Wi4W6h2+kc0LQR7KpbEcvG9bdYQ== 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=XIlH7fda8DVA/8CuDVAlsl6a9iCsX0SToxk1IZvCgcc=; b=aqfpj3CerMGkuPBjOzmJJer1+VNF9Zuu060ACAQkhJNw7QGE4luw/ghAVYh7MbR98skYqIi09ChFSvl/gaMtBeJ/+7kzA+zHMTWNchCVwYxLykecuiRVCCnEvj9HBcTWshdRHnFJBo5wwMFb4/BAPQfx1tUPsvqhzX3WVmvA8JTBlwYL/BSzbF4hnWCPyZCLqqkil6X4sNLDVHEE/Wi2skHwrD6RFtkrcBmnxm2+kmp8Vdxpp1qeaEuicv0yM/If4h1iIPjv54AExbR7lXiplkhu/A9i+oCVn0wd+C2a0HBEyU/tkZv4jxYv1gni3qSf1JNhZ3OaO8CllqNNJNcjvg== 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=XIlH7fda8DVA/8CuDVAlsl6a9iCsX0SToxk1IZvCgcc=; b=nvM6vIwGp/+jE0chPWfmuSxe+pNtBuEQEleKlS1W1BGwe2Oz2uyKlar+SpB1AVW+nFANPID4EXunK9rPX/aR2+t2xlaBCZ0ducswZbPMPpJ2UIuZEgcqvqrDn3hE/7SlL6uiqfpu77AACaO6hsjDTLRPKxEtJ4s76GG6lI3mKHg= Received: from BN0PR04CA0050.namprd04.prod.outlook.com (2603:10b6:408:e8::25) by MN6PR12MB8589.namprd12.prod.outlook.com (2603:10b6:208:47d::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.35; Mon, 8 Jul 2024 20:29:36 +0000 Received: from BN3PEPF0000B077.namprd04.prod.outlook.com (2603:10b6:408:e8:cafe::e1) by BN0PR04CA0050.outlook.office365.com (2603:10b6:408:e8::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.36 via Frontend Transport; Mon, 8 Jul 2024 20:29:36 +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 BN3PEPF0000B077.mail.protection.outlook.com (10.167.243.122) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7762.17 via Frontend Transport; Mon, 8 Jul 2024 20:29:35 +0000 Received: from hamza-pc.localhost (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.39; Mon, 8 Jul 2024 15:29:33 -0500 From: Hamza Mahfooz To: CC: Harry Wentland , Leo Li , Rodrigo Siqueira , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , Maxime Ripard , "Thomas Zimmermann" , Alex Hung , Wayne Lin , Mario Limonciello , , Hamza Mahfooz Subject: [PATCH 2/2] drm/amd/display: use drm_crtc_set_vblank_offdelay() Date: Mon, 8 Jul 2024 16:29:07 -0400 Message-ID: <20240708202907.383917-2-hamza.mahfooz@amd.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240708202907.383917-1-hamza.mahfooz@amd.com> References: <20240708202907.383917-1-hamza.mahfooz@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: BN3PEPF0000B077:EE_|MN6PR12MB8589:EE_ X-MS-Office365-Filtering-Correlation-Id: ab16d5af-c2a1-4cc0-3844-08dc9f8caefd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|1800799024|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: XT4ygjos652NjZ7qdyN5DxwEnjYk6OI1t46Sb0Gh8+dnRDLFLQfb1gt8jYeaZEASbynurzuG/PPaPH+4pCl4ZHH6WfLZQ2J34DzdjKf56+1EY82iGQ4ZJw+0RX8e/4Mz3M+le2xKPFPMwgfzIuiumAuhZsANru4+wXILwt9bEBEL9LJT0f67houXGtjc2dADoqyy+h0EUr2c9KL7PS41zh7iNtPai1asI0r1aHlYwOFVVsQPMNoU7RKDxkddGzZWopuQ1eeIrUjAFCQf2ZHdNvd9k12UkDw5x6jWdpx2aG5EmxRCbzm+IItf3QZkC6560Q/XF8cvqboacf6XAk6fHiIR3MMzWmB+COf3fss+mmNKIyFRbVLP8N9OXt1L6+X6bvThKAUn9DiGXl6Atg4VDy79ebIXHrg+JiCGqSbORQ26pSh81S6PPWVADzginM5zhAyryhDurlrhn8R6171pcDQoGmWXpph2dZWEtHCQ+HAa1WuUXfhWZVV4wRJEWs+n8ZNoz4P5hOChNLKcU/t28Z6EiiawXyIZmozoN++xmnyCMyMhfSaKqp/es0cq05oB3dWJTjJHDu/lrY7VPY3N+X8VeqYBm+SOqiHDVyg+yRR0PadMH0zQ5UBO8nLNcevHmnFtauMDTHMyV/bGwXdFOeUAZFSJlS4INzidpAZiDJz1HIbpXBW8MnON5kjqdmvbn2lWtYP2mpUN4GEsF5d7V4M0ESIcA7+HSZmWQzE0d4Us0gHot99Q37y+ubc86Tg5FcXZYnJg8UPV1zgtMjnlTY4ZgI3Z8L8HvYe+9rGRICRDOgEbOJw0oOEgIiDqfm+f1NL5BcHHx34w1JAuc8Oj003Ljg0IAyMoQhcwvKdJ5e0mQ5SF3aQUmW0NKPO8EzX5aTGEgMOGncvh8IlilgWTS8N1C5aL8ggW6JX5lpCQN5EmRg9zxUeXiY7gNejp+PQrosj/BkMKihNEpvmTpRVh4egXvoitzFS2227pHWQyjyy8DgUstG0B4MCNS2l9XwZMSKMK9CUIPt3GV7x12AN4fkYtZgZCCKv4ztmlICPDo16imc5j1AP949zrutMFDvHQnT5freQlrzQFKz9Wmw62ELBMiPlARn3kuMXJIAw2vD9XZ3uds6sYQUU6/ypHKql//LEzHP7UimEZJlXeszebhHIR0vDdprSMMODNYU7lZ1D/eNrjJ9iUGLTF7WMLVaWync0GkTKF5kK3crOmmOF19cbvL0dwWl21VPV+A4hOKnQB3QhXhkChfiVtxFbDiXkvafbNo17DCE8R9kG3tStpi6cju4f+N3LKbm9FHKpe+oDq7XaTPe8ZI7RXHOC+OoCqaJsgWC6/gTeMy32R+p0ezHkBXibHWvrEWcXNlJoqQwhe14a1fq7VVyCzHwgrE3FyEw4LW+KyLYRZ0tST4+GFDGEBH9GqZCr+SrpMzu/LHnHH6U5VyPkViWtlzfsnmNqr 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:(13230040)(376014)(1800799024)(36860700013)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jul 2024 20:29:35.7804 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ab16d5af-c2a1-4cc0-3844-08dc9f8caefd 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: BN3PEPF0000B077.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN6PR12MB8589 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" Hook up drm_crtc_set_vblank_offdelay() in amdgpu_dm, so that we can enable PSR more quickly for displays that support it. Signed-off-by: Hamza Mahfooz --- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) 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 fdbc9b57a23d..ee6c31e9d3c4 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -8231,7 +8231,7 @@ static int amdgpu_dm_encoder_init(struct drm_device *dev, static void manage_dm_interrupts(struct amdgpu_device *adev, struct amdgpu_crtc *acrtc, - bool enable) + struct dm_crtc_state *acrtc_state) { /* * We have no guarantee that the frontend index maps to the same @@ -8239,12 +8239,25 @@ static void manage_dm_interrupts(struct amdgpu_device *adev, * * TODO: Use a different interrupt or check DC itself for the mapping. */ - int irq_type = - amdgpu_display_crtc_idx_to_irq_type( - adev, - acrtc->crtc_id); + int irq_type = amdgpu_display_crtc_idx_to_irq_type(adev, + acrtc->crtc_id); + struct dc_crtc_timing *timing; + int offdelay; + + if (acrtc_state) { + timing = &acrtc_state->stream->timing; + + /* at least 2 frames */ + offdelay = 2000 / div64_u64(div64_u64((timing->pix_clk_100hz * + (uint64_t)100), + timing->v_total), + timing->h_total) + 1; + + if (acrtc_state->stream->link->psr_settings.psr_version < + DC_PSR_VERSION_UNSUPPORTED && + amdgpu_ip_version(adev, DCE_HWIP, 0) >= IP_VERSION(3, 5, 0)) + drm_crtc_set_vblank_offdelay(&acrtc->base, offdelay); - if (enable) { drm_crtc_vblank_on(&acrtc->base); amdgpu_irq_get( adev, @@ -9319,7 +9332,7 @@ static void amdgpu_dm_commit_streams(struct drm_atomic_state *state, if (old_crtc_state->active && (!new_crtc_state->active || drm_atomic_crtc_needs_modeset(new_crtc_state))) { - manage_dm_interrupts(adev, acrtc, false); + manage_dm_interrupts(adev, acrtc, NULL); dc_stream_release(dm_old_crtc_state->stream); } } @@ -9834,7 +9847,8 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state) drm_atomic_crtc_needs_modeset(new_crtc_state))) { dc_stream_retain(dm_new_crtc_state->stream); acrtc->dm_irq_params.stream = dm_new_crtc_state->stream; - manage_dm_interrupts(adev, acrtc, true); + manage_dm_interrupts(adev, acrtc, + to_dm_crtc_state(new_crtc_state)); } /* Handle vrr on->off / off->on transitions */ amdgpu_dm_handle_vrr_transition(dm_old_crtc_state, dm_new_crtc_state);