Path: blob/master/drivers/gpu/drm/amd/amdkfd/kfd_crat.h
26516 views
/* SPDX-License-Identifier: GPL-2.0 OR MIT */1/*2* Copyright 2014-2022 Advanced Micro Devices, Inc.3*4* Permission is hereby granted, free of charge, to any person obtaining a5* copy of this software and associated documentation files (the "Software"),6* to deal in the Software without restriction, including without limitation7* the rights to use, copy, modify, merge, publish, distribute, sublicense,8* and/or sell copies of the Software, and to permit persons to whom the9* Software is furnished to do so, subject to the following conditions:10*11* The above copyright notice and this permission notice shall be included in12* all copies or substantial portions of the Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL17* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR18* 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 OR20* OTHER DEALINGS IN THE SOFTWARE.21*/2223#ifndef KFD_CRAT_H_INCLUDED24#define KFD_CRAT_H_INCLUDED2526#include <linux/types.h>2728#pragma pack(1)2930/*31* 4CC signature value for the CRAT ACPI table32*/3334#define CRAT_SIGNATURE "CRAT"3536/*37* Component Resource Association Table (CRAT)38*/3940#define CRAT_OEMID_LENGTH 641#define CRAT_OEMTABLEID_LENGTH 842#define CRAT_RESERVED_LENGTH 64344/* Compute Unit flags */45#define COMPUTE_UNIT_CPU (1 << 0) /* Create Virtual CRAT for CPU */46#define COMPUTE_UNIT_GPU (1 << 1) /* Create Virtual CRAT for GPU */4748struct crat_header {49uint32_t signature;50uint32_t length;51uint8_t revision;52uint8_t checksum;53uint8_t oem_id[CRAT_OEMID_LENGTH];54uint8_t oem_table_id[CRAT_OEMTABLEID_LENGTH];55uint32_t oem_revision;56uint32_t creator_id;57uint32_t creator_revision;58uint32_t total_entries;59uint16_t num_domains;60uint8_t reserved[CRAT_RESERVED_LENGTH];61};6263/*64* The header structure is immediately followed by total_entries of the65* data definitions66*/6768/*69* The currently defined subtype entries in the CRAT70*/71#define CRAT_SUBTYPE_COMPUTEUNIT_AFFINITY 072#define CRAT_SUBTYPE_MEMORY_AFFINITY 173#define CRAT_SUBTYPE_CACHE_AFFINITY 274#define CRAT_SUBTYPE_TLB_AFFINITY 375#define CRAT_SUBTYPE_CCOMPUTE_AFFINITY 476#define CRAT_SUBTYPE_IOLINK_AFFINITY 577#define CRAT_SUBTYPE_MAX 67879/*80* Do not change the value of CRAT_SIBLINGMAP_SIZE from 3281* as it breaks the ABI.82*/83#define CRAT_SIBLINGMAP_SIZE 328485/*86* ComputeUnit Affinity structure and definitions87*/88#define CRAT_CU_FLAGS_ENABLED 0x0000000189#define CRAT_CU_FLAGS_HOT_PLUGGABLE 0x0000000290#define CRAT_CU_FLAGS_CPU_PRESENT 0x0000000491#define CRAT_CU_FLAGS_GPU_PRESENT 0x0000000892#define CRAT_CU_FLAGS_IOMMU_PRESENT 0x0000001093#define CRAT_CU_FLAGS_RESERVED 0xffffffe09495#define CRAT_COMPUTEUNIT_RESERVED_LENGTH 49697struct crat_subtype_computeunit {98uint8_t type;99uint8_t length;100uint16_t reserved;101uint32_t flags;102uint32_t proximity_domain;103uint32_t processor_id_low;104uint16_t num_cpu_cores;105uint16_t num_simd_cores;106uint16_t max_waves_simd;107uint16_t io_count;108uint16_t hsa_capability;109uint16_t lds_size_in_kb;110uint8_t wave_front_size;111uint8_t num_banks;112uint16_t micro_engine_id;113uint8_t array_count;114uint8_t num_cu_per_array;115uint8_t num_simd_per_cu;116uint8_t max_slots_scatch_cu;117uint8_t reserved2[CRAT_COMPUTEUNIT_RESERVED_LENGTH];118};119120/*121* HSA Memory Affinity structure and definitions122*/123#define CRAT_MEM_FLAGS_ENABLED 0x00000001124#define CRAT_MEM_FLAGS_HOT_PLUGGABLE 0x00000002125#define CRAT_MEM_FLAGS_NON_VOLATILE 0x00000004126#define CRAT_MEM_FLAGS_RESERVED 0xfffffff8127128#define CRAT_MEMORY_RESERVED_LENGTH 8129130struct crat_subtype_memory {131uint8_t type;132uint8_t length;133uint16_t reserved;134uint32_t flags;135uint32_t proximity_domain;136uint32_t base_addr_low;137uint32_t base_addr_high;138uint32_t length_low;139uint32_t length_high;140uint32_t width;141uint8_t visibility_type; /* for virtual (dGPU) CRAT */142uint8_t reserved2[CRAT_MEMORY_RESERVED_LENGTH - 1];143};144145/*146* HSA Cache Affinity structure and definitions147*/148#define CRAT_CACHE_FLAGS_ENABLED 0x00000001149#define CRAT_CACHE_FLAGS_DATA_CACHE 0x00000002150#define CRAT_CACHE_FLAGS_INST_CACHE 0x00000004151#define CRAT_CACHE_FLAGS_CPU_CACHE 0x00000008152#define CRAT_CACHE_FLAGS_SIMD_CACHE 0x00000010153#define CRAT_CACHE_FLAGS_RESERVED 0xffffffe0154155#define CRAT_CACHE_RESERVED_LENGTH 8156157struct crat_subtype_cache {158uint8_t type;159uint8_t length;160uint16_t reserved;161uint32_t flags;162uint32_t processor_id_low;163uint8_t sibling_map[CRAT_SIBLINGMAP_SIZE];164uint32_t cache_size;165uint8_t cache_level;166uint8_t lines_per_tag;167uint16_t cache_line_size;168uint8_t associativity;169uint8_t cache_properties;170uint16_t cache_latency;171uint8_t reserved2[CRAT_CACHE_RESERVED_LENGTH];172};173174/*175* HSA TLB Affinity structure and definitions176*/177#define CRAT_TLB_FLAGS_ENABLED 0x00000001178#define CRAT_TLB_FLAGS_DATA_TLB 0x00000002179#define CRAT_TLB_FLAGS_INST_TLB 0x00000004180#define CRAT_TLB_FLAGS_CPU_TLB 0x00000008181#define CRAT_TLB_FLAGS_SIMD_TLB 0x00000010182#define CRAT_TLB_FLAGS_RESERVED 0xffffffe0183184#define CRAT_TLB_RESERVED_LENGTH 4185186struct crat_subtype_tlb {187uint8_t type;188uint8_t length;189uint16_t reserved;190uint32_t flags;191uint32_t processor_id_low;192uint8_t sibling_map[CRAT_SIBLINGMAP_SIZE];193uint32_t tlb_level;194uint8_t data_tlb_associativity_2mb;195uint8_t data_tlb_size_2mb;196uint8_t instruction_tlb_associativity_2mb;197uint8_t instruction_tlb_size_2mb;198uint8_t data_tlb_associativity_4k;199uint8_t data_tlb_size_4k;200uint8_t instruction_tlb_associativity_4k;201uint8_t instruction_tlb_size_4k;202uint8_t data_tlb_associativity_1gb;203uint8_t data_tlb_size_1gb;204uint8_t instruction_tlb_associativity_1gb;205uint8_t instruction_tlb_size_1gb;206uint8_t reserved2[CRAT_TLB_RESERVED_LENGTH];207};208209/*210* HSA CCompute/APU Affinity structure and definitions211*/212#define CRAT_CCOMPUTE_FLAGS_ENABLED 0x00000001213#define CRAT_CCOMPUTE_FLAGS_RESERVED 0xfffffffe214215#define CRAT_CCOMPUTE_RESERVED_LENGTH 16216217struct crat_subtype_ccompute {218uint8_t type;219uint8_t length;220uint16_t reserved;221uint32_t flags;222uint32_t processor_id_low;223uint8_t sibling_map[CRAT_SIBLINGMAP_SIZE];224uint32_t apu_size;225uint8_t reserved2[CRAT_CCOMPUTE_RESERVED_LENGTH];226};227228/*229* HSA IO Link Affinity structure and definitions230*/231#define CRAT_IOLINK_FLAGS_ENABLED (1 << 0)232#define CRAT_IOLINK_FLAGS_NON_COHERENT (1 << 1)233#define CRAT_IOLINK_FLAGS_NO_ATOMICS_32_BIT (1 << 2)234#define CRAT_IOLINK_FLAGS_NO_ATOMICS_64_BIT (1 << 3)235#define CRAT_IOLINK_FLAGS_NO_PEER_TO_PEER_DMA (1 << 4)236#define CRAT_IOLINK_FLAGS_BI_DIRECTIONAL (1 << 31)237#define CRAT_IOLINK_FLAGS_RESERVED_MASK 0x7fffffe0238239/*240* IO interface types241*/242#define CRAT_IOLINK_TYPE_UNDEFINED 0243#define CRAT_IOLINK_TYPE_HYPERTRANSPORT 1244#define CRAT_IOLINK_TYPE_PCIEXPRESS 2245#define CRAT_IOLINK_TYPE_AMBA 3246#define CRAT_IOLINK_TYPE_MIPI 4247#define CRAT_IOLINK_TYPE_QPI_1_1 5248#define CRAT_IOLINK_TYPE_RESERVED1 6249#define CRAT_IOLINK_TYPE_RESERVED2 7250#define CRAT_IOLINK_TYPE_RAPID_IO 8251#define CRAT_IOLINK_TYPE_INFINIBAND 9252#define CRAT_IOLINK_TYPE_RESERVED3 10253#define CRAT_IOLINK_TYPE_XGMI 11254#define CRAT_IOLINK_TYPE_XGOP 12255#define CRAT_IOLINK_TYPE_GZ 13256#define CRAT_IOLINK_TYPE_ETHERNET_RDMA 14257#define CRAT_IOLINK_TYPE_RDMA_OTHER 15258#define CRAT_IOLINK_TYPE_OTHER 16259#define CRAT_IOLINK_TYPE_MAX 255260261#define CRAT_IOLINK_RESERVED_LENGTH 24262263struct crat_subtype_iolink {264uint8_t type;265uint8_t length;266uint16_t reserved;267uint32_t flags;268uint32_t proximity_domain_from;269uint32_t proximity_domain_to;270uint8_t io_interface_type;271uint8_t version_major;272uint16_t version_minor;273uint32_t minimum_latency;274uint32_t maximum_latency;275uint32_t minimum_bandwidth_mbs;276uint32_t maximum_bandwidth_mbs;277uint32_t recommended_transfer_size;278uint8_t reserved2[CRAT_IOLINK_RESERVED_LENGTH - 1];279uint8_t weight_xgmi;280};281282/*283* HSA generic sub-type header284*/285286#define CRAT_SUBTYPE_FLAGS_ENABLED 0x00000001287288struct crat_subtype_generic {289uint8_t type;290uint8_t length;291uint16_t reserved;292uint32_t flags;293};294295#pragma pack()296297struct kfd_node;298299/* Static table to describe GPU Cache information */300struct kfd_gpu_cache_info {301uint32_t cache_size;302uint32_t cache_level;303uint32_t cache_line_size;304uint32_t flags;305/* Indicates how many Compute Units share this cache306* within a SA. Value = 1 indicates the cache is not shared307*/308uint32_t num_cu_shared;309};310int kfd_get_gpu_cache_info(struct kfd_node *kdev, struct kfd_gpu_cache_info **pcache_info);311312void kfd_destroy_crat_image(void *crat_image);313int kfd_parse_crat_table(void *crat_image, struct list_head *device_list,314uint32_t proximity_domain);315int kfd_create_crat_image_virtual(void **crat_image, size_t *size,316int flags, struct kfd_node *kdev,317uint32_t proximity_domain);318319#endif /* KFD_CRAT_H_INCLUDED */320321322