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 28736606D808 for ; Wed, 4 Nov 2026 02:34:02 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AFCC610F959; Wed, 4 Nov 2026 02:33:56 +0000 (UTC) Received: from CH4PR04CU002.outbound.protection.outlook.com (mail-northcentralusazon11013012.outbound.protection.outlook.com [40.107.201.12]) by gabe.freedesktop.org (Postfix) with ESMTPS id 187CB10F978 for ; Wed, 4 Nov 2026 02:33:50 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qh4Pmzh5Lyi6StNHE8Q6UVdIqyuPOX0bKfJrG6EoWgHbVIWXTWR2bRvFf1ezwAxOUMFrXGxqG6FoEVALgIlJdKpT82ob38ueMfnUfsqm7asfk0H5szlX+CQP7+EOxdRurEnWu1qlQBfhvdiGZGHcrPbl//9iFmHHvO5IAMzbqJQ4DvWVbxFzGsSKaMaEpk1F2PZQ3mY4XBKs24seFaxBEWdD5YL9lYN9hZjXC8i6s9Vcsy0Vt8isuYJlkHBfM45dpgWDiGXh7R7zSBKNo+ICSH69jQ5FGa9ihR/9h3+GbwcYqZUUbFo1j2fjEoogv8UHA78Q0Igp9lgtkYuVZEYmjA== 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=JCnP+Er7nbU3y0J8KZTPgiUoHj6aJf32dXY7PnaCTXs=; b=TMN6q7IrMe7jdOeAdCRVjuu+YzsjZHxwjnP4WugYDRlP5z4ViEL3iGSBCVE/Anu24+PPcj9k4+7mB1RE9rYIQmMw0+Gdrm3h6JWkJONoRp1dO+Jzqiipf2ehYpjo1iEnj9OCX8UpKDQEooJxSKyEofKjbhHWKe8NgIKGyCxTcwvFXZQlj79HjUe8jVkPRba8P9Pz9KAtFwhE18sderbsVjgxdls95iaNH5sCnRYBRJEMhD836607aIhBk7zh8KYnpW5XnenR4j7n+PPF/XxcxvF6IOvbwvaVr96src7f7Te3yjVsG02kECcrf9x7+uLfA3cvbVXwRkfXPBT1eRH1Tw== 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=JCnP+Er7nbU3y0J8KZTPgiUoHj6aJf32dXY7PnaCTXs=; b=c6l+FNI2TaEOlR/oShbn662stcLunSvmSzbk1IRwnWSfYoB373xoQiqwMLtxNfl2mgxh+ELV2GjRll38RSI8b04ZQYzKspXA/XZ3tJ/mJLkS9G9lyvrzFJLHawKg11XRIRAfbio6WN1Fr5fuGcuEIVtCzT9zbjPSNCyHNFzG1d4= 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 PH7PR12MB5805.namprd12.prod.outlook.com (2603:10b6:510:1d1::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.569.12; Wed, 4 Nov 2026 02:33:46 +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.011; Wed, 4 Nov 2026 02:33:46 +0000 Content-Type: multipart/alternative; boundary="------------Qo91F8ptZGUOm34pJagMHkyY" Message-ID: <4fe2a2e2-62f0-4ce5-bc6a-d2f8777b5594@amd.com> Date: Wed, 4 Nov 2026 10:33:40 +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" , "Welton, Benjamin" 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: X-ClientProxiedBy: SEWP216CA0063.KORP216.PROD.OUTLOOK.COM (2603:1096:101:2ba::12) 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_|PH7PR12MB5805:EE_ X-MS-Office365-Filtering-Correlation-Id: 76f82031-2cd7-4b4e-b0d3-08df3a1c0ceb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|23010399003|376014|366016|1800799024|261028144727099003|261021121427099003|261022105027099003|261009223027099003|261026140227099003|261026121527099003|4143699003|11063799006|10067099003|56012099006|22082099003|18002099003|261102123227099003|13003099007|8096899003; X-Microsoft-Antispam-Message-Info: AyCE6HPvJeh4pMW2yCWvn0moLgifQ5Ry4OBrzLez7EAdYzSzSAreDAnPv79pn4tYnjDuCZqZM51sUHyDlRPDkKYf00KcCZ7/FZddO/wrFJFEeGtFfNDKCTdK8JxO20JIboSaIhAoR0FLHWl2O0u6sMHJ9eFzeGIfU76U/SVXe1SVLdRs/PLPTPY45ZwfFMOiRuuBWwMscT97u5jIbZJYrOwgfWwrXCxMI2BwDNj6Ss9A7ZwB4ydsiRTF7U2S5/GmTa0z6flT0+F5ingNmO9tJ/I9nMQ4/Kye62Ecj6zPiGj/pilEPw4xsf+NtjYyG23J6gk5tHwAbChY7mhNhVq2Z21z7ZKUaMKKYeL+zSTfspGvv9Qx7ITRw2ATRcOPFNSQrTtcOSbQ9pUsunfu99XZ9HKDEpaEmE/x5fuKMMo+VJYbwKUi9WeEmKia0ExHc1LbCUfuwjKLLPTShTLVGBBxoMukAhlnPVfIj6ngo1tTdtTV2ug/FZTENH2L+n0+QZMYqxpJopWw6vd7J0SqeaBcSFete8JA2EJlEochgk9kuj8VNYPmC2XbvCy+nRtld60Al69KB+q0R80AuMrV6vAq2tsBUTgN/7reju8t8NksOZDCNNUcmYiDI6AXoHjXxSWX 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)(23010399003)(376014)(366016)(1800799024)(261028144727099003)(261021121427099003)(261022105027099003)(261009223027099003)(261026140227099003)(261026121527099003)(4143699003)(11063799006)(10067099003)(56012099006)(22082099003)(18002099003)(261102123227099003)(13003099007)(8096899003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?ZUJOTU96ZHllczdaN3I5TjJUaEJLRVA0eGNjd0ZzMWE5d1dRYlNLVDd5bEJK?= =?utf-8?B?VjNsL2l0RU82NTJkZzlxdFRVZGFPc2hlMnBndXh6SHNDaWtmN2N5UHdGYzll?= =?utf-8?B?YnZHanhhcUlvT0pVWllOVkF3SGlVVzVCbjVuLzBpRWFsQWEzL2d6WFowQUkz?= =?utf-8?B?SmN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YaXBMNk9zdTNw?= =?utf-8?B?ZXpZb1F4eUhxanVBaVNPNi8wYVIrL0VUSjhCZXo0OVdObGJIb3duWW85TDg3?= =?utf-8?B?Y0w1aHNnaU0xaWNLVDNUUy9IVW10c25xSi9jRzNZMXFGTC90czhRQXVscU03?= =?utf-8?B?aGViZ0lJMkRkUU5zL2lEdGlqd3UvTlB6MmFwT3Y0ck1iSjdGU2RHSzEvV01W?= =?utf-8?B?SGtNaktrdFhtTDNTaDJscmFMa2gxSFN0Tm9oS3dFdCtZV3R2RU9xckxOVkUx?= =?utf-8?B?V2x5bmpTcDFtM2hkdXo5MGNLSk5hT3QxN09YSkpEdGhpckxRc1BJYmxzb0tG?= =?utf-8?B?Tm0relYzSFAwSGdNQzBYTjhTUmxaWExlQ05YNzdoWW1qNmREeU94QT09?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 76f82031-2cd7-4b4e-b0d3-08df3a1c0ceb X-MS-Exchange-CrossTenant-AuthSource: CH2PR12MB9457.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Nov 2026 02:33:46.2934 (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: rCJDA+/1PgvJ1wI1X/hhZaQc21vC1WunyCwa91/+hikqIhFaDD1thhYftfcn5TipV55mI2Cn0YlNQ+JkDYlKNQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB5805 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 --------------Qo91F8ptZGUOm34pJagMHkyY Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 10/30/2026 8:39 PM, James Zhu wrote: > > On 2026-10-30 02:10, Zhu, Lingshan wrote: >> 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 >> athttps://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 > > [JZ] IIUC, the corruption data is with multiple processes enabled on > same xcc. We still can have lock design to avoid multiple processes > running on same node(same XCCs). we can run one PMC profiler on node1 > only and leave other nodes on the same device have its own one only > PMC profilers process running without affecting each other,. This implementation only modifies perf_count_enable field in MQD, not touching per-XCC registers, and you have agreed that PMC registers are per-device before, so lets stick to the KFD design because it has been proven to work and this is a porting of KFD PMC. Thanks Lingshan > >>>> >>>> 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); >>>>>>>>>    } >>>>>>>>>      /** --------------Qo91F8ptZGUOm34pJagMHkyY Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
On 10/30/2026 8:39 PM, James Zhu wrote:

On 2026-10-30 02:10, Zhu, Lingshan wrote:
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 athttps://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

[JZ] IIUC, the corruption data is with multiple processes enabled on same xcc. We still can have lock design to avoid multiple processes running on same node(same XCCs). we can run one PMC profiler on node1 only and leave other nodes on the same device have its own one only PMC profilers process running without affecting each other,.
This implementation only modifies perf_count_enable field in MQD, not touching per-XCC registers, and you have agreed that PMC registers are per-device before,
so lets stick to the KFD design because it has been proven to work and this is a porting of KFD PMC.

Thanks
Lingshan


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);
   }
     /**
--------------Qo91F8ptZGUOm34pJagMHkyY--