From patchwork Mon Mar 11 19:22:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rodrigo Vivi X-Patchwork-Id: 13589284 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 A4D8FC54E58 for ; Mon, 11 Mar 2024 19:23:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0E0E6112C22; Mon, 11 Mar 2024 19:23:23 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="bwHVUbyx"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) by gabe.freedesktop.org (Postfix) with ESMTPS id EF60F112C20 for ; Mon, 11 Mar 2024 19:23:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710185002; x=1741721002; h=from:to:cc:subject:date:message-id: content-transfer-encoding:mime-version; bh=KhqWmD8qlozfu1bc1oCAIXvYQreVkTMp66V3YFFvhr0=; b=bwHVUbyxJPKmwm0kTuOf//WDtLaSEeq5YF3o9I5MOwmlS1IWdXKn4SBQ RwJ4+LSrq/hdc4mXGDnrqBMU+FGXg2OkqG/6vpbtrc+poTQSHxHub1nc+ ui8c/5jE5kNhhJ86JiMwRnvhnsjwmi9bpU70UyU9SNyH5diNLpnBjKJYu /BQFf77DIE6jPa5+bivz7gkMNXrqeRSLW7vbtk7AUXEpOg1JqQ0B2ERe1 MbtOsp0eYcWZFlSHFt3ebGAuPlZnnppFxd4LirrREiYgfOdCJblRcvMBb RlFnE34A4cFMNYtw/3kvM1pzcg0kcRft2b+HLumalMV+rFxCTibsGuSYT Q==; X-IronPort-AV: E=McAfee;i="6600,9927,11010"; a="16270822" X-IronPort-AV: E=Sophos;i="6.07,117,1708416000"; d="scan'208";a="16270822" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Mar 2024 12:23:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,117,1708416000"; d="scan'208";a="15762106" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by fmviesa005.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 11 Mar 2024 12:23:20 -0700 Received: from fmsmsx612.amr.corp.intel.com (10.18.126.92) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Mon, 11 Mar 2024 12:23:19 -0700 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx612.amr.corp.intel.com (10.18.126.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Mon, 11 Mar 2024 12:23:14 -0700 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx611.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35 via Frontend Transport; Mon, 11 Mar 2024 12:23:14 -0700 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (104.47.56.41) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Mon, 11 Mar 2024 12:23:09 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fP34+cduDfjgePir76HTnXUdgDJmABbixFXWTIG3N7t7Vh0prPbCY7IRKRdVTpsKLiB4phWktpPLOiphGPW6tckul7ycLik83W1i6YK7rgE37qTnCyyzKoS87sKvnOcOPxjNxnSt/LspeT+A+gO11unpCVW9FENT5hW6DN6jjppR/+QBlba/w4cttSG6I0aRY/pgD35K3S4NpWkkAZy3tJfUd0o2UuJmGrlCxLgL7Ipjmhf5SvQXf8DQ/bzdS8fTjpimtbcYrEVpGc4pXEnrzwEIGhzJzr42CR9AC8DH0yu2olK62CDSeVCEg2cfRRSdGhN/LLFz6Xw3pcfNIa9Xtg== 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=b1WWAD7UnCdGDidhQw2rN/uK6XfBrAwCZCcUw7E2EkU=; b=k18BjzsQB51AkrxZeg+toS5/Aw+LANK9w3bpAzIOzQ5w0+tDgmYqxCQp26mzJjFbrUbQweLZ2dRbCbEEChG657j9iIROU/ruqaLo7Nsk2Rw17b3x1Bc7TU35PKVEvyfrRtN2ZtAN+rZvHbFJ1i0e3cWaT/ukTo+YifE5nJPp1jJ6aS/JqR/ExYp5TYL46yrJSgMXUsC5V3hC1valZf+SoD/ZZ6/Dq9Bx8nyI5SzMheS02QP1e2FmVIa2y1e0KQHYer/ykx6fFmQogdpJkRq+dzS6RUWNt4mkuBqrcn6vFzm21q4lkJc9ErPQE5cvNYOlv8VAkoXO1h12+eBBlPT6TQ== 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: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from MN0PR11MB6059.namprd11.prod.outlook.com (2603:10b6:208:377::9) by SA0PR11MB4526.namprd11.prod.outlook.com (2603:10b6:806:96::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7386.16; Mon, 11 Mar 2024 19:23:07 +0000 Received: from MN0PR11MB6059.namprd11.prod.outlook.com ([fe80::7607:bd60:9638:7189]) by MN0PR11MB6059.namprd11.prod.outlook.com ([fe80::7607:bd60:9638:7189%4]) with mapi id 15.20.7386.016; Mon, 11 Mar 2024 19:23:07 +0000 From: Rodrigo Vivi To: CC: Rodrigo Vivi , Matthew Auld Subject: [PATCH 01/11] drm/xe: Introduce xe_pm_runtime_get_noresume for inner callers Date: Mon, 11 Mar 2024 15:22:53 -0400 Message-ID: <20240311192303.33961-1-rodrigo.vivi@intel.com> X-Mailer: git-send-email 2.44.0 X-ClientProxiedBy: SJ0PR05CA0198.namprd05.prod.outlook.com (2603:10b6:a03:330::23) To MN0PR11MB6059.namprd11.prod.outlook.com (2603:10b6:208:377::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN0PR11MB6059:EE_|SA0PR11MB4526:EE_ X-MS-Office365-Filtering-Correlation-Id: 9fd93e34-8f18-467e-ecef-08dc4200ae75 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: K5ctWqczbRGmMr5LQuZLbDm0ZILz73gpev7rmBSceg0NEdonz8l+Ve267i/w6FSZ14kC0Hb3BVQaMjcg3HTpo2PAA756WfNoVe5W0NU2XRsmyI9wP4/e/pfonc+UsvzI1CrRMtDsXjSi2T8Iqezi3xZSItPJ1yRW40Di4TpZwvkE1QpfsnTLqoLsT9uzC2vO7z3cJ8HgqkS7XTCdgunGVQD1pPTINBaM+txB7e0UD4MkZT8MDfdtNWkGQeIrKzUwwquzu9ZHmg8pzlXPj/S8Dp7Yragl2NiI00ZQxtt2qX4GibZgwZJrm1X/P9gcGJy7WTLriTNke8G5POYPOOctYL02CaWubt1G6y86eIgv4Rvz0V6FBwsSzad50Mv/2VG2yay6uBuEcOALYO7rsKPk2+cpAlzOu9i2YXkInJS0s0xUMtGcKpL4ao+UB/VVr7GwXyJbvsSsYJm09+AB+btsHWrc83MyLxFtfUsjHxRAR+V/cdEc7QOytKj+pccF86Yc3IGIA8ctmhdrA95EIZEKpNMYOuYuojUek+mdRiCY+PSMOv4S4YVnNBL4HMrK0b3aUzNR3CJHesvhg4KTGWJQ4F8n8rzGRp+eoj6Ukdj7bRqItn+m0LhYvGMSUjPIPLp+lnizmIR1iMZPPkSzxJnAxaWbrtJ/QxtBQZN+74yzgsA= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MN0PR11MB6059.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(1800799015)(376005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WtqJCG0PumRcUsv4Q2+bBkJb2lp/S4tDEXkJUSE+1eB7fAyCOHwsPXZVcVeh3vEnZj7soBll1SOo0DDdhapPEIW5UZ7kzIigqHn6Vf7VCw3BoF4UczqJIy5jsUzzPVLO4BZbRn8MFm7rGppVm5nYTVKm5i5lG2KJn7gJgs1K2LqG6js7EL88qQUYWccwF+t99r+v1l0TetRR9djkxPmDG5pS0Z22l2RJudgm7G6SMXKsp5Xh1vLdfxTSt4v+rmj9Q/WdovAzA8AICjoyYzZ42wF3AzhEz+TePbt5PYHjhBB8IeivETtPbw7aoAIVGFWVQLJAtOJHSIRj2GKRCbdkAMaiEkcYmpjAmQjJCT4neDvNudHPaZCxFjdycsRPiXQ29EYYHmYiq5nlFRxwwbSciwa3b81eqVuTZyfQy4ytnAYCx+FHrENg086jP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FGvjzbM2W9G27BI+a5lUbm5P2OOiGHFEBgiL11YqlyEIJ+Ft45Tdm4zePz47fGd0rnbANlXatG/nY2OD14l39FeXYuIEMFoxXub9aN0Cpl9ag== X-MS-Exchange-CrossTenant-Network-Message-Id: 9fd93e34-8f18-467e-ecef-08dc4200ae75 X-MS-Exchange-CrossTenant-AuthSource: MN0PR11MB6059.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Mar 2024 19:23:07.6475 (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: dSYSOtJ4KJWGxOCIgB1huqmmi9CZVT4/Om7/uMMe1w4t+QelQiVitsWbEtLhTIwL/j/XylmNKok5m9genDAxMw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR11MB4526 X-OriginatorOrg: intel.com X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Let's ensure that we have an option for inner callers that will raise WARN if device is not active and not protected by outer callers. Make this also a void function forcing every caller to unconditionally put the reference back afterwards. This will be very important for cases where we want to hold the reference before scheduling a work in a queue. Then the work job will be responsible for putting it back. While at this, already convert a case from mem_access_ongoing where it is not checking for the reference and put it back, what would cause the underflow. Signed-off-by: Rodrigo Vivi Reviewed-by: Matthew Auld --- drivers/gpu/drm/xe/xe_exec_queue.c | 2 +- drivers/gpu/drm/xe/xe_pm.c | 20 ++++++++++++++++++++ drivers/gpu/drm/xe/xe_pm.h | 1 + 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/xe/xe_exec_queue.c b/drivers/gpu/drm/xe/xe_exec_queue.c index 6a83bc57826a..f69a9c99329c 100644 --- a/drivers/gpu/drm/xe/xe_exec_queue.c +++ b/drivers/gpu/drm/xe/xe_exec_queue.c @@ -128,7 +128,7 @@ static int __xe_exec_queue_init(struct xe_exec_queue *q) * already grabbed the rpm ref outside any sensitive locks. */ if (!(q->flags & EXEC_QUEUE_FLAG_PERMANENT) && (q->flags & EXEC_QUEUE_FLAG_VM || !q->vm)) - drm_WARN_ON(&xe->drm, !xe_device_mem_access_get_if_ongoing(xe)); + xe_pm_runtime_get_noresume(xe); return 0; diff --git a/drivers/gpu/drm/xe/xe_pm.c b/drivers/gpu/drm/xe/xe_pm.c index 9fbb6f6c598a..847b263afe70 100644 --- a/drivers/gpu/drm/xe/xe_pm.c +++ b/drivers/gpu/drm/xe/xe_pm.c @@ -477,6 +477,26 @@ bool xe_pm_runtime_get_if_in_use(struct xe_device *xe) return pm_runtime_get_if_in_use(xe->drm.dev) > 0; } +/** + * xe_pm_runtime_get_noresume - Bump runtime PM usage counter without resuming + * @xe: xe device instance + * + * This function should be used in inner places where it is surely already + * protected by outer-bound callers of `xe_pm_runtime_get`. + * It will warn if not protected. + * The reference should be put back after this function regardless, since it + * will always bump the usage counter, regardless. + */ +void xe_pm_runtime_get_noresume(struct xe_device *xe) +{ + bool ref; + + ref = xe_pm_runtime_get_if_in_use(xe); + + if (drm_WARN(&xe->drm, !ref, "Missing outer runtime PM protection\n")) + pm_runtime_get_noresume(xe->drm.dev); +} + /** * xe_pm_runtime_resume_and_get - Resume, then get a runtime_pm ref if awake. * @xe: xe device instance diff --git a/drivers/gpu/drm/xe/xe_pm.h b/drivers/gpu/drm/xe/xe_pm.h index 0cb38ca244fe..119b630ad1d1 100644 --- a/drivers/gpu/drm/xe/xe_pm.h +++ b/drivers/gpu/drm/xe/xe_pm.h @@ -31,6 +31,7 @@ int xe_pm_runtime_get_ioctl(struct xe_device *xe); void xe_pm_runtime_put(struct xe_device *xe); int xe_pm_runtime_get_if_active(struct xe_device *xe); bool xe_pm_runtime_get_if_in_use(struct xe_device *xe); +void xe_pm_runtime_get_noresume(struct xe_device *xe); bool xe_pm_runtime_resume_and_get(struct xe_device *xe); void xe_pm_assert_unbounded_bridge(struct xe_device *xe); int xe_pm_set_vram_threshold(struct xe_device *xe, u32 threshold);