1d87f36a0SRajneesh Bhardwaj /* SPDX-License-Identifier: GPL-2.0 OR MIT */ 25b5c4e40SEvgeny Pinchuk /* 3d87f36a0SRajneesh Bhardwaj * Copyright 2014-2022 Advanced Micro Devices, Inc. 45b5c4e40SEvgeny Pinchuk * 55b5c4e40SEvgeny Pinchuk * Permission is hereby granted, free of charge, to any person obtaining a 65b5c4e40SEvgeny Pinchuk * copy of this software and associated documentation files (the "Software"), 75b5c4e40SEvgeny Pinchuk * to deal in the Software without restriction, including without limitation 85b5c4e40SEvgeny Pinchuk * the rights to use, copy, modify, merge, publish, distribute, sublicense, 95b5c4e40SEvgeny Pinchuk * and/or sell copies of the Software, and to permit persons to whom the 105b5c4e40SEvgeny Pinchuk * Software is furnished to do so, subject to the following conditions: 115b5c4e40SEvgeny Pinchuk * 125b5c4e40SEvgeny Pinchuk * The above copyright notice and this permission notice shall be included in 135b5c4e40SEvgeny Pinchuk * all copies or substantial portions of the Software. 145b5c4e40SEvgeny Pinchuk * 155b5c4e40SEvgeny Pinchuk * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 165b5c4e40SEvgeny Pinchuk * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 175b5c4e40SEvgeny Pinchuk * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 185b5c4e40SEvgeny Pinchuk * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 195b5c4e40SEvgeny Pinchuk * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 205b5c4e40SEvgeny Pinchuk * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 215b5c4e40SEvgeny Pinchuk * OTHER DEALINGS IN THE SOFTWARE. 225b5c4e40SEvgeny Pinchuk */ 235b5c4e40SEvgeny Pinchuk 245b5c4e40SEvgeny Pinchuk #ifndef __KFD_TOPOLOGY_H__ 255b5c4e40SEvgeny Pinchuk #define __KFD_TOPOLOGY_H__ 265b5c4e40SEvgeny Pinchuk 270a0bd4f9SMario Limonciello #include <linux/dmi.h> 285b5c4e40SEvgeny Pinchuk #include <linux/types.h> 295b5c4e40SEvgeny Pinchuk #include <linux/list.h> 30b5f57384SFelix Kuehling #include <linux/kfd_sysfs.h> 3164d1c3a4SFelix Kuehling #include "kfd_crat.h" 325b5c4e40SEvgeny Pinchuk 33c181159aSYong Zhao #define KFD_TOPOLOGY_PUBLIC_NAME_SIZE 32 345b5c4e40SEvgeny Pinchuk 35d230f1bfSJonathan Kim #define HSA_DBG_WATCH_ADDR_MASK_LO_BIT_GFX9 6 36567db9e0SJonathan Kim #define HSA_DBG_WATCH_ADDR_MASK_LO_BIT_GFX9_4_3 7 37d230f1bfSJonathan Kim #define HSA_DBG_WATCH_ADDR_MASK_LO_BIT_GFX10 7 38d230f1bfSJonathan Kim #define HSA_DBG_WATCH_ADDR_MASK_HI_BIT \ 39d230f1bfSJonathan Kim (29 << HSA_DBG_WATCH_ADDR_MASK_HI_BIT_SHIFT) 40567db9e0SJonathan Kim #define HSA_DBG_WATCH_ADDR_MASK_HI_BIT_GFX9_4_3 \ 41567db9e0SJonathan Kim (30 << HSA_DBG_WATCH_ADDR_MASK_HI_BIT_SHIFT) 42d230f1bfSJonathan Kim 435b5c4e40SEvgeny Pinchuk struct kfd_node_properties { 440c1690e3SShaoyun Liu uint64_t hive_id; 455b5c4e40SEvgeny Pinchuk uint32_t cpu_cores_count; 465b5c4e40SEvgeny Pinchuk uint32_t simd_count; 475b5c4e40SEvgeny Pinchuk uint32_t mem_banks_count; 485b5c4e40SEvgeny Pinchuk uint32_t caches_count; 495b5c4e40SEvgeny Pinchuk uint32_t io_links_count; 500f28cca8SRamesh Errabolu uint32_t p2p_links_count; 515b5c4e40SEvgeny Pinchuk uint32_t cpu_core_id_base; 525b5c4e40SEvgeny Pinchuk uint32_t simd_id_base; 535b5c4e40SEvgeny Pinchuk uint32_t capability; 54*ceb7114cSJonathan Kim uint32_t capability2; 55d230f1bfSJonathan Kim uint64_t debug_prop; 565b5c4e40SEvgeny Pinchuk uint32_t max_waves_per_simd; 575b5c4e40SEvgeny Pinchuk uint32_t lds_size_in_kb; 585b5c4e40SEvgeny Pinchuk uint32_t gds_size_in_kb; 5929e76462SOak Zeng uint32_t num_gws; 605b5c4e40SEvgeny Pinchuk uint32_t wave_front_size; 615b5c4e40SEvgeny Pinchuk uint32_t array_count; 625b5c4e40SEvgeny Pinchuk uint32_t simd_arrays_per_engine; 635b5c4e40SEvgeny Pinchuk uint32_t cu_per_simd_array; 645b5c4e40SEvgeny Pinchuk uint32_t simd_per_cu; 655b5c4e40SEvgeny Pinchuk uint32_t max_slots_scratch_cu; 665b5c4e40SEvgeny Pinchuk uint32_t engine_id; 679d6fa9c7SGraham Sider uint32_t gfx_target_version; 685b5c4e40SEvgeny Pinchuk uint32_t vendor_id; 695b5c4e40SEvgeny Pinchuk uint32_t device_id; 705b5c4e40SEvgeny Pinchuk uint32_t location_id; 713e58e95aSOri Messinger uint32_t domain; 725b5c4e40SEvgeny Pinchuk uint32_t max_engine_clk_fcompute; 735b5c4e40SEvgeny Pinchuk uint32_t max_engine_clk_ccompute; 747c9b7171SOak Zeng int32_t drm_render_minor; 7514568cf6SOak Zeng uint32_t num_sdma_engines; 7614568cf6SOak Zeng uint32_t num_sdma_xgmi_engines; 77bb71c74dSHuang Rui uint32_t num_sdma_queues_per_engine; 78f4feb9faSHuang Rui uint32_t num_cp_queues; 79517fff22SPhilip Yang uint32_t cwsr_size; 80517fff22SPhilip Yang uint32_t ctl_stack_size; 81517fff22SPhilip Yang uint32_t eop_buffer_size; 82517fff22SPhilip Yang uint32_t debug_memory_size; 83c181159aSYong Zhao char name[KFD_TOPOLOGY_PUBLIC_NAME_SIZE]; 845b5c4e40SEvgeny Pinchuk }; 855b5c4e40SEvgeny Pinchuk 865b5c4e40SEvgeny Pinchuk struct kfd_mem_properties { 875b5c4e40SEvgeny Pinchuk struct list_head list; 885b5c4e40SEvgeny Pinchuk uint32_t heap_type; 895b5c4e40SEvgeny Pinchuk uint64_t size_in_bytes; 905b5c4e40SEvgeny Pinchuk uint32_t flags; 915b5c4e40SEvgeny Pinchuk uint32_t width; 925b5c4e40SEvgeny Pinchuk uint32_t mem_clk_max; 938dc1db31SMukul Joshi struct kfd_node *gpu; 945b5c4e40SEvgeny Pinchuk struct kobject *kobj; 955b5c4e40SEvgeny Pinchuk struct attribute attr; 965b5c4e40SEvgeny Pinchuk }; 975b5c4e40SEvgeny Pinchuk 980752e66eSMukul Joshi #define CACHE_SIBLINGMAP_SIZE 128 99c0cc999fSMa Jun 1005b5c4e40SEvgeny Pinchuk struct kfd_cache_properties { 1015b5c4e40SEvgeny Pinchuk struct list_head list; 1025b5c4e40SEvgeny Pinchuk uint32_t processor_id_low; 1035b5c4e40SEvgeny Pinchuk uint32_t cache_level; 1045b5c4e40SEvgeny Pinchuk uint32_t cache_size; 1055b5c4e40SEvgeny Pinchuk uint32_t cacheline_size; 1065b5c4e40SEvgeny Pinchuk uint32_t cachelines_per_tag; 1075b5c4e40SEvgeny Pinchuk uint32_t cache_assoc; 1085b5c4e40SEvgeny Pinchuk uint32_t cache_latency; 1095b5c4e40SEvgeny Pinchuk uint32_t cache_type; 110c0cc999fSMa Jun uint8_t sibling_map[CACHE_SIBLINGMAP_SIZE]; 1118dc1db31SMukul Joshi struct kfd_node *gpu; 1125b5c4e40SEvgeny Pinchuk struct kobject *kobj; 1135b5c4e40SEvgeny Pinchuk struct attribute attr; 114c0cc999fSMa Jun uint32_t sibling_map_size; 1155b5c4e40SEvgeny Pinchuk }; 1165b5c4e40SEvgeny Pinchuk 1175b5c4e40SEvgeny Pinchuk struct kfd_iolink_properties { 1185b5c4e40SEvgeny Pinchuk struct list_head list; 1195b5c4e40SEvgeny Pinchuk uint32_t iolink_type; 1205b5c4e40SEvgeny Pinchuk uint32_t ver_maj; 1215b5c4e40SEvgeny Pinchuk uint32_t ver_min; 1225b5c4e40SEvgeny Pinchuk uint32_t node_from; 1235b5c4e40SEvgeny Pinchuk uint32_t node_to; 1245b5c4e40SEvgeny Pinchuk uint32_t weight; 1255b5c4e40SEvgeny Pinchuk uint32_t min_latency; 1265b5c4e40SEvgeny Pinchuk uint32_t max_latency; 1275b5c4e40SEvgeny Pinchuk uint32_t min_bandwidth; 1285b5c4e40SEvgeny Pinchuk uint32_t max_bandwidth; 1295b5c4e40SEvgeny Pinchuk uint32_t rec_transfer_size; 130e06b71b2SJonathan Kim uint32_t rec_sdma_eng_id_mask; 1315b5c4e40SEvgeny Pinchuk uint32_t flags; 1328dc1db31SMukul Joshi struct kfd_node *gpu; 1335b5c4e40SEvgeny Pinchuk struct kobject *kobj; 1345b5c4e40SEvgeny Pinchuk struct attribute attr; 1355b5c4e40SEvgeny Pinchuk }; 1365b5c4e40SEvgeny Pinchuk 137f4757347SAmber Lin struct kfd_perf_properties { 138f4757347SAmber Lin struct list_head list; 139f4757347SAmber Lin char block_name[16]; 140f4757347SAmber Lin uint32_t max_concurrent; 141f4757347SAmber Lin struct attribute_group *attr_group; 142f4757347SAmber Lin }; 143f4757347SAmber Lin 1445b5c4e40SEvgeny Pinchuk struct kfd_topology_device { 1455b5c4e40SEvgeny Pinchuk struct list_head list; 1465b5c4e40SEvgeny Pinchuk uint32_t gpu_id; 1474f449311SHarish Kasiviswanathan uint32_t proximity_domain; 1485b5c4e40SEvgeny Pinchuk struct kfd_node_properties node_props; 1495b5c4e40SEvgeny Pinchuk struct list_head mem_props; 1505b5c4e40SEvgeny Pinchuk struct list_head cache_props; 1515b5c4e40SEvgeny Pinchuk struct list_head io_link_props; 1520f28cca8SRamesh Errabolu struct list_head p2p_link_props; 153f4757347SAmber Lin struct list_head perf_props; 1548dc1db31SMukul Joshi struct kfd_node *gpu; 1555b5c4e40SEvgeny Pinchuk struct kobject *kobj_node; 1565b5c4e40SEvgeny Pinchuk struct kobject *kobj_mem; 1575b5c4e40SEvgeny Pinchuk struct kobject *kobj_cache; 1585b5c4e40SEvgeny Pinchuk struct kobject *kobj_iolink; 1590f28cca8SRamesh Errabolu struct kobject *kobj_p2plink; 160f4757347SAmber Lin struct kobject *kobj_perf; 1615b5c4e40SEvgeny Pinchuk struct attribute attr_gpuid; 1625b5c4e40SEvgeny Pinchuk struct attribute attr_name; 1635b5c4e40SEvgeny Pinchuk struct attribute attr_props; 16410f624efSMichael Chen union { 165520b8fb7SFelix Kuehling uint8_t oem_id[CRAT_OEMID_LENGTH]; 16610f624efSMichael Chen uint64_t oem_id64; 16710f624efSMichael Chen }; 168520b8fb7SFelix Kuehling uint8_t oem_table_id[CRAT_OEMTABLEID_LENGTH]; 169520b8fb7SFelix Kuehling uint32_t oem_revision; 1705b5c4e40SEvgeny Pinchuk }; 1715b5c4e40SEvgeny Pinchuk 1725b5c4e40SEvgeny Pinchuk struct kfd_system_properties { 1735b5c4e40SEvgeny Pinchuk uint32_t num_devices; /* Number of H-NUMA nodes */ 1745b5c4e40SEvgeny Pinchuk uint32_t generation_count; 1755b5c4e40SEvgeny Pinchuk uint64_t platform_oem; 1765b5c4e40SEvgeny Pinchuk uint64_t platform_id; 1775b5c4e40SEvgeny Pinchuk uint64_t platform_rev; 1785b5c4e40SEvgeny Pinchuk struct kobject *kobj_topology; 1795b5c4e40SEvgeny Pinchuk struct kobject *kobj_nodes; 1805b5c4e40SEvgeny Pinchuk struct attribute attr_genid; 1815b5c4e40SEvgeny Pinchuk struct attribute attr_props; 1825b5c4e40SEvgeny Pinchuk }; 1835b5c4e40SEvgeny Pinchuk 1840a0bd4f9SMario Limonciello struct dmi_mem_device { 1850a0bd4f9SMario Limonciello struct dmi_header header; 1860a0bd4f9SMario Limonciello u16 physical_handle; 1870a0bd4f9SMario Limonciello u16 error_handle; 1880a0bd4f9SMario Limonciello u16 total_width; 1890a0bd4f9SMario Limonciello u16 data_width; 1900a0bd4f9SMario Limonciello u16 size; 1910a0bd4f9SMario Limonciello u8 form_factor; 1920a0bd4f9SMario Limonciello u8 device_set; 1930a0bd4f9SMario Limonciello u8 device_locator; 1940a0bd4f9SMario Limonciello u8 bank_locator; 1950a0bd4f9SMario Limonciello u8 memory_type; 1960a0bd4f9SMario Limonciello u16 type_detail; 1970a0bd4f9SMario Limonciello u16 speed; 1980a0bd4f9SMario Limonciello } __packed; 1990a0bd4f9SMario Limonciello 2004f449311SHarish Kasiviswanathan struct kfd_topology_device *kfd_create_topology_device( 2014f449311SHarish Kasiviswanathan struct list_head *device_list); 2024f449311SHarish Kasiviswanathan void kfd_release_topology_device_list(struct list_head *device_list); 2035b5c4e40SEvgeny Pinchuk 2045b5c4e40SEvgeny Pinchuk #endif /* __KFD_TOPOLOGY_H__ */ 205