kfd_topology.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. /*
  2. * Copyright 2014 Advanced Micro Devices, Inc.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  18. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  19. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. * OTHER DEALINGS IN THE SOFTWARE.
  21. */
  22. #ifndef __KFD_TOPOLOGY_H__
  23. #define __KFD_TOPOLOGY_H__
  24. #include <linux/types.h>
  25. #include <linux/list.h>
  26. #include "kfd_crat.h"
  27. #define KFD_TOPOLOGY_PUBLIC_NAME_SIZE 128
  28. #define HSA_CAP_HOT_PLUGGABLE 0x00000001
  29. #define HSA_CAP_ATS_PRESENT 0x00000002
  30. #define HSA_CAP_SHARED_WITH_GRAPHICS 0x00000004
  31. #define HSA_CAP_QUEUE_SIZE_POW2 0x00000008
  32. #define HSA_CAP_QUEUE_SIZE_32BIT 0x00000010
  33. #define HSA_CAP_QUEUE_IDLE_EVENT 0x00000020
  34. #define HSA_CAP_VA_LIMIT 0x00000040
  35. #define HSA_CAP_WATCH_POINTS_SUPPORTED 0x00000080
  36. #define HSA_CAP_WATCH_POINTS_TOTALBITS_MASK 0x00000f00
  37. #define HSA_CAP_WATCH_POINTS_TOTALBITS_SHIFT 8
  38. #define HSA_CAP_DOORBELL_TYPE_TOTALBITS_MASK 0x00003000
  39. #define HSA_CAP_DOORBELL_TYPE_TOTALBITS_SHIFT 12
  40. #define HSA_CAP_RESERVED 0xffffc000
  41. #define HSA_CAP_DOORBELL_TYPE_PRE_1_0 0x0
  42. #define HSA_CAP_DOORBELL_TYPE_1_0 0x1
  43. #define HSA_CAP_DOORBELL_TYPE_2_0 0x2
  44. #define HSA_CAP_AQL_QUEUE_DOUBLE_MAP 0x00004000
  45. struct kfd_node_properties {
  46. uint32_t cpu_cores_count;
  47. uint32_t simd_count;
  48. uint32_t mem_banks_count;
  49. uint32_t caches_count;
  50. uint32_t io_links_count;
  51. uint32_t cpu_core_id_base;
  52. uint32_t simd_id_base;
  53. uint32_t capability;
  54. uint32_t max_waves_per_simd;
  55. uint32_t lds_size_in_kb;
  56. uint32_t gds_size_in_kb;
  57. uint32_t wave_front_size;
  58. uint32_t array_count;
  59. uint32_t simd_arrays_per_engine;
  60. uint32_t cu_per_simd_array;
  61. uint32_t simd_per_cu;
  62. uint32_t max_slots_scratch_cu;
  63. uint32_t engine_id;
  64. uint32_t vendor_id;
  65. uint32_t device_id;
  66. uint32_t location_id;
  67. uint32_t max_engine_clk_fcompute;
  68. uint32_t max_engine_clk_ccompute;
  69. int32_t drm_render_minor;
  70. uint16_t marketing_name[KFD_TOPOLOGY_PUBLIC_NAME_SIZE];
  71. };
  72. #define HSA_MEM_HEAP_TYPE_SYSTEM 0
  73. #define HSA_MEM_HEAP_TYPE_FB_PUBLIC 1
  74. #define HSA_MEM_HEAP_TYPE_FB_PRIVATE 2
  75. #define HSA_MEM_HEAP_TYPE_GPU_GDS 3
  76. #define HSA_MEM_HEAP_TYPE_GPU_LDS 4
  77. #define HSA_MEM_HEAP_TYPE_GPU_SCRATCH 5
  78. #define HSA_MEM_FLAGS_HOT_PLUGGABLE 0x00000001
  79. #define HSA_MEM_FLAGS_NON_VOLATILE 0x00000002
  80. #define HSA_MEM_FLAGS_RESERVED 0xfffffffc
  81. struct kfd_mem_properties {
  82. struct list_head list;
  83. uint32_t heap_type;
  84. uint64_t size_in_bytes;
  85. uint32_t flags;
  86. uint32_t width;
  87. uint32_t mem_clk_max;
  88. struct kobject *kobj;
  89. struct attribute attr;
  90. };
  91. #define HSA_CACHE_TYPE_DATA 0x00000001
  92. #define HSA_CACHE_TYPE_INSTRUCTION 0x00000002
  93. #define HSA_CACHE_TYPE_CPU 0x00000004
  94. #define HSA_CACHE_TYPE_HSACU 0x00000008
  95. #define HSA_CACHE_TYPE_RESERVED 0xfffffff0
  96. struct kfd_cache_properties {
  97. struct list_head list;
  98. uint32_t processor_id_low;
  99. uint32_t cache_level;
  100. uint32_t cache_size;
  101. uint32_t cacheline_size;
  102. uint32_t cachelines_per_tag;
  103. uint32_t cache_assoc;
  104. uint32_t cache_latency;
  105. uint32_t cache_type;
  106. uint8_t sibling_map[CRAT_SIBLINGMAP_SIZE];
  107. struct kobject *kobj;
  108. struct attribute attr;
  109. };
  110. struct kfd_iolink_properties {
  111. struct list_head list;
  112. uint32_t iolink_type;
  113. uint32_t ver_maj;
  114. uint32_t ver_min;
  115. uint32_t node_from;
  116. uint32_t node_to;
  117. uint32_t weight;
  118. uint32_t min_latency;
  119. uint32_t max_latency;
  120. uint32_t min_bandwidth;
  121. uint32_t max_bandwidth;
  122. uint32_t rec_transfer_size;
  123. uint32_t flags;
  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. uint32_t cache_count;
  140. struct list_head cache_props;
  141. uint32_t io_link_count;
  142. struct list_head io_link_props;
  143. struct list_head perf_props;
  144. struct kfd_dev *gpu;
  145. struct kobject *kobj_node;
  146. struct kobject *kobj_mem;
  147. struct kobject *kobj_cache;
  148. struct kobject *kobj_iolink;
  149. struct kobject *kobj_perf;
  150. struct attribute attr_gpuid;
  151. struct attribute attr_name;
  152. struct attribute attr_props;
  153. uint8_t oem_id[CRAT_OEMID_LENGTH];
  154. uint8_t oem_table_id[CRAT_OEMTABLEID_LENGTH];
  155. uint32_t oem_revision;
  156. };
  157. struct kfd_system_properties {
  158. uint32_t num_devices; /* Number of H-NUMA nodes */
  159. uint32_t generation_count;
  160. uint64_t platform_oem;
  161. uint64_t platform_id;
  162. uint64_t platform_rev;
  163. struct kobject *kobj_topology;
  164. struct kobject *kobj_nodes;
  165. struct attribute attr_genid;
  166. struct attribute attr_props;
  167. };
  168. struct kfd_topology_device *kfd_create_topology_device(
  169. struct list_head *device_list);
  170. void kfd_release_topology_device_list(struct list_head *device_list);
  171. #endif /* __KFD_TOPOLOGY_H__ */