This commit implements a device-wide PMC config for amdgpu, which including the profiling owner, and the profiling enablement indicator.
Signed-off-by: Zhu Lingshan <[email protected]> Reviewed-by: Benjamin Welton <[email protected]> --- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 9 +++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 +++ 2 files changed, 12 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index e3763c197138..f1db089921a7 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h @@ -620,6 +620,13 @@ enum amdgpu_enforce_isolation_mode { AMDGPU_ENFORCE_ISOLATION_NO_CLEANER_SHADER = 3, }; +struct amdgpu_pmc_profiler { + struct mutex lock; + struct drm_file *owner; + bool supported; + bool enable; +}; + struct amdgpu_device { struct device *dev; struct pci_dev *pdev; @@ -818,6 +825,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 380989f4c965..c466f67c6556 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); } /** -- 2.53.0
