linux/drivers/gpu/drm/amd/amdkfd/kfd_crat.h

/* 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.
 */

#ifndef KFD_CRAT_H_INCLUDED
#define KFD_CRAT_H_INCLUDED

#include <linux/types.h>

#pragma pack(1)

/*
 * 4CC signature value for the CRAT ACPI table
 */

#define CRAT_SIGNATURE

/*
 * Component Resource Association Table (CRAT)
 */

#define CRAT_OEMID_LENGTH
#define CRAT_OEMTABLEID_LENGTH
#define CRAT_RESERVED_LENGTH

/* Compute Unit flags */
#define COMPUTE_UNIT_CPU
#define COMPUTE_UNIT_GPU

struct crat_header {};

/*
 * The header structure is immediately followed by total_entries of the
 * data definitions
 */

/*
 * The currently defined subtype entries in the CRAT
 */
#define CRAT_SUBTYPE_COMPUTEUNIT_AFFINITY
#define CRAT_SUBTYPE_MEMORY_AFFINITY
#define CRAT_SUBTYPE_CACHE_AFFINITY
#define CRAT_SUBTYPE_TLB_AFFINITY
#define CRAT_SUBTYPE_CCOMPUTE_AFFINITY
#define CRAT_SUBTYPE_IOLINK_AFFINITY
#define CRAT_SUBTYPE_MAX

/*
 * Do not change the value of CRAT_SIBLINGMAP_SIZE from 32
 * as it breaks the ABI.
 */
#define CRAT_SIBLINGMAP_SIZE

/*
 * ComputeUnit Affinity structure and definitions
 */
#define CRAT_CU_FLAGS_ENABLED
#define CRAT_CU_FLAGS_HOT_PLUGGABLE
#define CRAT_CU_FLAGS_CPU_PRESENT
#define CRAT_CU_FLAGS_GPU_PRESENT
#define CRAT_CU_FLAGS_IOMMU_PRESENT
#define CRAT_CU_FLAGS_RESERVED

#define CRAT_COMPUTEUNIT_RESERVED_LENGTH

struct crat_subtype_computeunit {};

/*
 * HSA Memory Affinity structure and definitions
 */
#define CRAT_MEM_FLAGS_ENABLED
#define CRAT_MEM_FLAGS_HOT_PLUGGABLE
#define CRAT_MEM_FLAGS_NON_VOLATILE
#define CRAT_MEM_FLAGS_RESERVED

#define CRAT_MEMORY_RESERVED_LENGTH

struct crat_subtype_memory {};

/*
 * HSA Cache Affinity structure and definitions
 */
#define CRAT_CACHE_FLAGS_ENABLED
#define CRAT_CACHE_FLAGS_DATA_CACHE
#define CRAT_CACHE_FLAGS_INST_CACHE
#define CRAT_CACHE_FLAGS_CPU_CACHE
#define CRAT_CACHE_FLAGS_SIMD_CACHE
#define CRAT_CACHE_FLAGS_RESERVED

#define CRAT_CACHE_RESERVED_LENGTH

struct crat_subtype_cache {};

/*
 * HSA TLB Affinity structure and definitions
 */
#define CRAT_TLB_FLAGS_ENABLED
#define CRAT_TLB_FLAGS_DATA_TLB
#define CRAT_TLB_FLAGS_INST_TLB
#define CRAT_TLB_FLAGS_CPU_TLB
#define CRAT_TLB_FLAGS_SIMD_TLB
#define CRAT_TLB_FLAGS_RESERVED

#define CRAT_TLB_RESERVED_LENGTH

struct crat_subtype_tlb {};

/*
 * HSA CCompute/APU Affinity structure and definitions
 */
#define CRAT_CCOMPUTE_FLAGS_ENABLED
#define CRAT_CCOMPUTE_FLAGS_RESERVED

#define CRAT_CCOMPUTE_RESERVED_LENGTH

struct crat_subtype_ccompute {};

/*
 * HSA IO Link Affinity structure and definitions
 */
#define CRAT_IOLINK_FLAGS_ENABLED
#define CRAT_IOLINK_FLAGS_NON_COHERENT
#define CRAT_IOLINK_FLAGS_NO_ATOMICS_32_BIT
#define CRAT_IOLINK_FLAGS_NO_ATOMICS_64_BIT
#define CRAT_IOLINK_FLAGS_NO_PEER_TO_PEER_DMA
#define CRAT_IOLINK_FLAGS_BI_DIRECTIONAL
#define CRAT_IOLINK_FLAGS_RESERVED_MASK

/*
 * IO interface types
 */
#define CRAT_IOLINK_TYPE_UNDEFINED
#define CRAT_IOLINK_TYPE_HYPERTRANSPORT
#define CRAT_IOLINK_TYPE_PCIEXPRESS
#define CRAT_IOLINK_TYPE_AMBA
#define CRAT_IOLINK_TYPE_MIPI
#define CRAT_IOLINK_TYPE_QPI_1_1
#define CRAT_IOLINK_TYPE_RESERVED1
#define CRAT_IOLINK_TYPE_RESERVED2
#define CRAT_IOLINK_TYPE_RAPID_IO
#define CRAT_IOLINK_TYPE_INFINIBAND
#define CRAT_IOLINK_TYPE_RESERVED3
#define CRAT_IOLINK_TYPE_XGMI
#define CRAT_IOLINK_TYPE_XGOP
#define CRAT_IOLINK_TYPE_GZ
#define CRAT_IOLINK_TYPE_ETHERNET_RDMA
#define CRAT_IOLINK_TYPE_RDMA_OTHER
#define CRAT_IOLINK_TYPE_OTHER
#define CRAT_IOLINK_TYPE_MAX

#define CRAT_IOLINK_RESERVED_LENGTH

struct crat_subtype_iolink {};

/*
 * HSA generic sub-type header
 */

#define CRAT_SUBTYPE_FLAGS_ENABLED

struct crat_subtype_generic {};

#pragma pack()

struct kfd_node;

/* Static table to describe GPU Cache information */
struct kfd_gpu_cache_info {};
int kfd_get_gpu_cache_info(struct kfd_node *kdev, struct kfd_gpu_cache_info **pcache_info);

void kfd_destroy_crat_image(void *crat_image);
int kfd_parse_crat_table(void *crat_image, struct list_head *device_list,
			 uint32_t proximity_domain);
int kfd_create_crat_image_virtual(void **crat_image, size_t *size,
				  int flags, struct kfd_node *kdev,
				  uint32_t proximity_domain);

#endif /* KFD_CRAT_H_INCLUDED */