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
40d8807b2fSmrg#ifdef __cplusplus
41d8807b2fSmrgextern "C" {
42d8807b2fSmrg#endif
43d8807b2fSmrg
443f012e29Smrgstruct drm_amdgpu_info_hw_ip;
456532f28eSmrgstruct drm_amdgpu_bo_list_entry;
463f012e29Smrg
473f012e29Smrg/*--------------------------------------------------------------------------*/
483f012e29Smrg/* --------------------------- Defines ------------------------------------ */
493f012e29Smrg/*--------------------------------------------------------------------------*/
503f012e29Smrg
513f012e29Smrg/**
523f012e29Smrg * Define max. number of Command Buffers (IB) which could be sent to the single
533f012e29Smrg * hardware IP to accommodate CE/DE requirements
543f012e29Smrg *
553f012e29Smrg * \sa amdgpu_cs_ib_info
563f012e29Smrg*/
573f012e29Smrg#define AMDGPU_CS_MAX_IBS_PER_SUBMIT		4
583f012e29Smrg
593f012e29Smrg/**
603f012e29Smrg * Special timeout value meaning that the timeout is infinite.
613f012e29Smrg */
623f012e29Smrg#define AMDGPU_TIMEOUT_INFINITE			0xffffffffffffffffull
633f012e29Smrg
643f012e29Smrg/**
653f012e29Smrg * Used in amdgpu_cs_query_fence_status(), meaning that the given timeout
663f012e29Smrg * is absolute.
673f012e29Smrg */
683f012e29Smrg#define AMDGPU_QUERY_FENCE_TIMEOUT_IS_ABSOLUTE     (1 << 0)
693f012e29Smrg
703f012e29Smrg/*--------------------------------------------------------------------------*/
713f012e29Smrg/* ----------------------------- Enums ------------------------------------ */
723f012e29Smrg/*--------------------------------------------------------------------------*/
733f012e29Smrg
743f012e29Smrg/**
753f012e29Smrg * Enum describing possible handle types
763f012e29Smrg *
773f012e29Smrg * \sa amdgpu_bo_import, amdgpu_bo_export
783f012e29Smrg *
793f012e29Smrg*/
803f012e29Smrgenum amdgpu_bo_handle_type {
813f012e29Smrg	/** GEM flink name (needs DRM authentication, used by DRI2) */
823f012e29Smrg	amdgpu_bo_handle_type_gem_flink_name = 0,
833f012e29Smrg
843f012e29Smrg	/** KMS handle which is used by all driver ioctls */
853f012e29Smrg	amdgpu_bo_handle_type_kms = 1,
863f012e29Smrg
873f012e29Smrg	/** DMA-buf fd handle */
887cdc0497Smrg	amdgpu_bo_handle_type_dma_buf_fd = 2,
897cdc0497Smrg
905324fb0dSmrg	/** Deprecated in favour of and same behaviour as
915324fb0dSmrg	 * amdgpu_bo_handle_type_kms, use that instead of this
927cdc0497Smrg	 */
937cdc0497Smrg	amdgpu_bo_handle_type_kms_noimport = 3,
943f012e29Smrg};
953f012e29Smrg
963f012e29Smrg/** Define known types of GPU VM VA ranges */
973f012e29Smrgenum amdgpu_gpu_va_range
983f012e29Smrg{
993f012e29Smrg	/** Allocate from "normal"/general range */
1003f012e29Smrg	amdgpu_gpu_va_range_general = 0
1013f012e29Smrg};
1023f012e29Smrg
10300a23bdaSmrgenum amdgpu_sw_info {
10400a23bdaSmrg	amdgpu_sw_info_address32_hi = 0,
10500a23bdaSmrg};
10600a23bdaSmrg
1073f012e29Smrg/*--------------------------------------------------------------------------*/
1083f012e29Smrg/* -------------------------- Datatypes ----------------------------------- */
1093f012e29Smrg/*--------------------------------------------------------------------------*/
1103f012e29Smrg
1113f012e29Smrg/**
1123f012e29Smrg * Define opaque pointer to context associated with fd.
1133f012e29Smrg * This context will be returned as the result of
1143f012e29Smrg * "initialize" function and should be pass as the first
1153f012e29Smrg * parameter to any API call
1163f012e29Smrg */
117d4248a18Schristos#ifndef AMDGPU_DEVICE_TYPEDEF
118d4248a18Schristos#define AMDGPU_DEVICE_TYPEDEF
1193f012e29Smrgtypedef struct amdgpu_device *amdgpu_device_handle;
120d4248a18Schristos#endif
1213f012e29Smrg
1223f012e29Smrg/**
1233f012e29Smrg * Define GPU Context type as pointer to opaque structure
1243f012e29Smrg * Example of GPU Context is the "rendering" context associated
1253f012e29Smrg * with OpenGL context (glCreateContext)
1263f012e29Smrg */
1273f012e29Smrgtypedef struct amdgpu_context *amdgpu_context_handle;
1283f012e29Smrg
1293f012e29Smrg/**
1303f012e29Smrg * Define handle for amdgpu resources: buffer, GDS, etc.
1313f012e29Smrg */
1323f012e29Smrgtypedef struct amdgpu_bo *amdgpu_bo_handle;
1333f012e29Smrg
1343f012e29Smrg/**
1353f012e29Smrg * Define handle for list of BOs
1363f012e29Smrg */
1373f012e29Smrgtypedef struct amdgpu_bo_list *amdgpu_bo_list_handle;
1383f012e29Smrg
1393f012e29Smrg/**
1403f012e29Smrg * Define handle to be used to work with VA allocated ranges
1413f012e29Smrg */
1423f012e29Smrgtypedef struct amdgpu_va *amdgpu_va_handle;
1433f012e29Smrg
14448246ce7Smrg/**
14548246ce7Smrg * Define handle dealing with VA allocation. An amdgpu_device
14648246ce7Smrg * owns one of these, but they can also be used without a device.
14748246ce7Smrg */
14848246ce7Smrgtypedef struct amdgpu_va_manager *amdgpu_va_manager_handle;
14948246ce7Smrg
1503f012e29Smrg/**
1513f012e29Smrg * Define handle for semaphore
1523f012e29Smrg */
1533f012e29Smrgtypedef struct amdgpu_semaphore *amdgpu_semaphore_handle;
1543f012e29Smrg
1553f012e29Smrg/*--------------------------------------------------------------------------*/
1563f012e29Smrg/* -------------------------- Structures ---------------------------------- */
1573f012e29Smrg/*--------------------------------------------------------------------------*/
1583f012e29Smrg
1593f012e29Smrg/**
1603f012e29Smrg * Structure describing memory allocation request
1613f012e29Smrg *
1623f012e29Smrg * \sa amdgpu_bo_alloc()
1633f012e29Smrg *
1643f012e29Smrg*/
1653f012e29Smrgstruct amdgpu_bo_alloc_request {
1663f012e29Smrg	/** Allocation request. It must be aligned correctly. */
1673f012e29Smrg	uint64_t alloc_size;
1683f012e29Smrg
1693f012e29Smrg	/**
1703f012e29Smrg	 * It may be required to have some specific alignment requirements
1713f012e29Smrg	 * for physical back-up storage (e.g. for displayable surface).
1723f012e29Smrg	 * If 0 there is no special alignment requirement
1733f012e29Smrg	 */
1743f012e29Smrg	uint64_t phys_alignment;
1753f012e29Smrg
1763f012e29Smrg	/**
1773f012e29Smrg	 * UMD should specify where to allocate memory and how it
1783f012e29Smrg	 * will be accessed by the CPU.
1793f012e29Smrg	 */
1803f012e29Smrg	uint32_t preferred_heap;
1813f012e29Smrg
1823f012e29Smrg	/** Additional flags passed on allocation */
1833f012e29Smrg	uint64_t flags;
1843f012e29Smrg};
1853f012e29Smrg
1863f012e29Smrg/**
1873f012e29Smrg * Special UMD specific information associated with buffer.
1883f012e29Smrg *
1893f012e29Smrg * It may be need to pass some buffer charactersitic as part
1903f012e29Smrg * of buffer sharing. Such information are defined UMD and
1913f012e29Smrg * opaque for libdrm_amdgpu as well for kernel driver.
1923f012e29Smrg *
1933f012e29Smrg * \sa amdgpu_bo_set_metadata(), amdgpu_bo_query_info,
1943f012e29Smrg *     amdgpu_bo_import(), amdgpu_bo_export
1953f012e29Smrg *
1963f012e29Smrg*/
1973f012e29Smrgstruct amdgpu_bo_metadata {
1983f012e29Smrg	/** Special flag associated with surface */
1993f012e29Smrg	uint64_t flags;
2003f012e29Smrg
2013f012e29Smrg	/**
2023f012e29Smrg	 * ASIC-specific tiling information (also used by DCE).
2033f012e29Smrg	 * The encoding is defined by the AMDGPU_TILING_* definitions.
2043f012e29Smrg	 */
2053f012e29Smrg	uint64_t tiling_info;
2063f012e29Smrg
2073f012e29Smrg	/** Size of metadata associated with the buffer, in bytes. */
2083f012e29Smrg	uint32_t size_metadata;
2093f012e29Smrg
2103f012e29Smrg	/** UMD specific metadata. Opaque for kernel */
2113f012e29Smrg	uint32_t umd_metadata[64];
2123f012e29Smrg};
2133f012e29Smrg
2143f012e29Smrg/**
2153f012e29Smrg * Structure describing allocated buffer. Client may need
2163f012e29Smrg * to query such information as part of 'sharing' buffers mechanism
2173f012e29Smrg *
2183f012e29Smrg * \sa amdgpu_bo_set_metadata(), amdgpu_bo_query_info(),
2193f012e29Smrg *     amdgpu_bo_import(), amdgpu_bo_export()
2203f012e29Smrg*/
2213f012e29Smrgstruct amdgpu_bo_info {
2223f012e29Smrg	/** Allocated memory size */
2233f012e29Smrg	uint64_t alloc_size;
2243f012e29Smrg
2253f012e29Smrg	/**
2263f012e29Smrg	 * It may be required to have some specific alignment requirements
2273f012e29Smrg	 * for physical back-up storage.
2283f012e29Smrg	 */
2293f012e29Smrg	uint64_t phys_alignment;
2303f012e29Smrg
2313f012e29Smrg	/** Heap where to allocate memory. */
2323f012e29Smrg	uint32_t preferred_heap;
2333f012e29Smrg
2343f012e29Smrg	/** Additional allocation flags. */
2353f012e29Smrg	uint64_t alloc_flags;
2363f012e29Smrg
2373f012e29Smrg	/** Metadata associated with buffer if any. */
2383f012e29Smrg	struct amdgpu_bo_metadata metadata;
2393f012e29Smrg};
2403f012e29Smrg
2413f012e29Smrg/**
2423f012e29Smrg * Structure with information about "imported" buffer
2433f012e29Smrg *
2443f012e29Smrg * \sa amdgpu_bo_import()
2453f012e29Smrg *
2463f012e29Smrg */
2473f012e29Smrgstruct amdgpu_bo_import_result {
2483f012e29Smrg	/** Handle of memory/buffer to use */
2493f012e29Smrg	amdgpu_bo_handle buf_handle;
2503f012e29Smrg
2513f012e29Smrg	 /** Buffer size */
2523f012e29Smrg	uint64_t alloc_size;
2533f012e29Smrg};
2543f012e29Smrg
2553f012e29Smrg/**
2563f012e29Smrg *
2573f012e29Smrg * Structure to describe GDS partitioning information.
2583f012e29Smrg * \note OA and GWS resources are asscoiated with GDS partition
2593f012e29Smrg *
2603f012e29Smrg * \sa amdgpu_gpu_resource_query_gds_info
2613f012e29Smrg *
2623f012e29Smrg*/
2633f012e29Smrgstruct amdgpu_gds_resource_info {
2643f012e29Smrg	uint32_t gds_gfx_partition_size;
2653f012e29Smrg	uint32_t compute_partition_size;
2663f012e29Smrg	uint32_t gds_total_size;
2673f012e29Smrg	uint32_t gws_per_gfx_partition;
2683f012e29Smrg	uint32_t gws_per_compute_partition;
2693f012e29Smrg	uint32_t oa_per_gfx_partition;
2703f012e29Smrg	uint32_t oa_per_compute_partition;
2713f012e29Smrg};
2723f012e29Smrg
2733f012e29Smrg/**
2743f012e29Smrg * Structure describing CS fence
2753f012e29Smrg *
2763f012e29Smrg * \sa amdgpu_cs_query_fence_status(), amdgpu_cs_request, amdgpu_cs_submit()
2773f012e29Smrg *
2783f012e29Smrg*/
2793f012e29Smrgstruct amdgpu_cs_fence {
2803f012e29Smrg
2813f012e29Smrg	/** In which context IB was sent to execution */
2823f012e29Smrg	amdgpu_context_handle context;
2833f012e29Smrg
2843f012e29Smrg	/** To which HW IP type the fence belongs */
2853f012e29Smrg	uint32_t ip_type;
2863f012e29Smrg
2873f012e29Smrg	/** IP instance index if there are several IPs of the same type. */
2883f012e29Smrg	uint32_t ip_instance;
2893f012e29Smrg
2903f012e29Smrg	/** Ring index of the HW IP */
2913f012e29Smrg	uint32_t ring;
2923f012e29Smrg
2933f012e29Smrg	/** Specify fence for which we need to check submission status.*/
2943f012e29Smrg	uint64_t fence;
2953f012e29Smrg};
2963f012e29Smrg
2973f012e29Smrg/**
2983f012e29Smrg * Structure describing IB
2993f012e29Smrg *
3003f012e29Smrg * \sa amdgpu_cs_request, amdgpu_cs_submit()
3013f012e29Smrg *
3023f012e29Smrg*/
3033f012e29Smrgstruct amdgpu_cs_ib_info {
3043f012e29Smrg	/** Special flags */
3053f012e29Smrg	uint64_t flags;
3063f012e29Smrg
3073f012e29Smrg	/** Virtual MC address of the command buffer */
3083f012e29Smrg	uint64_t ib_mc_address;
3093f012e29Smrg
3103f012e29Smrg	/**
3113f012e29Smrg	 * Size of Command Buffer to be submitted.
3123f012e29Smrg	 *   - The size is in units of dwords (4 bytes).
3133f012e29Smrg	 *   - Could be 0
3143f012e29Smrg	 */
3153f012e29Smrg	uint32_t size;
3163f012e29Smrg};
3173f012e29Smrg
3183f012e29Smrg/**
3193f012e29Smrg * Structure describing fence information
3203f012e29Smrg *
3213f012e29Smrg * \sa amdgpu_cs_request, amdgpu_cs_query_fence,
3223f012e29Smrg *     amdgpu_cs_submit(), amdgpu_cs_query_fence_status()
3233f012e29Smrg*/
3243f012e29Smrgstruct amdgpu_cs_fence_info {
3253f012e29Smrg	/** buffer object for the fence */
3263f012e29Smrg	amdgpu_bo_handle handle;
3273f012e29Smrg
3283f012e29Smrg	/** fence offset in the unit of sizeof(uint64_t) */
3293f012e29Smrg	uint64_t offset;
3303f012e29Smrg};
3313f012e29Smrg
3323f012e29Smrg/**
3333f012e29Smrg * Structure describing submission request
3343f012e29Smrg *
3353f012e29Smrg * \note We could have several IBs as packet. e.g. CE, CE, DE case for gfx
3363f012e29Smrg *
3373f012e29Smrg * \sa amdgpu_cs_submit()
3383f012e29Smrg*/
3393f012e29Smrgstruct amdgpu_cs_request {
3403f012e29Smrg	/** Specify flags with additional information */
3413f012e29Smrg	uint64_t flags;
3423f012e29Smrg
3433f012e29Smrg	/** Specify HW IP block type to which to send the IB. */
3443f012e29Smrg	unsigned ip_type;
3453f012e29Smrg
3463f012e29Smrg	/** IP instance index if there are several IPs of the same type. */
3473f012e29Smrg	unsigned ip_instance;
3483f012e29Smrg
3493f012e29Smrg	/**
3503f012e29Smrg	 * Specify ring index of the IP. We could have several rings
3513f012e29Smrg	 * in the same IP. E.g. 0 for SDMA0 and 1 for SDMA1.
3523f012e29Smrg	 */
3533f012e29Smrg	uint32_t ring;
3543f012e29Smrg
3553f012e29Smrg	/**
3563f012e29Smrg	 * List handle with resources used by this request.
3573f012e29Smrg	 */
3583f012e29Smrg	amdgpu_bo_list_handle resources;
3593f012e29Smrg
3603f012e29Smrg	/**
3613f012e29Smrg	 * Number of dependencies this Command submission needs to
3623f012e29Smrg	 * wait for before starting execution.
3633f012e29Smrg	 */
3643f012e29Smrg	uint32_t number_of_dependencies;
3653f012e29Smrg
3663f012e29Smrg	/**
3673f012e29Smrg	 * Array of dependencies which need to be met before
3683f012e29Smrg	 * execution can start.
3693f012e29Smrg	 */
3703f012e29Smrg	struct amdgpu_cs_fence *dependencies;
3713f012e29Smrg
3723f012e29Smrg	/** Number of IBs to submit in the field ibs. */
3733f012e29Smrg	uint32_t number_of_ibs;
3743f012e29Smrg
3753f012e29Smrg	/**
3763f012e29Smrg	 * IBs to submit. Those IBs will be submit together as single entity
3773f012e29Smrg	 */
3783f012e29Smrg	struct amdgpu_cs_ib_info *ibs;
3793f012e29Smrg
3803f012e29Smrg	/**
3813f012e29Smrg	 * The returned sequence number for the command submission
3823f012e29Smrg	 */
3833f012e29Smrg	uint64_t seq_no;
3843f012e29Smrg
3853f012e29Smrg	/**
3863f012e29Smrg	 * The fence information
3873f012e29Smrg	 */
3883f012e29Smrg	struct amdgpu_cs_fence_info fence_info;
3893f012e29Smrg};
3903f012e29Smrg
3913f012e29Smrg/**
3923f012e29Smrg * Structure which provide information about GPU VM MC Address space
3933f012e29Smrg * alignments requirements
3943f012e29Smrg *
3953f012e29Smrg * \sa amdgpu_query_buffer_size_alignment
3963f012e29Smrg */
3973f012e29Smrgstruct amdgpu_buffer_size_alignments {
3983f012e29Smrg	/** Size alignment requirement for allocation in
3993f012e29Smrg	 * local memory */
4003f012e29Smrg	uint64_t size_local;
4013f012e29Smrg
4023f012e29Smrg	/**
4033f012e29Smrg	 * Size alignment requirement for allocation in remote memory
4043f012e29Smrg	 */
4053f012e29Smrg	uint64_t size_remote;
4063f012e29Smrg};
4073f012e29Smrg
4083f012e29Smrg/**
4093f012e29Smrg * Structure which provide information about heap
4103f012e29Smrg *
4113f012e29Smrg * \sa amdgpu_query_heap_info()
4123f012e29Smrg *
4133f012e29Smrg */
4143f012e29Smrgstruct amdgpu_heap_info {
4153f012e29Smrg	/** Theoretical max. available memory in the given heap */
4163f012e29Smrg	uint64_t heap_size;
4173f012e29Smrg
4183f012e29Smrg	/**
4193f012e29Smrg	 * Number of bytes allocated in the heap. This includes all processes
4203f012e29Smrg	 * and private allocations in the kernel. It changes when new buffers
4213f012e29Smrg	 * are allocated, freed, and moved. It cannot be larger than
4223f012e29Smrg	 * heap_size.
4233f012e29Smrg	 */
4243f012e29Smrg	uint64_t heap_usage;
4253f012e29Smrg
4263f012e29Smrg	/**
4273f012e29Smrg	 * Theoretical possible max. size of buffer which
4283f012e29Smrg	 * could be allocated in the given heap
4293f012e29Smrg	 */
4303f012e29Smrg	uint64_t max_allocation;
4313f012e29Smrg};
4323f012e29Smrg
4333f012e29Smrg/**
4343f012e29Smrg * Describe GPU h/w info needed for UMD correct initialization
4353f012e29Smrg *
4363f012e29Smrg * \sa amdgpu_query_gpu_info()
4373f012e29Smrg*/
4383f012e29Smrgstruct amdgpu_gpu_info {
4393f012e29Smrg	/** Asic id */
4403f012e29Smrg	uint32_t asic_id;
4413f012e29Smrg	/** Chip revision */
4423f012e29Smrg	uint32_t chip_rev;
4433f012e29Smrg	/** Chip external revision */
4443f012e29Smrg	uint32_t chip_external_rev;
4453f012e29Smrg	/** Family ID */
4463f012e29Smrg	uint32_t family_id;
4473f012e29Smrg	/** Special flags */
4483f012e29Smrg	uint64_t ids_flags;
4493f012e29Smrg	/** max engine clock*/
4503f012e29Smrg	uint64_t max_engine_clk;
4513f012e29Smrg	/** max memory clock */
4523f012e29Smrg	uint64_t max_memory_clk;
4533f012e29Smrg	/** number of shader engines */
4543f012e29Smrg	uint32_t num_shader_engines;
4553f012e29Smrg	/** number of shader arrays per engine */
4563f012e29Smrg	uint32_t num_shader_arrays_per_engine;
4573f012e29Smrg	/**  Number of available good shader pipes */
4583f012e29Smrg	uint32_t avail_quad_shader_pipes;
4593f012e29Smrg	/**  Max. number of shader pipes.(including good and bad pipes  */
4603f012e29Smrg	uint32_t max_quad_shader_pipes;
4613f012e29Smrg	/** Number of parameter cache entries per shader quad pipe */
4623f012e29Smrg	uint32_t cache_entries_per_quad_pipe;
4633f012e29Smrg	/**  Number of available graphics context */
4643f012e29Smrg	uint32_t num_hw_gfx_contexts;
4653f012e29Smrg	/** Number of render backend pipes */
4663f012e29Smrg	uint32_t rb_pipes;
4673f012e29Smrg	/**  Enabled render backend pipe mask */
4683f012e29Smrg	uint32_t enabled_rb_pipes_mask;
4693f012e29Smrg	/** Frequency of GPU Counter */
4703f012e29Smrg	uint32_t gpu_counter_freq;
4713f012e29Smrg	/** CC_RB_BACKEND_DISABLE.BACKEND_DISABLE per SE */
4723f012e29Smrg	uint32_t backend_disable[4];
4733f012e29Smrg	/** Value of MC_ARB_RAMCFG register*/
4743f012e29Smrg	uint32_t mc_arb_ramcfg;
4753f012e29Smrg	/** Value of GB_ADDR_CONFIG */
4763f012e29Smrg	uint32_t gb_addr_cfg;
4773f012e29Smrg	/** Values of the GB_TILE_MODE0..31 registers */
4783f012e29Smrg	uint32_t gb_tile_mode[32];
4793f012e29Smrg	/** Values of GB_MACROTILE_MODE0..15 registers */
4803f012e29Smrg	uint32_t gb_macro_tile_mode[16];
4813f012e29Smrg	/** Value of PA_SC_RASTER_CONFIG register per SE */
4823f012e29Smrg	uint32_t pa_sc_raster_cfg[4];
4833f012e29Smrg	/** Value of PA_SC_RASTER_CONFIG_1 register per SE */
4843f012e29Smrg	uint32_t pa_sc_raster_cfg1[4];
4853f012e29Smrg	/* CU info */
4863f012e29Smrg	uint32_t cu_active_number;
4873f012e29Smrg	uint32_t cu_ao_mask;
4883f012e29Smrg	uint32_t cu_bitmap[4][4];
4893f012e29Smrg	/* video memory type info*/
4903f012e29Smrg	uint32_t vram_type;
4913f012e29Smrg	/* video memory bit width*/
4923f012e29Smrg	uint32_t vram_bit_width;
4933f012e29Smrg	/** constant engine ram size*/
4943f012e29Smrg	uint32_t ce_ram_size;
4953f012e29Smrg	/* vce harvesting instance */
4963f012e29Smrg	uint32_t vce_harvest_config;
4973f012e29Smrg	/* PCI revision ID */
4983f012e29Smrg	uint32_t pci_rev_id;
4993f012e29Smrg};
5003f012e29Smrg
5013f012e29Smrg
5023f012e29Smrg/*--------------------------------------------------------------------------*/
5033f012e29Smrg/*------------------------- Functions --------------------------------------*/
5043f012e29Smrg/*--------------------------------------------------------------------------*/
5053f012e29Smrg
5063f012e29Smrg/*
5073f012e29Smrg * Initialization / Cleanup
5083f012e29Smrg *
5093f012e29Smrg*/
5103f012e29Smrg
5113f012e29Smrg/**
5123f012e29Smrg *
5133f012e29Smrg * \param   fd            - \c [in]  File descriptor for AMD GPU device
5143f012e29Smrg *                                   received previously as the result of
5153f012e29Smrg *                                   e.g. drmOpen() call.
5163f012e29Smrg *                                   For legacy fd type, the DRI2/DRI3
5173f012e29Smrg *                                   authentication should be done before
5183f012e29Smrg *                                   calling this function.
5193f012e29Smrg * \param   major_version - \c [out] Major version of library. It is assumed
5203f012e29Smrg *                                   that adding new functionality will cause
5213f012e29Smrg *                                   increase in major version
5223f012e29Smrg * \param   minor_version - \c [out] Minor version of library
5233f012e29Smrg * \param   device_handle - \c [out] Pointer to opaque context which should
5243f012e29Smrg *                                   be passed as the first parameter on each
5253f012e29Smrg *                                   API call
5263f012e29Smrg *
5273f012e29Smrg *
5283f012e29Smrg * \return   0 on success\n
5293f012e29Smrg *          <0 - Negative POSIX Error code
5303f012e29Smrg *
5313f012e29Smrg *
5323f012e29Smrg * \sa amdgpu_device_deinitialize()
5333f012e29Smrg*/
5343f012e29Smrgint amdgpu_device_initialize(int fd,
5353f012e29Smrg			     uint32_t *major_version,
5363f012e29Smrg			     uint32_t *minor_version,
5373f012e29Smrg			     amdgpu_device_handle *device_handle);
5383f012e29Smrg
53948246ce7Smrg/**
54048246ce7Smrg * Same as amdgpu_device_initialize() except when deduplicate_device
54148246ce7Smrg * is false *and* fd points to a device that was already initialized.
54248246ce7Smrg * In this case, amdgpu_device_initialize would return the same
54348246ce7Smrg * amdgpu_device_handle while here amdgpu_device_initialize2 would
54448246ce7Smrg * return a new handle.
54548246ce7Smrg * amdgpu_device_initialize() should be preferred in most situations;
54648246ce7Smrg * the only use-case where not-deduplicating devices make sense is
54748246ce7Smrg * when one wants to have isolated device handles in the same process.
54848246ce7Smrg */
54948246ce7Smrgint amdgpu_device_initialize2(int fd, bool deduplicate_device,
55048246ce7Smrg			      uint32_t *major_version,
55148246ce7Smrg			      uint32_t *minor_version,
55248246ce7Smrg			      amdgpu_device_handle *device_handle);
5533f012e29Smrg/**
5543f012e29Smrg *
5553f012e29Smrg * When access to such library does not needed any more the special
5563f012e29Smrg * function must be call giving opportunity to clean up any
5573f012e29Smrg * resources if needed.
5583f012e29Smrg *
5593f012e29Smrg * \param   device_handle - \c [in]  Context associated with file
5603f012e29Smrg *                                   descriptor for AMD GPU device
5613f012e29Smrg *                                   received previously as the
5623f012e29Smrg *                                   result e.g. of drmOpen() call.
5633f012e29Smrg *
5643f012e29Smrg * \return  0 on success\n
5653f012e29Smrg *         <0 - Negative POSIX Error code
5663f012e29Smrg *
5673f012e29Smrg * \sa amdgpu_device_initialize()
5683f012e29Smrg *
5693f012e29Smrg*/
5703f012e29Smrgint amdgpu_device_deinitialize(amdgpu_device_handle device_handle);
5713f012e29Smrg
572adfa0b0cSmrg/**
573adfa0b0cSmrg *
574adfa0b0cSmrg * /param device_handle - \c [in] Device handle.
575adfa0b0cSmrg *                           See #amdgpu_device_initialize()
576adfa0b0cSmrg *
577adfa0b0cSmrg * \return Returns the drm fd used for operations on this
578adfa0b0cSmrg *         device. This is still owned by the library and hence
579adfa0b0cSmrg *         should not be closed. Guaranteed to be valid until
580adfa0b0cSmrg *         #amdgpu_device_deinitialize gets called.
581adfa0b0cSmrg *
582adfa0b0cSmrg*/
583adfa0b0cSmrgint amdgpu_device_get_fd(amdgpu_device_handle device_handle);
584adfa0b0cSmrg
5853f012e29Smrg/*
5863f012e29Smrg * Memory Management
5873f012e29Smrg *
5883f012e29Smrg*/
5893f012e29Smrg
5903f012e29Smrg/**
5913f012e29Smrg * Allocate memory to be used by UMD for GPU related operations
5923f012e29Smrg *
5933f012e29Smrg * \param   dev		 - \c [in] Device handle.
5943f012e29Smrg *				   See #amdgpu_device_initialize()
5953f012e29Smrg * \param   alloc_buffer - \c [in] Pointer to the structure describing an
5963f012e29Smrg *				   allocation request
5973f012e29Smrg * \param   buf_handle	- \c [out] Allocated buffer handle
5983f012e29Smrg *
5993f012e29Smrg * \return   0 on success\n
6003f012e29Smrg *          <0 - Negative POSIX Error code
6013f012e29Smrg *
6023f012e29Smrg * \sa amdgpu_bo_free()
6033f012e29Smrg*/
6043f012e29Smrgint amdgpu_bo_alloc(amdgpu_device_handle dev,
6053f012e29Smrg		    struct amdgpu_bo_alloc_request *alloc_buffer,
6063f012e29Smrg		    amdgpu_bo_handle *buf_handle);
6073f012e29Smrg
6083f012e29Smrg/**
6093f012e29Smrg * Associate opaque data with buffer to be queried by another UMD
6103f012e29Smrg *
6113f012e29Smrg * \param   dev	       - \c [in] Device handle. See #amdgpu_device_initialize()
6123f012e29Smrg * \param   buf_handle - \c [in] Buffer handle
6133f012e29Smrg * \param   info       - \c [in] Metadata to associated with buffer
6143f012e29Smrg *
6153f012e29Smrg * \return   0 on success\n
6163f012e29Smrg *          <0 - Negative POSIX Error code
6173f012e29Smrg*/
6183f012e29Smrgint amdgpu_bo_set_metadata(amdgpu_bo_handle buf_handle,
6193f012e29Smrg			   struct amdgpu_bo_metadata *info);
6203f012e29Smrg
6213f012e29Smrg/**
6223f012e29Smrg * Query buffer information including metadata previusly associated with
6233f012e29Smrg * buffer.
6243f012e29Smrg *
6253f012e29Smrg * \param   dev	       - \c [in] Device handle.
6263f012e29Smrg *				 See #amdgpu_device_initialize()
6273f012e29Smrg * \param   buf_handle - \c [in]   Buffer handle
6283f012e29Smrg * \param   info       - \c [out]  Structure describing buffer
6293f012e29Smrg *
6303f012e29Smrg * \return   0 on success\n
6313f012e29Smrg *          <0 - Negative POSIX Error code
6323f012e29Smrg *
6333f012e29Smrg * \sa amdgpu_bo_set_metadata(), amdgpu_bo_alloc()
6343f012e29Smrg*/
6353f012e29Smrgint amdgpu_bo_query_info(amdgpu_bo_handle buf_handle,
6363f012e29Smrg			 struct amdgpu_bo_info *info);
6373f012e29Smrg
6383f012e29Smrg/**
6393f012e29Smrg * Allow others to get access to buffer
6403f012e29Smrg *
6413f012e29Smrg * \param   dev		  - \c [in] Device handle.
6423f012e29Smrg *				    See #amdgpu_device_initialize()
6433f012e29Smrg * \param   buf_handle    - \c [in] Buffer handle
6443f012e29Smrg * \param   type          - \c [in] Type of handle requested
6453f012e29Smrg * \param   shared_handle - \c [out] Special "shared" handle
6463f012e29Smrg *
6473f012e29Smrg * \return   0 on success\n
6483f012e29Smrg *          <0 - Negative POSIX Error code
6493f012e29Smrg *
6503f012e29Smrg * \sa amdgpu_bo_import()
6513f012e29Smrg *
6523f012e29Smrg*/
6533f012e29Smrgint amdgpu_bo_export(amdgpu_bo_handle buf_handle,
6543f012e29Smrg		     enum amdgpu_bo_handle_type type,
6553f012e29Smrg		     uint32_t *shared_handle);
6563f012e29Smrg
6573f012e29Smrg/**
6583f012e29Smrg * Request access to "shared" buffer
6593f012e29Smrg *
6603f012e29Smrg * \param   dev		  - \c [in] Device handle.
6613f012e29Smrg *				    See #amdgpu_device_initialize()
6623f012e29Smrg * \param   type	  - \c [in] Type of handle requested
6633f012e29Smrg * \param   shared_handle - \c [in] Shared handle received as result "import"
6643f012e29Smrg *				     operation
6653f012e29Smrg * \param   output        - \c [out] Pointer to structure with information
6663f012e29Smrg *				     about imported buffer
6673f012e29Smrg *
6683f012e29Smrg * \return   0 on success\n
6693f012e29Smrg *          <0 - Negative POSIX Error code
6703f012e29Smrg *
6713f012e29Smrg * \note  Buffer must be "imported" only using new "fd" (different from
6723f012e29Smrg *	  one used by "exporter").
6733f012e29Smrg *
6743f012e29Smrg * \sa amdgpu_bo_export()
6753f012e29Smrg *
6763f012e29Smrg*/
6773f012e29Smrgint amdgpu_bo_import(amdgpu_device_handle dev,
6783f012e29Smrg		     enum amdgpu_bo_handle_type type,
6793f012e29Smrg		     uint32_t shared_handle,
6803f012e29Smrg		     struct amdgpu_bo_import_result *output);
6813f012e29Smrg
6823f012e29Smrg/**
6833f012e29Smrg * Request GPU access to user allocated memory e.g. via "malloc"
6843f012e29Smrg *
6853f012e29Smrg * \param dev - [in] Device handle. See #amdgpu_device_initialize()
6863f012e29Smrg * \param cpu - [in] CPU address of user allocated memory which we
6873f012e29Smrg * want to map to GPU address space (make GPU accessible)
6883f012e29Smrg * (This address must be correctly aligned).
6893f012e29Smrg * \param size - [in] Size of allocation (must be correctly aligned)
6903f012e29Smrg * \param buf_handle - [out] Buffer handle for the userptr memory
6913f012e29Smrg * resource on submission and be used in other operations.
6923f012e29Smrg *
6933f012e29Smrg *
6943f012e29Smrg * \return   0 on success\n
6953f012e29Smrg *          <0 - Negative POSIX Error code
6963f012e29Smrg *
6973f012e29Smrg * \note
6983f012e29Smrg * This call doesn't guarantee that such memory will be persistently
6993f012e29Smrg * "locked" / make non-pageable. The purpose of this call is to provide
7003f012e29Smrg * opportunity for GPU get access to this resource during submission.
7013f012e29Smrg *
7023f012e29Smrg * The maximum amount of memory which could be mapped in this call depends
7033f012e29Smrg * if overcommit is disabled or not. If overcommit is disabled than the max.
7043f012e29Smrg * amount of memory to be pinned will be limited by left "free" size in total
7053f012e29Smrg * amount of memory which could be locked simultaneously ("GART" size).
7063f012e29Smrg *
7073f012e29Smrg * Supported (theoretical) max. size of mapping is restricted only by
7083f012e29Smrg * "GART" size.
7093f012e29Smrg *
7103f012e29Smrg * It is responsibility of caller to correctly specify access rights
7113f012e29Smrg * on VA assignment.
7123f012e29Smrg*/
7133f012e29Smrgint amdgpu_create_bo_from_user_mem(amdgpu_device_handle dev,
7143f012e29Smrg				    void *cpu, uint64_t size,
7153f012e29Smrg				    amdgpu_bo_handle *buf_handle);
7163f012e29Smrg
7177cdc0497Smrg/**
7187cdc0497Smrg * Validate if the user memory comes from BO
7197cdc0497Smrg *
7207cdc0497Smrg * \param dev - [in] Device handle. See #amdgpu_device_initialize()
7217cdc0497Smrg * \param cpu - [in] CPU address of user allocated memory which we
7227cdc0497Smrg * want to map to GPU address space (make GPU accessible)
7237cdc0497Smrg * (This address must be correctly aligned).
7247cdc0497Smrg * \param size - [in] Size of allocation (must be correctly aligned)
7257cdc0497Smrg * \param buf_handle - [out] Buffer handle for the userptr memory
7267cdc0497Smrg * if the user memory is not from BO, the buf_handle will be NULL.
7277cdc0497Smrg * \param offset_in_bo - [out] offset in this BO for this user memory
7287cdc0497Smrg *
7297cdc0497Smrg *
7307cdc0497Smrg * \return   0 on success\n
7317cdc0497Smrg *          <0 - Negative POSIX Error code
7327cdc0497Smrg *
7337cdc0497Smrg*/
7347cdc0497Smrgint amdgpu_find_bo_by_cpu_mapping(amdgpu_device_handle dev,
7357cdc0497Smrg				  void *cpu,
7367cdc0497Smrg				  uint64_t size,
7377cdc0497Smrg				  amdgpu_bo_handle *buf_handle,
7387cdc0497Smrg				  uint64_t *offset_in_bo);
7397cdc0497Smrg
7403f012e29Smrg/**
7415324fb0dSmrg * Free previously allocated memory
7423f012e29Smrg *
7433f012e29Smrg * \param   dev	       - \c [in] Device handle. See #amdgpu_device_initialize()
7443f012e29Smrg * \param   buf_handle - \c [in]  Buffer handle to free
7453f012e29Smrg *
7463f012e29Smrg * \return   0 on success\n
7473f012e29Smrg *          <0 - Negative POSIX Error code
7483f012e29Smrg *
7493f012e29Smrg * \note In the case of memory shared between different applications all
7503f012e29Smrg *	 resources will be “physically” freed only all such applications
7513f012e29Smrg *	 will be terminated
7523f012e29Smrg * \note If is UMD responsibility to ‘free’ buffer only when there is no
7533f012e29Smrg *	 more GPU access
7543f012e29Smrg *
7553f012e29Smrg * \sa amdgpu_bo_set_metadata(), amdgpu_bo_alloc()
7563f012e29Smrg *
7573f012e29Smrg*/
7583f012e29Smrgint amdgpu_bo_free(amdgpu_bo_handle buf_handle);
7593f012e29Smrg
7603f012e29Smrg/**
7617cdc0497Smrg * Increase the reference count of a buffer object
7627cdc0497Smrg *
7637cdc0497Smrg * \param   bo - \c [in]  Buffer object handle to increase the reference count
7647cdc0497Smrg *
7657cdc0497Smrg * \sa amdgpu_bo_alloc(), amdgpu_bo_free()
7667cdc0497Smrg *
7677cdc0497Smrg*/
7687cdc0497Smrgvoid amdgpu_bo_inc_ref(amdgpu_bo_handle bo);
7697cdc0497Smrg
7707cdc0497Smrg/**
7715324fb0dSmrg * Request CPU access to GPU accessible memory
7723f012e29Smrg *
7733f012e29Smrg * \param   buf_handle - \c [in] Buffer handle
7743f012e29Smrg * \param   cpu        - \c [out] CPU address to be used for access
7753f012e29Smrg *
7763f012e29Smrg * \return   0 on success\n
7773f012e29Smrg *          <0 - Negative POSIX Error code
7783f012e29Smrg *
7793f012e29Smrg * \sa amdgpu_bo_cpu_unmap()
7803f012e29Smrg *
7813f012e29Smrg*/
7823f012e29Smrgint amdgpu_bo_cpu_map(amdgpu_bo_handle buf_handle, void **cpu);
7833f012e29Smrg
7843f012e29Smrg/**
7853f012e29Smrg * Release CPU access to GPU memory
7863f012e29Smrg *
7873f012e29Smrg * \param   buf_handle  - \c [in] Buffer handle
7883f012e29Smrg *
7893f012e29Smrg * \return   0 on success\n
7903f012e29Smrg *          <0 - Negative POSIX Error code
7913f012e29Smrg *
7923f012e29Smrg * \sa amdgpu_bo_cpu_map()
7933f012e29Smrg *
7943f012e29Smrg*/
7953f012e29Smrgint amdgpu_bo_cpu_unmap(amdgpu_bo_handle buf_handle);
7963f012e29Smrg
7973f012e29Smrg/**
7983f012e29Smrg * Wait until a buffer is not used by the device.
7993f012e29Smrg *
8003f012e29Smrg * \param   dev           - \c [in] Device handle. See #amdgpu_device_initialize()
8013f012e29Smrg * \param   buf_handle    - \c [in] Buffer handle.
8023f012e29Smrg * \param   timeout_ns    - Timeout in nanoseconds.
8033f012e29Smrg * \param   buffer_busy   - 0 if buffer is idle, all GPU access was completed
8043f012e29Smrg *                            and no GPU access is scheduled.
8053f012e29Smrg *                          1 GPU access is in fly or scheduled
8063f012e29Smrg *
8073f012e29Smrg * \return   0 - on success
8083f012e29Smrg *          <0 - Negative POSIX Error code
8093f012e29Smrg */
8103f012e29Smrgint amdgpu_bo_wait_for_idle(amdgpu_bo_handle buf_handle,
8113f012e29Smrg			    uint64_t timeout_ns,
8123f012e29Smrg			    bool *buffer_busy);
8133f012e29Smrg
8146532f28eSmrg/**
8156532f28eSmrg * Creates a BO list handle for command submission.
8166532f28eSmrg *
8176532f28eSmrg * \param   dev			- \c [in] Device handle.
8186532f28eSmrg *				   See #amdgpu_device_initialize()
8196532f28eSmrg * \param   number_of_buffers	- \c [in] Number of BOs in the list
8206532f28eSmrg * \param   buffers		- \c [in] List of BO handles
8216532f28eSmrg * \param   result		- \c [out] Created BO list handle
8226532f28eSmrg *
8236532f28eSmrg * \return   0 on success\n
8246532f28eSmrg *          <0 - Negative POSIX Error code
8256532f28eSmrg *
8266532f28eSmrg * \sa amdgpu_bo_list_destroy_raw(), amdgpu_cs_submit_raw2()
8276532f28eSmrg*/
8286532f28eSmrgint amdgpu_bo_list_create_raw(amdgpu_device_handle dev,
8296532f28eSmrg			      uint32_t number_of_buffers,
8306532f28eSmrg			      struct drm_amdgpu_bo_list_entry *buffers,
8316532f28eSmrg			      uint32_t *result);
8326532f28eSmrg
8336532f28eSmrg/**
8346532f28eSmrg * Destroys a BO list handle.
8356532f28eSmrg *
8366532f28eSmrg * \param   bo_list	- \c [in] BO list handle.
8376532f28eSmrg *
8386532f28eSmrg * \return   0 on success\n
8396532f28eSmrg *          <0 - Negative POSIX Error code
8406532f28eSmrg *
8416532f28eSmrg * \sa amdgpu_bo_list_create_raw(), amdgpu_cs_submit_raw2()
8426532f28eSmrg*/
8436532f28eSmrgint amdgpu_bo_list_destroy_raw(amdgpu_device_handle dev, uint32_t bo_list);
8446532f28eSmrg
8453f012e29Smrg/**
8463f012e29Smrg * Creates a BO list handle for command submission.
8473f012e29Smrg *
8483f012e29Smrg * \param   dev			- \c [in] Device handle.
8493f012e29Smrg *				   See #amdgpu_device_initialize()
8503f012e29Smrg * \param   number_of_resources	- \c [in] Number of BOs in the list
8513f012e29Smrg * \param   resources		- \c [in] List of BO handles
8523f012e29Smrg * \param   resource_prios	- \c [in] Optional priority for each handle
8533f012e29Smrg * \param   result		- \c [out] Created BO list handle
8543f012e29Smrg *
8553f012e29Smrg * \return   0 on success\n
8563f012e29Smrg *          <0 - Negative POSIX Error code
8573f012e29Smrg *
8583f012e29Smrg * \sa amdgpu_bo_list_destroy()
8593f012e29Smrg*/
8603f012e29Smrgint amdgpu_bo_list_create(amdgpu_device_handle dev,
8613f012e29Smrg			  uint32_t number_of_resources,
8623f012e29Smrg			  amdgpu_bo_handle *resources,
8633f012e29Smrg			  uint8_t *resource_prios,
8643f012e29Smrg			  amdgpu_bo_list_handle *result);
8653f012e29Smrg
8663f012e29Smrg/**
8673f012e29Smrg * Destroys a BO list handle.
8683f012e29Smrg *
8693f012e29Smrg * \param   handle	- \c [in] BO list handle.
8703f012e29Smrg *
8713f012e29Smrg * \return   0 on success\n
8723f012e29Smrg *          <0 - Negative POSIX Error code
8733f012e29Smrg *
8743f012e29Smrg * \sa amdgpu_bo_list_create()
8753f012e29Smrg*/
8763f012e29Smrgint amdgpu_bo_list_destroy(amdgpu_bo_list_handle handle);
8773f012e29Smrg
8783f012e29Smrg/**
8793f012e29Smrg * Update resources for existing BO list
8803f012e29Smrg *
8813f012e29Smrg * \param   handle              - \c [in] BO list handle
8823f012e29Smrg * \param   number_of_resources - \c [in] Number of BOs in the list
8833f012e29Smrg * \param   resources           - \c [in] List of BO handles
8843f012e29Smrg * \param   resource_prios      - \c [in] Optional priority for each handle
8853f012e29Smrg *
8863f012e29Smrg * \return   0 on success\n
8873f012e29Smrg *          <0 - Negative POSIX Error code
8883f012e29Smrg *
8893f012e29Smrg * \sa amdgpu_bo_list_update()
8903f012e29Smrg*/
8913f012e29Smrgint amdgpu_bo_list_update(amdgpu_bo_list_handle handle,
8923f012e29Smrg			  uint32_t number_of_resources,
8933f012e29Smrg			  amdgpu_bo_handle *resources,
8943f012e29Smrg			  uint8_t *resource_prios);
8953f012e29Smrg
8963f012e29Smrg/*
8973f012e29Smrg * GPU Execution context
8983f012e29Smrg *
8993f012e29Smrg*/
9003f012e29Smrg
9013f012e29Smrg/**
9023f012e29Smrg * Create GPU execution Context
9033f012e29Smrg *
9043f012e29Smrg * For the purpose of GPU Scheduler and GPU Robustness extensions it is
9053f012e29Smrg * necessary to have information/identify rendering/compute contexts.
9063f012e29Smrg * It also may be needed to associate some specific requirements with such
9073f012e29Smrg * contexts.  Kernel driver will guarantee that submission from the same
9083f012e29Smrg * context will always be executed in order (first come, first serve).
9093f012e29Smrg *
9103f012e29Smrg *
91100a23bdaSmrg * \param   dev      - \c [in] Device handle. See #amdgpu_device_initialize()
91200a23bdaSmrg * \param   priority - \c [in] Context creation flags. See AMDGPU_CTX_PRIORITY_*
91300a23bdaSmrg * \param   context  - \c [out] GPU Context handle
9143f012e29Smrg *
9153f012e29Smrg * \return   0 on success\n
9163f012e29Smrg *          <0 - Negative POSIX Error code
9173f012e29Smrg *
9183f012e29Smrg * \sa amdgpu_cs_ctx_free()
9193f012e29Smrg *
9203f012e29Smrg*/
92100a23bdaSmrgint amdgpu_cs_ctx_create2(amdgpu_device_handle dev,
92200a23bdaSmrg			 uint32_t priority,
92300a23bdaSmrg			 amdgpu_context_handle *context);
92400a23bdaSmrg/**
92500a23bdaSmrg * Create GPU execution Context
92600a23bdaSmrg *
92700a23bdaSmrg * Refer to amdgpu_cs_ctx_create2 for full documentation. This call
92800a23bdaSmrg * is missing the priority parameter.
92900a23bdaSmrg *
93000a23bdaSmrg * \sa amdgpu_cs_ctx_create2()
93100a23bdaSmrg *
93200a23bdaSmrg*/
9333f012e29Smrgint amdgpu_cs_ctx_create(amdgpu_device_handle dev,
9343f012e29Smrg			 amdgpu_context_handle *context);
9353f012e29Smrg
9363f012e29Smrg/**
9373f012e29Smrg *
9383f012e29Smrg * Destroy GPU execution context when not needed any more
9393f012e29Smrg *
9403f012e29Smrg * \param   context - \c [in] GPU Context handle
9413f012e29Smrg *
9423f012e29Smrg * \return   0 on success\n
9433f012e29Smrg *          <0 - Negative POSIX Error code
9443f012e29Smrg *
9453f012e29Smrg * \sa amdgpu_cs_ctx_create()
9463f012e29Smrg *
9473f012e29Smrg*/
9483f012e29Smrgint amdgpu_cs_ctx_free(amdgpu_context_handle context);
9493f012e29Smrg
9505324fb0dSmrg/**
9515324fb0dSmrg * Override the submission priority for the given context using a master fd.
9525324fb0dSmrg *
9535324fb0dSmrg * \param   dev        - \c [in] device handle
9545324fb0dSmrg * \param   context    - \c [in] context handle for context id
9555324fb0dSmrg * \param   master_fd  - \c [in] The master fd to authorize the override.
9565324fb0dSmrg * \param   priority   - \c [in] The priority to assign to the context.
9575324fb0dSmrg *
9585324fb0dSmrg * \return 0 on success or a a negative Posix error code on failure.
9595324fb0dSmrg */
9605324fb0dSmrgint amdgpu_cs_ctx_override_priority(amdgpu_device_handle dev,
9615324fb0dSmrg                                    amdgpu_context_handle context,
9625324fb0dSmrg                                    int master_fd,
9635324fb0dSmrg                                    unsigned priority);
9645324fb0dSmrg
96550027b5bSmrg/**
96650027b5bSmrg * Set or query the stable power state for GPU profiling.
96750027b5bSmrg *
96850027b5bSmrg * \param   dev        - \c [in] device handle
96950027b5bSmrg * \param   op         - \c [in] AMDGPU_CTX_OP_{GET,SET}_STABLE_PSTATE
97050027b5bSmrg * \param   flags      - \c [in] AMDGPU_CTX_STABLE_PSTATE_*
97150027b5bSmrg * \param   out_flags  - \c [out] output current stable pstate
97250027b5bSmrg *
97350027b5bSmrg * \return  0 on success otherwise POSIX Error code.
97450027b5bSmrg */
97550027b5bSmrgint amdgpu_cs_ctx_stable_pstate(amdgpu_context_handle context,
97650027b5bSmrg			        uint32_t op,
97750027b5bSmrg			        uint32_t flags,
97850027b5bSmrg			        uint32_t *out_flags);
97950027b5bSmrg
9803f012e29Smrg/**
9813f012e29Smrg * Query reset state for the specific GPU Context
9823f012e29Smrg *
9833f012e29Smrg * \param   context - \c [in]  GPU Context handle
9843f012e29Smrg * \param   state   - \c [out] One of AMDGPU_CTX_*_RESET
9853f012e29Smrg * \param   hangs   - \c [out] Number of hangs caused by the context.
9863f012e29Smrg *
9873f012e29Smrg * \return   0 on success\n
9883f012e29Smrg *          <0 - Negative POSIX Error code
9893f012e29Smrg *
9903f012e29Smrg * \sa amdgpu_cs_ctx_create()
9913f012e29Smrg *
9923f012e29Smrg*/
9933f012e29Smrgint amdgpu_cs_query_reset_state(amdgpu_context_handle context,
9943f012e29Smrg				uint32_t *state, uint32_t *hangs);
9953f012e29Smrg
99688f8a8d2Smrg/**
99788f8a8d2Smrg * Query reset state for the specific GPU Context.
99888f8a8d2Smrg *
99988f8a8d2Smrg * \param   context - \c [in]  GPU Context handle
100088f8a8d2Smrg * \param   flags   - \c [out] A combination of AMDGPU_CTX_QUERY2_FLAGS_*
100188f8a8d2Smrg *
100288f8a8d2Smrg * \return   0 on success\n
100388f8a8d2Smrg *          <0 - Negative POSIX Error code
100488f8a8d2Smrg *
100588f8a8d2Smrg * \sa amdgpu_cs_ctx_create()
100688f8a8d2Smrg *
100788f8a8d2Smrg*/
100888f8a8d2Smrgint amdgpu_cs_query_reset_state2(amdgpu_context_handle context,
100988f8a8d2Smrg				 uint64_t *flags);
101088f8a8d2Smrg
10113f012e29Smrg/*
10123f012e29Smrg * Command Buffers Management
10133f012e29Smrg *
10143f012e29Smrg*/
10153f012e29Smrg
10163f012e29Smrg/**
10173f012e29Smrg * Send request to submit command buffers to hardware.
10183f012e29Smrg *
10193f012e29Smrg * Kernel driver could use GPU Scheduler to make decision when physically
10203f012e29Smrg * sent this request to the hardware. Accordingly this request could be put
10213f012e29Smrg * in queue and sent for execution later. The only guarantee is that request
10223f012e29Smrg * from the same GPU context to the same ip:ip_instance:ring will be executed in
10233f012e29Smrg * order.
10243f012e29Smrg *
10253f012e29Smrg * The caller can specify the user fence buffer/location with the fence_info in the
10263f012e29Smrg * cs_request.The sequence number is returned via the 'seq_no' parameter
10273f012e29Smrg * in ibs_request structure.
10283f012e29Smrg *
10293f012e29Smrg *
10303f012e29Smrg * \param   dev		       - \c [in]  Device handle.
10313f012e29Smrg *					  See #amdgpu_device_initialize()
10323f012e29Smrg * \param   context            - \c [in]  GPU Context
10333f012e29Smrg * \param   flags              - \c [in]  Global submission flags
10343f012e29Smrg * \param   ibs_request        - \c [in/out] Pointer to submission requests.
10353f012e29Smrg *					  We could submit to the several
10363f012e29Smrg *					  engines/rings simulteniously as
10373f012e29Smrg *					  'atomic' operation
10383f012e29Smrg * \param   number_of_requests - \c [in]  Number of submission requests
10393f012e29Smrg *
10403f012e29Smrg * \return   0 on success\n
10413f012e29Smrg *          <0 - Negative POSIX Error code
10423f012e29Smrg *
10433f012e29Smrg * \note It is required to pass correct resource list with buffer handles
10443f012e29Smrg *	 which will be accessible by command buffers from submission
10453f012e29Smrg *	 This will allow kernel driver to correctly implement "paging".
10463f012e29Smrg *	 Failure to do so will have unpredictable results.
10473f012e29Smrg *
10483f012e29Smrg * \sa amdgpu_command_buffer_alloc(), amdgpu_command_buffer_free(),
10493f012e29Smrg *     amdgpu_cs_query_fence_status()
10503f012e29Smrg *
10513f012e29Smrg*/
10523f012e29Smrgint amdgpu_cs_submit(amdgpu_context_handle context,
10533f012e29Smrg		     uint64_t flags,
10543f012e29Smrg		     struct amdgpu_cs_request *ibs_request,
10553f012e29Smrg		     uint32_t number_of_requests);
10563f012e29Smrg
10573f012e29Smrg/**
10583f012e29Smrg *  Query status of Command Buffer Submission
10593f012e29Smrg *
10603f012e29Smrg * \param   fence   - \c [in] Structure describing fence to query
10613f012e29Smrg * \param   timeout_ns - \c [in] Timeout value to wait
10623f012e29Smrg * \param   flags   - \c [in] Flags for the query
10633f012e29Smrg * \param   expired - \c [out] If fence expired or not.\n
10643f012e29Smrg *				0  – if fence is not expired\n
10653f012e29Smrg *				!0 - otherwise
10663f012e29Smrg *
10673f012e29Smrg * \return   0 on success\n
10683f012e29Smrg *          <0 - Negative POSIX Error code
10693f012e29Smrg *
10703f012e29Smrg * \note If UMD wants only to check operation status and returned immediately
10713f012e29Smrg *	 then timeout value as 0 must be passed. In this case success will be
10723f012e29Smrg *	 returned in the case if submission was completed or timeout error
10733f012e29Smrg *	 code.
10743f012e29Smrg *
10753f012e29Smrg * \sa amdgpu_cs_submit()
10763f012e29Smrg*/
10773f012e29Smrgint amdgpu_cs_query_fence_status(struct amdgpu_cs_fence *fence,
10783f012e29Smrg				 uint64_t timeout_ns,
10793f012e29Smrg				 uint64_t flags,
10803f012e29Smrg				 uint32_t *expired);
10813f012e29Smrg
1082d8807b2fSmrg/**
1083d8807b2fSmrg *  Wait for multiple fences
1084d8807b2fSmrg *
1085d8807b2fSmrg * \param   fences      - \c [in] The fence array to wait
1086d8807b2fSmrg * \param   fence_count - \c [in] The fence count
1087d8807b2fSmrg * \param   wait_all    - \c [in] If true, wait all fences to be signaled,
1088d8807b2fSmrg *                                otherwise, wait at least one fence
1089d8807b2fSmrg * \param   timeout_ns  - \c [in] The timeout to wait, in nanoseconds
1090d8807b2fSmrg * \param   status      - \c [out] '1' for signaled, '0' for timeout
1091d8807b2fSmrg * \param   first       - \c [out] the index of the first signaled fence from @fences
1092d8807b2fSmrg *
1093d8807b2fSmrg * \return  0 on success
1094d8807b2fSmrg *          <0 - Negative POSIX Error code
1095d8807b2fSmrg *
1096d8807b2fSmrg * \note    Currently it supports only one amdgpu_device. All fences come from
1097d8807b2fSmrg *          the same amdgpu_device with the same fd.
1098d8807b2fSmrg*/
1099d8807b2fSmrgint amdgpu_cs_wait_fences(struct amdgpu_cs_fence *fences,
1100d8807b2fSmrg			  uint32_t fence_count,
1101d8807b2fSmrg			  bool wait_all,
1102d8807b2fSmrg			  uint64_t timeout_ns,
1103d8807b2fSmrg			  uint32_t *status, uint32_t *first);
1104d8807b2fSmrg
11053f012e29Smrg/*
11063f012e29Smrg * Query / Info API
11073f012e29Smrg *
11083f012e29Smrg*/
11093f012e29Smrg
11103f012e29Smrg/**
11113f012e29Smrg * Query allocation size alignments
11123f012e29Smrg *
11133f012e29Smrg * UMD should query information about GPU VM MC size alignments requirements
11143f012e29Smrg * to be able correctly choose required allocation size and implement
11153f012e29Smrg * internal optimization if needed.
11163f012e29Smrg *
11173f012e29Smrg * \param   dev  - \c [in] Device handle. See #amdgpu_device_initialize()
11183f012e29Smrg * \param   info - \c [out] Pointer to structure to get size alignment
11193f012e29Smrg *			  requirements
11203f012e29Smrg *
11213f012e29Smrg * \return   0 on success\n
11223f012e29Smrg *          <0 - Negative POSIX Error code
11233f012e29Smrg *
11243f012e29Smrg*/
11253f012e29Smrgint amdgpu_query_buffer_size_alignment(amdgpu_device_handle dev,
11263f012e29Smrg				       struct amdgpu_buffer_size_alignments
11273f012e29Smrg						*info);
11283f012e29Smrg
11293f012e29Smrg/**
11303f012e29Smrg * Query firmware versions
11313f012e29Smrg *
11323f012e29Smrg * \param   dev	        - \c [in] Device handle. See #amdgpu_device_initialize()
11333f012e29Smrg * \param   fw_type     - \c [in] AMDGPU_INFO_FW_*
11343f012e29Smrg * \param   ip_instance - \c [in] Index of the IP block of the same type.
11353f012e29Smrg * \param   index       - \c [in] Index of the engine. (for SDMA and MEC)
11363f012e29Smrg * \param   version     - \c [out] Pointer to to the "version" return value
11373f012e29Smrg * \param   feature     - \c [out] Pointer to to the "feature" return value
11383f012e29Smrg *
11393f012e29Smrg * \return   0 on success\n
11403f012e29Smrg *          <0 - Negative POSIX Error code
11413f012e29Smrg *
11423f012e29Smrg*/
11433f012e29Smrgint amdgpu_query_firmware_version(amdgpu_device_handle dev, unsigned fw_type,
11443f012e29Smrg				  unsigned ip_instance, unsigned index,
11453f012e29Smrg				  uint32_t *version, uint32_t *feature);
11463f012e29Smrg
11473f012e29Smrg/**
11483f012e29Smrg * Query the number of HW IP instances of a certain type.
11493f012e29Smrg *
11503f012e29Smrg * \param   dev      - \c [in] Device handle. See #amdgpu_device_initialize()
11513f012e29Smrg * \param   type     - \c [in] Hardware IP block type = AMDGPU_HW_IP_*
11523f012e29Smrg * \param   count    - \c [out] Pointer to structure to get information
11533f012e29Smrg *
11543f012e29Smrg * \return   0 on success\n
11553f012e29Smrg *          <0 - Negative POSIX Error code
11563f012e29Smrg*/
11573f012e29Smrgint amdgpu_query_hw_ip_count(amdgpu_device_handle dev, unsigned type,
11583f012e29Smrg			     uint32_t *count);
11593f012e29Smrg
11603f012e29Smrg/**
11613f012e29Smrg * Query engine information
11623f012e29Smrg *
11633f012e29Smrg * This query allows UMD to query information different engines and their
11643f012e29Smrg * capabilities.
11653f012e29Smrg *
11663f012e29Smrg * \param   dev         - \c [in] Device handle. See #amdgpu_device_initialize()
11673f012e29Smrg * \param   type        - \c [in] Hardware IP block type = AMDGPU_HW_IP_*
11683f012e29Smrg * \param   ip_instance - \c [in] Index of the IP block of the same type.
11693f012e29Smrg * \param   info        - \c [out] Pointer to structure to get information
11703f012e29Smrg *
11713f012e29Smrg * \return   0 on success\n
11723f012e29Smrg *          <0 - Negative POSIX Error code
11733f012e29Smrg*/
11743f012e29Smrgint amdgpu_query_hw_ip_info(amdgpu_device_handle dev, unsigned type,
11753f012e29Smrg			    unsigned ip_instance,
11763f012e29Smrg			    struct drm_amdgpu_info_hw_ip *info);
11773f012e29Smrg
11783f012e29Smrg/**
11793f012e29Smrg * Query heap information
11803f012e29Smrg *
11813f012e29Smrg * This query allows UMD to query potentially available memory resources and
11823f012e29Smrg * adjust their logic if necessary.
11833f012e29Smrg *
11843f012e29Smrg * \param   dev  - \c [in] Device handle. See #amdgpu_device_initialize()
11853f012e29Smrg * \param   heap - \c [in] Heap type
11863f012e29Smrg * \param   info - \c [in] Pointer to structure to get needed information
11873f012e29Smrg *
11883f012e29Smrg * \return   0 on success\n
11893f012e29Smrg *          <0 - Negative POSIX Error code
11903f012e29Smrg *
11913f012e29Smrg*/
11923f012e29Smrgint amdgpu_query_heap_info(amdgpu_device_handle dev, uint32_t heap,
11933f012e29Smrg			   uint32_t flags, struct amdgpu_heap_info *info);
11943f012e29Smrg
11953f012e29Smrg/**
11963f012e29Smrg * Get the CRTC ID from the mode object ID
11973f012e29Smrg *
11983f012e29Smrg * \param   dev    - \c [in] Device handle. See #amdgpu_device_initialize()
11993f012e29Smrg * \param   id     - \c [in] Mode object ID
12003f012e29Smrg * \param   result - \c [in] Pointer to the CRTC ID
12013f012e29Smrg *
12023f012e29Smrg * \return   0 on success\n
12033f012e29Smrg *          <0 - Negative POSIX Error code
12043f012e29Smrg *
12053f012e29Smrg*/
12063f012e29Smrgint amdgpu_query_crtc_from_id(amdgpu_device_handle dev, unsigned id,
12073f012e29Smrg			      int32_t *result);
12083f012e29Smrg
12093f012e29Smrg/**
12103f012e29Smrg * Query GPU H/w Info
12113f012e29Smrg *
12123f012e29Smrg * Query hardware specific information
12133f012e29Smrg *
12143f012e29Smrg * \param   dev  - \c [in] Device handle. See #amdgpu_device_initialize()
12153f012e29Smrg * \param   heap - \c [in] Heap type
12163f012e29Smrg * \param   info - \c [in] Pointer to structure to get needed information
12173f012e29Smrg *
12183f012e29Smrg * \return   0 on success\n
12193f012e29Smrg *          <0 - Negative POSIX Error code
12203f012e29Smrg *
12213f012e29Smrg*/
12223f012e29Smrgint amdgpu_query_gpu_info(amdgpu_device_handle dev,
12233f012e29Smrg			   struct amdgpu_gpu_info *info);
12243f012e29Smrg
12253f012e29Smrg/**
12263f012e29Smrg * Query hardware or driver information.
12273f012e29Smrg *
12283f012e29Smrg * The return size is query-specific and depends on the "info_id" parameter.
12293f012e29Smrg * No more than "size" bytes is returned.
12303f012e29Smrg *
12313f012e29Smrg * \param   dev     - \c [in] Device handle. See #amdgpu_device_initialize()
12323f012e29Smrg * \param   info_id - \c [in] AMDGPU_INFO_*
12333f012e29Smrg * \param   size    - \c [in] Size of the returned value.
12343f012e29Smrg * \param   value   - \c [out] Pointer to the return value.
12353f012e29Smrg *
12363f012e29Smrg * \return   0 on success\n
12373f012e29Smrg *          <0 - Negative POSIX error code
12383f012e29Smrg *
12393f012e29Smrg*/
12403f012e29Smrgint amdgpu_query_info(amdgpu_device_handle dev, unsigned info_id,
12413f012e29Smrg		      unsigned size, void *value);
12423f012e29Smrg
124300a23bdaSmrg/**
124400a23bdaSmrg * Query hardware or driver information.
124500a23bdaSmrg *
124600a23bdaSmrg * The return size is query-specific and depends on the "info_id" parameter.
124700a23bdaSmrg * No more than "size" bytes is returned.
124800a23bdaSmrg *
124900a23bdaSmrg * \param   dev     - \c [in] Device handle. See #amdgpu_device_initialize()
125000a23bdaSmrg * \param   info    - \c [in] amdgpu_sw_info_*
125100a23bdaSmrg * \param   value   - \c [out] Pointer to the return value.
125200a23bdaSmrg *
125300a23bdaSmrg * \return   0 on success\n
125400a23bdaSmrg *          <0 - Negative POSIX error code
125500a23bdaSmrg *
125600a23bdaSmrg*/
125700a23bdaSmrgint amdgpu_query_sw_info(amdgpu_device_handle dev, enum amdgpu_sw_info info,
125800a23bdaSmrg			 void *value);
125900a23bdaSmrg
12603f012e29Smrg/**
12613f012e29Smrg * Query information about GDS
12623f012e29Smrg *
12633f012e29Smrg * \param   dev	     - \c [in] Device handle. See #amdgpu_device_initialize()
12643f012e29Smrg * \param   gds_info - \c [out] Pointer to structure to get GDS information
12653f012e29Smrg *
12663f012e29Smrg * \return   0 on success\n
12673f012e29Smrg *          <0 - Negative POSIX Error code
12683f012e29Smrg *
12693f012e29Smrg*/
12703f012e29Smrgint amdgpu_query_gds_info(amdgpu_device_handle dev,
12713f012e29Smrg			struct amdgpu_gds_resource_info *gds_info);
12723f012e29Smrg
1273d8807b2fSmrg/**
1274d8807b2fSmrg * Query information about sensor.
1275d8807b2fSmrg *
1276d8807b2fSmrg * The return size is query-specific and depends on the "sensor_type"
1277d8807b2fSmrg * parameter. No more than "size" bytes is returned.
1278d8807b2fSmrg *
1279d8807b2fSmrg * \param   dev         - \c [in] Device handle. See #amdgpu_device_initialize()
1280d8807b2fSmrg * \param   sensor_type - \c [in] AMDGPU_INFO_SENSOR_*
1281d8807b2fSmrg * \param   size        - \c [in] Size of the returned value.
1282d8807b2fSmrg * \param   value       - \c [out] Pointer to the return value.
1283d8807b2fSmrg *
1284d8807b2fSmrg * \return   0 on success\n
1285d8807b2fSmrg *          <0 - Negative POSIX Error code
1286d8807b2fSmrg *
1287d8807b2fSmrg*/
1288d8807b2fSmrgint amdgpu_query_sensor_info(amdgpu_device_handle dev, unsigned sensor_type,
1289d8807b2fSmrg			     unsigned size, void *value);
1290d8807b2fSmrg
129141687f09Smrg/**
129241687f09Smrg * Query information about video capabilities
129341687f09Smrg *
129441687f09Smrg * The return sizeof(struct drm_amdgpu_info_video_caps)
129541687f09Smrg *
129641687f09Smrg * \param   dev         - \c [in] Device handle. See #amdgpu_device_initialize()
129741687f09Smrg * \param   caps_type   - \c [in] AMDGPU_INFO_VIDEO_CAPS_DECODE(ENCODE)
129841687f09Smrg * \param   size        - \c [in] Size of the returned value.
129941687f09Smrg * \param   value       - \c [out] Pointer to the return value.
130041687f09Smrg *
130141687f09Smrg * \return   0 on success\n
130241687f09Smrg *          <0 - Negative POSIX Error code
130341687f09Smrg *
130441687f09Smrg*/
130541687f09Smrgint amdgpu_query_video_caps_info(amdgpu_device_handle dev, unsigned cap_type,
130641687f09Smrg                                 unsigned size, void *value);
130741687f09Smrg
130848246ce7Smrg/**
130948246ce7Smrg * Query information about VM faults
131048246ce7Smrg *
131148246ce7Smrg * The return sizeof(struct drm_amdgpu_info_gpuvm_fault)
131248246ce7Smrg *
131348246ce7Smrg * \param   dev         - \c [in] Device handle. See #amdgpu_device_initialize()
131448246ce7Smrg * \param   size        - \c [in] Size of the returned value.
131548246ce7Smrg * \param   value       - \c [out] Pointer to the return value.
131648246ce7Smrg *
131748246ce7Smrg * \return   0 on success\n
131848246ce7Smrg *          <0 - Negative POSIX Error code
131948246ce7Smrg *
132048246ce7Smrg*/
132148246ce7Smrgint amdgpu_query_gpuvm_fault_info(amdgpu_device_handle dev, unsigned size,
132248246ce7Smrg				  void *value);
132348246ce7Smrg
13243f012e29Smrg/**
13253f012e29Smrg * Read a set of consecutive memory-mapped registers.
13263f012e29Smrg * Not all registers are allowed to be read by userspace.
13273f012e29Smrg *
13283f012e29Smrg * \param   dev          - \c [in] Device handle. See #amdgpu_device_initialize(
13293f012e29Smrg * \param   dword_offset - \c [in] Register offset in dwords
13303f012e29Smrg * \param   count        - \c [in] The number of registers to read starting
13313f012e29Smrg *                                 from the offset
13323f012e29Smrg * \param   instance     - \c [in] GRBM_GFX_INDEX selector. It may have other
13333f012e29Smrg *                                 uses. Set it to 0xffffffff if unsure.
13343f012e29Smrg * \param   flags        - \c [in] Flags with additional information.
13353f012e29Smrg * \param   values       - \c [out] The pointer to return values.
13363f012e29Smrg *
13373f012e29Smrg * \return   0 on success\n
13383f012e29Smrg *          <0 - Negative POSIX error code
13393f012e29Smrg *
13403f012e29Smrg*/
13413f012e29Smrgint amdgpu_read_mm_registers(amdgpu_device_handle dev, unsigned dword_offset,
13423f012e29Smrg			     unsigned count, uint32_t instance, uint32_t flags,
13433f012e29Smrg			     uint32_t *values);
13443f012e29Smrg
13453f012e29Smrg/**
13463f012e29Smrg * Flag to request VA address range in the 32bit address space
13473f012e29Smrg*/
13483f012e29Smrg#define AMDGPU_VA_RANGE_32_BIT		0x1
134900a23bdaSmrg#define AMDGPU_VA_RANGE_HIGH		0x2
13504babd585Smrg#define AMDGPU_VA_RANGE_REPLAYABLE	0x4
13513f012e29Smrg
13523f012e29Smrg/**
13533f012e29Smrg * Allocate virtual address range
13543f012e29Smrg *
13553f012e29Smrg * \param dev - [in] Device handle. See #amdgpu_device_initialize()
13563f012e29Smrg * \param va_range_type - \c [in] Type of MC va range from which to allocate
13573f012e29Smrg * \param size - \c [in] Size of range. Size must be correctly* aligned.
13583f012e29Smrg * It is client responsibility to correctly aligned size based on the future
13593f012e29Smrg * usage of allocated range.
13603f012e29Smrg * \param va_base_alignment - \c [in] Overwrite base address alignment
13613f012e29Smrg * requirement for GPU VM MC virtual
13623f012e29Smrg * address assignment. Must be multiple of size alignments received as
13633f012e29Smrg * 'amdgpu_buffer_size_alignments'.
13643f012e29Smrg * If 0 use the default one.
13653f012e29Smrg * \param va_base_required - \c [in] Specified required va base address.
13663f012e29Smrg * If 0 then library choose available one.
13673f012e29Smrg * If !0 value will be passed and those value already "in use" then
13683f012e29Smrg * corresponding error status will be returned.
13693f012e29Smrg * \param va_base_allocated - \c [out] On return: Allocated VA base to be used
13703f012e29Smrg * by client.
13713f012e29Smrg * \param va_range_handle - \c [out] On return: Handle assigned to allocation
13723f012e29Smrg * \param flags - \c [in] flags for special VA range
13733f012e29Smrg *
13743f012e29Smrg * \return 0 on success\n
13753f012e29Smrg * >0 - AMD specific error code\n
13763f012e29Smrg * <0 - Negative POSIX Error code
13773f012e29Smrg *
13783f012e29Smrg * \notes \n
13793f012e29Smrg * It is client responsibility to correctly handle VA assignments and usage.
13803f012e29Smrg * Neither kernel driver nor libdrm_amdpgu are able to prevent and
13815324fb0dSmrg * detect wrong va assignment.
13823f012e29Smrg *
13833f012e29Smrg * It is client responsibility to correctly handle multi-GPU cases and to pass
13843f012e29Smrg * the corresponding arrays of all devices handles where corresponding VA will
13853f012e29Smrg * be used.
13863f012e29Smrg *
13873f012e29Smrg*/
13883f012e29Smrgint amdgpu_va_range_alloc(amdgpu_device_handle dev,
13893f012e29Smrg			   enum amdgpu_gpu_va_range va_range_type,
13903f012e29Smrg			   uint64_t size,
13913f012e29Smrg			   uint64_t va_base_alignment,
13923f012e29Smrg			   uint64_t va_base_required,
13933f012e29Smrg			   uint64_t *va_base_allocated,
13943f012e29Smrg			   amdgpu_va_handle *va_range_handle,
13953f012e29Smrg			   uint64_t flags);
13963f012e29Smrg
13973f012e29Smrg/**
13983f012e29Smrg * Free previously allocated virtual address range
13993f012e29Smrg *
14003f012e29Smrg *
14013f012e29Smrg * \param va_range_handle - \c [in] Handle assigned to VA allocation
14023f012e29Smrg *
14033f012e29Smrg * \return 0 on success\n
14043f012e29Smrg * >0 - AMD specific error code\n
14053f012e29Smrg * <0 - Negative POSIX Error code
14063f012e29Smrg *
14073f012e29Smrg*/
14083f012e29Smrgint amdgpu_va_range_free(amdgpu_va_handle va_range_handle);
14093f012e29Smrg
141048246ce7Smrg/**
141148246ce7Smrg * Return the starting address of the allocated virtual address range.
141248246ce7Smrg */
141348246ce7Smrguint64_t amdgpu_va_get_start_addr(amdgpu_va_handle va_handle);
141448246ce7Smrg
14153f012e29Smrg/**
14163f012e29Smrg* Query virtual address range
14173f012e29Smrg*
14183f012e29Smrg* UMD can query GPU VM range supported by each device
14193f012e29Smrg* to initialize its own VAM accordingly.
14203f012e29Smrg*
14213f012e29Smrg* \param   dev    - [in] Device handle. See #amdgpu_device_initialize()
14223f012e29Smrg* \param   type   - \c [in] Type of virtual address range
14233f012e29Smrg* \param   offset - \c [out] Start offset of virtual address range
14243f012e29Smrg* \param   size   - \c [out] Size of virtual address range
14253f012e29Smrg*
14263f012e29Smrg* \return   0 on success\n
14273f012e29Smrg*          <0 - Negative POSIX Error code
14283f012e29Smrg*
14293f012e29Smrg*/
14303f012e29Smrg
14313f012e29Smrgint amdgpu_va_range_query(amdgpu_device_handle dev,
14323f012e29Smrg			  enum amdgpu_gpu_va_range type,
14333f012e29Smrg			  uint64_t *start,
14343f012e29Smrg			  uint64_t *end);
14353f012e29Smrg
143648246ce7Smrg/**
143748246ce7Smrg * Allocate a amdgpu_va_manager object.
143848246ce7Smrg * The returned object has be initialized with the amdgpu_va_manager_init
143948246ce7Smrg * before use.
144048246ce7Smrg * On release, amdgpu_va_manager_deinit needs to be called, then the memory
144148246ce7Smrg * can be released using free().
144248246ce7Smrg */
144348246ce7Smrgamdgpu_va_manager_handle amdgpu_va_manager_alloc(void);
144448246ce7Smrg
144548246ce7Smrgvoid amdgpu_va_manager_init(amdgpu_va_manager_handle va_mgr,
144648246ce7Smrg			    uint64_t low_va_offset, uint64_t low_va_max,
144748246ce7Smrg			    uint64_t high_va_offset, uint64_t high_va_max,
144848246ce7Smrg			    uint32_t virtual_address_alignment);
144948246ce7Smrg
145048246ce7Smrgvoid amdgpu_va_manager_deinit(amdgpu_va_manager_handle va_mgr);
145148246ce7Smrg
145248246ce7Smrg/**
145348246ce7Smrg * Similar to #amdgpu_va_range_alloc() but allocates VA
145448246ce7Smrg * directly from an amdgpu_va_manager_handle instead of using
145548246ce7Smrg * the manager from an amdgpu_device.
145648246ce7Smrg */
145748246ce7Smrg
145848246ce7Smrgint amdgpu_va_range_alloc2(amdgpu_va_manager_handle va_mgr,
145948246ce7Smrg			   enum amdgpu_gpu_va_range va_range_type,
146048246ce7Smrg			   uint64_t size,
146148246ce7Smrg			   uint64_t va_base_alignment,
146248246ce7Smrg			   uint64_t va_base_required,
146348246ce7Smrg			   uint64_t *va_base_allocated,
146448246ce7Smrg			   amdgpu_va_handle *va_range_handle,
146548246ce7Smrg			   uint64_t flags);
146648246ce7Smrg
14673f012e29Smrg/**
14683f012e29Smrg *  VA mapping/unmapping for the buffer object
14693f012e29Smrg *
14703f012e29Smrg * \param  bo		- \c [in] BO handle
14713f012e29Smrg * \param  offset	- \c [in] Start offset to map
14723f012e29Smrg * \param  size		- \c [in] Size to map
14733f012e29Smrg * \param  addr		- \c [in] Start virtual address.
14743f012e29Smrg * \param  flags	- \c [in] Supported flags for mapping/unmapping
14753f012e29Smrg * \param  ops		- \c [in] AMDGPU_VA_OP_MAP or AMDGPU_VA_OP_UNMAP
14763f012e29Smrg *
14773f012e29Smrg * \return   0 on success\n
14783f012e29Smrg *          <0 - Negative POSIX Error code
14793f012e29Smrg *
14803f012e29Smrg*/
14813f012e29Smrg
14823f012e29Smrgint amdgpu_bo_va_op(amdgpu_bo_handle bo,
14833f012e29Smrg		    uint64_t offset,
14843f012e29Smrg		    uint64_t size,
14853f012e29Smrg		    uint64_t addr,
14863f012e29Smrg		    uint64_t flags,
14873f012e29Smrg		    uint32_t ops);
14883f012e29Smrg
1489d8807b2fSmrg/**
1490d8807b2fSmrg *  VA mapping/unmapping for a buffer object or PRT region.
1491d8807b2fSmrg *
1492d8807b2fSmrg * This is not a simple drop-in extension for amdgpu_bo_va_op; instead, all
1493d8807b2fSmrg * parameters are treated "raw", i.e. size is not automatically aligned, and
1494d8807b2fSmrg * all flags must be specified explicitly.
1495d8807b2fSmrg *
1496d8807b2fSmrg * \param  dev		- \c [in] device handle
1497d8807b2fSmrg * \param  bo		- \c [in] BO handle (may be NULL)
1498d8807b2fSmrg * \param  offset	- \c [in] Start offset to map
1499d8807b2fSmrg * \param  size		- \c [in] Size to map
1500d8807b2fSmrg * \param  addr		- \c [in] Start virtual address.
1501d8807b2fSmrg * \param  flags	- \c [in] Supported flags for mapping/unmapping
1502d8807b2fSmrg * \param  ops		- \c [in] AMDGPU_VA_OP_MAP or AMDGPU_VA_OP_UNMAP
1503d8807b2fSmrg *
1504d8807b2fSmrg * \return   0 on success\n
1505d8807b2fSmrg *          <0 - Negative POSIX Error code
1506d8807b2fSmrg *
1507d8807b2fSmrg*/
1508d8807b2fSmrg
1509d8807b2fSmrgint amdgpu_bo_va_op_raw(amdgpu_device_handle dev,
1510d8807b2fSmrg			amdgpu_bo_handle bo,
1511d8807b2fSmrg			uint64_t offset,
1512d8807b2fSmrg			uint64_t size,
1513d8807b2fSmrg			uint64_t addr,
1514d8807b2fSmrg			uint64_t flags,
1515d8807b2fSmrg			uint32_t ops);
1516d8807b2fSmrg
15173f012e29Smrg/**
15183f012e29Smrg *  create semaphore
15193f012e29Smrg *
15203f012e29Smrg * \param   sem	   - \c [out] semaphore handle
15213f012e29Smrg *
15223f012e29Smrg * \return   0 on success\n
15233f012e29Smrg *          <0 - Negative POSIX Error code
15243f012e29Smrg *
15253f012e29Smrg*/
15263f012e29Smrgint amdgpu_cs_create_semaphore(amdgpu_semaphore_handle *sem);
15273f012e29Smrg
15283f012e29Smrg/**
15293f012e29Smrg *  signal semaphore
15303f012e29Smrg *
15313f012e29Smrg * \param   context        - \c [in] GPU Context
15323f012e29Smrg * \param   ip_type        - \c [in] Hardware IP block type = AMDGPU_HW_IP_*
15333f012e29Smrg * \param   ip_instance    - \c [in] Index of the IP block of the same type
15343f012e29Smrg * \param   ring           - \c [in] Specify ring index of the IP
15353f012e29Smrg * \param   sem	           - \c [in] semaphore handle
15363f012e29Smrg *
15373f012e29Smrg * \return   0 on success\n
15383f012e29Smrg *          <0 - Negative POSIX Error code
15393f012e29Smrg *
15403f012e29Smrg*/
15413f012e29Smrgint amdgpu_cs_signal_semaphore(amdgpu_context_handle ctx,
15423f012e29Smrg			       uint32_t ip_type,
15433f012e29Smrg			       uint32_t ip_instance,
15443f012e29Smrg			       uint32_t ring,
15453f012e29Smrg			       amdgpu_semaphore_handle sem);
15463f012e29Smrg
15473f012e29Smrg/**
15483f012e29Smrg *  wait semaphore
15493f012e29Smrg *
15503f012e29Smrg * \param   context        - \c [in] GPU Context
15513f012e29Smrg * \param   ip_type        - \c [in] Hardware IP block type = AMDGPU_HW_IP_*
15523f012e29Smrg * \param   ip_instance    - \c [in] Index of the IP block of the same type
15533f012e29Smrg * \param   ring           - \c [in] Specify ring index of the IP
15543f012e29Smrg * \param   sem	           - \c [in] semaphore handle
15553f012e29Smrg *
15563f012e29Smrg * \return   0 on success\n
15573f012e29Smrg *          <0 - Negative POSIX Error code
15583f012e29Smrg *
15593f012e29Smrg*/
15603f012e29Smrgint amdgpu_cs_wait_semaphore(amdgpu_context_handle ctx,
15613f012e29Smrg			     uint32_t ip_type,
15623f012e29Smrg			     uint32_t ip_instance,
15633f012e29Smrg			     uint32_t ring,
15643f012e29Smrg			     amdgpu_semaphore_handle sem);
15653f012e29Smrg
15663f012e29Smrg/**
15673f012e29Smrg *  destroy semaphore
15683f012e29Smrg *
15693f012e29Smrg * \param   sem	    - \c [in] semaphore handle
15703f012e29Smrg *
15713f012e29Smrg * \return   0 on success\n
15723f012e29Smrg *          <0 - Negative POSIX Error code
15733f012e29Smrg *
15743f012e29Smrg*/
15753f012e29Smrgint amdgpu_cs_destroy_semaphore(amdgpu_semaphore_handle sem);
15763f012e29Smrg
1577037b3c26Smrg/**
1578037b3c26Smrg *  Get the ASIC marketing name
1579037b3c26Smrg *
1580037b3c26Smrg * \param   dev         - \c [in] Device handle. See #amdgpu_device_initialize()
1581037b3c26Smrg *
1582037b3c26Smrg * \return  the constant string of the marketing name
1583037b3c26Smrg *          "NULL" means the ASIC is not found
1584037b3c26Smrg*/
1585037b3c26Smrgconst char *amdgpu_get_marketing_name(amdgpu_device_handle dev);
1586037b3c26Smrg
158700a23bdaSmrg/**
158800a23bdaSmrg *  Create kernel sync object
158900a23bdaSmrg *
159000a23bdaSmrg * \param   dev         - \c [in]  device handle
159100a23bdaSmrg * \param   flags       - \c [in]  flags that affect creation
159200a23bdaSmrg * \param   syncobj     - \c [out] sync object handle
159300a23bdaSmrg *
159400a23bdaSmrg * \return   0 on success\n
159500a23bdaSmrg *          <0 - Negative POSIX Error code
159600a23bdaSmrg *
159700a23bdaSmrg*/
159800a23bdaSmrgint amdgpu_cs_create_syncobj2(amdgpu_device_handle dev,
159900a23bdaSmrg			      uint32_t  flags,
160000a23bdaSmrg			      uint32_t *syncobj);
160100a23bdaSmrg
1602d8807b2fSmrg/**
1603d8807b2fSmrg *  Create kernel sync object
1604d8807b2fSmrg *
1605d8807b2fSmrg * \param   dev	      - \c [in]  device handle
1606d8807b2fSmrg * \param   syncobj   - \c [out] sync object handle
1607d8807b2fSmrg *
1608d8807b2fSmrg * \return   0 on success\n
1609d8807b2fSmrg *          <0 - Negative POSIX Error code
1610d8807b2fSmrg *
1611d8807b2fSmrg*/
1612d8807b2fSmrgint amdgpu_cs_create_syncobj(amdgpu_device_handle dev,
1613d8807b2fSmrg			     uint32_t *syncobj);
1614d8807b2fSmrg/**
1615d8807b2fSmrg *  Destroy kernel sync object
1616d8807b2fSmrg *
1617d8807b2fSmrg * \param   dev	    - \c [in] device handle
1618d8807b2fSmrg * \param   syncobj - \c [in] sync object handle
1619d8807b2fSmrg *
1620d8807b2fSmrg * \return   0 on success\n
1621d8807b2fSmrg *          <0 - Negative POSIX Error code
1622d8807b2fSmrg *
1623d8807b2fSmrg*/
1624d8807b2fSmrgint amdgpu_cs_destroy_syncobj(amdgpu_device_handle dev,
1625d8807b2fSmrg			      uint32_t syncobj);
1626d8807b2fSmrg
162700a23bdaSmrg/**
162800a23bdaSmrg * Reset kernel sync objects to unsignalled state.
162900a23bdaSmrg *
163000a23bdaSmrg * \param dev           - \c [in] device handle
163100a23bdaSmrg * \param syncobjs      - \c [in] array of sync object handles
163200a23bdaSmrg * \param syncobj_count - \c [in] number of handles in syncobjs
163300a23bdaSmrg *
163400a23bdaSmrg * \return   0 on success\n
163500a23bdaSmrg *          <0 - Negative POSIX Error code
163600a23bdaSmrg *
163700a23bdaSmrg*/
163800a23bdaSmrgint amdgpu_cs_syncobj_reset(amdgpu_device_handle dev,
163900a23bdaSmrg			    const uint32_t *syncobjs, uint32_t syncobj_count);
164000a23bdaSmrg
164100a23bdaSmrg/**
164200a23bdaSmrg * Signal kernel sync objects.
164300a23bdaSmrg *
164400a23bdaSmrg * \param dev           - \c [in] device handle
164500a23bdaSmrg * \param syncobjs      - \c [in] array of sync object handles
164600a23bdaSmrg * \param syncobj_count - \c [in] number of handles in syncobjs
164700a23bdaSmrg *
164800a23bdaSmrg * \return   0 on success\n
164900a23bdaSmrg *          <0 - Negative POSIX Error code
165000a23bdaSmrg *
165100a23bdaSmrg*/
165200a23bdaSmrgint amdgpu_cs_syncobj_signal(amdgpu_device_handle dev,
165300a23bdaSmrg			     const uint32_t *syncobjs, uint32_t syncobj_count);
165400a23bdaSmrg
16555324fb0dSmrg/**
16565324fb0dSmrg * Signal kernel timeline sync objects.
16575324fb0dSmrg *
16585324fb0dSmrg * \param dev           - \c [in] device handle
16595324fb0dSmrg * \param syncobjs      - \c [in] array of sync object handles
16605324fb0dSmrg * \param points	- \c [in] array of timeline points
16615324fb0dSmrg * \param syncobj_count - \c [in] number of handles in syncobjs
16625324fb0dSmrg *
16635324fb0dSmrg * \return   0 on success\n
16645324fb0dSmrg *          <0 - Negative POSIX Error code
16655324fb0dSmrg *
16665324fb0dSmrg*/
16675324fb0dSmrgint amdgpu_cs_syncobj_timeline_signal(amdgpu_device_handle dev,
16685324fb0dSmrg				      const uint32_t *syncobjs,
16695324fb0dSmrg				      uint64_t *points,
16705324fb0dSmrg				      uint32_t syncobj_count);
16715324fb0dSmrg
167200a23bdaSmrg/**
167300a23bdaSmrg *  Wait for one or all sync objects to signal.
167400a23bdaSmrg *
167500a23bdaSmrg * \param   dev	    - \c [in] self-explanatory
167600a23bdaSmrg * \param   handles - \c [in] array of sync object handles
167700a23bdaSmrg * \param   num_handles - \c [in] self-explanatory
167800a23bdaSmrg * \param   timeout_nsec - \c [in] self-explanatory
167900a23bdaSmrg * \param   flags   - \c [in] a bitmask of DRM_SYNCOBJ_WAIT_FLAGS_*
168000a23bdaSmrg * \param   first_signaled - \c [in] self-explanatory
168100a23bdaSmrg *
168200a23bdaSmrg * \return   0 on success\n
168300a23bdaSmrg *          -ETIME - Timeout
168400a23bdaSmrg *          <0 - Negative POSIX Error code
168500a23bdaSmrg *
168600a23bdaSmrg */
168700a23bdaSmrgint amdgpu_cs_syncobj_wait(amdgpu_device_handle dev,
168800a23bdaSmrg			   uint32_t *handles, unsigned num_handles,
168900a23bdaSmrg			   int64_t timeout_nsec, unsigned flags,
169000a23bdaSmrg			   uint32_t *first_signaled);
169100a23bdaSmrg
16925324fb0dSmrg/**
16935324fb0dSmrg *  Wait for one or all sync objects on their points to signal.
16945324fb0dSmrg *
16955324fb0dSmrg * \param   dev	    - \c [in] self-explanatory
16965324fb0dSmrg * \param   handles - \c [in] array of sync object handles
16975324fb0dSmrg * \param   points - \c [in] array of sync points to wait
16985324fb0dSmrg * \param   num_handles - \c [in] self-explanatory
16995324fb0dSmrg * \param   timeout_nsec - \c [in] self-explanatory
17005324fb0dSmrg * \param   flags   - \c [in] a bitmask of DRM_SYNCOBJ_WAIT_FLAGS_*
17015324fb0dSmrg * \param   first_signaled - \c [in] self-explanatory
17025324fb0dSmrg *
17035324fb0dSmrg * \return   0 on success\n
17045324fb0dSmrg *          -ETIME - Timeout
17055324fb0dSmrg *          <0 - Negative POSIX Error code
17065324fb0dSmrg *
17075324fb0dSmrg */
17085324fb0dSmrgint amdgpu_cs_syncobj_timeline_wait(amdgpu_device_handle dev,
17095324fb0dSmrg				    uint32_t *handles, uint64_t *points,
17105324fb0dSmrg				    unsigned num_handles,
17115324fb0dSmrg				    int64_t timeout_nsec, unsigned flags,
17125324fb0dSmrg				    uint32_t *first_signaled);
17135324fb0dSmrg/**
17145324fb0dSmrg *  Query sync objects payloads.
17155324fb0dSmrg *
17165324fb0dSmrg * \param   dev	    - \c [in] self-explanatory
17175324fb0dSmrg * \param   handles - \c [in] array of sync object handles
17185324fb0dSmrg * \param   points - \c [out] array of sync points returned, which presents
17195324fb0dSmrg * syncobj payload.
17205324fb0dSmrg * \param   num_handles - \c [in] self-explanatory
17215324fb0dSmrg *
17225324fb0dSmrg * \return   0 on success\n
17235324fb0dSmrg *          -ETIME - Timeout
17245324fb0dSmrg *          <0 - Negative POSIX Error code
17255324fb0dSmrg *
17265324fb0dSmrg */
17275324fb0dSmrgint amdgpu_cs_syncobj_query(amdgpu_device_handle dev,
17285324fb0dSmrg			    uint32_t *handles, uint64_t *points,
17295324fb0dSmrg			    unsigned num_handles);
17309bd392adSmrg/**
17319bd392adSmrg *  Query sync objects last signaled or submitted point.
17329bd392adSmrg *
17339bd392adSmrg * \param   dev	    - \c [in] self-explanatory
17349bd392adSmrg * \param   handles - \c [in] array of sync object handles
17359bd392adSmrg * \param   points - \c [out] array of sync points returned, which presents
17369bd392adSmrg * syncobj payload.
17379bd392adSmrg * \param   num_handles - \c [in] self-explanatory
17389bd392adSmrg * \param   flags   - \c [in] a bitmask of DRM_SYNCOBJ_QUERY_FLAGS_*
17399bd392adSmrg *
17409bd392adSmrg * \return   0 on success\n
17419bd392adSmrg *          -ETIME - Timeout
17429bd392adSmrg *          <0 - Negative POSIX Error code
17439bd392adSmrg *
17449bd392adSmrg */
17459bd392adSmrgint amdgpu_cs_syncobj_query2(amdgpu_device_handle dev,
17469bd392adSmrg			     uint32_t *handles, uint64_t *points,
17479bd392adSmrg			     unsigned num_handles, uint32_t flags);
17485324fb0dSmrg
1749d8807b2fSmrg/**
1750d8807b2fSmrg *  Export kernel sync object to shareable fd.
1751d8807b2fSmrg *
1752d8807b2fSmrg * \param   dev	       - \c [in] device handle
1753d8807b2fSmrg * \param   syncobj    - \c [in] sync object handle
1754d8807b2fSmrg * \param   shared_fd  - \c [out] shared file descriptor.
1755d8807b2fSmrg *
1756d8807b2fSmrg * \return   0 on success\n
1757d8807b2fSmrg *          <0 - Negative POSIX Error code
1758d8807b2fSmrg *
1759d8807b2fSmrg*/
1760d8807b2fSmrgint amdgpu_cs_export_syncobj(amdgpu_device_handle dev,
1761d8807b2fSmrg			     uint32_t syncobj,
1762d8807b2fSmrg			     int *shared_fd);
1763d8807b2fSmrg/**
1764d8807b2fSmrg *  Import kernel sync object from shareable fd.
1765d8807b2fSmrg *
1766d8807b2fSmrg * \param   dev	       - \c [in] device handle
1767d8807b2fSmrg * \param   shared_fd  - \c [in] shared file descriptor.
1768d8807b2fSmrg * \param   syncobj    - \c [out] sync object handle
1769d8807b2fSmrg *
1770d8807b2fSmrg * \return   0 on success\n
1771d8807b2fSmrg *          <0 - Negative POSIX Error code
1772d8807b2fSmrg *
1773d8807b2fSmrg*/
1774d8807b2fSmrgint amdgpu_cs_import_syncobj(amdgpu_device_handle dev,
1775d8807b2fSmrg			     int shared_fd,
1776d8807b2fSmrg			     uint32_t *syncobj);
1777d8807b2fSmrg
177800a23bdaSmrg/**
177900a23bdaSmrg *  Export kernel sync object to a sync_file.
178000a23bdaSmrg *
178100a23bdaSmrg * \param   dev	       - \c [in] device handle
178200a23bdaSmrg * \param   syncobj    - \c [in] sync object handle
178300a23bdaSmrg * \param   sync_file_fd - \c [out] sync_file file descriptor.
178400a23bdaSmrg *
178500a23bdaSmrg * \return   0 on success\n
178600a23bdaSmrg *          <0 - Negative POSIX Error code
178700a23bdaSmrg *
178800a23bdaSmrg */
178900a23bdaSmrgint amdgpu_cs_syncobj_export_sync_file(amdgpu_device_handle dev,
179000a23bdaSmrg				       uint32_t syncobj,
179100a23bdaSmrg				       int *sync_file_fd);
179200a23bdaSmrg
179300a23bdaSmrg/**
179400a23bdaSmrg *  Import kernel sync object from a sync_file.
179500a23bdaSmrg *
179600a23bdaSmrg * \param   dev	       - \c [in] device handle
179700a23bdaSmrg * \param   syncobj    - \c [in] sync object handle
179800a23bdaSmrg * \param   sync_file_fd - \c [in] sync_file file descriptor.
179900a23bdaSmrg *
180000a23bdaSmrg * \return   0 on success\n
180100a23bdaSmrg *          <0 - Negative POSIX Error code
180200a23bdaSmrg *
180300a23bdaSmrg */
180400a23bdaSmrgint amdgpu_cs_syncobj_import_sync_file(amdgpu_device_handle dev,
180500a23bdaSmrg				       uint32_t syncobj,
180600a23bdaSmrg				       int sync_file_fd);
18075324fb0dSmrg/**
18085324fb0dSmrg *  Export kernel timeline sync object to a sync_file.
18095324fb0dSmrg *
18105324fb0dSmrg * \param   dev		- \c [in] device handle
18115324fb0dSmrg * \param   syncobj	- \c [in] sync object handle
18125324fb0dSmrg * \param   point	- \c [in] timeline point
18135324fb0dSmrg * \param   flags	- \c [in] flags
18145324fb0dSmrg * \param   sync_file_fd - \c [out] sync_file file descriptor.
18155324fb0dSmrg *
18165324fb0dSmrg * \return   0 on success\n
18175324fb0dSmrg *          <0 - Negative POSIX Error code
18185324fb0dSmrg *
18195324fb0dSmrg */
18205324fb0dSmrgint amdgpu_cs_syncobj_export_sync_file2(amdgpu_device_handle dev,
18215324fb0dSmrg					uint32_t syncobj,
18225324fb0dSmrg					uint64_t point,
18235324fb0dSmrg					uint32_t flags,
18245324fb0dSmrg					int *sync_file_fd);
18255324fb0dSmrg
18265324fb0dSmrg/**
18275324fb0dSmrg *  Import kernel timeline sync object from a sync_file.
18285324fb0dSmrg *
18295324fb0dSmrg * \param   dev		- \c [in] device handle
18305324fb0dSmrg * \param   syncobj	- \c [in] sync object handle
18315324fb0dSmrg * \param   point	- \c [in] timeline point
18325324fb0dSmrg * \param   sync_file_fd - \c [in] sync_file file descriptor.
18335324fb0dSmrg *
18345324fb0dSmrg * \return   0 on success\n
18355324fb0dSmrg *          <0 - Negative POSIX Error code
18365324fb0dSmrg *
18375324fb0dSmrg */
18385324fb0dSmrgint amdgpu_cs_syncobj_import_sync_file2(amdgpu_device_handle dev,
18395324fb0dSmrg					uint32_t syncobj,
18405324fb0dSmrg					uint64_t point,
18415324fb0dSmrg					int sync_file_fd);
18425324fb0dSmrg
18435324fb0dSmrg/**
18445324fb0dSmrg *  transfer between syncbojs.
18455324fb0dSmrg *
18465324fb0dSmrg * \param   dev		- \c [in] device handle
18475324fb0dSmrg * \param   dst_handle	- \c [in] sync object handle
18485324fb0dSmrg * \param   dst_point	- \c [in] timeline point, 0 presents dst is binary
18495324fb0dSmrg * \param   src_handle	- \c [in] sync object handle
18505324fb0dSmrg * \param   src_point	- \c [in] timeline point, 0 presents src is binary
18515324fb0dSmrg * \param   flags	- \c [in] flags
18525324fb0dSmrg *
18535324fb0dSmrg * \return   0 on success\n
18545324fb0dSmrg *          <0 - Negative POSIX Error code
18555324fb0dSmrg *
18565324fb0dSmrg */
18575324fb0dSmrgint amdgpu_cs_syncobj_transfer(amdgpu_device_handle dev,
18585324fb0dSmrg			       uint32_t dst_handle,
18595324fb0dSmrg			       uint64_t dst_point,
18605324fb0dSmrg			       uint32_t src_handle,
18615324fb0dSmrg			       uint64_t src_point,
18625324fb0dSmrg			       uint32_t flags);
186300a23bdaSmrg
186400a23bdaSmrg/**
186500a23bdaSmrg * Export an amdgpu fence as a handle (syncobj or fd).
186600a23bdaSmrg *
186700a23bdaSmrg * \param what		AMDGPU_FENCE_TO_HANDLE_GET_{SYNCOBJ, FD}
186800a23bdaSmrg * \param out_handle	returned handle
186900a23bdaSmrg *
187000a23bdaSmrg * \return   0 on success\n
187100a23bdaSmrg *          <0 - Negative POSIX Error code
187200a23bdaSmrg */
187300a23bdaSmrgint amdgpu_cs_fence_to_handle(amdgpu_device_handle dev,
187400a23bdaSmrg			      struct amdgpu_cs_fence *fence,
187500a23bdaSmrg			      uint32_t what,
187600a23bdaSmrg			      uint32_t *out_handle);
187700a23bdaSmrg
1878d8807b2fSmrg/**
1879d8807b2fSmrg *  Submit raw command submission to kernel
1880d8807b2fSmrg *
1881d8807b2fSmrg * \param   dev	       - \c [in] device handle
1882d8807b2fSmrg * \param   context    - \c [in] context handle for context id
1883d8807b2fSmrg * \param   bo_list_handle - \c [in] request bo list handle (0 for none)
1884d8807b2fSmrg * \param   num_chunks - \c [in] number of CS chunks to submit
1885d8807b2fSmrg * \param   chunks     - \c [in] array of CS chunks
1886d8807b2fSmrg * \param   seq_no     - \c [out] output sequence number for submission.
1887d8807b2fSmrg *
1888d8807b2fSmrg * \return   0 on success\n
1889d8807b2fSmrg *          <0 - Negative POSIX Error code
1890d8807b2fSmrg *
1891d8807b2fSmrg */
1892d8807b2fSmrgstruct drm_amdgpu_cs_chunk;
1893d8807b2fSmrgstruct drm_amdgpu_cs_chunk_dep;
1894d8807b2fSmrgstruct drm_amdgpu_cs_chunk_data;
1895d8807b2fSmrg
1896d8807b2fSmrgint amdgpu_cs_submit_raw(amdgpu_device_handle dev,
1897d8807b2fSmrg			 amdgpu_context_handle context,
1898d8807b2fSmrg			 amdgpu_bo_list_handle bo_list_handle,
1899d8807b2fSmrg			 int num_chunks,
1900d8807b2fSmrg			 struct drm_amdgpu_cs_chunk *chunks,
1901d8807b2fSmrg			 uint64_t *seq_no);
1902d8807b2fSmrg
19036532f28eSmrg/**
19046532f28eSmrg * Submit raw command submission to the kernel with a raw BO list handle.
19056532f28eSmrg *
19066532f28eSmrg * \param   dev	       - \c [in] device handle
19076532f28eSmrg * \param   context    - \c [in] context handle for context id
19086532f28eSmrg * \param   bo_list_handle - \c [in] raw bo list handle (0 for none)
19096532f28eSmrg * \param   num_chunks - \c [in] number of CS chunks to submit
19106532f28eSmrg * \param   chunks     - \c [in] array of CS chunks
19116532f28eSmrg * \param   seq_no     - \c [out] output sequence number for submission.
19126532f28eSmrg *
19136532f28eSmrg * \return   0 on success\n
19146532f28eSmrg *          <0 - Negative POSIX Error code
19156532f28eSmrg *
19166532f28eSmrg * \sa amdgpu_bo_list_create_raw(), amdgpu_bo_list_destroy_raw()
19176532f28eSmrg */
19186532f28eSmrgint amdgpu_cs_submit_raw2(amdgpu_device_handle dev,
19196532f28eSmrg			  amdgpu_context_handle context,
19206532f28eSmrg			  uint32_t bo_list_handle,
19216532f28eSmrg			  int num_chunks,
19226532f28eSmrg			  struct drm_amdgpu_cs_chunk *chunks,
19236532f28eSmrg			  uint64_t *seq_no);
19246532f28eSmrg
1925d8807b2fSmrgvoid amdgpu_cs_chunk_fence_to_dep(struct amdgpu_cs_fence *fence,
1926d8807b2fSmrg				  struct drm_amdgpu_cs_chunk_dep *dep);
1927d8807b2fSmrgvoid amdgpu_cs_chunk_fence_info_to_data(struct amdgpu_cs_fence_info *fence_info,
1928d8807b2fSmrg					struct drm_amdgpu_cs_chunk_data *data);
1929d8807b2fSmrg
193000a23bdaSmrg/**
193100a23bdaSmrg * Reserve VMID
193200a23bdaSmrg * \param   context - \c [in]  GPU Context
193300a23bdaSmrg * \param   flags - \c [in]  TBD
193400a23bdaSmrg *
193500a23bdaSmrg * \return  0 on success otherwise POSIX Error code
193600a23bdaSmrg*/
193700a23bdaSmrgint amdgpu_vm_reserve_vmid(amdgpu_device_handle dev, uint32_t flags);
193800a23bdaSmrg
193900a23bdaSmrg/**
194000a23bdaSmrg * Free reserved VMID
194100a23bdaSmrg * \param   context - \c [in]  GPU Context
194200a23bdaSmrg * \param   flags - \c [in]  TBD
194300a23bdaSmrg *
194400a23bdaSmrg * \return  0 on success otherwise POSIX Error code
194500a23bdaSmrg*/
194600a23bdaSmrgint amdgpu_vm_unreserve_vmid(amdgpu_device_handle dev, uint32_t flags);
194700a23bdaSmrg
1948d8807b2fSmrg#ifdef __cplusplus
1949d8807b2fSmrg}
1950d8807b2fSmrg#endif
19513f012e29Smrg#endif /* #ifdef _AMDGPU_H_ */
1952