0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 #ifndef KFD_CRAT_H_INCLUDED
0025 #define KFD_CRAT_H_INCLUDED
0026
0027 #include <linux/types.h>
0028
0029 #pragma pack(1)
0030
0031
0032
0033
0034
0035 #define CRAT_SIGNATURE "CRAT"
0036 #define CDIT_SIGNATURE "CDIT"
0037
0038
0039
0040
0041
0042 #define CRAT_OEMID_LENGTH 6
0043 #define CRAT_OEMTABLEID_LENGTH 8
0044 #define CRAT_RESERVED_LENGTH 6
0045
0046 #define CRAT_OEMID_64BIT_MASK ((1ULL << (CRAT_OEMID_LENGTH * 8)) - 1)
0047
0048
0049 #define COMPUTE_UNIT_CPU (1 << 0)
0050 #define COMPUTE_UNIT_GPU (1 << 1)
0051
0052 struct crat_header {
0053 uint32_t signature;
0054 uint32_t length;
0055 uint8_t revision;
0056 uint8_t checksum;
0057 uint8_t oem_id[CRAT_OEMID_LENGTH];
0058 uint8_t oem_table_id[CRAT_OEMTABLEID_LENGTH];
0059 uint32_t oem_revision;
0060 uint32_t creator_id;
0061 uint32_t creator_revision;
0062 uint32_t total_entries;
0063 uint16_t num_domains;
0064 uint8_t reserved[CRAT_RESERVED_LENGTH];
0065 };
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075 #define CRAT_SUBTYPE_COMPUTEUNIT_AFFINITY 0
0076 #define CRAT_SUBTYPE_MEMORY_AFFINITY 1
0077 #define CRAT_SUBTYPE_CACHE_AFFINITY 2
0078 #define CRAT_SUBTYPE_TLB_AFFINITY 3
0079 #define CRAT_SUBTYPE_CCOMPUTE_AFFINITY 4
0080 #define CRAT_SUBTYPE_IOLINK_AFFINITY 5
0081 #define CRAT_SUBTYPE_MAX 6
0082
0083 #define CRAT_SIBLINGMAP_SIZE 32
0084
0085
0086
0087
0088 #define CRAT_CU_FLAGS_ENABLED 0x00000001
0089 #define CRAT_CU_FLAGS_HOT_PLUGGABLE 0x00000002
0090 #define CRAT_CU_FLAGS_CPU_PRESENT 0x00000004
0091 #define CRAT_CU_FLAGS_GPU_PRESENT 0x00000008
0092 #define CRAT_CU_FLAGS_IOMMU_PRESENT 0x00000010
0093 #define CRAT_CU_FLAGS_RESERVED 0xffffffe0
0094
0095 #define CRAT_COMPUTEUNIT_RESERVED_LENGTH 4
0096
0097 struct crat_subtype_computeunit {
0098 uint8_t type;
0099 uint8_t length;
0100 uint16_t reserved;
0101 uint32_t flags;
0102 uint32_t proximity_domain;
0103 uint32_t processor_id_low;
0104 uint16_t num_cpu_cores;
0105 uint16_t num_simd_cores;
0106 uint16_t max_waves_simd;
0107 uint16_t io_count;
0108 uint16_t hsa_capability;
0109 uint16_t lds_size_in_kb;
0110 uint8_t wave_front_size;
0111 uint8_t num_banks;
0112 uint16_t micro_engine_id;
0113 uint8_t array_count;
0114 uint8_t num_cu_per_array;
0115 uint8_t num_simd_per_cu;
0116 uint8_t max_slots_scatch_cu;
0117 uint8_t reserved2[CRAT_COMPUTEUNIT_RESERVED_LENGTH];
0118 };
0119
0120
0121
0122
0123 #define CRAT_MEM_FLAGS_ENABLED 0x00000001
0124 #define CRAT_MEM_FLAGS_HOT_PLUGGABLE 0x00000002
0125 #define CRAT_MEM_FLAGS_NON_VOLATILE 0x00000004
0126 #define CRAT_MEM_FLAGS_RESERVED 0xfffffff8
0127
0128 #define CRAT_MEMORY_RESERVED_LENGTH 8
0129
0130 struct crat_subtype_memory {
0131 uint8_t type;
0132 uint8_t length;
0133 uint16_t reserved;
0134 uint32_t flags;
0135 uint32_t proximity_domain;
0136 uint32_t base_addr_low;
0137 uint32_t base_addr_high;
0138 uint32_t length_low;
0139 uint32_t length_high;
0140 uint32_t width;
0141 uint8_t visibility_type;
0142 uint8_t reserved2[CRAT_MEMORY_RESERVED_LENGTH - 1];
0143 };
0144
0145
0146
0147
0148 #define CRAT_CACHE_FLAGS_ENABLED 0x00000001
0149 #define CRAT_CACHE_FLAGS_DATA_CACHE 0x00000002
0150 #define CRAT_CACHE_FLAGS_INST_CACHE 0x00000004
0151 #define CRAT_CACHE_FLAGS_CPU_CACHE 0x00000008
0152 #define CRAT_CACHE_FLAGS_SIMD_CACHE 0x00000010
0153 #define CRAT_CACHE_FLAGS_RESERVED 0xffffffe0
0154
0155 #define CRAT_CACHE_RESERVED_LENGTH 8
0156
0157 struct crat_subtype_cache {
0158 uint8_t type;
0159 uint8_t length;
0160 uint16_t reserved;
0161 uint32_t flags;
0162 uint32_t processor_id_low;
0163 uint8_t sibling_map[CRAT_SIBLINGMAP_SIZE];
0164 uint32_t cache_size;
0165 uint8_t cache_level;
0166 uint8_t lines_per_tag;
0167 uint16_t cache_line_size;
0168 uint8_t associativity;
0169 uint8_t cache_properties;
0170 uint16_t cache_latency;
0171 uint8_t reserved2[CRAT_CACHE_RESERVED_LENGTH];
0172 };
0173
0174
0175
0176
0177 #define CRAT_TLB_FLAGS_ENABLED 0x00000001
0178 #define CRAT_TLB_FLAGS_DATA_TLB 0x00000002
0179 #define CRAT_TLB_FLAGS_INST_TLB 0x00000004
0180 #define CRAT_TLB_FLAGS_CPU_TLB 0x00000008
0181 #define CRAT_TLB_FLAGS_SIMD_TLB 0x00000010
0182 #define CRAT_TLB_FLAGS_RESERVED 0xffffffe0
0183
0184 #define CRAT_TLB_RESERVED_LENGTH 4
0185
0186 struct crat_subtype_tlb {
0187 uint8_t type;
0188 uint8_t length;
0189 uint16_t reserved;
0190 uint32_t flags;
0191 uint32_t processor_id_low;
0192 uint8_t sibling_map[CRAT_SIBLINGMAP_SIZE];
0193 uint32_t tlb_level;
0194 uint8_t data_tlb_associativity_2mb;
0195 uint8_t data_tlb_size_2mb;
0196 uint8_t instruction_tlb_associativity_2mb;
0197 uint8_t instruction_tlb_size_2mb;
0198 uint8_t data_tlb_associativity_4k;
0199 uint8_t data_tlb_size_4k;
0200 uint8_t instruction_tlb_associativity_4k;
0201 uint8_t instruction_tlb_size_4k;
0202 uint8_t data_tlb_associativity_1gb;
0203 uint8_t data_tlb_size_1gb;
0204 uint8_t instruction_tlb_associativity_1gb;
0205 uint8_t instruction_tlb_size_1gb;
0206 uint8_t reserved2[CRAT_TLB_RESERVED_LENGTH];
0207 };
0208
0209
0210
0211
0212 #define CRAT_CCOMPUTE_FLAGS_ENABLED 0x00000001
0213 #define CRAT_CCOMPUTE_FLAGS_RESERVED 0xfffffffe
0214
0215 #define CRAT_CCOMPUTE_RESERVED_LENGTH 16
0216
0217 struct crat_subtype_ccompute {
0218 uint8_t type;
0219 uint8_t length;
0220 uint16_t reserved;
0221 uint32_t flags;
0222 uint32_t processor_id_low;
0223 uint8_t sibling_map[CRAT_SIBLINGMAP_SIZE];
0224 uint32_t apu_size;
0225 uint8_t reserved2[CRAT_CCOMPUTE_RESERVED_LENGTH];
0226 };
0227
0228
0229
0230
0231 #define CRAT_IOLINK_FLAGS_ENABLED (1 << 0)
0232 #define CRAT_IOLINK_FLAGS_NON_COHERENT (1 << 1)
0233 #define CRAT_IOLINK_FLAGS_NO_ATOMICS_32_BIT (1 << 2)
0234 #define CRAT_IOLINK_FLAGS_NO_ATOMICS_64_BIT (1 << 3)
0235 #define CRAT_IOLINK_FLAGS_NO_PEER_TO_PEER_DMA (1 << 4)
0236 #define CRAT_IOLINK_FLAGS_BI_DIRECTIONAL (1 << 31)
0237 #define CRAT_IOLINK_FLAGS_RESERVED_MASK 0x7fffffe0
0238
0239
0240
0241
0242 #define CRAT_IOLINK_TYPE_UNDEFINED 0
0243 #define CRAT_IOLINK_TYPE_HYPERTRANSPORT 1
0244 #define CRAT_IOLINK_TYPE_PCIEXPRESS 2
0245 #define CRAT_IOLINK_TYPE_AMBA 3
0246 #define CRAT_IOLINK_TYPE_MIPI 4
0247 #define CRAT_IOLINK_TYPE_QPI_1_1 5
0248 #define CRAT_IOLINK_TYPE_RESERVED1 6
0249 #define CRAT_IOLINK_TYPE_RESERVED2 7
0250 #define CRAT_IOLINK_TYPE_RAPID_IO 8
0251 #define CRAT_IOLINK_TYPE_INFINIBAND 9
0252 #define CRAT_IOLINK_TYPE_RESERVED3 10
0253 #define CRAT_IOLINK_TYPE_XGMI 11
0254 #define CRAT_IOLINK_TYPE_XGOP 12
0255 #define CRAT_IOLINK_TYPE_GZ 13
0256 #define CRAT_IOLINK_TYPE_ETHERNET_RDMA 14
0257 #define CRAT_IOLINK_TYPE_RDMA_OTHER 15
0258 #define CRAT_IOLINK_TYPE_OTHER 16
0259 #define CRAT_IOLINK_TYPE_MAX 255
0260
0261 #define CRAT_IOLINK_RESERVED_LENGTH 24
0262
0263 struct crat_subtype_iolink {
0264 uint8_t type;
0265 uint8_t length;
0266 uint16_t reserved;
0267 uint32_t flags;
0268 uint32_t proximity_domain_from;
0269 uint32_t proximity_domain_to;
0270 uint8_t io_interface_type;
0271 uint8_t version_major;
0272 uint16_t version_minor;
0273 uint32_t minimum_latency;
0274 uint32_t maximum_latency;
0275 uint32_t minimum_bandwidth_mbs;
0276 uint32_t maximum_bandwidth_mbs;
0277 uint32_t recommended_transfer_size;
0278 uint8_t reserved2[CRAT_IOLINK_RESERVED_LENGTH - 1];
0279 uint8_t num_hops_xgmi;
0280 };
0281
0282
0283
0284
0285
0286 #define CRAT_SUBTYPE_FLAGS_ENABLED 0x00000001
0287
0288 struct crat_subtype_generic {
0289 uint8_t type;
0290 uint8_t length;
0291 uint16_t reserved;
0292 uint32_t flags;
0293 };
0294
0295
0296
0297
0298 #define CDIT_OEMID_LENGTH 6
0299 #define CDIT_OEMTABLEID_LENGTH 8
0300
0301 struct cdit_header {
0302 uint32_t signature;
0303 uint32_t length;
0304 uint8_t revision;
0305 uint8_t checksum;
0306 uint8_t oem_id[CDIT_OEMID_LENGTH];
0307 uint8_t oem_table_id[CDIT_OEMTABLEID_LENGTH];
0308 uint32_t oem_revision;
0309 uint32_t creator_id;
0310 uint32_t creator_revision;
0311 uint32_t total_entries;
0312 uint16_t num_domains;
0313 uint8_t entry[1];
0314 };
0315
0316 #pragma pack()
0317
0318 struct kfd_dev;
0319
0320 int kfd_create_crat_image_acpi(void **crat_image, size_t *size);
0321 void kfd_destroy_crat_image(void *crat_image);
0322 int kfd_parse_crat_table(void *crat_image, struct list_head *device_list,
0323 uint32_t proximity_domain);
0324 int kfd_create_crat_image_virtual(void **crat_image, size_t *size,
0325 int flags, struct kfd_dev *kdev,
0326 uint32_t proximity_domain);
0327
0328 #endif