Collect amdgpu_ptl_fmt in one header so both GFX, KFD and PSP drivers can share them without duplication.
Signed-off-by: Perry Yuan <[email protected]> Suggested-by: Alex Deucher <[email protected]> Reviewed-by: Yifan Zhang <[email protected]> --- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | 2 + drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h | 23 +------ drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 1 + drivers/gpu/drm/amd/include/amdgpu_ptl.h | 60 +++++++++++++++++++ .../gpu/drm/amd/include/kgd_kfd_interface.h | 1 + include/uapi/linux/kfd_ioctl.h | 11 ---- 6 files changed, 65 insertions(+), 33 deletions(-) create mode 100644 drivers/gpu/drm/amd/include/amdgpu_ptl.h diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h index cdbab7f8cee8..4fee011c2e26 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h @@ -38,6 +38,8 @@ #include "amdgpu_vm.h" #include "amdgpu_xcp.h" #include "kfd_topology.h" +#include "amdgpu_ptl.h" + extern uint64_t amdgpu_amdkfd_total_mem_size; enum TLB_FLUSH_TYPE { diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h index c6a896003596..562f731bf16c 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h @@ -32,6 +32,7 @@ #include "ta_rap_if.h" #include "ta_secureDisplay_if.h" #include <linux/bitops.h> +#include "amdgpu_ptl.h" #define PSP_FENCE_BUFFER_SIZE 0x1000 #define PSP_CMD_BUFFER_SIZE 0x1000 @@ -64,7 +65,6 @@ #define MBOX_TOS_RESP_MASK (GFX_CMD_RESPONSE_MASK | GFX_CMD_STATUS_MASK) extern const struct attribute_group amdgpu_flash_attr_group; -extern const struct attribute_group amdgpu_ptl_attr_group; enum psp_shared_mem_size { PSP_ASD_SHARED_MEM_SIZE = 0x0, @@ -385,24 +385,6 @@ struct psp_ptl_perf_req { uint32_t pref_format2; }; -enum amdgpu_ptl_disable_source { - AMDGPU_PTL_DISABLE_SYSFS = 0, - AMDGPU_PTL_DISABLE_PROFILER, - AMDGPU_PTL_DISABLE_MAX, -}; - -struct amdgpu_ptl { - enum amdgpu_ptl_fmt fmt1; - enum amdgpu_ptl_fmt fmt2; - bool enabled; - bool hw_supported; - bool permanently_disabled; - /* PTL disable reference counting */ - atomic_t disable_ref; - struct mutex mutex; - DECLARE_BITMAP(disable_bitmap, AMDGPU_PTL_DISABLE_MAX); -}; - struct psp_context { struct amdgpu_device *adev; struct psp_ring km_ring; @@ -679,7 +661,4 @@ int amdgpu_psp_get_fw_type(struct amdgpu_firmware_info *ucode, int amdgpu_ptl_perf_monitor_ctrl(struct amdgpu_device *adev, u32 req_code, u32 *ptl_state, u32 *fmt1, u32 *fmt2); -int amdgpu_ptl_sysfs_init(struct amdgpu_device *adev); -void amdgpu_ptl_sysfs_fini(struct amdgpu_device *adev); - #endif diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c index f375dffcbdf6..eacb2ab25a6f 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c @@ -44,6 +44,7 @@ #include "kfd_smi_events.h" #include "amdgpu_dma_buf.h" #include "kfd_debug.h" +#include "amdgpu_ptl.h" static long kfd_ioctl(struct file *, unsigned int, unsigned long); static int kfd_open(struct inode *, struct file *); diff --git a/drivers/gpu/drm/amd/include/amdgpu_ptl.h b/drivers/gpu/drm/amd/include/amdgpu_ptl.h new file mode 100644 index 000000000000..19eb8f6a765c --- /dev/null +++ b/drivers/gpu/drm/amd/include/amdgpu_ptl.h @@ -0,0 +1,60 @@ +/* + * Copyright 2026 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. + */ + +#ifndef __AMDGPU_PTL_H__ +#define __AMDGPU_PTL_H__ + +enum amdgpu_ptl_fmt { + AMDGPU_PTL_FMT_I8 = 0, + AMDGPU_PTL_FMT_F16 = 1, + AMDGPU_PTL_FMT_BF16 = 2, + AMDGPU_PTL_FMT_F32 = 3, + AMDGPU_PTL_FMT_F64 = 4, + AMDGPU_PTL_FMT_F8 = 5, + AMDGPU_PTL_FMT_VECTOR = 6, + AMDGPU_PTL_FMT_INVALID = 7, +}; + +enum amdgpu_ptl_disable_source { + AMDGPU_PTL_DISABLE_SYSFS = 0, + AMDGPU_PTL_DISABLE_PROFILER, + AMDGPU_PTL_DISABLE_MAX, +}; + +struct amdgpu_ptl { + enum amdgpu_ptl_fmt fmt1; + enum amdgpu_ptl_fmt fmt2; + bool enabled; + bool hw_supported; + bool permanently_disabled; + /* PTL disable reference counting */ + atomic_t disable_ref; + struct mutex mutex; + DECLARE_BITMAP(disable_bitmap, AMDGPU_PTL_DISABLE_MAX); +}; + +int amdgpu_ptl_sysfs_init(struct amdgpu_device *adev); +void amdgpu_ptl_sysfs_fini(struct amdgpu_device *adev); + +extern const struct attribute_group amdgpu_ptl_attr_group; + +#endif /* __AMDGPU_PTL_H__ */ diff --git a/drivers/gpu/drm/amd/include/kgd_kfd_interface.h b/drivers/gpu/drm/amd/include/kgd_kfd_interface.h index 295ce9364362..44e225e097d0 100644 --- a/drivers/gpu/drm/amd/include/kgd_kfd_interface.h +++ b/drivers/gpu/drm/amd/include/kgd_kfd_interface.h @@ -33,6 +33,7 @@ #include <linux/dma-fence.h> #include "amdgpu_irq.h" #include "amdgpu_gfx.h" +#include "amdgpu_ptl.h" struct pci_dev; struct amdgpu_device; diff --git a/include/uapi/linux/kfd_ioctl.h b/include/uapi/linux/kfd_ioctl.h index 905acff01700..32550e581673 100644 --- a/include/uapi/linux/kfd_ioctl.h +++ b/include/uapi/linux/kfd_ioctl.h @@ -1558,17 +1558,6 @@ struct kfd_ioctl_dbg_trap_args { }; }; -enum amdgpu_ptl_fmt { - AMDGPU_PTL_FMT_I8 = 0, - AMDGPU_PTL_FMT_F16 = 1, - AMDGPU_PTL_FMT_BF16 = 2, - AMDGPU_PTL_FMT_F32 = 3, - AMDGPU_PTL_FMT_F64 = 4, - AMDGPU_PTL_FMT_F8 = 5, - AMDGPU_PTL_FMT_VECTOR = 6, - AMDGPU_PTL_FMT_INVALID = 7, -}; - #define KFD_IOC_PROFILER_VERSION_NUM 1 enum kfd_profiler_ops { KFD_IOC_PROFILER_PMC = 0, -- 2.34.1
