drm/amdgpu: xgmi counters via perfevent
Subsystems (2)
PATCH 1/1 drm/amdgpu: xgmi counters via perfevent
get xgmi counters through perf_event.h.
added files:
amdgpu_pmu.c/h - handles perf event logic (e.g. start/stop/add/delete) amdgpu_df_pmc.c/h - xgmi counter setup logic via DF PerfmonCtr
modified files:soc15.c - added xgmi specific r/w functions to setup/read DF perfmonCtr amdgpu_device.c - added init call for amdgpu_pmuamdgpu.h - added macros for xgmi perf functions in soc15.c Makefile - added call to build amdgpu_pmu and amdgpu_df_pmc object files
validated on Vega20 D16302 2P system.
Change-Id I5ce94953b0a7919684c753d3006f0d44963b6bb5
Signed-off-by Jonathan Kim <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/Makefile | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 17 + drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 5 + drivers/gpu/drm/amd/amdgpu/amdgpu_df_pmc.c | 170 +++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_df_pmc.h | 65 ++++ drivers/gpu/drm/amd/amdgpu/amdgpu_pmu.c | 383 +++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_pmu.h | 37 ++ drivers/gpu/drm/amd/amdgpu/soc15.c | 159 ++++++++- 8 files changed, 829 insertions(+), 9 deletions(-) create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_df_pmc.c create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_df_pmc.h create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_pmu.c create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_pmu.h
drivers/gpu/drm/amd/amdgpu/Makefile +1 -1
@@ -54,7 +54,7 @@ amdgpu-y += amdgpu_device.o amdgpu_kms.o \ amdgpu_gtt_mgr.o amdgpu_vram_mgr.o amdgpu_virt.o amdgpu_atomfirmware.o \ amdgpu_vf_error.o amdgpu_sched.o amdgpu_debugfs.o amdgpu_ids.o \ amdgpu_gmc.o amdgpu_xgmi.o amdgpu_csa.o amdgpu_ras.o amdgpu_vm_cpu.o \ - amdgpu_vm_sdma.o + amdgpu_vm_sdma.o amdgpu_df_pmc.o amdgpu_pmu.o # add asic specific block amdgpu-$(CONFIG_DRM_AMDGPU_CIK)+= cik.o cik_ih.o kv_smc.o kv_dpm.o \
drivers/gpu/drm/amd/amdgpu/amdgpu.h +17 -0
@@ -558,6 +558,19 @@ struct amdgpu_asic_funcs { uint64_t *count1);/* do we need to reset the asic at init time (e.g., kexec) */ bool (*need_reset_on_init)(struct amdgpu_device *adev); + +/* xGMI link utilization */ +void (*get_xgmi_link_cntr)(struct amdgpu_device *adev, +int instance, +uint64_t *count); +int (*start_xgmi_link_cntr)(struct amdgpu_device *adev, +int instance, +int is_enable); +int (*stop_xgmi_link_cntr)(struct amdgpu_device *adev, +int instance, +int is_disable); +void (*reset_xgmi_link_cntr)(struct amdgpu_device *adev, +int instance); };/*
@@ -1068,6 +1081,10 @@ int emu_soc_asic_init(struct amdgpu_device *adev);#define amdgpu_asic_init_doorbell_index (adev) (adev)->asic_funcs->init_doorbell_index((adev))#define amdgpu_asic_get_pcie_usage (adev, cnt0, cnt1) ((adev)->asic_funcs->get_pcie_usage((adev), (cnt0), (cnt1)))#define amdgpu_asic_need_reset_on_init (adev) (adev)->asic_funcs->need_reset_on_init((adev)) +#define amdgpu_asic_get_xgmi_link_cntr (adev, instance, count) ((adev)->asic_funcs->get_xgmi_link_cntr((adev), (instance), (count))) +#define amdgpu_asic_start_xgmi_link_cntr (adev, instance, is_enable) ((adev)->asic_funcs->start_xgmi_link_cntr((adev), (instance), (is_enable))) +#define amdgpu_asic_stop_xgmi_link_cntr (adev, instance, is_disable) ((adev)->asic_funcs->stop_xgmi_link_cntr((adev), (instance), (is_disable))) +#define amdgpu_asic_reset_xgmi_link_cntr (adev, instance) ((adev)->asic_funcs->reset_xgmi_link_cntr((adev), (instance)))/* Common functions */ bool amdgpu_device_should_recover_gpu (struct amdgpu_device *adev);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +5 -0
@@ -61,6 +61,7 @@#include "amdgpu_xgmi.h" #include "amdgpu_ras.h" +#include "amdgpu_pmu.h" MODULE_FIRMWARE ("amdgpu/vega10_gpu_info.bin" );MODULE_FIRMWARE ("amdgpu/vega12_gpu_info.bin" );
@@ -2711,6 +2712,10 @@ int amdgpu_device_init(struct amdgpu_device *adev, goto failed; } + r =amdgpu_pmu_init (adev); +if (r) +dev_err (adev->dev,"amdgpu_pmu_init failed\n" ); +/* must succeed. */ amdgpu_ras_post_init (adev);
drivers/gpu/drm/amd/amdgpu/amdgpu_df_pmc.c new file +170 -0
170 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_df_pmc.h new file +65 -0
65 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_pmu.c new file +383 -0
383 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_pmu.h new file +37 -0
@@ -0,0 +1,37 @@ +/* +* Copyright 2019 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. +* +* Author: Jonathan Kim <[email protected]> +* +*/ + +#ifndef _AMDGPU_PMU_H_ +#define _AMDGPU_PMU_H_ + +enum amdgpu_pmu_perf_type { +PERF_TYPE_AMDGPU_DF =0 , +PERF_TYPE_AMDGPU_MAX +}; + + +int amdgpu_pmu_init (struct amdgpu_device *adev); + +#endif /* _AMDGPU_PMU_H_ */
drivers/gpu/drm/amd/amdgpu/soc15.c +151 -8
219 lines not on this page · raw message
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx