From mboxrd@z Thu Jan 1 00:00:00 1970 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 F33B0606A32C for ; Thu, 3 Dec 2026 02:50:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=bSk8cxJZ Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AF48F10E6C1; Thu, 3 Dec 2026 02:50:18 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) by gabe.freedesktop.org (Postfix) with ESMTPS id CB83910E6C1 for ; Thu, 3 Dec 2026 02:50:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796266212; x=1827802212; h=date:from:to:cc:subject:message-id:references: in-reply-to:mime-version; bh=ULZX1MuyuZUWZtAszlV3yc+s1pqO2t/oJNJ1c276xqk=; b=bSk8cxJZ8tZf1onerV++GOt744YZFFtzznX0hHefs2NwpqpInNTMSY1l s6xwwFRdD1Bqtrklh9+3mmFVrRxSRMtZB7Djxaz24JOyv1G44NOEWBIrD oklgy05kvMXGDPNl8VZmafcTreiOrX+OF0aQzTpUMQl4nPBeffrZb36R/ AkgupzyMM+S0+hEzhrTmL2doG/hSzuPVxfVnRPgr7bkTjkXD7rzyFZzzA 5vynGN0jVRSch0H1CXSSKP4Tzkxy4zZ8guuhk5cS/ev2yYzSgAbD1iksQ FbuIGvDpx9sYfHLlPX32jaX5AjnjpjrE5OD/AiaIZBPH1G4057mGKbxkX w==; X-CSE-ConnectionGUID: kvlDD774T/GQhRU1s1+/Qg== X-CSE-MsgGUID: ZGi95fZyQIieL+fhkfAc+w== X-IronPort-AV: E=McAfee;i="6800,10657,11984"; a="5091183" X-IronPort-AV: E=Sophos;i="6.27,247,1787036400"; d="scan'208";a="5091183" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2026 18:50:11 -0800 X-CSE-ConnectionGUID: mXBefHLdSayFOu9Bg5OnWA== X-CSE-MsgGUID: 4HRfD8JjRde81Gg/GQ2CYA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,247,1787036400"; d="scan'208";a="13563468" Received: from orsmsx903.amr.corp.intel.com ([10.22.229.25]) by orviesa003.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2026 18:50:11 -0800 Received: from ORSMSX903.amr.corp.intel.com (10.22.229.25) by ORSMSX903.amr.corp.intel.com (10.22.229.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Wed, 2 Dec 2026 18:50:10 -0800 Received: from ORSEDG903.ED.cps.intel.com (10.7.248.13) by ORSMSX903.amr.corp.intel.com (10.22.229.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57 via Frontend Transport; Wed, 2 Dec 2026 18:50:10 -0800 Received: from BYAPR05CU005.outbound.protection.outlook.com (52.101.85.70) by edgegateway.intel.com (134.134.137.113) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Wed, 2 Dec 2026 18:50:10 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=B1XdQZ0OmyoQu5Di8fE0pK9IAZ0zJU2ORwAc1uSSn1cSZ7FipS7L49xuvyrOL0dBsW8QfAat2YERTvMfIpoftOB4xy7Wx8Y81bhso+RAIfkz8t9itzsLjzveYoqyX6WiQ37uUTIEuNCISkqUZcic/hXjU50dqK/qwrU3nwDvJgw7ZFMGJ/xoe47A+k5VRdHiZUAn6ZbHNpVou3v2xRmUbLKSVwtsfOzA6wwSbWcX9hitDHxGBCyeIPJwBUJvzr2a2PtMNJ7sVyt/epXijl+S5nkv0wX8mQADwb9pmx/aNWUiMn3edl5WGsLBRgAUwkicdofNU1exZ+rATAegNXwa7w== 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=ULZX1MuyuZUWZtAszlV3yc+s1pqO2t/oJNJ1c276xqk=; b=tu8IjRSY4p77Iim9gC4uezYla+nDjlPg5F6ZPpQhtI+ijMxCUi5A1/daLx5EfrCrCQmMsrhEIsBGx+0VYc5k9QplacIZs5I/zj5J1FOVMZ1k2wnjC129EMC7q/oVT1JSuVar1pbWxBFUlytsEANPmGXzfaeoI6VYKIIqz0Oi43aBjFPgA7IWncfMgVN88euLAZJPs77VszEsshDc2CKqhIiz2kYvvN6hvLEdgeu9K4aKtDqcafyfaVFhcO+5mnfehL+ykeAHmo42U0rl2dSmbgwsHgsd6JisZtNY8z+QdtEfPPza2aj4DQZjCVMuT2G0VQN8NLdsjQtt4CiAPeIUWQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from LV2PR11MB6000.namprd11.prod.outlook.com (2603:10b6:408:17c::12) by SA1PR11MB9634.namprd11.prod.outlook.com (2603:10b6:806:4dc::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.12; Thu, 3 Dec 2026 02:50:07 +0000 Received: from LV2PR11MB6000.namprd11.prod.outlook.com ([fe80::7fd:3ebd:962e:1390]) by LV2PR11MB6000.namprd11.prod.outlook.com ([fe80::7fd:3ebd:962e:1390%3]) with mapi id 15.21.0688.009; Thu, 3 Dec 2026 02:50:06 +0000 Date: Wed, 2 Dec 2026 21:50:03 -0500 From: Rodrigo Vivi To: Zongyao Bai CC: Subject: Re: [PATCH v4 0/3] drm/xe/forcewake: add delayed release for engine-cycle queries Message-ID: References: <20261202232308.917828-1-zongyao.bai@intel.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261202232308.917828-1-zongyao.bai@intel.com> X-ClientProxiedBy: SJ0PR13CA0088.namprd13.prod.outlook.com (2603:10b6:a03:2c4::33) To LV2PR11MB6000.namprd11.prod.outlook.com (2603:10b6:408:17c::12) X-Archived-By: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR11MB6000:EE_|SA1PR11MB9634:EE_ X-MS-Office365-Filtering-Correlation-Id: 88bda53e-58cd-4ee0-e039-08df50e82334 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|23010399003|366016|1800799024|376014|22082099003|18002099003|10067099003|56012099006|261028144727099003|261102123227099003|261022105027099003|261021123027099003|261021121427099003|261026121527099003|261026140227099003|261009223027099003|11063799006; X-Microsoft-Antispam-Message-Info: +touCTvldLCSWgpI/TaxPPqCbZHxLPQScr0PHf/BSM3kIyGaXHKlW/oh3BMYFsSe+0RAfv8JR9ZMfvUmoUaeX7uUsKCGVVhtH0onwUMCNRDdTg6I/YYqO/EC57b08c57mv6ewvGJHCTdUNj2GyeFiPSGw2t7DiMkak2fKuiMv38zLabtmou5n9CUEu+ZtbCdXasIsLyS2RGNDAPIzVC6Juatpl0xuxB+5F2Mmxp6j4MHaV+Rr1v6g6UQ56Jb2gI/lls1fEV0HM+m60tYdcNC5+1tRATYixh0dSPO/aF1hwyDFc+s+efInUw7Q0ooX3P8S3JD4QhWJOANmJZUpfIb0uc+IZgv/+GzK7MEN368lfseFhLR5RjNWLnIIYti6F7GTYM2fsvRE6aiYO8EVzJItw7GAgvzecECahV5WrsSUo1kDKwoa490n4dOwZU5LhPwaUidcY+FbjwjcmQTKwfZMj8ULSn9OFu2kzfarsm7C+65DQiydtVcKaEWI5EQHH42uv12gSTsXod+S6Tl9LX8F+pTL8W4dg1pGdig94NTnfy6Bw0N8K7V7WweMpQm1KwGNC2XZhWuWN1Bpsb1xvJOpuKNZW4HN8pRzXPIawySuDwtVLk/da8mnOaDgXl3zJDi4bVzrQ793WaKKkTkaDCq/5lxQIYU2LAcktb7x7ISGVU= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:LV2PR11MB6000.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(23010399003)(366016)(1800799024)(376014)(22082099003)(18002099003)(10067099003)(56012099006)(261028144727099003)(261102123227099003)(261022105027099003)(261021123027099003)(261021121427099003)(261026121527099003)(261026140227099003)(261009223027099003)(11063799006); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?96u7c5hKotgC/7vW0TanZqi5AK7SDsFm/34xKeyWjkf7TLKcSmKVnto/rtd5?= =?us-ascii?Q?PDsaIUD3eY4E/x8dXrWb/MYwLm4nhqRiwLEbbIrKPO2azj1MzbTBOGH2M7Bh?= =?us-ascii?Q?XB19OaeldkZLnVzS3z+u+WZoMawFbFXbbj3JowT3/FnHDPl8+uig1KK+xtmU?= =?us-ascii?Q?I4sTAWUcmrWwLGRumcdCWKSNWJH2v3QQifa1EV72czoZTyrym1tAMIOzjKSf?= =?us-ascii?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9dNtSla4cQ0RegyUpHmjHPlL3oxLbxJIJPk0bsL22TYNB/OZILshRaz6uizTOezK5Nzz9f8pg== X-MS-Exchange-CrossTenant-Network-Message-Id: 88bda53e-58cd-4ee0-e039-08df50e82334 X-MS-Exchange-CrossTenant-AuthSource: LV2PR11MB6000.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2026 02:50:06.8810 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 51WCR9s3XOSA7SrLdZZ+G7NbH2Vq3yXpWF3EYYXVhoJMMLuC4CvoMHRvhKvFdf/bsRMe4yspN9jNXxvOqaN0Kw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR11MB9634 X-OriginatorOrg: intel.com X-BeenThere: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Intel-xe" X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 On Wed, Dec 02, 2026 at 11:23:05PM +0000, Zongyao Bai wrote: > Engine-cycle queries are issued repeatedly by profilers such as VTune > and PTI to correlate CPU and GPU timestamps, for example through Level > Zero zeDeviceGetGlobalTimestamps(). Each query wakes the engine > forcewake domain and puts it to sleep again, and waiting for both > acknowledgments dominates the query latency. > > This series adds an opt-in delayed release to forcewake. After the > final reference to a domain is dropped with xe_force_wake_put_delay(), > the domain stays awake for a short hold time, and a get within that > time reuses it without another wake request or ACK wait. The domain is > put to sleep from a delayed work in process context, so the sleep ACK > is waited for as in a regular put. The work sleeps only domains whose > hold time expired and that are still unreferenced, and requeues itself > for the rest. The hold time is 5 ms, and never less than two jiffies. > > Delayed release must not outlive the device being powered off, reset > or removed. System suspend, runtime suspend and PCIe FLR preparation > flush it: the pending work is canceled and the held domains are put to > sleep, while delayed release stays available after resume. GT shutdown, > device removal and post-registration probe failure stop it: the work is > disabled for good, and a later delayed put puts the domain to sleep > right away. > > Only engine-cycle queries opt in. All other forcewake users keep > releasing immediately. > > v4 (from Sashiko review): > - A PCIe FLR prepared through xe_device_suspend(flr) skips > xe_gt_suspend(), so the delayed release was not flushed before the > reset. The work could fire while the device is being reset and time > out waiting for the sleep ACK, or a domain could stay marked awake in > software after the FLR put it to sleep, making the next get skip the > wake. Flush delayed release in xe_gt_flr_prepare(). It is flushed > rather than stopped, as the device is used again after the FLR. > - Warn once if a delayed release is still outstanding at the points > where the GT MMIO is about to become inaccessible (system suspend, > hibernation, FLR preparation and runtime suspend). A new path that > misses the flush is then caught in testing. > - Rebase on drm-xe-next (264ec299c700). Handle the change of > drm_dev_unregister() to drm_dev_unplug() in the xe_device_probe() > error path. pushed to drm-xe-next, thanks > > v3 (all from Sashiko review): > - xe_pm_runtime_get_if_active() only returns true/false, so the delayed > release work could not tell "suspend in progress" from "runtime PM > disabled" and returned early in both. Use pm_runtime_get_if_active() > instead and do not drop the work while a runtime suspend is in > progress. The work never resumes the device and handles three cases: > a. runtime PM active: put the expired domains to sleep as before. > b. runtime suspend in progress: requeue and retry later. > b1. If the suspend completes, xe_force_wake_flush() cancels the > work and settles the delayed domains. > b2. If it aborts, the device returns to RPM_ACTIVE and the next > run puts the expired domains to sleep. > c. runtime PM disabled (e.g. CONFIG_PM=n): the device stays powered, > so release the domains without a runtime PM reference. > > - Do not count domains in delayed release as held in > xe_force_wake_assert_held(), since they are awake with no reference > and may be put to sleep by the delayed release work at any time. > > > v2 (all suggested by Rodrigo Vivi): > - Define the hold time in milliseconds and convert it with > msecs_to_jiffies(), keeping it at least two jiffies. (Rodrigo) > - Pass the hold time to __xe_force_wake_put() instead of a bool, with > 0 meaning an immediate release. (Rodrigo) > - Replace the queue_delayed_work()/delayed_work_pending() check with a > delayed_enabled flag protected by the forcewake lock and cleared by > xe_force_wake_stop(). (Rodrigo) > - Use xe_pm_runtime_get_if_active() in the delayed work instead of > asserting that the device is not runtime suspended. (Rodrigo) > - Rebase on drm-xe-next (4af7fae27dc6). > > Zongyao Bai (3): > drm/xe/forcewake: add delayed release with hysteresis > drm/xe/forcewake: flush delayed release at power and teardown > boundaries > drm/xe/query: use delayed forcewake release for engine-cycle queries > > drivers/gpu/drm/xe/xe_device.c | 14 ++ > drivers/gpu/drm/xe/xe_force_wake.c | 271 +++++++++++++++++++++-- > drivers/gpu/drm/xe/xe_force_wake.h | 43 +++- > drivers/gpu/drm/xe/xe_force_wake_types.h | 48 ++++ > drivers/gpu/drm/xe/xe_gt.c | 16 +- > drivers/gpu/drm/xe/xe_pm.c | 4 + > drivers/gpu/drm/xe/xe_query.c | 2 +- > 7 files changed, 365 insertions(+), 33 deletions(-) > > -- > 2.43.0 >