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

Signed-off-by: Zhu Lingshan <[email protected]>
---
  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);
  }
/**

Reply via email to