linux/drivers/gpu/drm/amd/amdkfd/kfd_topology.c

// SPDX-License-Identifier: GPL-2.0 OR MIT
/*
 * Copyright 2014-2022 Advanced Micro Devices, Inc.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 */

#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/pci.h>
#include <linux/errno.h>
#include <linux/acpi.h>
#include <linux/hash.h>
#include <linux/cpufreq.h>
#include <linux/log2.h>
#include <linux/dmi.h>
#include <linux/atomic.h>
#include <linux/crc16.h>

#include "kfd_priv.h"
#include "kfd_crat.h"
#include "kfd_topology.h"
#include "kfd_device_queue_manager.h"
#include "kfd_svm.h"
#include "kfd_debug.h"
#include "amdgpu_amdkfd.h"
#include "amdgpu_ras.h"
#include "amdgpu.h"

/* topology_device_list - Master list of all topology devices */
static struct list_head topology_device_list;
static struct kfd_system_properties sys_props;

static DECLARE_RWSEM(topology_lock);
static uint32_t topology_crat_proximity_domain;

struct kfd_topology_device *kfd_topology_device_by_proximity_domain_no_lock(
						uint32_t proximity_domain)
{}

struct kfd_topology_device *kfd_topology_device_by_proximity_domain(
						uint32_t proximity_domain)
{}

struct kfd_topology_device *kfd_topology_device_by_id(uint32_t gpu_id)
{}

struct kfd_node *kfd_device_by_id(uint32_t gpu_id)
{}

struct kfd_node *kfd_device_by_pci_dev(const struct pci_dev *pdev)
{}

/* Called with write topology_lock acquired */
static void kfd_release_topology_device(struct kfd_topology_device *dev)
{}

void kfd_release_topology_device_list(struct list_head *device_list)
{}

static void kfd_release_live_view(void)
{}

struct kfd_topology_device *kfd_create_topology_device(
				struct list_head *device_list)
{}


#define sysfs_show_gen_prop(buffer, offs, fmt, ...)
#define sysfs_show_32bit_prop(buffer, offs, name, value)
#define sysfs_show_64bit_prop(buffer, offs, name, value)
#define sysfs_show_32bit_val(buffer, offs, value)
#define sysfs_show_str_val(buffer, offs, value)

static ssize_t sysprops_show(struct kobject *kobj, struct attribute *attr,
		char *buffer)
{}

static void kfd_topology_kobj_release(struct kobject *kobj)
{}

static const struct sysfs_ops sysprops_ops =;

static const struct kobj_type sysprops_type =;

static ssize_t iolink_show(struct kobject *kobj, struct attribute *attr,
		char *buffer)
{}

static const struct sysfs_ops iolink_ops =;

static const struct kobj_type iolink_type =;

static ssize_t mem_show(struct kobject *kobj, struct attribute *attr,
		char *buffer)
{}

static const struct sysfs_ops mem_ops =;

static const struct kobj_type mem_type =;

static ssize_t kfd_cache_show(struct kobject *kobj, struct attribute *attr,
		char *buffer)
{}

static const struct sysfs_ops cache_ops =;

static const struct kobj_type cache_type =;

/****** Sysfs of Performance Counters ******/

struct kfd_perf_attr {};

static ssize_t perf_show(struct kobject *kobj, struct kobj_attribute *attrs,
			char *buf)
{}

#define KFD_PERF_DESC(_name, _data)

static struct kfd_perf_attr perf_attr_iommu[] =;
/****************************************/

static ssize_t node_show(struct kobject *kobj, struct attribute *attr,
		char *buffer)
{}

static const struct sysfs_ops node_ops =;

static const struct kobj_type node_type =;

static void kfd_remove_sysfs_file(struct kobject *kobj, struct attribute *attr)
{}

static void kfd_remove_sysfs_node_entry(struct kfd_topology_device *dev)
{}

static int kfd_build_sysfs_node_entry(struct kfd_topology_device *dev,
		uint32_t id)
{}

/* Called with write topology lock acquired */
static int kfd_build_sysfs_node_tree(void)
{}

/* Called with write topology lock acquired */
static void kfd_remove_sysfs_node_tree(void)
{}

static int kfd_topology_update_sysfs(void)
{}

static void kfd_topology_release_sysfs(void)
{}

/* Called with write topology_lock acquired */
static void kfd_topology_update_device_list(struct list_head *temp_list,
					struct list_head *master_list)
{}

static void kfd_debug_print_topology(void)
{}

/* Helper function for intializing platform_xx members of
 * kfd_system_properties. Uses OEM info from the last CPU/APU node.
 */
static void kfd_update_system_properties(void)
{}

static void find_system_memory(const struct dmi_header *dm,
	void *private)
{}

/* kfd_add_non_crat_information - Add information that is not currently
 *	defined in CRAT but is necessary for KFD topology
 * @dev - topology device to which addition info is added
 */
static void kfd_add_non_crat_information(struct kfd_topology_device *kdev)
{}

int kfd_topology_init(void)
{}

void kfd_topology_shutdown(void)
{}

static uint32_t kfd_generate_gpu_id(struct kfd_node *gpu)
{}
/* kfd_assign_gpu - Attach @gpu to the correct kfd topology device. If
 *		the GPU device is not already present in the topology device
 *		list then return NULL. This means a new topology device has to
 *		be created for this GPU.
 */
static struct kfd_topology_device *kfd_assign_gpu(struct kfd_node *gpu)
{}

static void kfd_notify_gpu_change(uint32_t gpu_id, int arrival)
{}

/* kfd_fill_mem_clk_max_info - Since CRAT doesn't have memory clock info,
 *		patch this after CRAT parsing.
 */
static void kfd_fill_mem_clk_max_info(struct kfd_topology_device *dev)
{}

static void kfd_set_iolink_no_atomics(struct kfd_topology_device *dev,
					struct kfd_topology_device *target_gpu_dev,
					struct kfd_iolink_properties *link)
{}

static void kfd_set_iolink_non_coherent(struct kfd_topology_device *to_dev,
		struct kfd_iolink_properties *outbound_link,
		struct kfd_iolink_properties *inbound_link)
{}

static void kfd_fill_iolink_non_crat_info(struct kfd_topology_device *dev)
{}

static int kfd_build_p2p_node_entry(struct kfd_topology_device *dev,
				struct kfd_iolink_properties *p2plink)
{}

static int kfd_create_indirect_link_prop(struct kfd_topology_device *kdev, int gpu_node)
{}

#if defined(CONFIG_HSA_AMD_P2P)
static int kfd_add_peer_prop(struct kfd_topology_device *kdev,
		struct kfd_topology_device *peer, int from, int to)
{}
#endif

static int kfd_dev_create_p2p_links(void)
{}

/* Helper function. See kfd_fill_gpu_cache_info for parameter description */
static int fill_in_l1_pcache(struct kfd_cache_properties **props_ext,
				struct kfd_gpu_cache_info *pcache_info,
				int cu_bitmask,
				int cache_type, unsigned int cu_processor_id,
				int cu_block)
{}

/* Helper function. See kfd_fill_gpu_cache_info for parameter description */
static int fill_in_l2_l3_pcache(struct kfd_cache_properties **props_ext,
				struct kfd_gpu_cache_info *pcache_info,
				struct amdgpu_cu_info *cu_info,
				struct amdgpu_gfx_config *gfx_info,
				int cache_type, unsigned int cu_processor_id,
				struct kfd_node *knode)
{}

#define KFD_MAX_CACHE_TYPES

/* kfd_fill_cache_non_crat_info - Fill GPU cache info using kfd_gpu_cache_info
 * tables
 */
static void kfd_fill_cache_non_crat_info(struct kfd_topology_device *dev, struct kfd_node *kdev)
{}

static int kfd_topology_add_device_locked(struct kfd_node *gpu,
					  struct kfd_topology_device **dev)
{}

static void kfd_topology_set_dbg_firmware_support(struct kfd_topology_device *dev)
{}

static void kfd_topology_set_capabilities(struct kfd_topology_device *dev)
{}

int kfd_topology_add_device(struct kfd_node *gpu)
{}

/**
 * kfd_topology_update_io_links() - Update IO links after device removal.
 * @proximity_domain: Proximity domain value of the dev being removed.
 *
 * The topology list currently is arranged in increasing order of
 * proximity domain.
 *
 * Two things need to be done when a device is removed:
 * 1. All the IO links to this device need to be removed.
 * 2. All nodes after the current device node need to move
 *    up once this device node is removed from the topology
 *    list. As a result, the proximity domain values for
 *    all nodes after the node being deleted reduce by 1.
 *    This would also cause the proximity domain values for
 *    io links to be updated based on new proximity domain
 *    values.
 *
 * Context: The caller must hold write topology_lock.
 */
static void kfd_topology_update_io_links(int proximity_domain)
{}

int kfd_topology_remove_device(struct kfd_node *gpu)
{}

/* kfd_topology_enum_kfd_devices - Enumerate through all devices in KFD
 *	topology. If GPU device is found @idx, then valid kfd_dev pointer is
 *	returned through @kdev
 * Return -	0: On success (@kdev will be NULL for non GPU nodes)
 *		-1: If end of list
 */
int kfd_topology_enum_kfd_devices(uint8_t idx, struct kfd_node **kdev)
{}

static int kfd_cpumask_to_apic_id(const struct cpumask *cpumask)
{}

/* kfd_numa_node_to_apic_id - Returns the APIC ID of the first logical processor
 *	of the given NUMA node (numa_node_id)
 * Return -1 on failure
 */
int kfd_numa_node_to_apic_id(int numa_node_id)
{}

#if defined(CONFIG_DEBUG_FS)

int kfd_debugfs_hqds_by_device(struct seq_file *m, void *data)
{}

int kfd_debugfs_rls_by_device(struct seq_file *m, void *data)
{}

#endif