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 0EDC3CD6E40 for ; Tue, 26 May 2026 14:12:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5F3E610E678; Tue, 26 May 2026 14:12:04 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="DQY7mPJZ"; dkim-atps=neutral Received: from CH1PR05CU001.outbound.protection.outlook.com (mail-northcentralusazon11010039.outbound.protection.outlook.com [52.101.193.39]) by gabe.freedesktop.org (Postfix) with ESMTPS id 25B3A10E671 for ; Tue, 26 May 2026 14:12:03 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=AR0h25cup9VqhNG4EI6F+yKXb/z3Xq9BS+RMqQuJjhv0yh/DiJhErNoU748DrdlizBXBPOw74fgm2AwE3EelButNw0okHnRnYSR/+eqd2XFPupr9cqSEWZYfGY1xGNBx4QZoHpepIaCVeT8/E9dphpNLO4YBpQjv96wlr5mJ1X+FHfpdPRB5ly2MnEUXSsshhcYiXGOVMvkRqfT/gaS0+22wd7/rvJvachy+kKJN7lik6KVmXQSMPvWQO+s4KEtnhhvoHztKgI7q2i9gcBZP/+8+O6cohWeJEQdjyfqpuMhFbc7UbmJhTtAEstW/7eYfI+SOy+m/OT3XMmgY3AaKtw== 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=w3Q5e32e5nb1AsyWCw8OpcMRtZyvOYv2ptw752gUI48=; b=G18ObNuzZZzXwDQ488hr9m8ihuUwYDFqP8vKVU+5Fgsq9QR6XsoQEEvXFGwBbZUIotnFRqy149T31A6clShW68mOt6XghTlng1Q+lE1Xsr80QccL194IfrrL4Yy0adNDDFlLXgY4cX9kvi1mZimTIOkqivc3XSHkqEmmW2LfCTD2l9ezh6WZp7JuDSIEKxLA7TuCtXtEASpN1kF8vAzzyiPAqYmTlBq67OjTdEhjSraUy7QipWfL/9eG3SiswM6ySztR12a08iMD5yOq6czKywSIBOWh2HnkKpI16HhX1TZvXKxv9PE0DPhqliEoW0LMcNX9qZOxH78ALIwf+eS2ug== 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=w3Q5e32e5nb1AsyWCw8OpcMRtZyvOYv2ptw752gUI48=; b=DQY7mPJZSvzvk8GAB48XIvKaetrcLsqcFlBqDQ7p0FcO2pBZZYg5NlcW3VfMSPTfrNKgsd4hsNL9mC16K9nLIzstboviOAog/VmRS4peGqmA/XbBlPtVuAA1jiM4gP4sP9nqu7L+kWV8egHxkiH/iDPcr7+QgpZ9/R0W9Ipl+js= Received: from BN9PR03CA0665.namprd03.prod.outlook.com (2603:10b6:408:10e::10) by IA1PR12MB8239.namprd12.prod.outlook.com (2603:10b6:208:3f7::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.48.19; Tue, 26 May 2026 14:11:52 +0000 Received: from BN3PEPF0000B078.namprd04.prod.outlook.com (2603:10b6:408:10e:cafe::af) by BN9PR03CA0665.outlook.office365.com (2603:10b6:408:10e::10) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.71.12 via Frontend Transport; Tue, 26 May 2026 14:11:52 +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=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by BN3PEPF0000B078.mail.protection.outlook.com (10.167.243.123) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.71.7 via Frontend Transport; Tue, 26 May 2026 14:11:52 +0000 Received: from work-495456.amd.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.41; Tue, 26 May 2026 09:11:50 -0500 From: James Zhu To: CC: , , Subject: [PATCH v4 02/17] drm/amdgpu: add profiler manager initialization and release Date: Tue, 26 May 2026 10:11:14 -0400 Message-ID: <20260526141129.592886-2-James.Zhu@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260526141129.592886-1-James.Zhu@amd.com> References: <20260526141129.592886-1-James.Zhu@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN3PEPF0000B078:EE_|IA1PR12MB8239:EE_ X-MS-Office365-Filtering-Correlation-Id: c74c6544-4a83-4145-8c75-08debb30bc63 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|1800799024|36860700016|376014|11063799006|6133799003|3023799007|22082099003|56012099003|18002099003; X-Microsoft-Antispam-Message-Info: CXmmhcW9GTFjzhztwjWHIpBp17PFE5q7uhxhZiBAQCBdhE/EOrjmz9k03dvbOav/yp+wRyWf6OUO16x6exY6kuuYPvC3+aqFKCp7ifrxhHhfRBJjfR1Dkmh3xN9ep3AviZ/8hsHjLRyjXiaxnjv/hGiFioqxSGgbrd/agdLzDsyHwLtGxrYneOo7Q/PzH5pBsvknDSjX1TvxKVZMHIiFVAZ5i4c9EqmqswjLhr4RbTmEw3nFr4m6r7VfZroEV+mKPLbDssjKPSIWKfNgc6FjkYdpRnNZurk/BYYLhH8DAtktDj4EDu6Wp4zBf8qBfNyv5aZBejPb8OVIeKaEkdjDSIo8sqUCilqJTaUZcN5xLDZPUZubSqBRDRqU2Fpv+67CYkI4cf15FITXhInitONzWPw5UIkvPdzmz+oJPqeNmx9S03meKFFQ82E49RahFV2/r2s6/8EprhklBTm/iPsyYpDlAfpfeM5ue25USsU+yfNAAgSR0tNSKzAOOsVbx3cPPhIyAfmcXp2hzTkFCWYgs6OkpsOXG4TPwgqilSkFIJHKraqb7t3C9nWgBCK517lCPvMOYlVYsQZQKwFCCLLZgKk0kDMAYQj7OleAMx7sgm8S5AVlk1BPJkbK5pevU+yZiDcoEq0URPKI4qUr+b6q3q0l/I+W0v69DcyAUo7xuox87ESPb4MUyzRSynWNeoijL7SJCv9FbjBqra/o6V+a8YWODjPc+Nxvu0zcoHRm2ws= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:satlexmb07.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(82310400026)(1800799024)(36860700016)(376014)(11063799006)(6133799003)(3023799007)(22082099003)(56012099003)(18002099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zRSZUevxeFM7E5Bl8hzElZ2XlUbwwETJZ3SVzIGAbhhB2P4IjpbRj3tbvKA2Upv3HV+YKYcAWELuLuBpmFrOZGRk4zFRMFTFMqjxCObeAdwOv1w24w0sL4r1krJv336YzPDdH9lAhO2H3Tbr1GaUTvpI34UedeDVApbKnqwc/1Oe2blaGwGHN9o3D+pvh0/S6aqA3TD2uj6GGJjBGrk7iVodcpDIXxFYAp5PTbYP7CAzAldqJmiyQi+EcZCHKS2ke2suiO/wYMfgxS1rRfN9/YHs+y4OpbquL0hJJOEe+TqOrHayN+CC/1hxE9679BaKV6GHiUPP09ECbviK5DyvfiF0xnvHQ+UIwN7PiB82b6b9h7POuT1uM+vsDHJw2XZ/WpwVS4hTgPvv9wA+qF2Htlt/8qObd/g/loA4F9wkp2X9yU50Tl8cfCcZvsU5IiFM X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 May 2026 14:11:52.6237 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c74c6544-4a83-4145-8c75-08debb30bc63 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=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN3PEPF0000B078.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB8239 X-BeenThere: amd-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion list for AMD gfx List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: amd-gfx-bounces@lists.freedesktop.org Sender: "amd-gfx" to introduce the profiler manager infrastructure needed to support per-process GPU hardware profiling features such as SPM and PCS. Two new files are added: - amdgpu_profiler.c/.h: define struct amdgpu_profiler_mgr, which holds an array of per-XCP partition managers (amdgpu_profiler_xcp_mgr), each reference-counted via kref and protected by a dedicated mutex. A device-level struct amdgpu_profiler_mgr prof_mgr is embedded in struct amdgpu_device and its top-level mutex is initialized during amdgpu_device_init(). The per-XCP profiler manager is initialized lazily on the first amdgpu_driver_open_kms() call for a given XCP partition: - If the XCP manager is already initialized, only the kref is incremented. - On file close (amdgpu_drm_release()), the kref is decremented and the per-XCP manager is destroyed (mutex destroyed, is_initialized cleared) when the last user releases it. Non-partitioned devices uses XCP partition 0. Initialization is skipped when fpriv->xcp_id is AMDGPU_XCP_NO_PARTITION, which indicates the device has not yet been fully initialized. -v3: rename is_init to is_initialized in amdgpu_profiler_xcp_mgr -v4: fix mistake Signed-off-by: James Zhu Reviewed-by: Bing Ma --- drivers/gpu/drm/amd/amdgpu/Makefile | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 3 + drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 5 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_profiler.c | 89 ++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_profiler.h | 48 +++++++++++ 7 files changed, 148 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_profiler.c create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_profiler.h diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile b/drivers/gpu/drm/amd/amdgpu/Makefile index e70322bd2086..a54869a20e73 100644 --- a/drivers/gpu/drm/amd/amdgpu/Makefile +++ b/drivers/gpu/drm/amd/amdgpu/Makefile @@ -72,7 +72,7 @@ amdgpu-y += amdgpu_device.o amdgpu_reg_access.o amdgpu_doorbell_mgr.o amdgpu_kms amdgpu_eeprom.o amdgpu_mca.o amdgpu_psp_ta.o amdgpu_lsdma.o \ amdgpu_ring_mux.o amdgpu_xcp.o amdgpu_seq64.o amdgpu_aca.o amdgpu_dev_coredump.o \ amdgpu_cper.o amdgpu_userq_fence.o amdgpu_eviction_fence.o amdgpu_ip.o amdgpu_events.o \ - amdgpu_cwsr.o + amdgpu_cwsr.o amdgpu_profiler.o amdgpu-$(CONFIG_PROC_FS) += amdgpu_fdinfo.o diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index 36ee18250dcf..3394c17aed05 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h @@ -110,6 +110,7 @@ #include "amdgpu_seq64.h" #include "amdgpu_reg_state.h" #include "amdgpu_userq.h" +#include "amdgpu_profiler.h" #include "amdgpu_eviction_fence.h" #include "amdgpu_ip.h" #if defined(CONFIG_DRM_AMD_ISP) @@ -1207,6 +1208,8 @@ struct amdgpu_device { struct amdgpu_uma_carveout_info uma_info; + struct amdgpu_profiler_mgr prof_mgr; + /* KFD * Must be last --ends in a flexible-array member. */ diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index e646a621c317..b5300c181c7b 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -3754,6 +3754,7 @@ int amdgpu_device_init(struct amdgpu_device *adev, mutex_init(&adev->gfx.userq_sch_mutex); mutex_init(&adev->gfx.workload_profile_mutex); mutex_init(&adev->vcn.workload_profile_mutex); + mutex_init(&adev->prof_mgr.mutex); amdgpu_device_init_apu_flags(adev); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c index 7b14a0c24a8c..476d40dde319 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c @@ -2971,6 +2971,7 @@ static int amdgpu_drm_release(struct inode *inode, struct file *filp) amdgpu_evf_mgr_flush_suspend(&fpriv->evf_mgr); amdgpu_userq_mgr_fini(&fpriv->userq_mgr); amdgpu_evf_mgr_fini(&fpriv->evf_mgr); + amdgpu_profiler_mgr_fini(fpriv_to_prof_mgr(fpriv), fpriv); drm_dev_exit(idx); } diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c index 70cc70b6bac5..696f0b0a949f 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c @@ -1628,6 +1628,11 @@ int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv) dev_dbg(adev->dev, "cwsr trap not enabled"); } + r = amdgpu_profiler_mgr_init(fpriv_to_prof_mgr(fpriv), fpriv); + if (r) + DRM_WARN("Can't setup profiler\n"); + + amdgpu_ctx_mgr_init(&fpriv->ctx_mgr, adev); file_priv->driver_priv = fpriv; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_profiler.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_profiler.c new file mode 100644 index 000000000000..ffe65664e1d4 --- /dev/null +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_profiler.c @@ -0,0 +1,89 @@ +// SPDX-License-Identifier: GPL-2.0 OR MIT +/* + * Copyright 2026 Advanced Micro Devices, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "amdgpu.h" + +/* + * Profiler revision change log + * + * 1.1 - Initial revision + */ + +#define AMDGPU_PROFILER_VERSION_MAJOR 1 +#define AMDGPU_PROFILER_VERSION_MINOR 1 + +int amdgpu_profiler_mgr_init( + struct amdgpu_profiler_mgr *prof_mgr, + struct amdgpu_fpriv *fpriv) +{ + struct amdgpu_profiler_xcp_mgr *prof_xcp_mgr; + struct amdgpu_device *adev = fpriv_to_adev(fpriv); + + if (fpriv->xcp_id == AMDGPU_XCP_NO_PARTITION) + return 0; + + mutex_lock(&prof_mgr->mutex); + + prof_xcp_mgr = &prof_mgr->prof_xcp_mgr[fpriv->xcp_id]; + if (prof_xcp_mgr->is_initialized) { + kref_get(&prof_xcp_mgr->ref); + mutex_unlock(&prof_mgr->mutex); + return 0; + } + + dev_dbg(adev->dev, "Initialize profiler on render node %d xcp %d", + adev->ddev.render->index, fpriv->xcp_id); + kref_init(&prof_xcp_mgr->ref); + mutex_init(&prof_xcp_mgr->mutex); + prof_xcp_mgr->xcp_id = fpriv->xcp_id; + + prof_xcp_mgr->is_initialized = true; + + mutex_unlock(&prof_mgr->mutex); + return 0; +} + +static void amdgpu_profiler_mgr_release(struct kref *ref) +{ + struct amdgpu_profiler_xcp_mgr *prof_xcp_mgr = + container_of(ref, struct amdgpu_profiler_xcp_mgr, ref); + + mutex_destroy(&prof_xcp_mgr->mutex); + prof_xcp_mgr->is_initialized = false; +} + +void amdgpu_profiler_mgr_fini( + struct amdgpu_profiler_mgr *prof_mgr, + struct amdgpu_fpriv *fpriv) +{ + struct amdgpu_profiler_xcp_mgr *prof_xcp_mgr; + + if (fpriv->xcp_id == AMDGPU_XCP_NO_PARTITION) + return; + + mutex_lock(&prof_mgr->mutex); + prof_xcp_mgr = &prof_mgr->prof_xcp_mgr[fpriv->xcp_id]; + if (prof_xcp_mgr->is_initialized) + kref_put(&prof_xcp_mgr->ref, amdgpu_profiler_mgr_release); + mutex_unlock(&prof_mgr->mutex); +} diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_profiler.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_profiler.h new file mode 100644 index 000000000000..c33018f01d0c --- /dev/null +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_profiler.h @@ -0,0 +1,48 @@ +/* SPDX-License-Identifier: GPL-2.0 OR MIT */ +/* + * Copyright 2026 Advanced Micro Devices, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + */ + +#ifndef AMDGPU_PROFILER_H_ +#define AMDGPU_PROFILER_H_ + +#define fpriv_to_prof_mgr(fpriv) (&(fpriv)->userq_mgr.adev->prof_mgr) +#define fpriv_to_adev(fpriv) ((fpriv)->userq_mgr.adev) + +struct amdgpu_profiler_xcp_mgr { + struct mutex mutex; + uint32_t xcp_id; + bool is_initialized; + struct kref ref; +}; + +struct amdgpu_profiler_mgr { + struct mutex mutex; + struct amdgpu_profiler_xcp_mgr prof_xcp_mgr[MAX_XCP]; +}; + +int amdgpu_profiler_mgr_init(struct amdgpu_profiler_mgr *prof_mgr, + struct amdgpu_fpriv *fpriv); +void amdgpu_profiler_mgr_fini(struct amdgpu_profiler_mgr *prof_mgr, + struct amdgpu_fpriv *fpriv); + +#endif /* AMDGPU_PROFILER_H_ */ -- 2.34.1