Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 OR MIT */
0002 /*
0003  * Copyright 2014-2022 Advanced Micro Devices, Inc.
0004  *
0005  * Permission is hereby granted, free of charge, to any person obtaining a
0006  * copy of this software and associated documentation files (the "Software"),
0007  * to deal in the Software without restriction, including without limitation
0008  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
0009  * and/or sell copies of the Software, and to permit persons to whom the
0010  * Software is furnished to do so, subject to the following conditions:
0011  *
0012  * The above copyright notice and this permission notice shall be included in
0013  * all copies or substantial portions of the Software.
0014  *
0015  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0016  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0017  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
0018  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
0019  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
0020  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
0021  * OTHER DEALINGS IN THE SOFTWARE.
0022  */
0023 
0024 #ifndef __KFD_TOPOLOGY_H__
0025 #define __KFD_TOPOLOGY_H__
0026 
0027 #include <linux/types.h>
0028 #include <linux/list.h>
0029 #include <linux/kfd_sysfs.h>
0030 #include "kfd_crat.h"
0031 
0032 #define KFD_TOPOLOGY_PUBLIC_NAME_SIZE 32
0033 
0034 struct kfd_node_properties {
0035     uint64_t hive_id;
0036     uint32_t cpu_cores_count;
0037     uint32_t simd_count;
0038     uint32_t mem_banks_count;
0039     uint32_t caches_count;
0040     uint32_t io_links_count;
0041     uint32_t p2p_links_count;
0042     uint32_t cpu_core_id_base;
0043     uint32_t simd_id_base;
0044     uint32_t capability;
0045     uint32_t max_waves_per_simd;
0046     uint32_t lds_size_in_kb;
0047     uint32_t gds_size_in_kb;
0048     uint32_t num_gws;
0049     uint32_t wave_front_size;
0050     uint32_t array_count;
0051     uint32_t simd_arrays_per_engine;
0052     uint32_t cu_per_simd_array;
0053     uint32_t simd_per_cu;
0054     uint32_t max_slots_scratch_cu;
0055     uint32_t engine_id;
0056     uint32_t gfx_target_version;
0057     uint32_t vendor_id;
0058     uint32_t device_id;
0059     uint32_t location_id;
0060     uint32_t domain;
0061     uint32_t max_engine_clk_fcompute;
0062     uint32_t max_engine_clk_ccompute;
0063     int32_t  drm_render_minor;
0064     uint32_t num_sdma_engines;
0065     uint32_t num_sdma_xgmi_engines;
0066     uint32_t num_sdma_queues_per_engine;
0067     uint32_t num_cp_queues;
0068     char name[KFD_TOPOLOGY_PUBLIC_NAME_SIZE];
0069 };
0070 
0071 struct kfd_mem_properties {
0072     struct list_head    list;
0073     uint32_t        heap_type;
0074     uint64_t        size_in_bytes;
0075     uint32_t        flags;
0076     uint32_t        width;
0077     uint32_t        mem_clk_max;
0078     struct kfd_dev      *gpu;
0079     struct kobject      *kobj;
0080     struct attribute    attr;
0081 };
0082 
0083 struct kfd_cache_properties {
0084     struct list_head    list;
0085     uint32_t        processor_id_low;
0086     uint32_t        cache_level;
0087     uint32_t        cache_size;
0088     uint32_t        cacheline_size;
0089     uint32_t        cachelines_per_tag;
0090     uint32_t        cache_assoc;
0091     uint32_t        cache_latency;
0092     uint32_t        cache_type;
0093     uint8_t         sibling_map[CRAT_SIBLINGMAP_SIZE];
0094     struct kfd_dev      *gpu;
0095     struct kobject      *kobj;
0096     struct attribute    attr;
0097 };
0098 
0099 struct kfd_iolink_properties {
0100     struct list_head    list;
0101     uint32_t        iolink_type;
0102     uint32_t        ver_maj;
0103     uint32_t        ver_min;
0104     uint32_t        node_from;
0105     uint32_t        node_to;
0106     uint32_t        weight;
0107     uint32_t        min_latency;
0108     uint32_t        max_latency;
0109     uint32_t        min_bandwidth;
0110     uint32_t        max_bandwidth;
0111     uint32_t        rec_transfer_size;
0112     uint32_t        flags;
0113     struct kfd_dev      *gpu;
0114     struct kobject      *kobj;
0115     struct attribute    attr;
0116 };
0117 
0118 struct kfd_perf_properties {
0119     struct list_head    list;
0120     char            block_name[16];
0121     uint32_t        max_concurrent;
0122     struct attribute_group  *attr_group;
0123 };
0124 
0125 struct kfd_topology_device {
0126     struct list_head        list;
0127     uint32_t            gpu_id;
0128     uint32_t            proximity_domain;
0129     struct kfd_node_properties  node_props;
0130     struct list_head        mem_props;
0131     uint32_t            cache_count;
0132     struct list_head        cache_props;
0133     struct list_head        io_link_props;
0134     struct list_head        p2p_link_props;
0135     struct list_head        perf_props;
0136     struct kfd_dev          *gpu;
0137     struct kobject          *kobj_node;
0138     struct kobject          *kobj_mem;
0139     struct kobject          *kobj_cache;
0140     struct kobject          *kobj_iolink;
0141     struct kobject          *kobj_p2plink;
0142     struct kobject          *kobj_perf;
0143     struct attribute        attr_gpuid;
0144     struct attribute        attr_name;
0145     struct attribute        attr_props;
0146     uint8_t             oem_id[CRAT_OEMID_LENGTH];
0147     uint8_t             oem_table_id[CRAT_OEMTABLEID_LENGTH];
0148     uint32_t            oem_revision;
0149 };
0150 
0151 struct kfd_system_properties {
0152     uint32_t        num_devices;     /* Number of H-NUMA nodes */
0153     uint32_t        generation_count;
0154     uint64_t        platform_oem;
0155     uint64_t        platform_id;
0156     uint64_t        platform_rev;
0157     struct kobject      *kobj_topology;
0158     struct kobject      *kobj_nodes;
0159     struct attribute    attr_genid;
0160     struct attribute    attr_props;
0161 };
0162 
0163 struct kfd_topology_device *kfd_create_topology_device(
0164         struct list_head *device_list);
0165 void kfd_release_topology_device_list(struct list_head *device_list);
0166 
0167 #endif /* __KFD_TOPOLOGY_H__ */