kfd_topology.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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_priv.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_AQL_QUEUE_DOUBLE_MAP 0x00004000
  44. struct kfd_node_properties {
  45. uint32_t cpu_cores_count;
  46. uint32_t simd_count;
  47. uint32_t mem_banks_count;
  48. uint32_t caches_count;
  49. uint32_t io_links_count;
  50. uint32_t cpu_core_id_base;
  51. uint32_t simd_id_base;
  52. uint32_t capability;
  53. uint32_t max_waves_per_simd;
  54. uint32_t lds_size_in_kb;
  55. uint32_t gds_size_in_kb;
  56. uint32_t wave_front_size;
  57. uint32_t array_count;
  58. uint32_t simd_arrays_per_engine;
  59. uint32_t cu_per_simd_array;
  60. uint32_t simd_per_cu;
  61. uint32_t max_slots_scratch_cu;
  62. uint32_t engine_id;
  63. uint32_t vendor_id;
  64. uint32_t device_id;
  65. uint32_t location_id;
  66. uint32_t max_engine_clk_fcompute;
  67. uint32_t max_engine_clk_ccompute;
  68. uint16_t marketing_name[KFD_TOPOLOGY_PUBLIC_NAME_SIZE];
  69. };
  70. #define HSA_MEM_HEAP_TYPE_SYSTEM 0
  71. #define HSA_MEM_HEAP_TYPE_FB_PUBLIC 1
  72. #define HSA_MEM_HEAP_TYPE_FB_PRIVATE 2
  73. #define HSA_MEM_HEAP_TYPE_GPU_GDS 3
  74. #define HSA_MEM_HEAP_TYPE_GPU_LDS 4
  75. #define HSA_MEM_HEAP_TYPE_GPU_SCRATCH 5
  76. #define HSA_MEM_FLAGS_HOT_PLUGGABLE 0x00000001
  77. #define HSA_MEM_FLAGS_NON_VOLATILE 0x00000002
  78. #define HSA_MEM_FLAGS_RESERVED 0xfffffffc
  79. struct kfd_mem_properties {
  80. struct list_head list;
  81. uint32_t heap_type;
  82. uint64_t size_in_bytes;
  83. uint32_t flags;
  84. uint32_t width;
  85. uint32_t mem_clk_max;
  86. struct kobject *kobj;
  87. struct attribute attr;
  88. };
  89. #define HSA_CACHE_TYPE_DATA 0x00000001
  90. #define HSA_CACHE_TYPE_INSTRUCTION 0x00000002
  91. #define HSA_CACHE_TYPE_CPU 0x00000004
  92. #define HSA_CACHE_TYPE_HSACU 0x00000008
  93. #define HSA_CACHE_TYPE_RESERVED 0xfffffff0
  94. struct kfd_cache_properties {
  95. struct list_head list;
  96. uint32_t processor_id_low;
  97. uint32_t cache_level;
  98. uint32_t cache_size;
  99. uint32_t cacheline_size;
  100. uint32_t cachelines_per_tag;
  101. uint32_t cache_assoc;
  102. uint32_t cache_latency;
  103. uint32_t cache_type;
  104. uint8_t sibling_map[CRAT_SIBLINGMAP_SIZE];
  105. struct kobject *kobj;
  106. struct attribute attr;
  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 flags;
  122. struct kobject *kobj;
  123. struct attribute attr;
  124. };
  125. struct kfd_perf_properties {
  126. struct list_head list;
  127. char block_name[16];
  128. uint32_t max_concurrent;
  129. struct attribute_group *attr_group;
  130. };
  131. struct kfd_topology_device {
  132. struct list_head list;
  133. uint32_t gpu_id;
  134. uint32_t proximity_domain;
  135. struct kfd_node_properties node_props;
  136. struct list_head mem_props;
  137. uint32_t cache_count;
  138. struct list_head cache_props;
  139. uint32_t io_link_count;
  140. struct list_head io_link_props;
  141. struct list_head perf_props;
  142. struct kfd_dev *gpu;
  143. struct kobject *kobj_node;
  144. struct kobject *kobj_mem;
  145. struct kobject *kobj_cache;
  146. struct kobject *kobj_iolink;
  147. struct kobject *kobj_perf;
  148. struct attribute attr_gpuid;
  149. struct attribute attr_name;
  150. struct attribute attr_props;
  151. uint8_t oem_id[CRAT_OEMID_LENGTH];
  152. uint8_t oem_table_id[CRAT_OEMTABLEID_LENGTH];
  153. uint32_t oem_revision;
  154. };
  155. struct kfd_system_properties {
  156. uint32_t num_devices; /* Number of H-NUMA nodes */
  157. uint32_t generation_count;
  158. uint64_t platform_oem;
  159. uint64_t platform_id;
  160. uint64_t platform_rev;
  161. struct kobject *kobj_topology;
  162. struct kobject *kobj_nodes;
  163. struct attribute attr_genid;
  164. struct attribute attr_props;
  165. };
  166. struct kfd_topology_device *kfd_create_topology_device(
  167. struct list_head *device_list);
  168. void kfd_release_topology_device_list(struct list_head *device_list);
  169. extern bool amd_iommu_pc_supported(void);
  170. extern u8 amd_iommu_pc_get_max_banks(u16 devid);
  171. extern u8 amd_iommu_pc_get_max_counters(u16 devid);
  172. #endif /* __KFD_TOPOLOGY_H__ */