amdgpu.h revision 3f012e29
13f012e29Smrg/* 23f012e29Smrg * Copyright 2014 Advanced Micro Devices, Inc. 33f012e29Smrg * 43f012e29Smrg * Permission is hereby granted, free of charge, to any person obtaining a 53f012e29Smrg * copy of this software and associated documentation files (the "Software"), 63f012e29Smrg * to deal in the Software without restriction, including without limitation 73f012e29Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 83f012e29Smrg * and/or sell copies of the Software, and to permit persons to whom the 93f012e29Smrg * Software is furnished to do so, subject to the following conditions: 103f012e29Smrg * 113f012e29Smrg * The above copyright notice and this permission notice shall be included in 123f012e29Smrg * all copies or substantial portions of the Software. 133f012e29Smrg * 143f012e29Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 153f012e29Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 163f012e29Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 173f012e29Smrg * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 183f012e29Smrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 193f012e29Smrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 203f012e29Smrg * OTHER DEALINGS IN THE SOFTWARE. 213f012e29Smrg * 223f012e29Smrg */ 233f012e29Smrg 243f012e29Smrg/** 253f012e29Smrg * \file amdgpu.h 263f012e29Smrg * 273f012e29Smrg * Declare public libdrm_amdgpu API 283f012e29Smrg * 293f012e29Smrg * This file define API exposed by libdrm_amdgpu library. 303f012e29Smrg * User wanted to use libdrm_amdgpu functionality must include 313f012e29Smrg * this file. 323f012e29Smrg * 333f012e29Smrg */ 343f012e29Smrg#ifndef _AMDGPU_H_ 353f012e29Smrg#define _AMDGPU_H_ 363f012e29Smrg 373f012e29Smrg#include <stdint.h> 383f012e29Smrg#include <stdbool.h> 393f012e29Smrg 403f012e29Smrgstruct drm_amdgpu_info_hw_ip; 413f012e29Smrg 423f012e29Smrg/*--------------------------------------------------------------------------*/ 433f012e29Smrg/* --------------------------- Defines ------------------------------------ */ 443f012e29Smrg/*--------------------------------------------------------------------------*/ 453f012e29Smrg 463f012e29Smrg/** 473f012e29Smrg * Define max. number of Command Buffers (IB) which could be sent to the single 483f012e29Smrg * hardware IP to accommodate CE/DE requirements 493f012e29Smrg * 503f012e29Smrg * \sa amdgpu_cs_ib_info 513f012e29Smrg*/ 523f012e29Smrg#define AMDGPU_CS_MAX_IBS_PER_SUBMIT 4 533f012e29Smrg 543f012e29Smrg/** 553f012e29Smrg * Special timeout value meaning that the timeout is infinite. 563f012e29Smrg */ 573f012e29Smrg#define AMDGPU_TIMEOUT_INFINITE 0xffffffffffffffffull 583f012e29Smrg 593f012e29Smrg/** 603f012e29Smrg * Used in amdgpu_cs_query_fence_status(), meaning that the given timeout 613f012e29Smrg * is absolute. 623f012e29Smrg */ 633f012e29Smrg#define AMDGPU_QUERY_FENCE_TIMEOUT_IS_ABSOLUTE (1 << 0) 643f012e29Smrg 653f012e29Smrg/*--------------------------------------------------------------------------*/ 663f012e29Smrg/* ----------------------------- Enums ------------------------------------ */ 673f012e29Smrg/*--------------------------------------------------------------------------*/ 683f012e29Smrg 693f012e29Smrg/** 703f012e29Smrg * Enum describing possible handle types 713f012e29Smrg * 723f012e29Smrg * \sa amdgpu_bo_import, amdgpu_bo_export 733f012e29Smrg * 743f012e29Smrg*/ 753f012e29Smrgenum amdgpu_bo_handle_type { 763f012e29Smrg /** GEM flink name (needs DRM authentication, used by DRI2) */ 773f012e29Smrg amdgpu_bo_handle_type_gem_flink_name = 0, 783f012e29Smrg 793f012e29Smrg /** KMS handle which is used by all driver ioctls */ 803f012e29Smrg amdgpu_bo_handle_type_kms = 1, 813f012e29Smrg 823f012e29Smrg /** DMA-buf fd handle */ 833f012e29Smrg amdgpu_bo_handle_type_dma_buf_fd = 2 843f012e29Smrg}; 853f012e29Smrg 863f012e29Smrg/** Define known types of GPU VM VA ranges */ 873f012e29Smrgenum amdgpu_gpu_va_range 883f012e29Smrg{ 893f012e29Smrg /** Allocate from "normal"/general range */ 903f012e29Smrg amdgpu_gpu_va_range_general = 0 913f012e29Smrg}; 923f012e29Smrg 933f012e29Smrg/*--------------------------------------------------------------------------*/ 943f012e29Smrg/* -------------------------- Datatypes ----------------------------------- */ 953f012e29Smrg/*--------------------------------------------------------------------------*/ 963f012e29Smrg 973f012e29Smrg/** 983f012e29Smrg * Define opaque pointer to context associated with fd. 993f012e29Smrg * This context will be returned as the result of 1003f012e29Smrg * "initialize" function and should be pass as the first 1013f012e29Smrg * parameter to any API call 1023f012e29Smrg */ 1033f012e29Smrgtypedef struct amdgpu_device *amdgpu_device_handle; 1043f012e29Smrg 1053f012e29Smrg/** 1063f012e29Smrg * Define GPU Context type as pointer to opaque structure 1073f012e29Smrg * Example of GPU Context is the "rendering" context associated 1083f012e29Smrg * with OpenGL context (glCreateContext) 1093f012e29Smrg */ 1103f012e29Smrgtypedef struct amdgpu_context *amdgpu_context_handle; 1113f012e29Smrg 1123f012e29Smrg/** 1133f012e29Smrg * Define handle for amdgpu resources: buffer, GDS, etc. 1143f012e29Smrg */ 1153f012e29Smrgtypedef struct amdgpu_bo *amdgpu_bo_handle; 1163f012e29Smrg 1173f012e29Smrg/** 1183f012e29Smrg * Define handle for list of BOs 1193f012e29Smrg */ 1203f012e29Smrgtypedef struct amdgpu_bo_list *amdgpu_bo_list_handle; 1213f012e29Smrg 1223f012e29Smrg/** 1233f012e29Smrg * Define handle to be used to work with VA allocated ranges 1243f012e29Smrg */ 1253f012e29Smrgtypedef struct amdgpu_va *amdgpu_va_handle; 1263f012e29Smrg 1273f012e29Smrg/** 1283f012e29Smrg * Define handle for semaphore 1293f012e29Smrg */ 1303f012e29Smrgtypedef struct amdgpu_semaphore *amdgpu_semaphore_handle; 1313f012e29Smrg 1323f012e29Smrg/*--------------------------------------------------------------------------*/ 1333f012e29Smrg/* -------------------------- Structures ---------------------------------- */ 1343f012e29Smrg/*--------------------------------------------------------------------------*/ 1353f012e29Smrg 1363f012e29Smrg/** 1373f012e29Smrg * Structure describing memory allocation request 1383f012e29Smrg * 1393f012e29Smrg * \sa amdgpu_bo_alloc() 1403f012e29Smrg * 1413f012e29Smrg*/ 1423f012e29Smrgstruct amdgpu_bo_alloc_request { 1433f012e29Smrg /** Allocation request. It must be aligned correctly. */ 1443f012e29Smrg uint64_t alloc_size; 1453f012e29Smrg 1463f012e29Smrg /** 1473f012e29Smrg * It may be required to have some specific alignment requirements 1483f012e29Smrg * for physical back-up storage (e.g. for displayable surface). 1493f012e29Smrg * If 0 there is no special alignment requirement 1503f012e29Smrg */ 1513f012e29Smrg uint64_t phys_alignment; 1523f012e29Smrg 1533f012e29Smrg /** 1543f012e29Smrg * UMD should specify where to allocate memory and how it 1553f012e29Smrg * will be accessed by the CPU. 1563f012e29Smrg */ 1573f012e29Smrg uint32_t preferred_heap; 1583f012e29Smrg 1593f012e29Smrg /** Additional flags passed on allocation */ 1603f012e29Smrg uint64_t flags; 1613f012e29Smrg}; 1623f012e29Smrg 1633f012e29Smrg/** 1643f012e29Smrg * Special UMD specific information associated with buffer. 1653f012e29Smrg * 1663f012e29Smrg * It may be need to pass some buffer charactersitic as part 1673f012e29Smrg * of buffer sharing. Such information are defined UMD and 1683f012e29Smrg * opaque for libdrm_amdgpu as well for kernel driver. 1693f012e29Smrg * 1703f012e29Smrg * \sa amdgpu_bo_set_metadata(), amdgpu_bo_query_info, 1713f012e29Smrg * amdgpu_bo_import(), amdgpu_bo_export 1723f012e29Smrg * 1733f012e29Smrg*/ 1743f012e29Smrgstruct amdgpu_bo_metadata { 1753f012e29Smrg /** Special flag associated with surface */ 1763f012e29Smrg uint64_t flags; 1773f012e29Smrg 1783f012e29Smrg /** 1793f012e29Smrg * ASIC-specific tiling information (also used by DCE). 1803f012e29Smrg * The encoding is defined by the AMDGPU_TILING_* definitions. 1813f012e29Smrg */ 1823f012e29Smrg uint64_t tiling_info; 1833f012e29Smrg 1843f012e29Smrg /** Size of metadata associated with the buffer, in bytes. */ 1853f012e29Smrg uint32_t size_metadata; 1863f012e29Smrg 1873f012e29Smrg /** UMD specific metadata. Opaque for kernel */ 1883f012e29Smrg uint32_t umd_metadata[64]; 1893f012e29Smrg}; 1903f012e29Smrg 1913f012e29Smrg/** 1923f012e29Smrg * Structure describing allocated buffer. Client may need 1933f012e29Smrg * to query such information as part of 'sharing' buffers mechanism 1943f012e29Smrg * 1953f012e29Smrg * \sa amdgpu_bo_set_metadata(), amdgpu_bo_query_info(), 1963f012e29Smrg * amdgpu_bo_import(), amdgpu_bo_export() 1973f012e29Smrg*/ 1983f012e29Smrgstruct amdgpu_bo_info { 1993f012e29Smrg /** Allocated memory size */ 2003f012e29Smrg uint64_t alloc_size; 2013f012e29Smrg 2023f012e29Smrg /** 2033f012e29Smrg * It may be required to have some specific alignment requirements 2043f012e29Smrg * for physical back-up storage. 2053f012e29Smrg */ 2063f012e29Smrg uint64_t phys_alignment; 2073f012e29Smrg 2083f012e29Smrg /** Heap where to allocate memory. */ 2093f012e29Smrg uint32_t preferred_heap; 2103f012e29Smrg 2113f012e29Smrg /** Additional allocation flags. */ 2123f012e29Smrg uint64_t alloc_flags; 2133f012e29Smrg 2143f012e29Smrg /** Metadata associated with buffer if any. */ 2153f012e29Smrg struct amdgpu_bo_metadata metadata; 2163f012e29Smrg}; 2173f012e29Smrg 2183f012e29Smrg/** 2193f012e29Smrg * Structure with information about "imported" buffer 2203f012e29Smrg * 2213f012e29Smrg * \sa amdgpu_bo_import() 2223f012e29Smrg * 2233f012e29Smrg */ 2243f012e29Smrgstruct amdgpu_bo_import_result { 2253f012e29Smrg /** Handle of memory/buffer to use */ 2263f012e29Smrg amdgpu_bo_handle buf_handle; 2273f012e29Smrg 2283f012e29Smrg /** Buffer size */ 2293f012e29Smrg uint64_t alloc_size; 2303f012e29Smrg}; 2313f012e29Smrg 2323f012e29Smrg/** 2333f012e29Smrg * 2343f012e29Smrg * Structure to describe GDS partitioning information. 2353f012e29Smrg * \note OA and GWS resources are asscoiated with GDS partition 2363f012e29Smrg * 2373f012e29Smrg * \sa amdgpu_gpu_resource_query_gds_info 2383f012e29Smrg * 2393f012e29Smrg*/ 2403f012e29Smrgstruct amdgpu_gds_resource_info { 2413f012e29Smrg uint32_t gds_gfx_partition_size; 2423f012e29Smrg uint32_t compute_partition_size; 2433f012e29Smrg uint32_t gds_total_size; 2443f012e29Smrg uint32_t gws_per_gfx_partition; 2453f012e29Smrg uint32_t gws_per_compute_partition; 2463f012e29Smrg uint32_t oa_per_gfx_partition; 2473f012e29Smrg uint32_t oa_per_compute_partition; 2483f012e29Smrg}; 2493f012e29Smrg 2503f012e29Smrg/** 2513f012e29Smrg * Structure describing CS fence 2523f012e29Smrg * 2533f012e29Smrg * \sa amdgpu_cs_query_fence_status(), amdgpu_cs_request, amdgpu_cs_submit() 2543f012e29Smrg * 2553f012e29Smrg*/ 2563f012e29Smrgstruct amdgpu_cs_fence { 2573f012e29Smrg 2583f012e29Smrg /** In which context IB was sent to execution */ 2593f012e29Smrg amdgpu_context_handle context; 2603f012e29Smrg 2613f012e29Smrg /** To which HW IP type the fence belongs */ 2623f012e29Smrg uint32_t ip_type; 2633f012e29Smrg 2643f012e29Smrg /** IP instance index if there are several IPs of the same type. */ 2653f012e29Smrg uint32_t ip_instance; 2663f012e29Smrg 2673f012e29Smrg /** Ring index of the HW IP */ 2683f012e29Smrg uint32_t ring; 2693f012e29Smrg 2703f012e29Smrg /** Specify fence for which we need to check submission status.*/ 2713f012e29Smrg uint64_t fence; 2723f012e29Smrg}; 2733f012e29Smrg 2743f012e29Smrg/** 2753f012e29Smrg * Structure describing IB 2763f012e29Smrg * 2773f012e29Smrg * \sa amdgpu_cs_request, amdgpu_cs_submit() 2783f012e29Smrg * 2793f012e29Smrg*/ 2803f012e29Smrgstruct amdgpu_cs_ib_info { 2813f012e29Smrg /** Special flags */ 2823f012e29Smrg uint64_t flags; 2833f012e29Smrg 2843f012e29Smrg /** Virtual MC address of the command buffer */ 2853f012e29Smrg uint64_t ib_mc_address; 2863f012e29Smrg 2873f012e29Smrg /** 2883f012e29Smrg * Size of Command Buffer to be submitted. 2893f012e29Smrg * - The size is in units of dwords (4 bytes). 2903f012e29Smrg * - Could be 0 2913f012e29Smrg */ 2923f012e29Smrg uint32_t size; 2933f012e29Smrg}; 2943f012e29Smrg 2953f012e29Smrg/** 2963f012e29Smrg * Structure describing fence information 2973f012e29Smrg * 2983f012e29Smrg * \sa amdgpu_cs_request, amdgpu_cs_query_fence, 2993f012e29Smrg * amdgpu_cs_submit(), amdgpu_cs_query_fence_status() 3003f012e29Smrg*/ 3013f012e29Smrgstruct amdgpu_cs_fence_info { 3023f012e29Smrg /** buffer object for the fence */ 3033f012e29Smrg amdgpu_bo_handle handle; 3043f012e29Smrg 3053f012e29Smrg /** fence offset in the unit of sizeof(uint64_t) */ 3063f012e29Smrg uint64_t offset; 3073f012e29Smrg}; 3083f012e29Smrg 3093f012e29Smrg/** 3103f012e29Smrg * Structure describing submission request 3113f012e29Smrg * 3123f012e29Smrg * \note We could have several IBs as packet. e.g. CE, CE, DE case for gfx 3133f012e29Smrg * 3143f012e29Smrg * \sa amdgpu_cs_submit() 3153f012e29Smrg*/ 3163f012e29Smrgstruct amdgpu_cs_request { 3173f012e29Smrg /** Specify flags with additional information */ 3183f012e29Smrg uint64_t flags; 3193f012e29Smrg 3203f012e29Smrg /** Specify HW IP block type to which to send the IB. */ 3213f012e29Smrg unsigned ip_type; 3223f012e29Smrg 3233f012e29Smrg /** IP instance index if there are several IPs of the same type. */ 3243f012e29Smrg unsigned ip_instance; 3253f012e29Smrg 3263f012e29Smrg /** 3273f012e29Smrg * Specify ring index of the IP. We could have several rings 3283f012e29Smrg * in the same IP. E.g. 0 for SDMA0 and 1 for SDMA1. 3293f012e29Smrg */ 3303f012e29Smrg uint32_t ring; 3313f012e29Smrg 3323f012e29Smrg /** 3333f012e29Smrg * List handle with resources used by this request. 3343f012e29Smrg */ 3353f012e29Smrg amdgpu_bo_list_handle resources; 3363f012e29Smrg 3373f012e29Smrg /** 3383f012e29Smrg * Number of dependencies this Command submission needs to 3393f012e29Smrg * wait for before starting execution. 3403f012e29Smrg */ 3413f012e29Smrg uint32_t number_of_dependencies; 3423f012e29Smrg 3433f012e29Smrg /** 3443f012e29Smrg * Array of dependencies which need to be met before 3453f012e29Smrg * execution can start. 3463f012e29Smrg */ 3473f012e29Smrg struct amdgpu_cs_fence *dependencies; 3483f012e29Smrg 3493f012e29Smrg /** Number of IBs to submit in the field ibs. */ 3503f012e29Smrg uint32_t number_of_ibs; 3513f012e29Smrg 3523f012e29Smrg /** 3533f012e29Smrg * IBs to submit. Those IBs will be submit together as single entity 3543f012e29Smrg */ 3553f012e29Smrg struct amdgpu_cs_ib_info *ibs; 3563f012e29Smrg 3573f012e29Smrg /** 3583f012e29Smrg * The returned sequence number for the command submission 3593f012e29Smrg */ 3603f012e29Smrg uint64_t seq_no; 3613f012e29Smrg 3623f012e29Smrg /** 3633f012e29Smrg * The fence information 3643f012e29Smrg */ 3653f012e29Smrg struct amdgpu_cs_fence_info fence_info; 3663f012e29Smrg}; 3673f012e29Smrg 3683f012e29Smrg/** 3693f012e29Smrg * Structure which provide information about GPU VM MC Address space 3703f012e29Smrg * alignments requirements 3713f012e29Smrg * 3723f012e29Smrg * \sa amdgpu_query_buffer_size_alignment 3733f012e29Smrg */ 3743f012e29Smrgstruct amdgpu_buffer_size_alignments { 3753f012e29Smrg /** Size alignment requirement for allocation in 3763f012e29Smrg * local memory */ 3773f012e29Smrg uint64_t size_local; 3783f012e29Smrg 3793f012e29Smrg /** 3803f012e29Smrg * Size alignment requirement for allocation in remote memory 3813f012e29Smrg */ 3823f012e29Smrg uint64_t size_remote; 3833f012e29Smrg}; 3843f012e29Smrg 3853f012e29Smrg/** 3863f012e29Smrg * Structure which provide information about heap 3873f012e29Smrg * 3883f012e29Smrg * \sa amdgpu_query_heap_info() 3893f012e29Smrg * 3903f012e29Smrg */ 3913f012e29Smrgstruct amdgpu_heap_info { 3923f012e29Smrg /** Theoretical max. available memory in the given heap */ 3933f012e29Smrg uint64_t heap_size; 3943f012e29Smrg 3953f012e29Smrg /** 3963f012e29Smrg * Number of bytes allocated in the heap. This includes all processes 3973f012e29Smrg * and private allocations in the kernel. It changes when new buffers 3983f012e29Smrg * are allocated, freed, and moved. It cannot be larger than 3993f012e29Smrg * heap_size. 4003f012e29Smrg */ 4013f012e29Smrg uint64_t heap_usage; 4023f012e29Smrg 4033f012e29Smrg /** 4043f012e29Smrg * Theoretical possible max. size of buffer which 4053f012e29Smrg * could be allocated in the given heap 4063f012e29Smrg */ 4073f012e29Smrg uint64_t max_allocation; 4083f012e29Smrg}; 4093f012e29Smrg 4103f012e29Smrg/** 4113f012e29Smrg * Describe GPU h/w info needed for UMD correct initialization 4123f012e29Smrg * 4133f012e29Smrg * \sa amdgpu_query_gpu_info() 4143f012e29Smrg*/ 4153f012e29Smrgstruct amdgpu_gpu_info { 4163f012e29Smrg /** Asic id */ 4173f012e29Smrg uint32_t asic_id; 4183f012e29Smrg /** Chip revision */ 4193f012e29Smrg uint32_t chip_rev; 4203f012e29Smrg /** Chip external revision */ 4213f012e29Smrg uint32_t chip_external_rev; 4223f012e29Smrg /** Family ID */ 4233f012e29Smrg uint32_t family_id; 4243f012e29Smrg /** Special flags */ 4253f012e29Smrg uint64_t ids_flags; 4263f012e29Smrg /** max engine clock*/ 4273f012e29Smrg uint64_t max_engine_clk; 4283f012e29Smrg /** max memory clock */ 4293f012e29Smrg uint64_t max_memory_clk; 4303f012e29Smrg /** number of shader engines */ 4313f012e29Smrg uint32_t num_shader_engines; 4323f012e29Smrg /** number of shader arrays per engine */ 4333f012e29Smrg uint32_t num_shader_arrays_per_engine; 4343f012e29Smrg /** Number of available good shader pipes */ 4353f012e29Smrg uint32_t avail_quad_shader_pipes; 4363f012e29Smrg /** Max. number of shader pipes.(including good and bad pipes */ 4373f012e29Smrg uint32_t max_quad_shader_pipes; 4383f012e29Smrg /** Number of parameter cache entries per shader quad pipe */ 4393f012e29Smrg uint32_t cache_entries_per_quad_pipe; 4403f012e29Smrg /** Number of available graphics context */ 4413f012e29Smrg uint32_t num_hw_gfx_contexts; 4423f012e29Smrg /** Number of render backend pipes */ 4433f012e29Smrg uint32_t rb_pipes; 4443f012e29Smrg /** Enabled render backend pipe mask */ 4453f012e29Smrg uint32_t enabled_rb_pipes_mask; 4463f012e29Smrg /** Frequency of GPU Counter */ 4473f012e29Smrg uint32_t gpu_counter_freq; 4483f012e29Smrg /** CC_RB_BACKEND_DISABLE.BACKEND_DISABLE per SE */ 4493f012e29Smrg uint32_t backend_disable[4]; 4503f012e29Smrg /** Value of MC_ARB_RAMCFG register*/ 4513f012e29Smrg uint32_t mc_arb_ramcfg; 4523f012e29Smrg /** Value of GB_ADDR_CONFIG */ 4533f012e29Smrg uint32_t gb_addr_cfg; 4543f012e29Smrg /** Values of the GB_TILE_MODE0..31 registers */ 4553f012e29Smrg uint32_t gb_tile_mode[32]; 4563f012e29Smrg /** Values of GB_MACROTILE_MODE0..15 registers */ 4573f012e29Smrg uint32_t gb_macro_tile_mode[16]; 4583f012e29Smrg /** Value of PA_SC_RASTER_CONFIG register per SE */ 4593f012e29Smrg uint32_t pa_sc_raster_cfg[4]; 4603f012e29Smrg /** Value of PA_SC_RASTER_CONFIG_1 register per SE */ 4613f012e29Smrg uint32_t pa_sc_raster_cfg1[4]; 4623f012e29Smrg /* CU info */ 4633f012e29Smrg uint32_t cu_active_number; 4643f012e29Smrg uint32_t cu_ao_mask; 4653f012e29Smrg uint32_t cu_bitmap[4][4]; 4663f012e29Smrg /* video memory type info*/ 4673f012e29Smrg uint32_t vram_type; 4683f012e29Smrg /* video memory bit width*/ 4693f012e29Smrg uint32_t vram_bit_width; 4703f012e29Smrg /** constant engine ram size*/ 4713f012e29Smrg uint32_t ce_ram_size; 4723f012e29Smrg /* vce harvesting instance */ 4733f012e29Smrg uint32_t vce_harvest_config; 4743f012e29Smrg /* PCI revision ID */ 4753f012e29Smrg uint32_t pci_rev_id; 4763f012e29Smrg}; 4773f012e29Smrg 4783f012e29Smrg 4793f012e29Smrg/*--------------------------------------------------------------------------*/ 4803f012e29Smrg/*------------------------- Functions --------------------------------------*/ 4813f012e29Smrg/*--------------------------------------------------------------------------*/ 4823f012e29Smrg 4833f012e29Smrg/* 4843f012e29Smrg * Initialization / Cleanup 4853f012e29Smrg * 4863f012e29Smrg*/ 4873f012e29Smrg 4883f012e29Smrg/** 4893f012e29Smrg * 4903f012e29Smrg * \param fd - \c [in] File descriptor for AMD GPU device 4913f012e29Smrg * received previously as the result of 4923f012e29Smrg * e.g. drmOpen() call. 4933f012e29Smrg * For legacy fd type, the DRI2/DRI3 4943f012e29Smrg * authentication should be done before 4953f012e29Smrg * calling this function. 4963f012e29Smrg * \param major_version - \c [out] Major version of library. It is assumed 4973f012e29Smrg * that adding new functionality will cause 4983f012e29Smrg * increase in major version 4993f012e29Smrg * \param minor_version - \c [out] Minor version of library 5003f012e29Smrg * \param device_handle - \c [out] Pointer to opaque context which should 5013f012e29Smrg * be passed as the first parameter on each 5023f012e29Smrg * API call 5033f012e29Smrg * 5043f012e29Smrg * 5053f012e29Smrg * \return 0 on success\n 5063f012e29Smrg * <0 - Negative POSIX Error code 5073f012e29Smrg * 5083f012e29Smrg * 5093f012e29Smrg * \sa amdgpu_device_deinitialize() 5103f012e29Smrg*/ 5113f012e29Smrgint amdgpu_device_initialize(int fd, 5123f012e29Smrg uint32_t *major_version, 5133f012e29Smrg uint32_t *minor_version, 5143f012e29Smrg amdgpu_device_handle *device_handle); 5153f012e29Smrg 5163f012e29Smrg/** 5173f012e29Smrg * 5183f012e29Smrg * When access to such library does not needed any more the special 5193f012e29Smrg * function must be call giving opportunity to clean up any 5203f012e29Smrg * resources if needed. 5213f012e29Smrg * 5223f012e29Smrg * \param device_handle - \c [in] Context associated with file 5233f012e29Smrg * descriptor for AMD GPU device 5243f012e29Smrg * received previously as the 5253f012e29Smrg * result e.g. of drmOpen() call. 5263f012e29Smrg * 5273f012e29Smrg * \return 0 on success\n 5283f012e29Smrg * <0 - Negative POSIX Error code 5293f012e29Smrg * 5303f012e29Smrg * \sa amdgpu_device_initialize() 5313f012e29Smrg * 5323f012e29Smrg*/ 5333f012e29Smrgint amdgpu_device_deinitialize(amdgpu_device_handle device_handle); 5343f012e29Smrg 5353f012e29Smrg/* 5363f012e29Smrg * Memory Management 5373f012e29Smrg * 5383f012e29Smrg*/ 5393f012e29Smrg 5403f012e29Smrg/** 5413f012e29Smrg * Allocate memory to be used by UMD for GPU related operations 5423f012e29Smrg * 5433f012e29Smrg * \param dev - \c [in] Device handle. 5443f012e29Smrg * See #amdgpu_device_initialize() 5453f012e29Smrg * \param alloc_buffer - \c [in] Pointer to the structure describing an 5463f012e29Smrg * allocation request 5473f012e29Smrg * \param buf_handle - \c [out] Allocated buffer handle 5483f012e29Smrg * 5493f012e29Smrg * \return 0 on success\n 5503f012e29Smrg * <0 - Negative POSIX Error code 5513f012e29Smrg * 5523f012e29Smrg * \sa amdgpu_bo_free() 5533f012e29Smrg*/ 5543f012e29Smrgint amdgpu_bo_alloc(amdgpu_device_handle dev, 5553f012e29Smrg struct amdgpu_bo_alloc_request *alloc_buffer, 5563f012e29Smrg amdgpu_bo_handle *buf_handle); 5573f012e29Smrg 5583f012e29Smrg/** 5593f012e29Smrg * Associate opaque data with buffer to be queried by another UMD 5603f012e29Smrg * 5613f012e29Smrg * \param dev - \c [in] Device handle. See #amdgpu_device_initialize() 5623f012e29Smrg * \param buf_handle - \c [in] Buffer handle 5633f012e29Smrg * \param info - \c [in] Metadata to associated with buffer 5643f012e29Smrg * 5653f012e29Smrg * \return 0 on success\n 5663f012e29Smrg * <0 - Negative POSIX Error code 5673f012e29Smrg*/ 5683f012e29Smrgint amdgpu_bo_set_metadata(amdgpu_bo_handle buf_handle, 5693f012e29Smrg struct amdgpu_bo_metadata *info); 5703f012e29Smrg 5713f012e29Smrg/** 5723f012e29Smrg * Query buffer information including metadata previusly associated with 5733f012e29Smrg * buffer. 5743f012e29Smrg * 5753f012e29Smrg * \param dev - \c [in] Device handle. 5763f012e29Smrg * See #amdgpu_device_initialize() 5773f012e29Smrg * \param buf_handle - \c [in] Buffer handle 5783f012e29Smrg * \param info - \c [out] Structure describing buffer 5793f012e29Smrg * 5803f012e29Smrg * \return 0 on success\n 5813f012e29Smrg * <0 - Negative POSIX Error code 5823f012e29Smrg * 5833f012e29Smrg * \sa amdgpu_bo_set_metadata(), amdgpu_bo_alloc() 5843f012e29Smrg*/ 5853f012e29Smrgint amdgpu_bo_query_info(amdgpu_bo_handle buf_handle, 5863f012e29Smrg struct amdgpu_bo_info *info); 5873f012e29Smrg 5883f012e29Smrg/** 5893f012e29Smrg * Allow others to get access to buffer 5903f012e29Smrg * 5913f012e29Smrg * \param dev - \c [in] Device handle. 5923f012e29Smrg * See #amdgpu_device_initialize() 5933f012e29Smrg * \param buf_handle - \c [in] Buffer handle 5943f012e29Smrg * \param type - \c [in] Type of handle requested 5953f012e29Smrg * \param shared_handle - \c [out] Special "shared" handle 5963f012e29Smrg * 5973f012e29Smrg * \return 0 on success\n 5983f012e29Smrg * <0 - Negative POSIX Error code 5993f012e29Smrg * 6003f012e29Smrg * \sa amdgpu_bo_import() 6013f012e29Smrg * 6023f012e29Smrg*/ 6033f012e29Smrgint amdgpu_bo_export(amdgpu_bo_handle buf_handle, 6043f012e29Smrg enum amdgpu_bo_handle_type type, 6053f012e29Smrg uint32_t *shared_handle); 6063f012e29Smrg 6073f012e29Smrg/** 6083f012e29Smrg * Request access to "shared" buffer 6093f012e29Smrg * 6103f012e29Smrg * \param dev - \c [in] Device handle. 6113f012e29Smrg * See #amdgpu_device_initialize() 6123f012e29Smrg * \param type - \c [in] Type of handle requested 6133f012e29Smrg * \param shared_handle - \c [in] Shared handle received as result "import" 6143f012e29Smrg * operation 6153f012e29Smrg * \param output - \c [out] Pointer to structure with information 6163f012e29Smrg * about imported buffer 6173f012e29Smrg * 6183f012e29Smrg * \return 0 on success\n 6193f012e29Smrg * <0 - Negative POSIX Error code 6203f012e29Smrg * 6213f012e29Smrg * \note Buffer must be "imported" only using new "fd" (different from 6223f012e29Smrg * one used by "exporter"). 6233f012e29Smrg * 6243f012e29Smrg * \sa amdgpu_bo_export() 6253f012e29Smrg * 6263f012e29Smrg*/ 6273f012e29Smrgint amdgpu_bo_import(amdgpu_device_handle dev, 6283f012e29Smrg enum amdgpu_bo_handle_type type, 6293f012e29Smrg uint32_t shared_handle, 6303f012e29Smrg struct amdgpu_bo_import_result *output); 6313f012e29Smrg 6323f012e29Smrg/** 6333f012e29Smrg * Request GPU access to user allocated memory e.g. via "malloc" 6343f012e29Smrg * 6353f012e29Smrg * \param dev - [in] Device handle. See #amdgpu_device_initialize() 6363f012e29Smrg * \param cpu - [in] CPU address of user allocated memory which we 6373f012e29Smrg * want to map to GPU address space (make GPU accessible) 6383f012e29Smrg * (This address must be correctly aligned). 6393f012e29Smrg * \param size - [in] Size of allocation (must be correctly aligned) 6403f012e29Smrg * \param buf_handle - [out] Buffer handle for the userptr memory 6413f012e29Smrg * resource on submission and be used in other operations. 6423f012e29Smrg * 6433f012e29Smrg * 6443f012e29Smrg * \return 0 on success\n 6453f012e29Smrg * <0 - Negative POSIX Error code 6463f012e29Smrg * 6473f012e29Smrg * \note 6483f012e29Smrg * This call doesn't guarantee that such memory will be persistently 6493f012e29Smrg * "locked" / make non-pageable. The purpose of this call is to provide 6503f012e29Smrg * opportunity for GPU get access to this resource during submission. 6513f012e29Smrg * 6523f012e29Smrg * The maximum amount of memory which could be mapped in this call depends 6533f012e29Smrg * if overcommit is disabled or not. If overcommit is disabled than the max. 6543f012e29Smrg * amount of memory to be pinned will be limited by left "free" size in total 6553f012e29Smrg * amount of memory which could be locked simultaneously ("GART" size). 6563f012e29Smrg * 6573f012e29Smrg * Supported (theoretical) max. size of mapping is restricted only by 6583f012e29Smrg * "GART" size. 6593f012e29Smrg * 6603f012e29Smrg * It is responsibility of caller to correctly specify access rights 6613f012e29Smrg * on VA assignment. 6623f012e29Smrg*/ 6633f012e29Smrgint amdgpu_create_bo_from_user_mem(amdgpu_device_handle dev, 6643f012e29Smrg void *cpu, uint64_t size, 6653f012e29Smrg amdgpu_bo_handle *buf_handle); 6663f012e29Smrg 6673f012e29Smrg/** 6683f012e29Smrg * Free previosuly allocated memory 6693f012e29Smrg * 6703f012e29Smrg * \param dev - \c [in] Device handle. See #amdgpu_device_initialize() 6713f012e29Smrg * \param buf_handle - \c [in] Buffer handle to free 6723f012e29Smrg * 6733f012e29Smrg * \return 0 on success\n 6743f012e29Smrg * <0 - Negative POSIX Error code 6753f012e29Smrg * 6763f012e29Smrg * \note In the case of memory shared between different applications all 6773f012e29Smrg * resources will be “physically” freed only all such applications 6783f012e29Smrg * will be terminated 6793f012e29Smrg * \note If is UMD responsibility to ‘free’ buffer only when there is no 6803f012e29Smrg * more GPU access 6813f012e29Smrg * 6823f012e29Smrg * \sa amdgpu_bo_set_metadata(), amdgpu_bo_alloc() 6833f012e29Smrg * 6843f012e29Smrg*/ 6853f012e29Smrgint amdgpu_bo_free(amdgpu_bo_handle buf_handle); 6863f012e29Smrg 6873f012e29Smrg/** 6883f012e29Smrg * Request CPU access to GPU accessible memory 6893f012e29Smrg * 6903f012e29Smrg * \param buf_handle - \c [in] Buffer handle 6913f012e29Smrg * \param cpu - \c [out] CPU address to be used for access 6923f012e29Smrg * 6933f012e29Smrg * \return 0 on success\n 6943f012e29Smrg * <0 - Negative POSIX Error code 6953f012e29Smrg * 6963f012e29Smrg * \sa amdgpu_bo_cpu_unmap() 6973f012e29Smrg * 6983f012e29Smrg*/ 6993f012e29Smrgint amdgpu_bo_cpu_map(amdgpu_bo_handle buf_handle, void **cpu); 7003f012e29Smrg 7013f012e29Smrg/** 7023f012e29Smrg * Release CPU access to GPU memory 7033f012e29Smrg * 7043f012e29Smrg * \param buf_handle - \c [in] Buffer handle 7053f012e29Smrg * 7063f012e29Smrg * \return 0 on success\n 7073f012e29Smrg * <0 - Negative POSIX Error code 7083f012e29Smrg * 7093f012e29Smrg * \sa amdgpu_bo_cpu_map() 7103f012e29Smrg * 7113f012e29Smrg*/ 7123f012e29Smrgint amdgpu_bo_cpu_unmap(amdgpu_bo_handle buf_handle); 7133f012e29Smrg 7143f012e29Smrg/** 7153f012e29Smrg * Wait until a buffer is not used by the device. 7163f012e29Smrg * 7173f012e29Smrg * \param dev - \c [in] Device handle. See #amdgpu_device_initialize() 7183f012e29Smrg * \param buf_handle - \c [in] Buffer handle. 7193f012e29Smrg * \param timeout_ns - Timeout in nanoseconds. 7203f012e29Smrg * \param buffer_busy - 0 if buffer is idle, all GPU access was completed 7213f012e29Smrg * and no GPU access is scheduled. 7223f012e29Smrg * 1 GPU access is in fly or scheduled 7233f012e29Smrg * 7243f012e29Smrg * \return 0 - on success 7253f012e29Smrg * <0 - Negative POSIX Error code 7263f012e29Smrg */ 7273f012e29Smrgint amdgpu_bo_wait_for_idle(amdgpu_bo_handle buf_handle, 7283f012e29Smrg uint64_t timeout_ns, 7293f012e29Smrg bool *buffer_busy); 7303f012e29Smrg 7313f012e29Smrg/** 7323f012e29Smrg * Creates a BO list handle for command submission. 7333f012e29Smrg * 7343f012e29Smrg * \param dev - \c [in] Device handle. 7353f012e29Smrg * See #amdgpu_device_initialize() 7363f012e29Smrg * \param number_of_resources - \c [in] Number of BOs in the list 7373f012e29Smrg * \param resources - \c [in] List of BO handles 7383f012e29Smrg * \param resource_prios - \c [in] Optional priority for each handle 7393f012e29Smrg * \param result - \c [out] Created BO list handle 7403f012e29Smrg * 7413f012e29Smrg * \return 0 on success\n 7423f012e29Smrg * <0 - Negative POSIX Error code 7433f012e29Smrg * 7443f012e29Smrg * \sa amdgpu_bo_list_destroy() 7453f012e29Smrg*/ 7463f012e29Smrgint amdgpu_bo_list_create(amdgpu_device_handle dev, 7473f012e29Smrg uint32_t number_of_resources, 7483f012e29Smrg amdgpu_bo_handle *resources, 7493f012e29Smrg uint8_t *resource_prios, 7503f012e29Smrg amdgpu_bo_list_handle *result); 7513f012e29Smrg 7523f012e29Smrg/** 7533f012e29Smrg * Destroys a BO list handle. 7543f012e29Smrg * 7553f012e29Smrg * \param handle - \c [in] BO list handle. 7563f012e29Smrg * 7573f012e29Smrg * \return 0 on success\n 7583f012e29Smrg * <0 - Negative POSIX Error code 7593f012e29Smrg * 7603f012e29Smrg * \sa amdgpu_bo_list_create() 7613f012e29Smrg*/ 7623f012e29Smrgint amdgpu_bo_list_destroy(amdgpu_bo_list_handle handle); 7633f012e29Smrg 7643f012e29Smrg/** 7653f012e29Smrg * Update resources for existing BO list 7663f012e29Smrg * 7673f012e29Smrg * \param handle - \c [in] BO list handle 7683f012e29Smrg * \param number_of_resources - \c [in] Number of BOs in the list 7693f012e29Smrg * \param resources - \c [in] List of BO handles 7703f012e29Smrg * \param resource_prios - \c [in] Optional priority for each handle 7713f012e29Smrg * 7723f012e29Smrg * \return 0 on success\n 7733f012e29Smrg * <0 - Negative POSIX Error code 7743f012e29Smrg * 7753f012e29Smrg * \sa amdgpu_bo_list_update() 7763f012e29Smrg*/ 7773f012e29Smrgint amdgpu_bo_list_update(amdgpu_bo_list_handle handle, 7783f012e29Smrg uint32_t number_of_resources, 7793f012e29Smrg amdgpu_bo_handle *resources, 7803f012e29Smrg uint8_t *resource_prios); 7813f012e29Smrg 7823f012e29Smrg/* 7833f012e29Smrg * GPU Execution context 7843f012e29Smrg * 7853f012e29Smrg*/ 7863f012e29Smrg 7873f012e29Smrg/** 7883f012e29Smrg * Create GPU execution Context 7893f012e29Smrg * 7903f012e29Smrg * For the purpose of GPU Scheduler and GPU Robustness extensions it is 7913f012e29Smrg * necessary to have information/identify rendering/compute contexts. 7923f012e29Smrg * It also may be needed to associate some specific requirements with such 7933f012e29Smrg * contexts. Kernel driver will guarantee that submission from the same 7943f012e29Smrg * context will always be executed in order (first come, first serve). 7953f012e29Smrg * 7963f012e29Smrg * 7973f012e29Smrg * \param dev - \c [in] Device handle. See #amdgpu_device_initialize() 7983f012e29Smrg * \param context - \c [out] GPU Context handle 7993f012e29Smrg * 8003f012e29Smrg * \return 0 on success\n 8013f012e29Smrg * <0 - Negative POSIX Error code 8023f012e29Smrg * 8033f012e29Smrg * \sa amdgpu_cs_ctx_free() 8043f012e29Smrg * 8053f012e29Smrg*/ 8063f012e29Smrgint amdgpu_cs_ctx_create(amdgpu_device_handle dev, 8073f012e29Smrg amdgpu_context_handle *context); 8083f012e29Smrg 8093f012e29Smrg/** 8103f012e29Smrg * 8113f012e29Smrg * Destroy GPU execution context when not needed any more 8123f012e29Smrg * 8133f012e29Smrg * \param context - \c [in] GPU Context handle 8143f012e29Smrg * 8153f012e29Smrg * \return 0 on success\n 8163f012e29Smrg * <0 - Negative POSIX Error code 8173f012e29Smrg * 8183f012e29Smrg * \sa amdgpu_cs_ctx_create() 8193f012e29Smrg * 8203f012e29Smrg*/ 8213f012e29Smrgint amdgpu_cs_ctx_free(amdgpu_context_handle context); 8223f012e29Smrg 8233f012e29Smrg/** 8243f012e29Smrg * Query reset state for the specific GPU Context 8253f012e29Smrg * 8263f012e29Smrg * \param context - \c [in] GPU Context handle 8273f012e29Smrg * \param state - \c [out] One of AMDGPU_CTX_*_RESET 8283f012e29Smrg * \param hangs - \c [out] Number of hangs caused by the context. 8293f012e29Smrg * 8303f012e29Smrg * \return 0 on success\n 8313f012e29Smrg * <0 - Negative POSIX Error code 8323f012e29Smrg * 8333f012e29Smrg * \sa amdgpu_cs_ctx_create() 8343f012e29Smrg * 8353f012e29Smrg*/ 8363f012e29Smrgint amdgpu_cs_query_reset_state(amdgpu_context_handle context, 8373f012e29Smrg uint32_t *state, uint32_t *hangs); 8383f012e29Smrg 8393f012e29Smrg/* 8403f012e29Smrg * Command Buffers Management 8413f012e29Smrg * 8423f012e29Smrg*/ 8433f012e29Smrg 8443f012e29Smrg/** 8453f012e29Smrg * Send request to submit command buffers to hardware. 8463f012e29Smrg * 8473f012e29Smrg * Kernel driver could use GPU Scheduler to make decision when physically 8483f012e29Smrg * sent this request to the hardware. Accordingly this request could be put 8493f012e29Smrg * in queue and sent for execution later. The only guarantee is that request 8503f012e29Smrg * from the same GPU context to the same ip:ip_instance:ring will be executed in 8513f012e29Smrg * order. 8523f012e29Smrg * 8533f012e29Smrg * The caller can specify the user fence buffer/location with the fence_info in the 8543f012e29Smrg * cs_request.The sequence number is returned via the 'seq_no' parameter 8553f012e29Smrg * in ibs_request structure. 8563f012e29Smrg * 8573f012e29Smrg * 8583f012e29Smrg * \param dev - \c [in] Device handle. 8593f012e29Smrg * See #amdgpu_device_initialize() 8603f012e29Smrg * \param context - \c [in] GPU Context 8613f012e29Smrg * \param flags - \c [in] Global submission flags 8623f012e29Smrg * \param ibs_request - \c [in/out] Pointer to submission requests. 8633f012e29Smrg * We could submit to the several 8643f012e29Smrg * engines/rings simulteniously as 8653f012e29Smrg * 'atomic' operation 8663f012e29Smrg * \param number_of_requests - \c [in] Number of submission requests 8673f012e29Smrg * 8683f012e29Smrg * \return 0 on success\n 8693f012e29Smrg * <0 - Negative POSIX Error code 8703f012e29Smrg * 8713f012e29Smrg * \note It is required to pass correct resource list with buffer handles 8723f012e29Smrg * which will be accessible by command buffers from submission 8733f012e29Smrg * This will allow kernel driver to correctly implement "paging". 8743f012e29Smrg * Failure to do so will have unpredictable results. 8753f012e29Smrg * 8763f012e29Smrg * \sa amdgpu_command_buffer_alloc(), amdgpu_command_buffer_free(), 8773f012e29Smrg * amdgpu_cs_query_fence_status() 8783f012e29Smrg * 8793f012e29Smrg*/ 8803f012e29Smrgint amdgpu_cs_submit(amdgpu_context_handle context, 8813f012e29Smrg uint64_t flags, 8823f012e29Smrg struct amdgpu_cs_request *ibs_request, 8833f012e29Smrg uint32_t number_of_requests); 8843f012e29Smrg 8853f012e29Smrg/** 8863f012e29Smrg * Query status of Command Buffer Submission 8873f012e29Smrg * 8883f012e29Smrg * \param fence - \c [in] Structure describing fence to query 8893f012e29Smrg * \param timeout_ns - \c [in] Timeout value to wait 8903f012e29Smrg * \param flags - \c [in] Flags for the query 8913f012e29Smrg * \param expired - \c [out] If fence expired or not.\n 8923f012e29Smrg * 0 – if fence is not expired\n 8933f012e29Smrg * !0 - otherwise 8943f012e29Smrg * 8953f012e29Smrg * \return 0 on success\n 8963f012e29Smrg * <0 - Negative POSIX Error code 8973f012e29Smrg * 8983f012e29Smrg * \note If UMD wants only to check operation status and returned immediately 8993f012e29Smrg * then timeout value as 0 must be passed. In this case success will be 9003f012e29Smrg * returned in the case if submission was completed or timeout error 9013f012e29Smrg * code. 9023f012e29Smrg * 9033f012e29Smrg * \sa amdgpu_cs_submit() 9043f012e29Smrg*/ 9053f012e29Smrgint amdgpu_cs_query_fence_status(struct amdgpu_cs_fence *fence, 9063f012e29Smrg uint64_t timeout_ns, 9073f012e29Smrg uint64_t flags, 9083f012e29Smrg uint32_t *expired); 9093f012e29Smrg 9103f012e29Smrg/* 9113f012e29Smrg * Query / Info API 9123f012e29Smrg * 9133f012e29Smrg*/ 9143f012e29Smrg 9153f012e29Smrg/** 9163f012e29Smrg * Query allocation size alignments 9173f012e29Smrg * 9183f012e29Smrg * UMD should query information about GPU VM MC size alignments requirements 9193f012e29Smrg * to be able correctly choose required allocation size and implement 9203f012e29Smrg * internal optimization if needed. 9213f012e29Smrg * 9223f012e29Smrg * \param dev - \c [in] Device handle. See #amdgpu_device_initialize() 9233f012e29Smrg * \param info - \c [out] Pointer to structure to get size alignment 9243f012e29Smrg * requirements 9253f012e29Smrg * 9263f012e29Smrg * \return 0 on success\n 9273f012e29Smrg * <0 - Negative POSIX Error code 9283f012e29Smrg * 9293f012e29Smrg*/ 9303f012e29Smrgint amdgpu_query_buffer_size_alignment(amdgpu_device_handle dev, 9313f012e29Smrg struct amdgpu_buffer_size_alignments 9323f012e29Smrg *info); 9333f012e29Smrg 9343f012e29Smrg/** 9353f012e29Smrg * Query firmware versions 9363f012e29Smrg * 9373f012e29Smrg * \param dev - \c [in] Device handle. See #amdgpu_device_initialize() 9383f012e29Smrg * \param fw_type - \c [in] AMDGPU_INFO_FW_* 9393f012e29Smrg * \param ip_instance - \c [in] Index of the IP block of the same type. 9403f012e29Smrg * \param index - \c [in] Index of the engine. (for SDMA and MEC) 9413f012e29Smrg * \param version - \c [out] Pointer to to the "version" return value 9423f012e29Smrg * \param feature - \c [out] Pointer to to the "feature" return value 9433f012e29Smrg * 9443f012e29Smrg * \return 0 on success\n 9453f012e29Smrg * <0 - Negative POSIX Error code 9463f012e29Smrg * 9473f012e29Smrg*/ 9483f012e29Smrgint amdgpu_query_firmware_version(amdgpu_device_handle dev, unsigned fw_type, 9493f012e29Smrg unsigned ip_instance, unsigned index, 9503f012e29Smrg uint32_t *version, uint32_t *feature); 9513f012e29Smrg 9523f012e29Smrg/** 9533f012e29Smrg * Query the number of HW IP instances of a certain type. 9543f012e29Smrg * 9553f012e29Smrg * \param dev - \c [in] Device handle. See #amdgpu_device_initialize() 9563f012e29Smrg * \param type - \c [in] Hardware IP block type = AMDGPU_HW_IP_* 9573f012e29Smrg * \param count - \c [out] Pointer to structure to get information 9583f012e29Smrg * 9593f012e29Smrg * \return 0 on success\n 9603f012e29Smrg * <0 - Negative POSIX Error code 9613f012e29Smrg*/ 9623f012e29Smrgint amdgpu_query_hw_ip_count(amdgpu_device_handle dev, unsigned type, 9633f012e29Smrg uint32_t *count); 9643f012e29Smrg 9653f012e29Smrg/** 9663f012e29Smrg * Query engine information 9673f012e29Smrg * 9683f012e29Smrg * This query allows UMD to query information different engines and their 9693f012e29Smrg * capabilities. 9703f012e29Smrg * 9713f012e29Smrg * \param dev - \c [in] Device handle. See #amdgpu_device_initialize() 9723f012e29Smrg * \param type - \c [in] Hardware IP block type = AMDGPU_HW_IP_* 9733f012e29Smrg * \param ip_instance - \c [in] Index of the IP block of the same type. 9743f012e29Smrg * \param info - \c [out] Pointer to structure to get information 9753f012e29Smrg * 9763f012e29Smrg * \return 0 on success\n 9773f012e29Smrg * <0 - Negative POSIX Error code 9783f012e29Smrg*/ 9793f012e29Smrgint amdgpu_query_hw_ip_info(amdgpu_device_handle dev, unsigned type, 9803f012e29Smrg unsigned ip_instance, 9813f012e29Smrg struct drm_amdgpu_info_hw_ip *info); 9823f012e29Smrg 9833f012e29Smrg/** 9843f012e29Smrg * Query heap information 9853f012e29Smrg * 9863f012e29Smrg * This query allows UMD to query potentially available memory resources and 9873f012e29Smrg * adjust their logic if necessary. 9883f012e29Smrg * 9893f012e29Smrg * \param dev - \c [in] Device handle. See #amdgpu_device_initialize() 9903f012e29Smrg * \param heap - \c [in] Heap type 9913f012e29Smrg * \param info - \c [in] Pointer to structure to get needed information 9923f012e29Smrg * 9933f012e29Smrg * \return 0 on success\n 9943f012e29Smrg * <0 - Negative POSIX Error code 9953f012e29Smrg * 9963f012e29Smrg*/ 9973f012e29Smrgint amdgpu_query_heap_info(amdgpu_device_handle dev, uint32_t heap, 9983f012e29Smrg uint32_t flags, struct amdgpu_heap_info *info); 9993f012e29Smrg 10003f012e29Smrg/** 10013f012e29Smrg * Get the CRTC ID from the mode object ID 10023f012e29Smrg * 10033f012e29Smrg * \param dev - \c [in] Device handle. See #amdgpu_device_initialize() 10043f012e29Smrg * \param id - \c [in] Mode object ID 10053f012e29Smrg * \param result - \c [in] Pointer to the CRTC ID 10063f012e29Smrg * 10073f012e29Smrg * \return 0 on success\n 10083f012e29Smrg * <0 - Negative POSIX Error code 10093f012e29Smrg * 10103f012e29Smrg*/ 10113f012e29Smrgint amdgpu_query_crtc_from_id(amdgpu_device_handle dev, unsigned id, 10123f012e29Smrg int32_t *result); 10133f012e29Smrg 10143f012e29Smrg/** 10153f012e29Smrg * Query GPU H/w Info 10163f012e29Smrg * 10173f012e29Smrg * Query hardware specific information 10183f012e29Smrg * 10193f012e29Smrg * \param dev - \c [in] Device handle. See #amdgpu_device_initialize() 10203f012e29Smrg * \param heap - \c [in] Heap type 10213f012e29Smrg * \param info - \c [in] Pointer to structure to get needed information 10223f012e29Smrg * 10233f012e29Smrg * \return 0 on success\n 10243f012e29Smrg * <0 - Negative POSIX Error code 10253f012e29Smrg * 10263f012e29Smrg*/ 10273f012e29Smrgint amdgpu_query_gpu_info(amdgpu_device_handle dev, 10283f012e29Smrg struct amdgpu_gpu_info *info); 10293f012e29Smrg 10303f012e29Smrg/** 10313f012e29Smrg * Query hardware or driver information. 10323f012e29Smrg * 10333f012e29Smrg * The return size is query-specific and depends on the "info_id" parameter. 10343f012e29Smrg * No more than "size" bytes is returned. 10353f012e29Smrg * 10363f012e29Smrg * \param dev - \c [in] Device handle. See #amdgpu_device_initialize() 10373f012e29Smrg * \param info_id - \c [in] AMDGPU_INFO_* 10383f012e29Smrg * \param size - \c [in] Size of the returned value. 10393f012e29Smrg * \param value - \c [out] Pointer to the return value. 10403f012e29Smrg * 10413f012e29Smrg * \return 0 on success\n 10423f012e29Smrg * <0 - Negative POSIX error code 10433f012e29Smrg * 10443f012e29Smrg*/ 10453f012e29Smrgint amdgpu_query_info(amdgpu_device_handle dev, unsigned info_id, 10463f012e29Smrg unsigned size, void *value); 10473f012e29Smrg 10483f012e29Smrg/** 10493f012e29Smrg * Query information about GDS 10503f012e29Smrg * 10513f012e29Smrg * \param dev - \c [in] Device handle. See #amdgpu_device_initialize() 10523f012e29Smrg * \param gds_info - \c [out] Pointer to structure to get GDS information 10533f012e29Smrg * 10543f012e29Smrg * \return 0 on success\n 10553f012e29Smrg * <0 - Negative POSIX Error code 10563f012e29Smrg * 10573f012e29Smrg*/ 10583f012e29Smrgint amdgpu_query_gds_info(amdgpu_device_handle dev, 10593f012e29Smrg struct amdgpu_gds_resource_info *gds_info); 10603f012e29Smrg 10613f012e29Smrg/** 10623f012e29Smrg * Read a set of consecutive memory-mapped registers. 10633f012e29Smrg * Not all registers are allowed to be read by userspace. 10643f012e29Smrg * 10653f012e29Smrg * \param dev - \c [in] Device handle. See #amdgpu_device_initialize( 10663f012e29Smrg * \param dword_offset - \c [in] Register offset in dwords 10673f012e29Smrg * \param count - \c [in] The number of registers to read starting 10683f012e29Smrg * from the offset 10693f012e29Smrg * \param instance - \c [in] GRBM_GFX_INDEX selector. It may have other 10703f012e29Smrg * uses. Set it to 0xffffffff if unsure. 10713f012e29Smrg * \param flags - \c [in] Flags with additional information. 10723f012e29Smrg * \param values - \c [out] The pointer to return values. 10733f012e29Smrg * 10743f012e29Smrg * \return 0 on success\n 10753f012e29Smrg * <0 - Negative POSIX error code 10763f012e29Smrg * 10773f012e29Smrg*/ 10783f012e29Smrgint amdgpu_read_mm_registers(amdgpu_device_handle dev, unsigned dword_offset, 10793f012e29Smrg unsigned count, uint32_t instance, uint32_t flags, 10803f012e29Smrg uint32_t *values); 10813f012e29Smrg 10823f012e29Smrg/** 10833f012e29Smrg * Flag to request VA address range in the 32bit address space 10843f012e29Smrg*/ 10853f012e29Smrg#define AMDGPU_VA_RANGE_32_BIT 0x1 10863f012e29Smrg 10873f012e29Smrg/** 10883f012e29Smrg * Allocate virtual address range 10893f012e29Smrg * 10903f012e29Smrg * \param dev - [in] Device handle. See #amdgpu_device_initialize() 10913f012e29Smrg * \param va_range_type - \c [in] Type of MC va range from which to allocate 10923f012e29Smrg * \param size - \c [in] Size of range. Size must be correctly* aligned. 10933f012e29Smrg * It is client responsibility to correctly aligned size based on the future 10943f012e29Smrg * usage of allocated range. 10953f012e29Smrg * \param va_base_alignment - \c [in] Overwrite base address alignment 10963f012e29Smrg * requirement for GPU VM MC virtual 10973f012e29Smrg * address assignment. Must be multiple of size alignments received as 10983f012e29Smrg * 'amdgpu_buffer_size_alignments'. 10993f012e29Smrg * If 0 use the default one. 11003f012e29Smrg * \param va_base_required - \c [in] Specified required va base address. 11013f012e29Smrg * If 0 then library choose available one. 11023f012e29Smrg * If !0 value will be passed and those value already "in use" then 11033f012e29Smrg * corresponding error status will be returned. 11043f012e29Smrg * \param va_base_allocated - \c [out] On return: Allocated VA base to be used 11053f012e29Smrg * by client. 11063f012e29Smrg * \param va_range_handle - \c [out] On return: Handle assigned to allocation 11073f012e29Smrg * \param flags - \c [in] flags for special VA range 11083f012e29Smrg * 11093f012e29Smrg * \return 0 on success\n 11103f012e29Smrg * >0 - AMD specific error code\n 11113f012e29Smrg * <0 - Negative POSIX Error code 11123f012e29Smrg * 11133f012e29Smrg * \notes \n 11143f012e29Smrg * It is client responsibility to correctly handle VA assignments and usage. 11153f012e29Smrg * Neither kernel driver nor libdrm_amdpgu are able to prevent and 11163f012e29Smrg * detect wrong va assignemnt. 11173f012e29Smrg * 11183f012e29Smrg * It is client responsibility to correctly handle multi-GPU cases and to pass 11193f012e29Smrg * the corresponding arrays of all devices handles where corresponding VA will 11203f012e29Smrg * be used. 11213f012e29Smrg * 11223f012e29Smrg*/ 11233f012e29Smrgint amdgpu_va_range_alloc(amdgpu_device_handle dev, 11243f012e29Smrg enum amdgpu_gpu_va_range va_range_type, 11253f012e29Smrg uint64_t size, 11263f012e29Smrg uint64_t va_base_alignment, 11273f012e29Smrg uint64_t va_base_required, 11283f012e29Smrg uint64_t *va_base_allocated, 11293f012e29Smrg amdgpu_va_handle *va_range_handle, 11303f012e29Smrg uint64_t flags); 11313f012e29Smrg 11323f012e29Smrg/** 11333f012e29Smrg * Free previously allocated virtual address range 11343f012e29Smrg * 11353f012e29Smrg * 11363f012e29Smrg * \param va_range_handle - \c [in] Handle assigned to VA allocation 11373f012e29Smrg * 11383f012e29Smrg * \return 0 on success\n 11393f012e29Smrg * >0 - AMD specific error code\n 11403f012e29Smrg * <0 - Negative POSIX Error code 11413f012e29Smrg * 11423f012e29Smrg*/ 11433f012e29Smrgint amdgpu_va_range_free(amdgpu_va_handle va_range_handle); 11443f012e29Smrg 11453f012e29Smrg/** 11463f012e29Smrg* Query virtual address range 11473f012e29Smrg* 11483f012e29Smrg* UMD can query GPU VM range supported by each device 11493f012e29Smrg* to initialize its own VAM accordingly. 11503f012e29Smrg* 11513f012e29Smrg* \param dev - [in] Device handle. See #amdgpu_device_initialize() 11523f012e29Smrg* \param type - \c [in] Type of virtual address range 11533f012e29Smrg* \param offset - \c [out] Start offset of virtual address range 11543f012e29Smrg* \param size - \c [out] Size of virtual address range 11553f012e29Smrg* 11563f012e29Smrg* \return 0 on success\n 11573f012e29Smrg* <0 - Negative POSIX Error code 11583f012e29Smrg* 11593f012e29Smrg*/ 11603f012e29Smrg 11613f012e29Smrgint amdgpu_va_range_query(amdgpu_device_handle dev, 11623f012e29Smrg enum amdgpu_gpu_va_range type, 11633f012e29Smrg uint64_t *start, 11643f012e29Smrg uint64_t *end); 11653f012e29Smrg 11663f012e29Smrg/** 11673f012e29Smrg * VA mapping/unmapping for the buffer object 11683f012e29Smrg * 11693f012e29Smrg * \param bo - \c [in] BO handle 11703f012e29Smrg * \param offset - \c [in] Start offset to map 11713f012e29Smrg * \param size - \c [in] Size to map 11723f012e29Smrg * \param addr - \c [in] Start virtual address. 11733f012e29Smrg * \param flags - \c [in] Supported flags for mapping/unmapping 11743f012e29Smrg * \param ops - \c [in] AMDGPU_VA_OP_MAP or AMDGPU_VA_OP_UNMAP 11753f012e29Smrg * 11763f012e29Smrg * \return 0 on success\n 11773f012e29Smrg * <0 - Negative POSIX Error code 11783f012e29Smrg * 11793f012e29Smrg*/ 11803f012e29Smrg 11813f012e29Smrgint amdgpu_bo_va_op(amdgpu_bo_handle bo, 11823f012e29Smrg uint64_t offset, 11833f012e29Smrg uint64_t size, 11843f012e29Smrg uint64_t addr, 11853f012e29Smrg uint64_t flags, 11863f012e29Smrg uint32_t ops); 11873f012e29Smrg 11883f012e29Smrg/** 11893f012e29Smrg * create semaphore 11903f012e29Smrg * 11913f012e29Smrg * \param sem - \c [out] semaphore handle 11923f012e29Smrg * 11933f012e29Smrg * \return 0 on success\n 11943f012e29Smrg * <0 - Negative POSIX Error code 11953f012e29Smrg * 11963f012e29Smrg*/ 11973f012e29Smrgint amdgpu_cs_create_semaphore(amdgpu_semaphore_handle *sem); 11983f012e29Smrg 11993f012e29Smrg/** 12003f012e29Smrg * signal semaphore 12013f012e29Smrg * 12023f012e29Smrg * \param context - \c [in] GPU Context 12033f012e29Smrg * \param ip_type - \c [in] Hardware IP block type = AMDGPU_HW_IP_* 12043f012e29Smrg * \param ip_instance - \c [in] Index of the IP block of the same type 12053f012e29Smrg * \param ring - \c [in] Specify ring index of the IP 12063f012e29Smrg * \param sem - \c [in] semaphore handle 12073f012e29Smrg * 12083f012e29Smrg * \return 0 on success\n 12093f012e29Smrg * <0 - Negative POSIX Error code 12103f012e29Smrg * 12113f012e29Smrg*/ 12123f012e29Smrgint amdgpu_cs_signal_semaphore(amdgpu_context_handle ctx, 12133f012e29Smrg uint32_t ip_type, 12143f012e29Smrg uint32_t ip_instance, 12153f012e29Smrg uint32_t ring, 12163f012e29Smrg amdgpu_semaphore_handle sem); 12173f012e29Smrg 12183f012e29Smrg/** 12193f012e29Smrg * wait semaphore 12203f012e29Smrg * 12213f012e29Smrg * \param context - \c [in] GPU Context 12223f012e29Smrg * \param ip_type - \c [in] Hardware IP block type = AMDGPU_HW_IP_* 12233f012e29Smrg * \param ip_instance - \c [in] Index of the IP block of the same type 12243f012e29Smrg * \param ring - \c [in] Specify ring index of the IP 12253f012e29Smrg * \param sem - \c [in] semaphore handle 12263f012e29Smrg * 12273f012e29Smrg * \return 0 on success\n 12283f012e29Smrg * <0 - Negative POSIX Error code 12293f012e29Smrg * 12303f012e29Smrg*/ 12313f012e29Smrgint amdgpu_cs_wait_semaphore(amdgpu_context_handle ctx, 12323f012e29Smrg uint32_t ip_type, 12333f012e29Smrg uint32_t ip_instance, 12343f012e29Smrg uint32_t ring, 12353f012e29Smrg amdgpu_semaphore_handle sem); 12363f012e29Smrg 12373f012e29Smrg/** 12383f012e29Smrg * destroy semaphore 12393f012e29Smrg * 12403f012e29Smrg * \param sem - \c [in] semaphore handle 12413f012e29Smrg * 12423f012e29Smrg * \return 0 on success\n 12433f012e29Smrg * <0 - Negative POSIX Error code 12443f012e29Smrg * 12453f012e29Smrg*/ 12463f012e29Smrgint amdgpu_cs_destroy_semaphore(amdgpu_semaphore_handle sem); 12473f012e29Smrg 12483f012e29Smrg#endif /* #ifdef _AMDGPU_H_ */ 1249