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 BE16F606A31E for ; Fri, 30 Oct 2026 06:10:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=4mBXz5dM Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 47C5510E81A; Fri, 30 Oct 2026 06:10:44 +0000 (UTC) Received: from BN1PR04CU002.outbound.protection.outlook.com (mail-eastus2azon11010066.outbound.protection.outlook.com [52.101.56.66]) by gabe.freedesktop.org (Postfix) with ESMTPS id CD85C10E81A for ; Fri, 30 Oct 2026 06:10:37 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=stfOqR9dYLr0CX28doqK0WoRuc1MvNI257xP3HIEStxAOWyX/fIagRds+ZFYM7UR2dzG1q68IzjANTb3i4JiWKN1LUwOcJbTr6al3F5lgwRRYGtrsZNs3gofUC3d/R9U+Zx4JNeYtkcuUNg7VGxyPe2GFMOTeYnK2C5hdrH8wgktVHtL7ETlhz//i/pxPo2RX9dnvdLmn4z0axZnM50FDmeI4e9EiVwcLBKmKvDmnROdmrupcecGiMXeVh1MrT4K3XRkmu9/dxZgEgu88kurREEWI6BRBV14/uTLcgyz59/+lJA5F8f9VkRUiuZHtYsKrcbc1WHkYvCFp/b4fZtjEw== 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=50HPnoBzy/oiCzju+nKIE26ZxTx/VMjeFn3vlBYIc14=; b=ZCpndC2Qws1XyzGbADCl7hOlpUKlK85IBBecX3ximQh6tOPALbBkSpD6zv8vo5/DTF9yrmtvrWXd9Sz7xxjuF1hbS5Ubkuc1I4JuGfzT8pwwkUgo6RRqdNDjBCotrbOJqyQJ9a8c9DOYNZO5GK6LtWOI9Q+NIjcJrt0FDYd+QFjUreArVIyqL9/IqMjmao+ng3boLrJt0QT1d2SwBcTBA+JacRkh4+fm34uqlxRrtiYmN8CoPt7FH+a5wjLy/xrp675mwtwLp/6/ipVDAiycjsuTbKZxyeMDwUQk7MSyeVjl5qatTMPfJXIO6tBPGc9bEaftfXGHh7ZFgYUuNZqJPA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none 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=50HPnoBzy/oiCzju+nKIE26ZxTx/VMjeFn3vlBYIc14=; b=4mBXz5dMuoRavKqrOUnmL/t9k+tLcWoLNtGOTGWzpBKKF/PDeupWJM6rQBFNUAbP0A0FuO2iAA58rGKSgy/RCAqGn+Ms82OtX4oVfe19yu/+hGlt7D/nPoOJiCcxblLDpk95KwZSRSsku7yFvr1dRmZg0gN1fBBn/yhyVXot0E0= Authentication-Results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from CH2PR12MB9457.namprd12.prod.outlook.com (2603:10b6:610:27c::7) by MN2PR12MB4439.namprd12.prod.outlook.com (2603:10b6:208:262::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.569.10; Fri, 30 Oct 2026 06:10:34 +0000 Received: from CH2PR12MB9457.namprd12.prod.outlook.com ([fe80::85a8:1df:840a:cd4c]) by CH2PR12MB9457.namprd12.prod.outlook.com ([fe80::85a8:1df:840a:cd4c%4]) with mapi id 15.21.0569.009; Fri, 30 Oct 2026 06:10:33 +0000 Content-Type: multipart/alternative; boundary="------------hhns7jLoM6YRxnm7l2rzZBET" Message-ID: Date: Fri, 30 Oct 2026 14:10:27 +0800 User-Agent: Mozilla Thunderbird Subject: Re: [RFC 02/10] drm/amdgpu: add device-wide PMC config To: James Zhu , "Zhu, James" , "Deucher, Alexander" , "Kuehling, Felix" Cc: "Huang, Ray" , "amd-gfx@lists.freedesktop.org" References: <20260922093436.596947-1-lingshan.zhu@amd.com> <20260922093436.596947-3-lingshan.zhu@amd.com> <6394fa47-ec53-4e54-9cc9-bbd59b97f174@amd.com> <61ab80af-0a33-4660-9f80-13966c3583a2@amd.com> <2a1a10f7-6a49-435f-abb2-0894ff804acd@amd.com> Content-Language: en-US From: "Zhu, Lingshan" In-Reply-To: <2a1a10f7-6a49-435f-abb2-0894ff804acd@amd.com> X-ClientProxiedBy: SG2PR04CA0203.apcprd04.prod.outlook.com (2603:1096:4:187::22) To CH2PR12MB9457.namprd12.prod.outlook.com (2603:10b6:610:27c::7) X-Archived-By: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR12MB9457:EE_|MN2PR12MB4439:EE_ X-MS-Office365-Filtering-Correlation-Id: 3a0f471d-3f98-4acd-7613-08df364c8200 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|376014|23010399003|366016|13003099007|18002099003|22082099003|56012099006|4143699003|11063799006|8096899003|261009223027099003|261026121527099003|261026140227099003|261028144727099003|261022105027099003|261021121427099003|10067099003; X-Microsoft-Antispam-Message-Info: cb3J6vWlBlTYJGENrEhpY/ILhd1TRH1k/O7DgcgY4n5/0hs/b/It2asaP5XF1E8CtdVeIl2iABNU6SQipP59UkXBNTVcu0MEe+opcekJm4dl28IRQgul7MimCiB4j0aFVzWcBVZDFzO+lldiuJaVGkhmkFwLmpXKbbYk3nQtddatgUPUJSSe0jN8f+n+4ROUnvtpofrvVAl0XkrfV5csys5ZMeyEzAnQDdO2+e79P5eKt0lZAiIcHbnAw5i/qk1jTnyPrmGtJQ/5g6WYS6FM5fv7uDq5W/1a4liqnQk3hIz/JF9D2JI9BCv/87kxHzpFMyPI1fwphT+z0Y6nEEdm6OVyr566XOk4yJMZrUytPA/kR+ySLPvRz90a58DuIXyU3+s3IZSDohv5BO4i28XEfu/m1KGWC5LZB8SZ/0Ui8COJk7inVH+XI4S0FrAJGhA6soEkIq1h9A1V+znW28OlCU+IxZBsFI/Jb/cGfSeCIIlaG7wtJRa5igw2LrRkjFbTfemDccOcRz6bfrS1MyeGBy9Q4MwnUWtcchI9s62Kue5hTDizt2Hvzw5IgIZklGIOkJj1KsxH2cHJB+fsEuCR0Kf84Md6SWf2rWxUwfBCbh8Juxa6jHlgxPdWdiCWs6ZN X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH2PR12MB9457.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(376014)(23010399003)(366016)(13003099007)(18002099003)(22082099003)(56012099006)(4143699003)(11063799006)(8096899003)(261009223027099003)(261026121527099003)(261026140227099003)(261028144727099003)(261022105027099003)(261021121427099003)(10067099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?YUg4MjRyR2hka29YR05hWkVFVzh0N3V3a1A5VkRzaC85dVU4clVYZ2xJdC9C?= =?utf-8?B?Z1orUFVxMVErcHlaMFhHUTRiaU53b0ZWN1pWeFRqbEZtMnIvLzY4TmpHOXVX?= =?utf-8?B?THpSSWtJSFlqb0hkOGRzbHVlbDZBTUhldzlCZGRlSk5tbG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IS2k5MTVYekJhSHp5RkFQUTJZcFd6c3psUDRmRGF4dXk1Zlp6?= =?utf-8?B?S0QzQ1VoVklER2xNTU9oU1dqOFlUM1BoWWNMTzY1dmRHMVdJcmp1UHB3TFBM?= =?utf-8?B?VkJ1OFZOSlEvODF0M05OVGp4bVpOdDFsb0dLNk5KNFZ1QjBhTkJseWplUnVH?= =?utf-8?B?ak85TjBwTFR1OFJpRDh0djFsVXpiWWd2YVVDcFZNQjlvakpuOXdNR09zVFBS?= =?utf-8?B?d2Vtdk95NXZPU2hiNzBSQ0RNZ2RrZGF4YTBFQlpyRnFaNk9tT1dxaDlTY2pN?= =?utf-8?B?N21pcXlGQUpxM1NhcmlBNDFybHFSK003b1d5UllhRWFqMGFnbHBiTldBWkRV?= =?utf-8?B?dUFvOXVQWm9STk1HZ0NhU1kzb253NVkzUFlGQ1J6TnhMYk9WM3ZmQT09?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3a0f471d-3f98-4acd-7613-08df364c8200 X-MS-Exchange-CrossTenant-AuthSource: CH2PR12MB9457.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2026 06:10:33.7954 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: zZmnS5MhT8X+z6+1YaviUQK0ngWKX2fRduCP5A4p0Qbwbk0wGQbA3KDEU/04uObImlKpaXLI/A8etOtUMFsEGg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4439 X-BeenThere: amd-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion list for AMD gfx List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "amd-gfx" X-Spam-Status: No, score=-14.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, HTML_MESSAGE,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 --------------hhns7jLoM6YRxnm7l2rzZBET Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 10/29/2026 9:37 PM, James Zhu wrote: > > On 2026-10-28 23:13, Zhu, Lingshan wrote: >> On 10/28/2026 8:53 PM, Zhu, James wrote: >>> AMD General >>> >>> Hi, Lingshan, >>> >>> Sorry to reply later! Just be back from vacation. >>> >>> Yes, there is only one set of PMC registers on the device. >>> But the minimum control scope is XCC. So, I think we should design >>> PMC based on >>> Node instead of device. We need not enable the PMC on XCCs which >>> have no PMC >>> data collection request. >>> Since the request is based on render node. >> They are per-device registers, so the scope should be the device, not >> XCC. > [JZ] where did you get this information? From what I know, Compute / > Shader PMCs / RLC & SPM Control / //  /  / / PC Sampling are all XCC > based.  a are all  are For GFX11/12, the instance number of XCC is 0, therefore their xcc_mask is 1, so the registers are per-device. You can read these information from sysfs and debugfs. Please also take a look at KFD implementation at https://lists.freedesktop.org/archives/amd-gfx/2026-February/138408.html It says: multiple PMC profilers on the same device can result in corrupted counter data >> >> Another reason is, I assume we don't want one user to sniff another >> through PMC. > [JZ] if it is true, is it more easy to sniffer  for per device design. > the other nodes within the same device will enable PMC unexpectedly. so we have implemented reservation/locking for PMC. Thanks Lingshan >> >> Thanks >> Lingshan >>> Thanks & Best Regards! >>> >>> James Zhu >>> >>> -------------------------------------------------------------------------------- >>> >>> *From:* Zhu, Lingshan >>> *Sent:* Thursday, October 8, 2026 3:50 AM >>> *To:* Zhu, James; Deucher, Alexander >>> ; Kuehling, Felix >>> *Cc:* Huang, Ray;amd-gfx@lists.freedesktop.org >>> >>> *Subject:* Re: [RFC 02/10] drm/amdgpu: add device-wide PMC config >>> >>> On 9/24/2026 11:40 PM, James Zhu wrote: >>> >>>> On 2026-09-23 23:23, Zhu, Lingshan wrote: >>>>> On 9/23/2026 10:13 PM, James Zhu wrote: >>>>>> On 2026-09-22 05:34, Zhu Lingshan wrote: >>>>>>> This commit implements a device-wide PMC config >>>>>>> for amdgpu, which including the profiling owner, >>>>>>> and the profiling enablement indicator. >>>>>> [JZ] I think it should be render-node wide, not device-wide >>>>> Hi James, >>>>> >>>>> It could be, but we don't have a requirement document defines the >>>>> scope. >>>>> >>>>> But normally a profiler is a device scope, >>>>> I see KFD profiler operates on all queues under the device queue >>>>> manager >>>> [JZ] One device could be split into multiple nodes with different >>>> processes >>>> running. >>>> >>>> I am wondering if this is really we want.  Ben may comment on it. >>> Hello James, >>> >>> Sorry for the late reply, it was mid-autumn festival and national >>> holidays. >>> >>> In my understanding, there is only one set of PMC registers on the >>> device, so it should >>> be device scope. >>> >>> Thanks >>> Lingshan >>> >>>>> Thanks >>>>> Lingshan >>>>>>> Signed-off-by: Zhu Lingshan >>>>>>> >>>>>>> --- >>>>>>>    drivers/gpu/drm/amd/amdgpu/amdgpu.h        | 8 ++++++++ >>>>>>>    drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 +++ >>>>>>>    2 files changed, 11 insertions(+) >>>>>>> >>>>>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h >>>>>>> b/drivers/gpu/drm/amd/ >>>>>>> amdgpu/amdgpu.h >>>>>>> index 8eff6b9ebe81..45897dca802f 100644 >>>>>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h >>>>>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h >>>>>>> @@ -620,6 +620,12 @@ enum amdgpu_enforce_isolation_mode { >>>>>>>        AMDGPU_ENFORCE_ISOLATION_NO_CLEANER_SHADER = 3, >>>>>>>    }; >>>>>>>    +struct amdgpu_pmc_profiler { >>>>>>> +    struct mutex        lock; >>>>>>> +    struct drm_file        *owner; >>>>>>> +    bool            enable; >>>>>>> +}; >>>>>>> + >>>>>>>    struct amdgpu_device { >>>>>>>        struct device            *dev; >>>>>>>        struct pci_dev            *pdev; >>>>>>> @@ -818,6 +824,8 @@ struct amdgpu_device { >>>>>>>         */ >>>>>>>        struct xarray userq_doorbell_xa; >>>>>>>    +    struct amdgpu_pmc_profiler    pmc_profiler; >>>>>>> + >>>>>>>        /* df */ >>>>>>>        struct amdgpu_df                df; >>>>>>>    diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c >>>>>>> b/drivers/gpu/ >>>>>>> drm/amd/amdgpu/amdgpu_device.c >>>>>>> index c924a55fd16f..74ed42e53264 100644 >>>>>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c >>>>>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c >>>>>>> @@ -3673,6 +3673,7 @@ int amdgpu_device_init(struct >>>>>>> amdgpu_device *adev, >>>>>>>        mutex_init(&adev->pm.stable_pstate_ctx_lock); >>>>>>>        mutex_init(&adev->benchmark_mutex); >>>>>>>        mutex_init(&adev->gfx.reset_sem_mutex); >>>>>>> +    mutex_init(&adev->pmc_profiler.lock); >>>>>>>          /* Associate locks with lockdep classes for ordering >>>>>>> validation */ >>>>>>>        amdgpu_lockdep_set_class(adev); >>>>>>> @@ -4244,6 +4245,8 @@ void amdgpu_device_fini_sw(struct >>>>>>> amdgpu_device *adev) >>>>>>>        kfree(adev->pci_state); >>>>>>>        kfree(adev->pcie_reset_ctx.swds_pcistate); >>>>>>>        kfree(adev->pcie_reset_ctx.swus_pcistate); >>>>>>> + >>>>>>> +    mutex_destroy(&adev->pmc_profiler.lock); >>>>>>>    } >>>>>>>      /** --------------hhns7jLoM6YRxnm7l2rzZBET Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
On 10/29/2026 9:37 PM, James Zhu wrote:

On 2026-10-28 23:13, Zhu, Lingshan wrote:
On 10/28/2026 8:53 PM, Zhu, James wrote:
AMD General

Hi, Lingshan,

Sorry to reply later! Just be back from vacation.

Yes, there is only one set of PMC registers on the device.
But the minimum control scope is XCC. So, I think we should design PMC based on
Node instead of device. We need not enable the PMC on XCCs which have no PMC
data collection request.
Since the request is based on render node.
They are per-device registers, so the scope should be the device, not XCC.
[JZ] where did you get this information? From what I know, Compute / Shader PMCs / RLC & SPM Control / //  /  / / PC Sampling are all XCC based.  a are all  are
For GFX11/12, the instance number of XCC is 0, therefore their xcc_mask is 1, so the registers are per-device.
You can read these information from sysfs and debugfs.

Please also take a look at KFD implementation at https://lists.freedesktop.org/archives/amd-gfx/2026-February/138408.html

It says: multiple PMC profilers on the same device can result in corrupted counter data

Another reason is, I assume we don't want one user to sniff another through PMC.
[JZ] if it is true, is it more easy to sniffer  for per device design. the other nodes within the same device will enable PMC unexpectedly.
so we have implemented reservation/locking for PMC.

Thanks
Lingshan

Thanks
Lingshan
Thanks & Best Regards!

James Zhu

--------------------------------------------------------------------------------
*From:* Zhu, Lingshan<Lingshan.Zhu@amd.com>
*Sent:* Thursday, October 8, 2026 3:50 AM
*To:* Zhu, James<James.Zhu@amd.com>; Deucher, Alexander
<Alexander.Deucher@amd.com>; Kuehling, Felix<Felix.Kuehling@amd.com>
*Cc:* Huang, Ray<Ray.Huang@amd.com>;amd-gfx@lists.freedesktop.org <amd- gfx@lists.freedesktop.org>
*Subject:* Re: [RFC 02/10] drm/amdgpu: add device-wide PMC config

On 9/24/2026 11:40 PM, James Zhu wrote:

On 2026-09-23 23:23, Zhu, Lingshan wrote:
On 9/23/2026 10:13 PM, James Zhu wrote:
On 2026-09-22 05:34, Zhu Lingshan wrote:
This commit implements a device-wide PMC config
for amdgpu, which including the profiling owner,
and the profiling enablement indicator.
[JZ] I think it should be render-node wide, not device-wide
Hi James,

It could be, but we don't have a requirement document defines the scope.

But normally a profiler is a device scope,
I see KFD profiler operates on all queues under the device queue manager
[JZ] One device could be split into multiple nodes with different processes
running.

I am wondering if this is really we want.  Ben may comment on it.
Hello James,

Sorry for the late reply, it was mid-autumn festival and national holidays.

In my understanding, there is only one set of PMC registers on the device, so it should
be device scope.

Thanks
Lingshan

Thanks
Lingshan
Signed-off-by: Zhu Lingshan<lingshan.zhu@amd.com> <mailto:lingshan.zhu@amd.com>
---
   drivers/gpu/drm/amd/amdgpu/amdgpu.h        | 8 ++++++++
   drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 +++
   2 files changed, 11 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/
amdgpu/amdgpu.h
index 8eff6b9ebe81..45897dca802f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -620,6 +620,12 @@ enum amdgpu_enforce_isolation_mode {
       AMDGPU_ENFORCE_ISOLATION_NO_CLEANER_SHADER = 3,
   };
   +struct amdgpu_pmc_profiler {
+    struct mutex        lock;
+    struct drm_file        *owner;
+    bool            enable;
+};
+
   struct amdgpu_device {
       struct device            *dev;
       struct pci_dev            *pdev;
@@ -818,6 +824,8 @@ struct amdgpu_device {
        */
       struct xarray userq_doorbell_xa;
   +    struct amdgpu_pmc_profiler    pmc_profiler;
+
       /* df */
       struct amdgpu_df                df;
   diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/
drm/amd/amdgpu/amdgpu_device.c
index c924a55fd16f..74ed42e53264 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -3673,6 +3673,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
       mutex_init(&adev->pm.stable_pstate_ctx_lock);
       mutex_init(&adev->benchmark_mutex);
       mutex_init(&adev->gfx.reset_sem_mutex);
+    mutex_init(&adev->pmc_profiler.lock);
         /* Associate locks with lockdep classes for ordering validation */
       amdgpu_lockdep_set_class(adev);
@@ -4244,6 +4245,8 @@ void amdgpu_device_fini_sw(struct amdgpu_device *adev)
       kfree(adev->pci_state);
       kfree(adev->pcie_reset_ctx.swds_pcistate);
       kfree(adev->pcie_reset_ctx.swus_pcistate);
+
+    mutex_destroy(&adev->pmc_profiler.lock);
   }
     /**
--------------hhns7jLoM6YRxnm7l2rzZBET--