kfd_topology.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. /* SPDX-License-Identifier: GPL-2.0 OR MIT */
  2. /*
  3. * Copyright 2014-2022 Advanced Micro Devices, Inc.
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining a
  6. * copy of this software and associated documentation files (the "Software"),
  7. * to deal in the Software without restriction, including without limitation
  8. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  9. * and/or sell copies of the Software, and to permit persons to whom the
  10. * Software is furnished to do so, subject to the following conditions:
  11. *
  12. * The above copyright notice and this permission notice shall be included in
  13. * all copies or substantial portions of the Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  18. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  19. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  20. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  21. * OTHER DEALINGS IN THE SOFTWARE.
  22. */
  23. #ifndef __KFD_TOPOLOGY_H__
  24. #define __KFD_TOPOLOGY_H__
  25. #include <linux/dmi.h>
  26. #include <linux/types.h>
  27. #include <linux/list.h>
  28. #include <linux/kfd_sysfs.h>
  29. #include "kfd_crat.h"
  30. #define KFD_TOPOLOGY_PUBLIC_NAME_SIZE 32
  31. #define HSA_DBG_WATCH_ADDR_MASK_LO_BIT_GFX9 6
  32. #define HSA_DBG_WATCH_ADDR_MASK_LO_BIT_GFX9_4_3 7
  33. #define HSA_DBG_WATCH_ADDR_MASK_LO_BIT_GFX10 7
  34. #define HSA_DBG_WATCH_ADDR_MASK_HI_BIT \
  35. (29 << HSA_DBG_WATCH_ADDR_MASK_HI_BIT_SHIFT)
  36. #define HSA_DBG_WATCH_ADDR_MASK_HI_BIT_GFX9_4_3 \
  37. (30 << HSA_DBG_WATCH_ADDR_MASK_HI_BIT_SHIFT)
  38. struct kfd_node_properties {
  39. uint64_t hive_id;
  40. uint32_t cpu_cores_count;
  41. uint32_t simd_count;
  42. uint32_t mem_banks_count;
  43. uint32_t caches_count;
  44. uint32_t io_links_count;
  45. uint32_t p2p_links_count;
  46. uint32_t cpu_core_id_base;
  47. uint32_t simd_id_base;
  48. uint32_t capability;
  49. uint32_t capability2;
  50. uint64_t debug_prop;
  51. uint32_t max_waves_per_simd;
  52. uint32_t lds_size_in_kb;
  53. uint32_t gds_size_in_kb;
  54. uint32_t num_gws;
  55. uint32_t wave_front_size;
  56. uint32_t array_count;
  57. uint32_t simd_arrays_per_engine;
  58. uint32_t cu_per_simd_array;
  59. uint32_t simd_per_cu;
  60. uint32_t max_slots_scratch_cu;
  61. uint32_t engine_id;
  62. uint32_t gfx_target_version;
  63. uint32_t vendor_id;
  64. uint32_t device_id;
  65. uint32_t location_id;
  66. uint32_t domain;
  67. uint32_t max_engine_clk_fcompute;
  68. uint32_t max_engine_clk_ccompute;
  69. int32_t drm_render_minor;
  70. uint32_t num_sdma_engines;
  71. uint32_t num_sdma_xgmi_engines;
  72. uint32_t num_sdma_queues_per_engine;
  73. uint32_t num_cp_queues;
  74. uint32_t cwsr_size;
  75. uint32_t ctl_stack_size;
  76. uint32_t eop_buffer_size;
  77. uint32_t debug_memory_size;
  78. char name[KFD_TOPOLOGY_PUBLIC_NAME_SIZE];
  79. };
  80. struct kfd_mem_properties {
  81. struct list_head list;
  82. uint32_t heap_type;
  83. uint64_t size_in_bytes;
  84. uint32_t flags;
  85. uint32_t width;
  86. uint32_t mem_clk_max;
  87. struct kfd_node *gpu;
  88. struct kobject *kobj;
  89. struct attribute attr;
  90. };
  91. #define CACHE_SIBLINGMAP_SIZE 128
  92. struct kfd_cache_properties {
  93. struct list_head list;
  94. uint32_t processor_id_low;
  95. uint32_t cache_level;
  96. uint32_t cache_size;
  97. uint32_t cacheline_size;
  98. uint32_t cachelines_per_tag;
  99. uint32_t cache_assoc;
  100. uint32_t cache_latency;
  101. uint32_t cache_type;
  102. uint8_t sibling_map[CACHE_SIBLINGMAP_SIZE];
  103. struct kfd_node *gpu;
  104. struct kobject *kobj;
  105. struct attribute attr;
  106. uint32_t sibling_map_size;
  107. };
  108. struct kfd_iolink_properties {
  109. struct list_head list;
  110. uint32_t iolink_type;
  111. uint32_t ver_maj;
  112. uint32_t ver_min;
  113. uint32_t node_from;
  114. uint32_t node_to;
  115. uint32_t weight;
  116. uint32_t min_latency;
  117. uint32_t max_latency;
  118. uint32_t min_bandwidth;
  119. uint32_t max_bandwidth;
  120. uint32_t rec_transfer_size;
  121. uint32_t rec_sdma_eng_id_mask;
  122. uint32_t flags;
  123. struct kfd_node *gpu;
  124. struct kobject *kobj;
  125. struct attribute attr;
  126. };
  127. struct kfd_perf_properties {
  128. struct list_head list;
  129. char block_name[16];
  130. uint32_t max_concurrent;
  131. struct attribute_group *attr_group;
  132. };
  133. struct kfd_topology_device {
  134. struct list_head list;
  135. uint32_t gpu_id;
  136. uint32_t proximity_domain;
  137. struct kfd_node_properties node_props;
  138. struct list_head mem_props;
  139. struct list_head cache_props;
  140. struct list_head io_link_props;
  141. struct list_head p2p_link_props;
  142. struct list_head perf_props;
  143. struct kfd_node *gpu;
  144. struct kobject *kobj_node;
  145. struct kobject *kobj_mem;
  146. struct kobject *kobj_cache;
  147. struct kobject *kobj_iolink;
  148. struct kobject *kobj_p2plink;
  149. struct kobject *kobj_perf;
  150. struct attribute attr_gpuid;
  151. struct attribute attr_name;
  152. struct attribute attr_props;
  153. union {
  154. uint8_t oem_id[CRAT_OEMID_LENGTH];
  155. uint64_t oem_id64;
  156. };
  157. uint8_t oem_table_id[CRAT_OEMTABLEID_LENGTH];
  158. uint32_t oem_revision;
  159. };
  160. struct kfd_system_properties {
  161. uint32_t num_devices; /* Number of H-NUMA nodes */
  162. uint32_t generation_count;
  163. uint64_t platform_oem;
  164. uint64_t platform_id;
  165. uint64_t platform_rev;
  166. struct kobject *kobj_topology;
  167. struct kobject *kobj_nodes;
  168. struct attribute attr_genid;
  169. struct attribute attr_props;
  170. };
  171. struct dmi_mem_device {
  172. struct dmi_header header;
  173. u16 physical_handle;
  174. u16 error_handle;
  175. u16 total_width;
  176. u16 data_width;
  177. u16 size;
  178. u8 form_factor;
  179. u8 device_set;
  180. u8 device_locator;
  181. u8 bank_locator;
  182. u8 memory_type;
  183. u16 type_detail;
  184. u16 speed;
  185. } __packed;
  186. struct kfd_topology_device *kfd_create_topology_device(
  187. struct list_head *device_list);
  188. void kfd_release_topology_device_list(struct list_head *device_list);
  189. #if IS_ENABLED(CONFIG_HSA_AMD)
  190. void kfd_update_svm_support_properties(struct amdgpu_device *adev);
  191. #else
  192. static inline void kfd_update_svm_support_properties(struct amdgpu_device *adev) {}
  193. #endif
  194. #endif /* __KFD_TOPOLOGY_H__ */