Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 Advanced Micro Devices, Inc. |
| 3 | * |
| 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 5 | * copy of this software and associated documentation files (the "Software"), |
| 6 | * to deal in the Software without restriction, including without limitation |
| 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 8 | * and/or sell copies of the Software, and to permit persons to whom the |
| 9 | * Software is furnished to do so, subject to the following conditions: |
| 10 | * |
| 11 | * The above copyright notice and this permission notice shall be included in |
| 12 | * all copies or substantial portions of the Software. |
| 13 | * |
| 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 17 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 20 | * OTHER DEALINGS IN THE SOFTWARE. |
| 21 | * |
Emil Velikov | a30da8e | 2015-08-07 17:20:51 +0100 | [diff] [blame] | 22 | */ |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 23 | |
| 24 | /** |
| 25 | * \file amdgpu.h |
| 26 | * |
| 27 | * Declare public libdrm_amdgpu API |
| 28 | * |
| 29 | * This file define API exposed by libdrm_amdgpu library. |
| 30 | * User wanted to use libdrm_amdgpu functionality must include |
| 31 | * this file. |
| 32 | * |
| 33 | */ |
| 34 | #ifndef _AMDGPU_H_ |
| 35 | #define _AMDGPU_H_ |
| 36 | |
| 37 | #include <stdint.h> |
| 38 | #include <stdbool.h> |
| 39 | |
Nicolai Hähnle | 41be41f | 2017-05-13 23:03:55 +0200 | [diff] [blame] | 40 | #ifdef __cplusplus |
| 41 | extern "C" { |
| 42 | #endif |
| 43 | |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 44 | struct drm_amdgpu_info_hw_ip; |
| 45 | |
| 46 | /*--------------------------------------------------------------------------*/ |
| 47 | /* --------------------------- Defines ------------------------------------ */ |
| 48 | /*--------------------------------------------------------------------------*/ |
| 49 | |
| 50 | /** |
| 51 | * Define max. number of Command Buffers (IB) which could be sent to the single |
| 52 | * hardware IP to accommodate CE/DE requirements |
| 53 | * |
| 54 | * \sa amdgpu_cs_ib_info |
| 55 | */ |
| 56 | #define AMDGPU_CS_MAX_IBS_PER_SUBMIT 4 |
| 57 | |
| 58 | /** |
Marek Olšák | 67c994f | 2015-06-26 21:58:17 +0200 | [diff] [blame] | 59 | * Special timeout value meaning that the timeout is infinite. |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 60 | */ |
| 61 | #define AMDGPU_TIMEOUT_INFINITE 0xffffffffffffffffull |
| 62 | |
Marek Olšák | 67c994f | 2015-06-26 21:58:17 +0200 | [diff] [blame] | 63 | /** |
Christian König | 5463d2e | 2015-07-09 11:48:32 +0200 | [diff] [blame] | 64 | * Used in amdgpu_cs_query_fence_status(), meaning that the given timeout |
Marek Olšák | 67c994f | 2015-06-26 21:58:17 +0200 | [diff] [blame] | 65 | * is absolute. |
| 66 | */ |
| 67 | #define AMDGPU_QUERY_FENCE_TIMEOUT_IS_ABSOLUTE (1 << 0) |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 68 | |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 69 | /*--------------------------------------------------------------------------*/ |
| 70 | /* ----------------------------- Enums ------------------------------------ */ |
| 71 | /*--------------------------------------------------------------------------*/ |
| 72 | |
| 73 | /** |
| 74 | * Enum describing possible handle types |
| 75 | * |
| 76 | * \sa amdgpu_bo_import, amdgpu_bo_export |
| 77 | * |
| 78 | */ |
| 79 | enum amdgpu_bo_handle_type { |
| 80 | /** GEM flink name (needs DRM authentication, used by DRI2) */ |
| 81 | amdgpu_bo_handle_type_gem_flink_name = 0, |
| 82 | |
| 83 | /** KMS handle which is used by all driver ioctls */ |
| 84 | amdgpu_bo_handle_type_kms = 1, |
| 85 | |
| 86 | /** DMA-buf fd handle */ |
| 87 | amdgpu_bo_handle_type_dma_buf_fd = 2 |
| 88 | }; |
| 89 | |
Sabre Shao | 23fab59 | 2015-07-09 13:50:36 +0800 | [diff] [blame] | 90 | /** Define known types of GPU VM VA ranges */ |
| 91 | enum amdgpu_gpu_va_range |
| 92 | { |
| 93 | /** Allocate from "normal"/general range */ |
| 94 | amdgpu_gpu_va_range_general = 0 |
| 95 | }; |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 96 | |
Marek Olšák | ad5b702 | 2018-02-02 18:15:00 +0100 | [diff] [blame^] | 97 | enum amdgpu_sw_info { |
| 98 | amdgpu_sw_info_address32_hi = 0, |
| 99 | }; |
| 100 | |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 101 | /*--------------------------------------------------------------------------*/ |
| 102 | /* -------------------------- Datatypes ----------------------------------- */ |
| 103 | /*--------------------------------------------------------------------------*/ |
| 104 | |
| 105 | /** |
| 106 | * Define opaque pointer to context associated with fd. |
| 107 | * This context will be returned as the result of |
| 108 | * "initialize" function and should be pass as the first |
| 109 | * parameter to any API call |
| 110 | */ |
| 111 | typedef struct amdgpu_device *amdgpu_device_handle; |
| 112 | |
| 113 | /** |
| 114 | * Define GPU Context type as pointer to opaque structure |
| 115 | * Example of GPU Context is the "rendering" context associated |
| 116 | * with OpenGL context (glCreateContext) |
| 117 | */ |
| 118 | typedef struct amdgpu_context *amdgpu_context_handle; |
| 119 | |
| 120 | /** |
| 121 | * Define handle for amdgpu resources: buffer, GDS, etc. |
| 122 | */ |
| 123 | typedef struct amdgpu_bo *amdgpu_bo_handle; |
| 124 | |
| 125 | /** |
Christian König | 6dc2eaf | 2015-04-22 14:52:34 +0200 | [diff] [blame] | 126 | * Define handle for list of BOs |
| 127 | */ |
| 128 | typedef struct amdgpu_bo_list *amdgpu_bo_list_handle; |
| 129 | |
Sabre Shao | 23fab59 | 2015-07-09 13:50:36 +0800 | [diff] [blame] | 130 | /** |
| 131 | * Define handle to be used to work with VA allocated ranges |
| 132 | */ |
| 133 | typedef struct amdgpu_va *amdgpu_va_handle; |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 134 | |
Marek Olšák | 6afadea | 2016-01-12 22:13:07 +0100 | [diff] [blame] | 135 | /** |
| 136 | * Define handle for semaphore |
| 137 | */ |
| 138 | typedef struct amdgpu_semaphore *amdgpu_semaphore_handle; |
| 139 | |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 140 | /*--------------------------------------------------------------------------*/ |
| 141 | /* -------------------------- Structures ---------------------------------- */ |
| 142 | /*--------------------------------------------------------------------------*/ |
| 143 | |
| 144 | /** |
| 145 | * Structure describing memory allocation request |
| 146 | * |
| 147 | * \sa amdgpu_bo_alloc() |
| 148 | * |
| 149 | */ |
| 150 | struct amdgpu_bo_alloc_request { |
| 151 | /** Allocation request. It must be aligned correctly. */ |
| 152 | uint64_t alloc_size; |
| 153 | |
| 154 | /** |
| 155 | * It may be required to have some specific alignment requirements |
| 156 | * for physical back-up storage (e.g. for displayable surface). |
| 157 | * If 0 there is no special alignment requirement |
| 158 | */ |
| 159 | uint64_t phys_alignment; |
| 160 | |
| 161 | /** |
| 162 | * UMD should specify where to allocate memory and how it |
| 163 | * will be accessed by the CPU. |
| 164 | */ |
| 165 | uint32_t preferred_heap; |
| 166 | |
| 167 | /** Additional flags passed on allocation */ |
| 168 | uint64_t flags; |
| 169 | }; |
| 170 | |
| 171 | /** |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 172 | * Special UMD specific information associated with buffer. |
| 173 | * |
| 174 | * It may be need to pass some buffer charactersitic as part |
| 175 | * of buffer sharing. Such information are defined UMD and |
| 176 | * opaque for libdrm_amdgpu as well for kernel driver. |
| 177 | * |
| 178 | * \sa amdgpu_bo_set_metadata(), amdgpu_bo_query_info, |
| 179 | * amdgpu_bo_import(), amdgpu_bo_export |
| 180 | * |
| 181 | */ |
| 182 | struct amdgpu_bo_metadata { |
| 183 | /** Special flag associated with surface */ |
| 184 | uint64_t flags; |
| 185 | |
| 186 | /** |
| 187 | * ASIC-specific tiling information (also used by DCE). |
| 188 | * The encoding is defined by the AMDGPU_TILING_* definitions. |
| 189 | */ |
| 190 | uint64_t tiling_info; |
| 191 | |
| 192 | /** Size of metadata associated with the buffer, in bytes. */ |
| 193 | uint32_t size_metadata; |
| 194 | |
| 195 | /** UMD specific metadata. Opaque for kernel */ |
| 196 | uint32_t umd_metadata[64]; |
| 197 | }; |
| 198 | |
| 199 | /** |
| 200 | * Structure describing allocated buffer. Client may need |
| 201 | * to query such information as part of 'sharing' buffers mechanism |
| 202 | * |
| 203 | * \sa amdgpu_bo_set_metadata(), amdgpu_bo_query_info(), |
| 204 | * amdgpu_bo_import(), amdgpu_bo_export() |
| 205 | */ |
| 206 | struct amdgpu_bo_info { |
| 207 | /** Allocated memory size */ |
| 208 | uint64_t alloc_size; |
| 209 | |
| 210 | /** |
| 211 | * It may be required to have some specific alignment requirements |
| 212 | * for physical back-up storage. |
| 213 | */ |
| 214 | uint64_t phys_alignment; |
| 215 | |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 216 | /** Heap where to allocate memory. */ |
| 217 | uint32_t preferred_heap; |
| 218 | |
| 219 | /** Additional allocation flags. */ |
| 220 | uint64_t alloc_flags; |
| 221 | |
| 222 | /** Metadata associated with buffer if any. */ |
| 223 | struct amdgpu_bo_metadata metadata; |
| 224 | }; |
| 225 | |
| 226 | /** |
| 227 | * Structure with information about "imported" buffer |
| 228 | * |
| 229 | * \sa amdgpu_bo_import() |
| 230 | * |
| 231 | */ |
| 232 | struct amdgpu_bo_import_result { |
| 233 | /** Handle of memory/buffer to use */ |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 234 | amdgpu_bo_handle buf_handle; |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 235 | |
| 236 | /** Buffer size */ |
| 237 | uint64_t alloc_size; |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 238 | }; |
| 239 | |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 240 | /** |
| 241 | * |
| 242 | * Structure to describe GDS partitioning information. |
| 243 | * \note OA and GWS resources are asscoiated with GDS partition |
| 244 | * |
| 245 | * \sa amdgpu_gpu_resource_query_gds_info |
| 246 | * |
| 247 | */ |
| 248 | struct amdgpu_gds_resource_info { |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 249 | uint32_t gds_gfx_partition_size; |
| 250 | uint32_t compute_partition_size; |
| 251 | uint32_t gds_total_size; |
| 252 | uint32_t gws_per_gfx_partition; |
| 253 | uint32_t gws_per_compute_partition; |
| 254 | uint32_t oa_per_gfx_partition; |
| 255 | uint32_t oa_per_compute_partition; |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 256 | }; |
| 257 | |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 258 | /** |
Christian König | 5463d2e | 2015-07-09 11:48:32 +0200 | [diff] [blame] | 259 | * Structure describing CS fence |
Christian König | 0f37bc9 | 2015-06-24 14:17:57 +0200 | [diff] [blame] | 260 | * |
Christian König | 5463d2e | 2015-07-09 11:48:32 +0200 | [diff] [blame] | 261 | * \sa amdgpu_cs_query_fence_status(), amdgpu_cs_request, amdgpu_cs_submit() |
Christian König | 0f37bc9 | 2015-06-24 14:17:57 +0200 | [diff] [blame] | 262 | * |
| 263 | */ |
Christian König | 5463d2e | 2015-07-09 11:48:32 +0200 | [diff] [blame] | 264 | struct amdgpu_cs_fence { |
| 265 | |
| 266 | /** In which context IB was sent to execution */ |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 267 | amdgpu_context_handle context; |
Christian König | 0f37bc9 | 2015-06-24 14:17:57 +0200 | [diff] [blame] | 268 | |
| 269 | /** To which HW IP type the fence belongs */ |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 270 | uint32_t ip_type; |
Christian König | 0f37bc9 | 2015-06-24 14:17:57 +0200 | [diff] [blame] | 271 | |
| 272 | /** IP instance index if there are several IPs of the same type. */ |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 273 | uint32_t ip_instance; |
Christian König | 0f37bc9 | 2015-06-24 14:17:57 +0200 | [diff] [blame] | 274 | |
| 275 | /** Ring index of the HW IP */ |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 276 | uint32_t ring; |
Christian König | 0f37bc9 | 2015-06-24 14:17:57 +0200 | [diff] [blame] | 277 | |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 278 | /** Specify fence for which we need to check submission status.*/ |
| 279 | uint64_t fence; |
Christian König | 0f37bc9 | 2015-06-24 14:17:57 +0200 | [diff] [blame] | 280 | }; |
| 281 | |
| 282 | /** |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 283 | * Structure describing IB |
| 284 | * |
| 285 | * \sa amdgpu_cs_request, amdgpu_cs_submit() |
| 286 | * |
| 287 | */ |
| 288 | struct amdgpu_cs_ib_info { |
| 289 | /** Special flags */ |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 290 | uint64_t flags; |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 291 | |
Marek Olšák | 76af5c2 | 2015-06-02 13:05:41 +0200 | [diff] [blame] | 292 | /** Virtual MC address of the command buffer */ |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 293 | uint64_t ib_mc_address; |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 294 | |
| 295 | /** |
| 296 | * Size of Command Buffer to be submitted. |
| 297 | * - The size is in units of dwords (4 bytes). |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 298 | * - Could be 0 |
| 299 | */ |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 300 | uint32_t size; |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 301 | }; |
| 302 | |
| 303 | /** |
Ken Wang | 926c805 | 2015-07-10 22:22:27 +0800 | [diff] [blame] | 304 | * Structure describing fence information |
| 305 | * |
| 306 | * \sa amdgpu_cs_request, amdgpu_cs_query_fence, |
| 307 | * amdgpu_cs_submit(), amdgpu_cs_query_fence_status() |
| 308 | */ |
| 309 | struct amdgpu_cs_fence_info { |
| 310 | /** buffer object for the fence */ |
| 311 | amdgpu_bo_handle handle; |
| 312 | |
| 313 | /** fence offset in the unit of sizeof(uint64_t) */ |
| 314 | uint64_t offset; |
| 315 | }; |
| 316 | |
| 317 | /** |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 318 | * Structure describing submission request |
| 319 | * |
| 320 | * \note We could have several IBs as packet. e.g. CE, CE, DE case for gfx |
| 321 | * |
| 322 | * \sa amdgpu_cs_submit() |
| 323 | */ |
| 324 | struct amdgpu_cs_request { |
| 325 | /** Specify flags with additional information */ |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 326 | uint64_t flags; |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 327 | |
| 328 | /** Specify HW IP block type to which to send the IB. */ |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 329 | unsigned ip_type; |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 330 | |
| 331 | /** IP instance index if there are several IPs of the same type. */ |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 332 | unsigned ip_instance; |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 333 | |
| 334 | /** |
| 335 | * Specify ring index of the IP. We could have several rings |
| 336 | * in the same IP. E.g. 0 for SDMA0 and 1 for SDMA1. |
| 337 | */ |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 338 | uint32_t ring; |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 339 | |
| 340 | /** |
Christian König | 6dc2eaf | 2015-04-22 14:52:34 +0200 | [diff] [blame] | 341 | * List handle with resources used by this request. |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 342 | */ |
Christian König | 6dc2eaf | 2015-04-22 14:52:34 +0200 | [diff] [blame] | 343 | amdgpu_bo_list_handle resources; |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 344 | |
Christian König | 0f37bc9 | 2015-06-24 14:17:57 +0200 | [diff] [blame] | 345 | /** |
| 346 | * Number of dependencies this Command submission needs to |
| 347 | * wait for before starting execution. |
| 348 | */ |
| 349 | uint32_t number_of_dependencies; |
| 350 | |
| 351 | /** |
| 352 | * Array of dependencies which need to be met before |
| 353 | * execution can start. |
| 354 | */ |
Christian König | 5463d2e | 2015-07-09 11:48:32 +0200 | [diff] [blame] | 355 | struct amdgpu_cs_fence *dependencies; |
Christian König | 0f37bc9 | 2015-06-24 14:17:57 +0200 | [diff] [blame] | 356 | |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 357 | /** Number of IBs to submit in the field ibs. */ |
| 358 | uint32_t number_of_ibs; |
| 359 | |
| 360 | /** |
| 361 | * IBs to submit. Those IBs will be submit together as single entity |
| 362 | */ |
| 363 | struct amdgpu_cs_ib_info *ibs; |
Ken Wang | 926c805 | 2015-07-10 22:22:27 +0800 | [diff] [blame] | 364 | |
| 365 | /** |
| 366 | * The returned sequence number for the command submission |
| 367 | */ |
| 368 | uint64_t seq_no; |
| 369 | |
| 370 | /** |
| 371 | * The fence information |
| 372 | */ |
| 373 | struct amdgpu_cs_fence_info fence_info; |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 374 | }; |
| 375 | |
| 376 | /** |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 377 | * Structure which provide information about GPU VM MC Address space |
| 378 | * alignments requirements |
| 379 | * |
| 380 | * \sa amdgpu_query_buffer_size_alignment |
| 381 | */ |
| 382 | struct amdgpu_buffer_size_alignments { |
| 383 | /** Size alignment requirement for allocation in |
| 384 | * local memory */ |
| 385 | uint64_t size_local; |
| 386 | |
| 387 | /** |
| 388 | * Size alignment requirement for allocation in remote memory |
| 389 | */ |
| 390 | uint64_t size_remote; |
| 391 | }; |
| 392 | |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 393 | /** |
| 394 | * Structure which provide information about heap |
| 395 | * |
| 396 | * \sa amdgpu_query_heap_info() |
| 397 | * |
| 398 | */ |
| 399 | struct amdgpu_heap_info { |
| 400 | /** Theoretical max. available memory in the given heap */ |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 401 | uint64_t heap_size; |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 402 | |
| 403 | /** |
| 404 | * Number of bytes allocated in the heap. This includes all processes |
| 405 | * and private allocations in the kernel. It changes when new buffers |
| 406 | * are allocated, freed, and moved. It cannot be larger than |
| 407 | * heap_size. |
| 408 | */ |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 409 | uint64_t heap_usage; |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 410 | |
| 411 | /** |
| 412 | * Theoretical possible max. size of buffer which |
| 413 | * could be allocated in the given heap |
| 414 | */ |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 415 | uint64_t max_allocation; |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 416 | }; |
| 417 | |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 418 | /** |
| 419 | * Describe GPU h/w info needed for UMD correct initialization |
| 420 | * |
| 421 | * \sa amdgpu_query_gpu_info() |
| 422 | */ |
| 423 | struct amdgpu_gpu_info { |
| 424 | /** Asic id */ |
| 425 | uint32_t asic_id; |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 426 | /** Chip revision */ |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 427 | uint32_t chip_rev; |
| 428 | /** Chip external revision */ |
| 429 | uint32_t chip_external_rev; |
| 430 | /** Family ID */ |
| 431 | uint32_t family_id; |
| 432 | /** Special flags */ |
| 433 | uint64_t ids_flags; |
| 434 | /** max engine clock*/ |
| 435 | uint64_t max_engine_clk; |
Ken Wang | fc9fc7d | 2015-06-03 17:07:44 +0800 | [diff] [blame] | 436 | /** max memory clock */ |
| 437 | uint64_t max_memory_clk; |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 438 | /** number of shader engines */ |
| 439 | uint32_t num_shader_engines; |
| 440 | /** number of shader arrays per engine */ |
| 441 | uint32_t num_shader_arrays_per_engine; |
| 442 | /** Number of available good shader pipes */ |
| 443 | uint32_t avail_quad_shader_pipes; |
| 444 | /** Max. number of shader pipes.(including good and bad pipes */ |
| 445 | uint32_t max_quad_shader_pipes; |
| 446 | /** Number of parameter cache entries per shader quad pipe */ |
| 447 | uint32_t cache_entries_per_quad_pipe; |
| 448 | /** Number of available graphics context */ |
| 449 | uint32_t num_hw_gfx_contexts; |
| 450 | /** Number of render backend pipes */ |
| 451 | uint32_t rb_pipes; |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 452 | /** Enabled render backend pipe mask */ |
| 453 | uint32_t enabled_rb_pipes_mask; |
| 454 | /** Frequency of GPU Counter */ |
| 455 | uint32_t gpu_counter_freq; |
| 456 | /** CC_RB_BACKEND_DISABLE.BACKEND_DISABLE per SE */ |
| 457 | uint32_t backend_disable[4]; |
| 458 | /** Value of MC_ARB_RAMCFG register*/ |
| 459 | uint32_t mc_arb_ramcfg; |
| 460 | /** Value of GB_ADDR_CONFIG */ |
| 461 | uint32_t gb_addr_cfg; |
| 462 | /** Values of the GB_TILE_MODE0..31 registers */ |
| 463 | uint32_t gb_tile_mode[32]; |
| 464 | /** Values of GB_MACROTILE_MODE0..15 registers */ |
| 465 | uint32_t gb_macro_tile_mode[16]; |
| 466 | /** Value of PA_SC_RASTER_CONFIG register per SE */ |
| 467 | uint32_t pa_sc_raster_cfg[4]; |
| 468 | /** Value of PA_SC_RASTER_CONFIG_1 register per SE */ |
| 469 | uint32_t pa_sc_raster_cfg1[4]; |
| 470 | /* CU info */ |
| 471 | uint32_t cu_active_number; |
| 472 | uint32_t cu_ao_mask; |
| 473 | uint32_t cu_bitmap[4][4]; |
Ken Wang | 4bf2941 | 2015-06-03 17:15:29 +0800 | [diff] [blame] | 474 | /* video memory type info*/ |
| 475 | uint32_t vram_type; |
| 476 | /* video memory bit width*/ |
| 477 | uint32_t vram_bit_width; |
Ken Wang | cdd1edc | 2015-06-03 17:21:27 +0800 | [diff] [blame] | 478 | /** constant engine ram size*/ |
| 479 | uint32_t ce_ram_size; |
Leo Liu | d2cbe9e | 2015-07-13 12:51:34 -0400 | [diff] [blame] | 480 | /* vce harvesting instance */ |
| 481 | uint32_t vce_harvest_config; |
Jammy Zhou | d01c361 | 2015-08-03 15:46:42 +0800 | [diff] [blame] | 482 | /* PCI revision ID */ |
| 483 | uint32_t pci_rev_id; |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 484 | }; |
| 485 | |
| 486 | |
| 487 | /*--------------------------------------------------------------------------*/ |
| 488 | /*------------------------- Functions --------------------------------------*/ |
| 489 | /*--------------------------------------------------------------------------*/ |
| 490 | |
| 491 | /* |
| 492 | * Initialization / Cleanup |
| 493 | * |
| 494 | */ |
| 495 | |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 496 | /** |
| 497 | * |
| 498 | * \param fd - \c [in] File descriptor for AMD GPU device |
| 499 | * received previously as the result of |
| 500 | * e.g. drmOpen() call. |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 501 | * For legacy fd type, the DRI2/DRI3 |
| 502 | * authentication should be done before |
| 503 | * calling this function. |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 504 | * \param major_version - \c [out] Major version of library. It is assumed |
| 505 | * that adding new functionality will cause |
| 506 | * increase in major version |
| 507 | * \param minor_version - \c [out] Minor version of library |
| 508 | * \param device_handle - \c [out] Pointer to opaque context which should |
| 509 | * be passed as the first parameter on each |
| 510 | * API call |
| 511 | * |
| 512 | * |
| 513 | * \return 0 on success\n |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 514 | * <0 - Negative POSIX Error code |
| 515 | * |
| 516 | * |
| 517 | * \sa amdgpu_device_deinitialize() |
| 518 | */ |
| 519 | int amdgpu_device_initialize(int fd, |
| 520 | uint32_t *major_version, |
| 521 | uint32_t *minor_version, |
| 522 | amdgpu_device_handle *device_handle); |
| 523 | |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 524 | /** |
| 525 | * |
| 526 | * When access to such library does not needed any more the special |
| 527 | * function must be call giving opportunity to clean up any |
| 528 | * resources if needed. |
| 529 | * |
| 530 | * \param device_handle - \c [in] Context associated with file |
| 531 | * descriptor for AMD GPU device |
| 532 | * received previously as the |
| 533 | * result e.g. of drmOpen() call. |
| 534 | * |
| 535 | * \return 0 on success\n |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 536 | * <0 - Negative POSIX Error code |
| 537 | * |
| 538 | * \sa amdgpu_device_initialize() |
| 539 | * |
| 540 | */ |
| 541 | int amdgpu_device_deinitialize(amdgpu_device_handle device_handle); |
| 542 | |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 543 | /* |
| 544 | * Memory Management |
| 545 | * |
| 546 | */ |
| 547 | |
| 548 | /** |
| 549 | * Allocate memory to be used by UMD for GPU related operations |
| 550 | * |
| 551 | * \param dev - \c [in] Device handle. |
| 552 | * See #amdgpu_device_initialize() |
| 553 | * \param alloc_buffer - \c [in] Pointer to the structure describing an |
| 554 | * allocation request |
Jammy Zhou | 8aeffcc | 2015-07-13 20:57:44 +0800 | [diff] [blame] | 555 | * \param buf_handle - \c [out] Allocated buffer handle |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 556 | * |
| 557 | * \return 0 on success\n |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 558 | * <0 - Negative POSIX Error code |
| 559 | * |
| 560 | * \sa amdgpu_bo_free() |
| 561 | */ |
| 562 | int amdgpu_bo_alloc(amdgpu_device_handle dev, |
| 563 | struct amdgpu_bo_alloc_request *alloc_buffer, |
Jammy Zhou | 8aeffcc | 2015-07-13 20:57:44 +0800 | [diff] [blame] | 564 | amdgpu_bo_handle *buf_handle); |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 565 | |
| 566 | /** |
| 567 | * Associate opaque data with buffer to be queried by another UMD |
| 568 | * |
| 569 | * \param dev - \c [in] Device handle. See #amdgpu_device_initialize() |
| 570 | * \param buf_handle - \c [in] Buffer handle |
| 571 | * \param info - \c [in] Metadata to associated with buffer |
| 572 | * |
| 573 | * \return 0 on success\n |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 574 | * <0 - Negative POSIX Error code |
| 575 | */ |
| 576 | int amdgpu_bo_set_metadata(amdgpu_bo_handle buf_handle, |
| 577 | struct amdgpu_bo_metadata *info); |
| 578 | |
| 579 | /** |
| 580 | * Query buffer information including metadata previusly associated with |
| 581 | * buffer. |
| 582 | * |
| 583 | * \param dev - \c [in] Device handle. |
| 584 | * See #amdgpu_device_initialize() |
| 585 | * \param buf_handle - \c [in] Buffer handle |
| 586 | * \param info - \c [out] Structure describing buffer |
| 587 | * |
| 588 | * \return 0 on success\n |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 589 | * <0 - Negative POSIX Error code |
| 590 | * |
| 591 | * \sa amdgpu_bo_set_metadata(), amdgpu_bo_alloc() |
| 592 | */ |
| 593 | int amdgpu_bo_query_info(amdgpu_bo_handle buf_handle, |
| 594 | struct amdgpu_bo_info *info); |
| 595 | |
| 596 | /** |
| 597 | * Allow others to get access to buffer |
| 598 | * |
| 599 | * \param dev - \c [in] Device handle. |
| 600 | * See #amdgpu_device_initialize() |
| 601 | * \param buf_handle - \c [in] Buffer handle |
| 602 | * \param type - \c [in] Type of handle requested |
| 603 | * \param shared_handle - \c [out] Special "shared" handle |
| 604 | * |
| 605 | * \return 0 on success\n |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 606 | * <0 - Negative POSIX Error code |
| 607 | * |
| 608 | * \sa amdgpu_bo_import() |
| 609 | * |
| 610 | */ |
| 611 | int amdgpu_bo_export(amdgpu_bo_handle buf_handle, |
| 612 | enum amdgpu_bo_handle_type type, |
| 613 | uint32_t *shared_handle); |
| 614 | |
| 615 | /** |
| 616 | * Request access to "shared" buffer |
| 617 | * |
| 618 | * \param dev - \c [in] Device handle. |
| 619 | * See #amdgpu_device_initialize() |
| 620 | * \param type - \c [in] Type of handle requested |
| 621 | * \param shared_handle - \c [in] Shared handle received as result "import" |
| 622 | * operation |
| 623 | * \param output - \c [out] Pointer to structure with information |
| 624 | * about imported buffer |
| 625 | * |
| 626 | * \return 0 on success\n |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 627 | * <0 - Negative POSIX Error code |
| 628 | * |
| 629 | * \note Buffer must be "imported" only using new "fd" (different from |
| 630 | * one used by "exporter"). |
| 631 | * |
| 632 | * \sa amdgpu_bo_export() |
| 633 | * |
| 634 | */ |
| 635 | int amdgpu_bo_import(amdgpu_device_handle dev, |
| 636 | enum amdgpu_bo_handle_type type, |
| 637 | uint32_t shared_handle, |
| 638 | struct amdgpu_bo_import_result *output); |
| 639 | |
| 640 | /** |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 641 | * Request GPU access to user allocated memory e.g. via "malloc" |
| 642 | * |
| 643 | * \param dev - [in] Device handle. See #amdgpu_device_initialize() |
| 644 | * \param cpu - [in] CPU address of user allocated memory which we |
| 645 | * want to map to GPU address space (make GPU accessible) |
| 646 | * (This address must be correctly aligned). |
| 647 | * \param size - [in] Size of allocation (must be correctly aligned) |
Jammy Zhou | 8aeffcc | 2015-07-13 20:57:44 +0800 | [diff] [blame] | 648 | * \param buf_handle - [out] Buffer handle for the userptr memory |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 649 | * resource on submission and be used in other operations. |
| 650 | * |
| 651 | * |
Christian König | 28462eb | 2015-06-30 16:27:27 +0200 | [diff] [blame] | 652 | * \return 0 on success\n |
| 653 | * <0 - Negative POSIX Error code |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 654 | * |
| 655 | * \note |
| 656 | * This call doesn't guarantee that such memory will be persistently |
| 657 | * "locked" / make non-pageable. The purpose of this call is to provide |
| 658 | * opportunity for GPU get access to this resource during submission. |
| 659 | * |
| 660 | * The maximum amount of memory which could be mapped in this call depends |
| 661 | * if overcommit is disabled or not. If overcommit is disabled than the max. |
| 662 | * amount of memory to be pinned will be limited by left "free" size in total |
| 663 | * amount of memory which could be locked simultaneously ("GART" size). |
| 664 | * |
| 665 | * Supported (theoretical) max. size of mapping is restricted only by |
| 666 | * "GART" size. |
| 667 | * |
| 668 | * It is responsibility of caller to correctly specify access rights |
| 669 | * on VA assignment. |
| 670 | */ |
| 671 | int amdgpu_create_bo_from_user_mem(amdgpu_device_handle dev, |
| 672 | void *cpu, uint64_t size, |
Jammy Zhou | 8aeffcc | 2015-07-13 20:57:44 +0800 | [diff] [blame] | 673 | amdgpu_bo_handle *buf_handle); |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 674 | |
| 675 | /** |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 676 | * Free previosuly allocated memory |
| 677 | * |
| 678 | * \param dev - \c [in] Device handle. See #amdgpu_device_initialize() |
| 679 | * \param buf_handle - \c [in] Buffer handle to free |
| 680 | * |
| 681 | * \return 0 on success\n |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 682 | * <0 - Negative POSIX Error code |
| 683 | * |
| 684 | * \note In the case of memory shared between different applications all |
| 685 | * resources will be “physically” freed only all such applications |
| 686 | * will be terminated |
| 687 | * \note If is UMD responsibility to ‘free’ buffer only when there is no |
| 688 | * more GPU access |
| 689 | * |
| 690 | * \sa amdgpu_bo_set_metadata(), amdgpu_bo_alloc() |
| 691 | * |
| 692 | */ |
| 693 | int amdgpu_bo_free(amdgpu_bo_handle buf_handle); |
| 694 | |
| 695 | /** |
Eric Engestrom | 0b3f978 | 2016-04-03 19:48:06 +0100 | [diff] [blame] | 696 | * Request CPU access to GPU accessible memory |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 697 | * |
| 698 | * \param buf_handle - \c [in] Buffer handle |
| 699 | * \param cpu - \c [out] CPU address to be used for access |
| 700 | * |
| 701 | * \return 0 on success\n |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 702 | * <0 - Negative POSIX Error code |
| 703 | * |
| 704 | * \sa amdgpu_bo_cpu_unmap() |
| 705 | * |
| 706 | */ |
| 707 | int amdgpu_bo_cpu_map(amdgpu_bo_handle buf_handle, void **cpu); |
| 708 | |
| 709 | /** |
| 710 | * Release CPU access to GPU memory |
| 711 | * |
| 712 | * \param buf_handle - \c [in] Buffer handle |
| 713 | * |
| 714 | * \return 0 on success\n |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 715 | * <0 - Negative POSIX Error code |
| 716 | * |
| 717 | * \sa amdgpu_bo_cpu_map() |
| 718 | * |
| 719 | */ |
| 720 | int amdgpu_bo_cpu_unmap(amdgpu_bo_handle buf_handle); |
| 721 | |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 722 | /** |
| 723 | * Wait until a buffer is not used by the device. |
| 724 | * |
Emil Velikov | c19fa2b | 2015-08-07 16:48:02 +0100 | [diff] [blame] | 725 | * \param dev - \c [in] Device handle. See #amdgpu_device_initialize() |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 726 | * \param buf_handle - \c [in] Buffer handle. |
| 727 | * \param timeout_ns - Timeout in nanoseconds. |
| 728 | * \param buffer_busy - 0 if buffer is idle, all GPU access was completed |
| 729 | * and no GPU access is scheduled. |
| 730 | * 1 GPU access is in fly or scheduled |
| 731 | * |
| 732 | * \return 0 - on success |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 733 | * <0 - Negative POSIX Error code |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 734 | */ |
| 735 | int amdgpu_bo_wait_for_idle(amdgpu_bo_handle buf_handle, |
| 736 | uint64_t timeout_ns, |
| 737 | bool *buffer_busy); |
| 738 | |
Christian König | 6dc2eaf | 2015-04-22 14:52:34 +0200 | [diff] [blame] | 739 | /** |
| 740 | * Creates a BO list handle for command submission. |
| 741 | * |
| 742 | * \param dev - \c [in] Device handle. |
| 743 | * See #amdgpu_device_initialize() |
| 744 | * \param number_of_resources - \c [in] Number of BOs in the list |
| 745 | * \param resources - \c [in] List of BO handles |
| 746 | * \param resource_prios - \c [in] Optional priority for each handle |
| 747 | * \param result - \c [out] Created BO list handle |
| 748 | * |
| 749 | * \return 0 on success\n |
Christian König | 6dc2eaf | 2015-04-22 14:52:34 +0200 | [diff] [blame] | 750 | * <0 - Negative POSIX Error code |
| 751 | * |
| 752 | * \sa amdgpu_bo_list_destroy() |
| 753 | */ |
| 754 | int amdgpu_bo_list_create(amdgpu_device_handle dev, |
| 755 | uint32_t number_of_resources, |
| 756 | amdgpu_bo_handle *resources, |
| 757 | uint8_t *resource_prios, |
| 758 | amdgpu_bo_list_handle *result); |
| 759 | |
| 760 | /** |
| 761 | * Destroys a BO list handle. |
| 762 | * |
| 763 | * \param handle - \c [in] BO list handle. |
| 764 | * |
| 765 | * \return 0 on success\n |
Christian König | 6dc2eaf | 2015-04-22 14:52:34 +0200 | [diff] [blame] | 766 | * <0 - Negative POSIX Error code |
| 767 | * |
| 768 | * \sa amdgpu_bo_list_create() |
| 769 | */ |
| 770 | int amdgpu_bo_list_destroy(amdgpu_bo_list_handle handle); |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 771 | |
Jammy Zhou | 7244698 | 2015-05-18 20:27:24 +0800 | [diff] [blame] | 772 | /** |
| 773 | * Update resources for existing BO list |
| 774 | * |
| 775 | * \param handle - \c [in] BO list handle |
| 776 | * \param number_of_resources - \c [in] Number of BOs in the list |
| 777 | * \param resources - \c [in] List of BO handles |
| 778 | * \param resource_prios - \c [in] Optional priority for each handle |
| 779 | * |
| 780 | * \return 0 on success\n |
Jammy Zhou | 7244698 | 2015-05-18 20:27:24 +0800 | [diff] [blame] | 781 | * <0 - Negative POSIX Error code |
| 782 | * |
| 783 | * \sa amdgpu_bo_list_update() |
| 784 | */ |
| 785 | int amdgpu_bo_list_update(amdgpu_bo_list_handle handle, |
| 786 | uint32_t number_of_resources, |
| 787 | amdgpu_bo_handle *resources, |
| 788 | uint8_t *resource_prios); |
| 789 | |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 790 | /* |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 791 | * GPU Execution context |
| 792 | * |
| 793 | */ |
| 794 | |
| 795 | /** |
| 796 | * Create GPU execution Context |
| 797 | * |
| 798 | * For the purpose of GPU Scheduler and GPU Robustness extensions it is |
| 799 | * necessary to have information/identify rendering/compute contexts. |
| 800 | * It also may be needed to associate some specific requirements with such |
| 801 | * contexts. Kernel driver will guarantee that submission from the same |
| 802 | * context will always be executed in order (first come, first serve). |
| 803 | * |
| 804 | * |
Andres Rodriguez | 35bc82c | 2017-10-20 10:57:59 -0400 | [diff] [blame] | 805 | * \param dev - \c [in] Device handle. See #amdgpu_device_initialize() |
| 806 | * \param priority - \c [in] Context creation flags. See AMDGPU_CTX_PRIORITY_* |
| 807 | * \param context - \c [out] GPU Context handle |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 808 | * |
| 809 | * \return 0 on success\n |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 810 | * <0 - Negative POSIX Error code |
| 811 | * |
| 812 | * \sa amdgpu_cs_ctx_free() |
| 813 | * |
| 814 | */ |
Andres Rodriguez | 35bc82c | 2017-10-20 10:57:59 -0400 | [diff] [blame] | 815 | int amdgpu_cs_ctx_create2(amdgpu_device_handle dev, |
| 816 | uint32_t priority, |
| 817 | amdgpu_context_handle *context); |
| 818 | /** |
| 819 | * Create GPU execution Context |
| 820 | * |
| 821 | * Refer to amdgpu_cs_ctx_create2 for full documentation. This call |
| 822 | * is missing the priority parameter. |
| 823 | * |
| 824 | * \sa amdgpu_cs_ctx_create2() |
| 825 | * |
| 826 | */ |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 827 | int amdgpu_cs_ctx_create(amdgpu_device_handle dev, |
| 828 | amdgpu_context_handle *context); |
| 829 | |
| 830 | /** |
| 831 | * |
| 832 | * Destroy GPU execution context when not needed any more |
| 833 | * |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 834 | * \param context - \c [in] GPU Context handle |
| 835 | * |
| 836 | * \return 0 on success\n |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 837 | * <0 - Negative POSIX Error code |
| 838 | * |
| 839 | * \sa amdgpu_cs_ctx_create() |
| 840 | * |
| 841 | */ |
Christian König | 9c2afff | 2015-04-22 12:21:13 +0200 | [diff] [blame] | 842 | int amdgpu_cs_ctx_free(amdgpu_context_handle context); |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 843 | |
| 844 | /** |
| 845 | * Query reset state for the specific GPU Context |
| 846 | * |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 847 | * \param context - \c [in] GPU Context handle |
Marek Olšák | 4b39a8e | 2015-05-05 21:23:02 +0200 | [diff] [blame] | 848 | * \param state - \c [out] One of AMDGPU_CTX_*_RESET |
| 849 | * \param hangs - \c [out] Number of hangs caused by the context. |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 850 | * |
| 851 | * \return 0 on success\n |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 852 | * <0 - Negative POSIX Error code |
| 853 | * |
| 854 | * \sa amdgpu_cs_ctx_create() |
| 855 | * |
| 856 | */ |
Christian König | 9c2afff | 2015-04-22 12:21:13 +0200 | [diff] [blame] | 857 | int amdgpu_cs_query_reset_state(amdgpu_context_handle context, |
Marek Olšák | 4b39a8e | 2015-05-05 21:23:02 +0200 | [diff] [blame] | 858 | uint32_t *state, uint32_t *hangs); |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 859 | |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 860 | /* |
| 861 | * Command Buffers Management |
| 862 | * |
| 863 | */ |
| 864 | |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 865 | /** |
| 866 | * Send request to submit command buffers to hardware. |
| 867 | * |
| 868 | * Kernel driver could use GPU Scheduler to make decision when physically |
| 869 | * sent this request to the hardware. Accordingly this request could be put |
| 870 | * in queue and sent for execution later. The only guarantee is that request |
| 871 | * from the same GPU context to the same ip:ip_instance:ring will be executed in |
| 872 | * order. |
| 873 | * |
Ken Wang | 926c805 | 2015-07-10 22:22:27 +0800 | [diff] [blame] | 874 | * The caller can specify the user fence buffer/location with the fence_info in the |
Eric Engestrom | 0b3f978 | 2016-04-03 19:48:06 +0100 | [diff] [blame] | 875 | * cs_request.The sequence number is returned via the 'seq_no' parameter |
Ken Wang | 926c805 | 2015-07-10 22:22:27 +0800 | [diff] [blame] | 876 | * in ibs_request structure. |
| 877 | * |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 878 | * |
| 879 | * \param dev - \c [in] Device handle. |
| 880 | * See #amdgpu_device_initialize() |
| 881 | * \param context - \c [in] GPU Context |
| 882 | * \param flags - \c [in] Global submission flags |
Ken Wang | 926c805 | 2015-07-10 22:22:27 +0800 | [diff] [blame] | 883 | * \param ibs_request - \c [in/out] Pointer to submission requests. |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 884 | * We could submit to the several |
| 885 | * engines/rings simulteniously as |
| 886 | * 'atomic' operation |
| 887 | * \param number_of_requests - \c [in] Number of submission requests |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 888 | * |
| 889 | * \return 0 on success\n |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 890 | * <0 - Negative POSIX Error code |
| 891 | * |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 892 | * \note It is required to pass correct resource list with buffer handles |
| 893 | * which will be accessible by command buffers from submission |
| 894 | * This will allow kernel driver to correctly implement "paging". |
| 895 | * Failure to do so will have unpredictable results. |
| 896 | * |
| 897 | * \sa amdgpu_command_buffer_alloc(), amdgpu_command_buffer_free(), |
| 898 | * amdgpu_cs_query_fence_status() |
| 899 | * |
| 900 | */ |
Christian König | 9c2afff | 2015-04-22 12:21:13 +0200 | [diff] [blame] | 901 | int amdgpu_cs_submit(amdgpu_context_handle context, |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 902 | uint64_t flags, |
| 903 | struct amdgpu_cs_request *ibs_request, |
Ken Wang | 926c805 | 2015-07-10 22:22:27 +0800 | [diff] [blame] | 904 | uint32_t number_of_requests); |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 905 | |
| 906 | /** |
| 907 | * Query status of Command Buffer Submission |
| 908 | * |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 909 | * \param fence - \c [in] Structure describing fence to query |
Jammy Zhou | f91b56d | 2015-07-09 13:51:13 +0800 | [diff] [blame] | 910 | * \param timeout_ns - \c [in] Timeout value to wait |
| 911 | * \param flags - \c [in] Flags for the query |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 912 | * \param expired - \c [out] If fence expired or not.\n |
| 913 | * 0 – if fence is not expired\n |
| 914 | * !0 - otherwise |
| 915 | * |
| 916 | * \return 0 on success\n |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 917 | * <0 - Negative POSIX Error code |
| 918 | * |
| 919 | * \note If UMD wants only to check operation status and returned immediately |
| 920 | * then timeout value as 0 must be passed. In this case success will be |
| 921 | * returned in the case if submission was completed or timeout error |
| 922 | * code. |
| 923 | * |
| 924 | * \sa amdgpu_cs_submit() |
| 925 | */ |
Christian König | 5463d2e | 2015-07-09 11:48:32 +0200 | [diff] [blame] | 926 | int amdgpu_cs_query_fence_status(struct amdgpu_cs_fence *fence, |
Jammy Zhou | f91b56d | 2015-07-09 13:51:13 +0800 | [diff] [blame] | 927 | uint64_t timeout_ns, |
| 928 | uint64_t flags, |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 929 | uint32_t *expired); |
| 930 | |
Nicolai Hähnle | d8d45a4 | 2017-04-13 16:43:14 +0200 | [diff] [blame] | 931 | /** |
| 932 | * Wait for multiple fences |
| 933 | * |
| 934 | * \param fences - \c [in] The fence array to wait |
| 935 | * \param fence_count - \c [in] The fence count |
| 936 | * \param wait_all - \c [in] If true, wait all fences to be signaled, |
| 937 | * otherwise, wait at least one fence |
| 938 | * \param timeout_ns - \c [in] The timeout to wait, in nanoseconds |
| 939 | * \param status - \c [out] '1' for signaled, '0' for timeout |
| 940 | * \param first - \c [out] the index of the first signaled fence from @fences |
| 941 | * |
| 942 | * \return 0 on success |
| 943 | * <0 - Negative POSIX Error code |
| 944 | * |
| 945 | * \note Currently it supports only one amdgpu_device. All fences come from |
| 946 | * the same amdgpu_device with the same fd. |
| 947 | */ |
| 948 | int amdgpu_cs_wait_fences(struct amdgpu_cs_fence *fences, |
| 949 | uint32_t fence_count, |
| 950 | bool wait_all, |
| 951 | uint64_t timeout_ns, |
| 952 | uint32_t *status, uint32_t *first); |
| 953 | |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 954 | /* |
| 955 | * Query / Info API |
| 956 | * |
| 957 | */ |
| 958 | |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 959 | /** |
| 960 | * Query allocation size alignments |
| 961 | * |
| 962 | * UMD should query information about GPU VM MC size alignments requirements |
| 963 | * to be able correctly choose required allocation size and implement |
| 964 | * internal optimization if needed. |
| 965 | * |
| 966 | * \param dev - \c [in] Device handle. See #amdgpu_device_initialize() |
| 967 | * \param info - \c [out] Pointer to structure to get size alignment |
| 968 | * requirements |
| 969 | * |
| 970 | * \return 0 on success\n |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 971 | * <0 - Negative POSIX Error code |
| 972 | * |
| 973 | */ |
| 974 | int amdgpu_query_buffer_size_alignment(amdgpu_device_handle dev, |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 975 | struct amdgpu_buffer_size_alignments |
| 976 | *info); |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 977 | |
| 978 | /** |
| 979 | * Query firmware versions |
| 980 | * |
| 981 | * \param dev - \c [in] Device handle. See #amdgpu_device_initialize() |
| 982 | * \param fw_type - \c [in] AMDGPU_INFO_FW_* |
| 983 | * \param ip_instance - \c [in] Index of the IP block of the same type. |
| 984 | * \param index - \c [in] Index of the engine. (for SDMA and MEC) |
| 985 | * \param version - \c [out] Pointer to to the "version" return value |
| 986 | * \param feature - \c [out] Pointer to to the "feature" return value |
| 987 | * |
| 988 | * \return 0 on success\n |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 989 | * <0 - Negative POSIX Error code |
| 990 | * |
| 991 | */ |
| 992 | int amdgpu_query_firmware_version(amdgpu_device_handle dev, unsigned fw_type, |
| 993 | unsigned ip_instance, unsigned index, |
| 994 | uint32_t *version, uint32_t *feature); |
| 995 | |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 996 | /** |
| 997 | * Query the number of HW IP instances of a certain type. |
| 998 | * |
| 999 | * \param dev - \c [in] Device handle. See #amdgpu_device_initialize() |
| 1000 | * \param type - \c [in] Hardware IP block type = AMDGPU_HW_IP_* |
| 1001 | * \param count - \c [out] Pointer to structure to get information |
| 1002 | * |
| 1003 | * \return 0 on success\n |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 1004 | * <0 - Negative POSIX Error code |
| 1005 | */ |
| 1006 | int amdgpu_query_hw_ip_count(amdgpu_device_handle dev, unsigned type, |
| 1007 | uint32_t *count); |
| 1008 | |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 1009 | /** |
| 1010 | * Query engine information |
| 1011 | * |
| 1012 | * This query allows UMD to query information different engines and their |
| 1013 | * capabilities. |
| 1014 | * |
| 1015 | * \param dev - \c [in] Device handle. See #amdgpu_device_initialize() |
| 1016 | * \param type - \c [in] Hardware IP block type = AMDGPU_HW_IP_* |
| 1017 | * \param ip_instance - \c [in] Index of the IP block of the same type. |
| 1018 | * \param info - \c [out] Pointer to structure to get information |
| 1019 | * |
| 1020 | * \return 0 on success\n |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 1021 | * <0 - Negative POSIX Error code |
| 1022 | */ |
| 1023 | int amdgpu_query_hw_ip_info(amdgpu_device_handle dev, unsigned type, |
| 1024 | unsigned ip_instance, |
| 1025 | struct drm_amdgpu_info_hw_ip *info); |
| 1026 | |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 1027 | /** |
| 1028 | * Query heap information |
| 1029 | * |
| 1030 | * This query allows UMD to query potentially available memory resources and |
| 1031 | * adjust their logic if necessary. |
| 1032 | * |
| 1033 | * \param dev - \c [in] Device handle. See #amdgpu_device_initialize() |
| 1034 | * \param heap - \c [in] Heap type |
| 1035 | * \param info - \c [in] Pointer to structure to get needed information |
| 1036 | * |
| 1037 | * \return 0 on success\n |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 1038 | * <0 - Negative POSIX Error code |
| 1039 | * |
| 1040 | */ |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 1041 | int amdgpu_query_heap_info(amdgpu_device_handle dev, uint32_t heap, |
| 1042 | uint32_t flags, struct amdgpu_heap_info *info); |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 1043 | |
| 1044 | /** |
| 1045 | * Get the CRTC ID from the mode object ID |
| 1046 | * |
| 1047 | * \param dev - \c [in] Device handle. See #amdgpu_device_initialize() |
| 1048 | * \param id - \c [in] Mode object ID |
| 1049 | * \param result - \c [in] Pointer to the CRTC ID |
| 1050 | * |
| 1051 | * \return 0 on success\n |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 1052 | * <0 - Negative POSIX Error code |
| 1053 | * |
| 1054 | */ |
| 1055 | int amdgpu_query_crtc_from_id(amdgpu_device_handle dev, unsigned id, |
| 1056 | int32_t *result); |
| 1057 | |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 1058 | /** |
| 1059 | * Query GPU H/w Info |
| 1060 | * |
| 1061 | * Query hardware specific information |
| 1062 | * |
| 1063 | * \param dev - \c [in] Device handle. See #amdgpu_device_initialize() |
| 1064 | * \param heap - \c [in] Heap type |
| 1065 | * \param info - \c [in] Pointer to structure to get needed information |
| 1066 | * |
| 1067 | * \return 0 on success\n |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 1068 | * <0 - Negative POSIX Error code |
| 1069 | * |
| 1070 | */ |
| 1071 | int amdgpu_query_gpu_info(amdgpu_device_handle dev, |
| 1072 | struct amdgpu_gpu_info *info); |
| 1073 | |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 1074 | /** |
| 1075 | * Query hardware or driver information. |
| 1076 | * |
| 1077 | * The return size is query-specific and depends on the "info_id" parameter. |
| 1078 | * No more than "size" bytes is returned. |
| 1079 | * |
| 1080 | * \param dev - \c [in] Device handle. See #amdgpu_device_initialize() |
| 1081 | * \param info_id - \c [in] AMDGPU_INFO_* |
| 1082 | * \param size - \c [in] Size of the returned value. |
| 1083 | * \param value - \c [out] Pointer to the return value. |
| 1084 | * |
| 1085 | * \return 0 on success\n |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 1086 | * <0 - Negative POSIX error code |
| 1087 | * |
| 1088 | */ |
| 1089 | int amdgpu_query_info(amdgpu_device_handle dev, unsigned info_id, |
| 1090 | unsigned size, void *value); |
| 1091 | |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 1092 | /** |
Marek Olšák | ad5b702 | 2018-02-02 18:15:00 +0100 | [diff] [blame^] | 1093 | * Query hardware or driver information. |
| 1094 | * |
| 1095 | * The return size is query-specific and depends on the "info_id" parameter. |
| 1096 | * No more than "size" bytes is returned. |
| 1097 | * |
| 1098 | * \param dev - \c [in] Device handle. See #amdgpu_device_initialize() |
| 1099 | * \param info - \c [in] amdgpu_sw_info_* |
| 1100 | * \param value - \c [out] Pointer to the return value. |
| 1101 | * |
| 1102 | * \return 0 on success\n |
| 1103 | * <0 - Negative POSIX error code |
| 1104 | * |
| 1105 | */ |
| 1106 | int amdgpu_query_sw_info(amdgpu_device_handle dev, enum amdgpu_sw_info info, |
| 1107 | void *value); |
| 1108 | |
| 1109 | /** |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 1110 | * Query information about GDS |
| 1111 | * |
| 1112 | * \param dev - \c [in] Device handle. See #amdgpu_device_initialize() |
| 1113 | * \param gds_info - \c [out] Pointer to structure to get GDS information |
| 1114 | * |
| 1115 | * \return 0 on success\n |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 1116 | * <0 - Negative POSIX Error code |
| 1117 | * |
| 1118 | */ |
| 1119 | int amdgpu_query_gds_info(amdgpu_device_handle dev, |
| 1120 | struct amdgpu_gds_resource_info *gds_info); |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 1121 | |
| 1122 | /** |
Samuel Pitoiset | 047aba1 | 2017-04-04 16:34:56 +0200 | [diff] [blame] | 1123 | * Query information about sensor. |
| 1124 | * |
| 1125 | * The return size is query-specific and depends on the "sensor_type" |
| 1126 | * parameter. No more than "size" bytes is returned. |
| 1127 | * |
| 1128 | * \param dev - \c [in] Device handle. See #amdgpu_device_initialize() |
| 1129 | * \param sensor_type - \c [in] AMDGPU_INFO_SENSOR_* |
| 1130 | * \param size - \c [in] Size of the returned value. |
| 1131 | * \param value - \c [out] Pointer to the return value. |
| 1132 | * |
| 1133 | * \return 0 on success\n |
| 1134 | * <0 - Negative POSIX Error code |
| 1135 | * |
| 1136 | */ |
| 1137 | int amdgpu_query_sensor_info(amdgpu_device_handle dev, unsigned sensor_type, |
| 1138 | unsigned size, void *value); |
| 1139 | |
| 1140 | /** |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 1141 | * Read a set of consecutive memory-mapped registers. |
| 1142 | * Not all registers are allowed to be read by userspace. |
| 1143 | * |
| 1144 | * \param dev - \c [in] Device handle. See #amdgpu_device_initialize( |
| 1145 | * \param dword_offset - \c [in] Register offset in dwords |
| 1146 | * \param count - \c [in] The number of registers to read starting |
| 1147 | * from the offset |
| 1148 | * \param instance - \c [in] GRBM_GFX_INDEX selector. It may have other |
| 1149 | * uses. Set it to 0xffffffff if unsure. |
| 1150 | * \param flags - \c [in] Flags with additional information. |
| 1151 | * \param values - \c [out] The pointer to return values. |
| 1152 | * |
| 1153 | * \return 0 on success\n |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 1154 | * <0 - Negative POSIX error code |
| 1155 | * |
| 1156 | */ |
| 1157 | int amdgpu_read_mm_registers(amdgpu_device_handle dev, unsigned dword_offset, |
| 1158 | unsigned count, uint32_t instance, uint32_t flags, |
| 1159 | uint32_t *values); |
| 1160 | |
Sabre Shao | 23fab59 | 2015-07-09 13:50:36 +0800 | [diff] [blame] | 1161 | /** |
Jammy Zhou | ffa305d | 2015-08-17 11:09:08 +0800 | [diff] [blame] | 1162 | * Flag to request VA address range in the 32bit address space |
| 1163 | */ |
| 1164 | #define AMDGPU_VA_RANGE_32_BIT 0x1 |
| 1165 | |
| 1166 | /** |
Sabre Shao | 23fab59 | 2015-07-09 13:50:36 +0800 | [diff] [blame] | 1167 | * Allocate virtual address range |
| 1168 | * |
| 1169 | * \param dev - [in] Device handle. See #amdgpu_device_initialize() |
| 1170 | * \param va_range_type - \c [in] Type of MC va range from which to allocate |
| 1171 | * \param size - \c [in] Size of range. Size must be correctly* aligned. |
| 1172 | * It is client responsibility to correctly aligned size based on the future |
| 1173 | * usage of allocated range. |
| 1174 | * \param va_base_alignment - \c [in] Overwrite base address alignment |
| 1175 | * requirement for GPU VM MC virtual |
| 1176 | * address assignment. Must be multiple of size alignments received as |
| 1177 | * 'amdgpu_buffer_size_alignments'. |
| 1178 | * If 0 use the default one. |
| 1179 | * \param va_base_required - \c [in] Specified required va base address. |
| 1180 | * If 0 then library choose available one. |
| 1181 | * If !0 value will be passed and those value already "in use" then |
| 1182 | * corresponding error status will be returned. |
| 1183 | * \param va_base_allocated - \c [out] On return: Allocated VA base to be used |
| 1184 | * by client. |
| 1185 | * \param va_range_handle - \c [out] On return: Handle assigned to allocation |
Jammy Zhou | 95d0f35 | 2015-07-16 10:29:58 +0800 | [diff] [blame] | 1186 | * \param flags - \c [in] flags for special VA range |
Sabre Shao | 23fab59 | 2015-07-09 13:50:36 +0800 | [diff] [blame] | 1187 | * |
| 1188 | * \return 0 on success\n |
| 1189 | * >0 - AMD specific error code\n |
| 1190 | * <0 - Negative POSIX Error code |
| 1191 | * |
| 1192 | * \notes \n |
| 1193 | * It is client responsibility to correctly handle VA assignments and usage. |
| 1194 | * Neither kernel driver nor libdrm_amdpgu are able to prevent and |
| 1195 | * detect wrong va assignemnt. |
| 1196 | * |
| 1197 | * It is client responsibility to correctly handle multi-GPU cases and to pass |
| 1198 | * the corresponding arrays of all devices handles where corresponding VA will |
| 1199 | * be used. |
| 1200 | * |
| 1201 | */ |
| 1202 | int amdgpu_va_range_alloc(amdgpu_device_handle dev, |
| 1203 | enum amdgpu_gpu_va_range va_range_type, |
| 1204 | uint64_t size, |
| 1205 | uint64_t va_base_alignment, |
| 1206 | uint64_t va_base_required, |
| 1207 | uint64_t *va_base_allocated, |
Jammy Zhou | 95d0f35 | 2015-07-16 10:29:58 +0800 | [diff] [blame] | 1208 | amdgpu_va_handle *va_range_handle, |
| 1209 | uint64_t flags); |
Sabre Shao | 23fab59 | 2015-07-09 13:50:36 +0800 | [diff] [blame] | 1210 | |
| 1211 | /** |
| 1212 | * Free previously allocated virtual address range |
| 1213 | * |
| 1214 | * |
| 1215 | * \param va_range_handle - \c [in] Handle assigned to VA allocation |
| 1216 | * |
| 1217 | * \return 0 on success\n |
| 1218 | * >0 - AMD specific error code\n |
| 1219 | * <0 - Negative POSIX Error code |
| 1220 | * |
| 1221 | */ |
| 1222 | int amdgpu_va_range_free(amdgpu_va_handle va_range_handle); |
| 1223 | |
Sabre Shao | 12802da | 2015-07-09 13:53:24 +0800 | [diff] [blame] | 1224 | /** |
| 1225 | * Query virtual address range |
| 1226 | * |
| 1227 | * UMD can query GPU VM range supported by each device |
| 1228 | * to initialize its own VAM accordingly. |
| 1229 | * |
| 1230 | * \param dev - [in] Device handle. See #amdgpu_device_initialize() |
| 1231 | * \param type - \c [in] Type of virtual address range |
| 1232 | * \param offset - \c [out] Start offset of virtual address range |
| 1233 | * \param size - \c [out] Size of virtual address range |
| 1234 | * |
| 1235 | * \return 0 on success\n |
| 1236 | * <0 - Negative POSIX Error code |
| 1237 | * |
| 1238 | */ |
| 1239 | |
| 1240 | int amdgpu_va_range_query(amdgpu_device_handle dev, |
| 1241 | enum amdgpu_gpu_va_range type, |
| 1242 | uint64_t *start, |
| 1243 | uint64_t *end); |
| 1244 | |
Jammy Zhou | 8aeffcc | 2015-07-13 20:57:44 +0800 | [diff] [blame] | 1245 | /** |
| 1246 | * VA mapping/unmapping for the buffer object |
| 1247 | * |
| 1248 | * \param bo - \c [in] BO handle |
| 1249 | * \param offset - \c [in] Start offset to map |
| 1250 | * \param size - \c [in] Size to map |
| 1251 | * \param addr - \c [in] Start virtual address. |
| 1252 | * \param flags - \c [in] Supported flags for mapping/unmapping |
| 1253 | * \param ops - \c [in] AMDGPU_VA_OP_MAP or AMDGPU_VA_OP_UNMAP |
| 1254 | * |
| 1255 | * \return 0 on success\n |
| 1256 | * <0 - Negative POSIX Error code |
| 1257 | * |
| 1258 | */ |
| 1259 | |
| 1260 | int amdgpu_bo_va_op(amdgpu_bo_handle bo, |
| 1261 | uint64_t offset, |
| 1262 | uint64_t size, |
| 1263 | uint64_t addr, |
| 1264 | uint64_t flags, |
| 1265 | uint32_t ops); |
| 1266 | |
Marek Olšák | 6afadea | 2016-01-12 22:13:07 +0100 | [diff] [blame] | 1267 | /** |
Nicolai Hähnle | 4e369f2 | 2017-02-08 13:02:56 +0100 | [diff] [blame] | 1268 | * VA mapping/unmapping for a buffer object or PRT region. |
| 1269 | * |
| 1270 | * This is not a simple drop-in extension for amdgpu_bo_va_op; instead, all |
| 1271 | * parameters are treated "raw", i.e. size is not automatically aligned, and |
| 1272 | * all flags must be specified explicitly. |
| 1273 | * |
| 1274 | * \param dev - \c [in] device handle |
| 1275 | * \param bo - \c [in] BO handle (may be NULL) |
| 1276 | * \param offset - \c [in] Start offset to map |
| 1277 | * \param size - \c [in] Size to map |
| 1278 | * \param addr - \c [in] Start virtual address. |
| 1279 | * \param flags - \c [in] Supported flags for mapping/unmapping |
| 1280 | * \param ops - \c [in] AMDGPU_VA_OP_MAP or AMDGPU_VA_OP_UNMAP |
| 1281 | * |
| 1282 | * \return 0 on success\n |
| 1283 | * <0 - Negative POSIX Error code |
| 1284 | * |
| 1285 | */ |
| 1286 | |
| 1287 | int amdgpu_bo_va_op_raw(amdgpu_device_handle dev, |
| 1288 | amdgpu_bo_handle bo, |
| 1289 | uint64_t offset, |
| 1290 | uint64_t size, |
| 1291 | uint64_t addr, |
| 1292 | uint64_t flags, |
| 1293 | uint32_t ops); |
| 1294 | |
| 1295 | /** |
Marek Olšák | 6afadea | 2016-01-12 22:13:07 +0100 | [diff] [blame] | 1296 | * create semaphore |
| 1297 | * |
| 1298 | * \param sem - \c [out] semaphore handle |
| 1299 | * |
| 1300 | * \return 0 on success\n |
| 1301 | * <0 - Negative POSIX Error code |
| 1302 | * |
| 1303 | */ |
| 1304 | int amdgpu_cs_create_semaphore(amdgpu_semaphore_handle *sem); |
| 1305 | |
| 1306 | /** |
| 1307 | * signal semaphore |
| 1308 | * |
| 1309 | * \param context - \c [in] GPU Context |
| 1310 | * \param ip_type - \c [in] Hardware IP block type = AMDGPU_HW_IP_* |
| 1311 | * \param ip_instance - \c [in] Index of the IP block of the same type |
| 1312 | * \param ring - \c [in] Specify ring index of the IP |
| 1313 | * \param sem - \c [in] semaphore handle |
| 1314 | * |
| 1315 | * \return 0 on success\n |
| 1316 | * <0 - Negative POSIX Error code |
| 1317 | * |
| 1318 | */ |
| 1319 | int amdgpu_cs_signal_semaphore(amdgpu_context_handle ctx, |
| 1320 | uint32_t ip_type, |
| 1321 | uint32_t ip_instance, |
| 1322 | uint32_t ring, |
| 1323 | amdgpu_semaphore_handle sem); |
| 1324 | |
| 1325 | /** |
| 1326 | * wait semaphore |
| 1327 | * |
| 1328 | * \param context - \c [in] GPU Context |
| 1329 | * \param ip_type - \c [in] Hardware IP block type = AMDGPU_HW_IP_* |
| 1330 | * \param ip_instance - \c [in] Index of the IP block of the same type |
| 1331 | * \param ring - \c [in] Specify ring index of the IP |
| 1332 | * \param sem - \c [in] semaphore handle |
| 1333 | * |
| 1334 | * \return 0 on success\n |
| 1335 | * <0 - Negative POSIX Error code |
| 1336 | * |
| 1337 | */ |
| 1338 | int amdgpu_cs_wait_semaphore(amdgpu_context_handle ctx, |
| 1339 | uint32_t ip_type, |
| 1340 | uint32_t ip_instance, |
| 1341 | uint32_t ring, |
| 1342 | amdgpu_semaphore_handle sem); |
| 1343 | |
| 1344 | /** |
| 1345 | * destroy semaphore |
| 1346 | * |
| 1347 | * \param sem - \c [in] semaphore handle |
| 1348 | * |
| 1349 | * \return 0 on success\n |
| 1350 | * <0 - Negative POSIX Error code |
| 1351 | * |
| 1352 | */ |
| 1353 | int amdgpu_cs_destroy_semaphore(amdgpu_semaphore_handle sem); |
| 1354 | |
Junwei Zhang | 670f1e4 | 2016-09-12 11:14:11 -0400 | [diff] [blame] | 1355 | /** |
| 1356 | * Get the ASIC marketing name |
| 1357 | * |
| 1358 | * \param dev - \c [in] Device handle. See #amdgpu_device_initialize() |
| 1359 | * |
| 1360 | * \return the constant string of the marketing name |
| 1361 | * "NULL" means the ASIC is not found |
| 1362 | */ |
| 1363 | const char *amdgpu_get_marketing_name(amdgpu_device_handle dev); |
| 1364 | |
Dave Airlie | 69532d0 | 2017-07-16 20:18:40 +0100 | [diff] [blame] | 1365 | /** |
| 1366 | * Create kernel sync object |
| 1367 | * |
David Mao | 1749d56 | 2017-11-28 11:22:26 +0800 | [diff] [blame] | 1368 | * \param dev - \c [in] device handle |
| 1369 | * \param flags - \c [in] flags that affect creation |
| 1370 | * \param syncobj - \c [out] sync object handle |
| 1371 | * |
| 1372 | * \return 0 on success\n |
| 1373 | * <0 - Negative POSIX Error code |
| 1374 | * |
| 1375 | */ |
| 1376 | int amdgpu_cs_create_syncobj2(amdgpu_device_handle dev, |
| 1377 | uint32_t flags, |
| 1378 | uint32_t *syncobj); |
| 1379 | |
| 1380 | /** |
| 1381 | * Create kernel sync object |
| 1382 | * |
Dave Airlie | 69532d0 | 2017-07-16 20:18:40 +0100 | [diff] [blame] | 1383 | * \param dev - \c [in] device handle |
| 1384 | * \param syncobj - \c [out] sync object handle |
| 1385 | * |
| 1386 | * \return 0 on success\n |
| 1387 | * <0 - Negative POSIX Error code |
| 1388 | * |
| 1389 | */ |
| 1390 | int amdgpu_cs_create_syncobj(amdgpu_device_handle dev, |
| 1391 | uint32_t *syncobj); |
| 1392 | /** |
| 1393 | * Destroy kernel sync object |
| 1394 | * |
| 1395 | * \param dev - \c [in] device handle |
| 1396 | * \param syncobj - \c [in] sync object handle |
| 1397 | * |
| 1398 | * \return 0 on success\n |
| 1399 | * <0 - Negative POSIX Error code |
| 1400 | * |
| 1401 | */ |
| 1402 | int amdgpu_cs_destroy_syncobj(amdgpu_device_handle dev, |
| 1403 | uint32_t syncobj); |
| 1404 | |
| 1405 | /** |
Bas Nieuwenhuizen | 5889f6b | 2017-12-17 00:27:10 +0100 | [diff] [blame] | 1406 | * Reset kernel sync objects to unsignalled state. |
| 1407 | * |
| 1408 | * \param dev - \c [in] device handle |
| 1409 | * \param syncobjs - \c [in] array of sync object handles |
| 1410 | * \param syncobj_count - \c [in] number of handles in syncobjs |
| 1411 | * |
| 1412 | * \return 0 on success\n |
| 1413 | * <0 - Negative POSIX Error code |
| 1414 | * |
| 1415 | */ |
| 1416 | int amdgpu_cs_syncobj_reset(amdgpu_device_handle dev, |
| 1417 | const uint32_t *syncobjs, uint32_t syncobj_count); |
| 1418 | |
| 1419 | /** |
| 1420 | * Signal kernel sync objects. |
| 1421 | * |
| 1422 | * \param dev - \c [in] device handle |
| 1423 | * \param syncobjs - \c [in] array of sync object handles |
| 1424 | * \param syncobj_count - \c [in] number of handles in syncobjs |
| 1425 | * |
| 1426 | * \return 0 on success\n |
| 1427 | * <0 - Negative POSIX Error code |
| 1428 | * |
| 1429 | */ |
| 1430 | int amdgpu_cs_syncobj_signal(amdgpu_device_handle dev, |
| 1431 | const uint32_t *syncobjs, uint32_t syncobj_count); |
| 1432 | |
| 1433 | /** |
Marek Olšák | 59aa57b | 2017-09-11 21:58:03 +0200 | [diff] [blame] | 1434 | * Wait for one or all sync objects to signal. |
| 1435 | * |
| 1436 | * \param dev - \c [in] self-explanatory |
| 1437 | * \param handles - \c [in] array of sync object handles |
| 1438 | * \param num_handles - \c [in] self-explanatory |
| 1439 | * \param timeout_nsec - \c [in] self-explanatory |
| 1440 | * \param flags - \c [in] a bitmask of DRM_SYNCOBJ_WAIT_FLAGS_* |
| 1441 | * \param first_signaled - \c [in] self-explanatory |
| 1442 | * |
| 1443 | * \return 0 on success\n |
| 1444 | * -ETIME - Timeout |
| 1445 | * <0 - Negative POSIX Error code |
| 1446 | * |
| 1447 | */ |
| 1448 | int amdgpu_cs_syncobj_wait(amdgpu_device_handle dev, |
| 1449 | uint32_t *handles, unsigned num_handles, |
| 1450 | int64_t timeout_nsec, unsigned flags, |
| 1451 | uint32_t *first_signaled); |
| 1452 | |
| 1453 | /** |
Dave Airlie | 69532d0 | 2017-07-16 20:18:40 +0100 | [diff] [blame] | 1454 | * Export kernel sync object to shareable fd. |
| 1455 | * |
| 1456 | * \param dev - \c [in] device handle |
| 1457 | * \param syncobj - \c [in] sync object handle |
| 1458 | * \param shared_fd - \c [out] shared file descriptor. |
| 1459 | * |
| 1460 | * \return 0 on success\n |
| 1461 | * <0 - Negative POSIX Error code |
| 1462 | * |
| 1463 | */ |
| 1464 | int amdgpu_cs_export_syncobj(amdgpu_device_handle dev, |
| 1465 | uint32_t syncobj, |
| 1466 | int *shared_fd); |
| 1467 | /** |
| 1468 | * Import kernel sync object from shareable fd. |
| 1469 | * |
| 1470 | * \param dev - \c [in] device handle |
| 1471 | * \param shared_fd - \c [in] shared file descriptor. |
| 1472 | * \param syncobj - \c [out] sync object handle |
| 1473 | * |
| 1474 | * \return 0 on success\n |
| 1475 | * <0 - Negative POSIX Error code |
| 1476 | * |
| 1477 | */ |
| 1478 | int amdgpu_cs_import_syncobj(amdgpu_device_handle dev, |
| 1479 | int shared_fd, |
| 1480 | uint32_t *syncobj); |
| 1481 | |
Dave Airlie | 22790a6 | 2017-07-18 01:31:27 +0100 | [diff] [blame] | 1482 | /** |
Marek Olšák | b6e2450 | 2017-09-11 21:12:12 +0200 | [diff] [blame] | 1483 | * Export kernel sync object to a sync_file. |
| 1484 | * |
| 1485 | * \param dev - \c [in] device handle |
| 1486 | * \param syncobj - \c [in] sync object handle |
| 1487 | * \param sync_file_fd - \c [out] sync_file file descriptor. |
| 1488 | * |
| 1489 | * \return 0 on success\n |
| 1490 | * <0 - Negative POSIX Error code |
| 1491 | * |
| 1492 | */ |
| 1493 | int amdgpu_cs_syncobj_export_sync_file(amdgpu_device_handle dev, |
| 1494 | uint32_t syncobj, |
| 1495 | int *sync_file_fd); |
| 1496 | |
| 1497 | /** |
| 1498 | * Import kernel sync object from a sync_file. |
| 1499 | * |
| 1500 | * \param dev - \c [in] device handle |
| 1501 | * \param syncobj - \c [in] sync object handle |
| 1502 | * \param sync_file_fd - \c [in] sync_file file descriptor. |
| 1503 | * |
| 1504 | * \return 0 on success\n |
| 1505 | * <0 - Negative POSIX Error code |
| 1506 | * |
| 1507 | */ |
| 1508 | int amdgpu_cs_syncobj_import_sync_file(amdgpu_device_handle dev, |
| 1509 | uint32_t syncobj, |
| 1510 | int sync_file_fd); |
| 1511 | |
| 1512 | /** |
Marek Olšák | c74d461 | 2017-09-08 16:05:54 +0200 | [diff] [blame] | 1513 | * Export an amdgpu fence as a handle (syncobj or fd). |
| 1514 | * |
| 1515 | * \param what AMDGPU_FENCE_TO_HANDLE_GET_{SYNCOBJ, FD} |
| 1516 | * \param out_handle returned handle |
| 1517 | * |
| 1518 | * \return 0 on success\n |
| 1519 | * <0 - Negative POSIX Error code |
| 1520 | */ |
| 1521 | int amdgpu_cs_fence_to_handle(amdgpu_device_handle dev, |
| 1522 | struct amdgpu_cs_fence *fence, |
| 1523 | uint32_t what, |
| 1524 | uint32_t *out_handle); |
| 1525 | |
| 1526 | /** |
Dave Airlie | 22790a6 | 2017-07-18 01:31:27 +0100 | [diff] [blame] | 1527 | * Submit raw command submission to kernel |
| 1528 | * |
| 1529 | * \param dev - \c [in] device handle |
| 1530 | * \param context - \c [in] context handle for context id |
| 1531 | * \param bo_list_handle - \c [in] request bo list handle (0 for none) |
| 1532 | * \param num_chunks - \c [in] number of CS chunks to submit |
| 1533 | * \param chunks - \c [in] array of CS chunks |
| 1534 | * \param seq_no - \c [out] output sequence number for submission. |
| 1535 | * |
| 1536 | * \return 0 on success\n |
| 1537 | * <0 - Negative POSIX Error code |
| 1538 | * |
| 1539 | */ |
| 1540 | struct drm_amdgpu_cs_chunk; |
| 1541 | struct drm_amdgpu_cs_chunk_dep; |
| 1542 | struct drm_amdgpu_cs_chunk_data; |
| 1543 | |
| 1544 | int amdgpu_cs_submit_raw(amdgpu_device_handle dev, |
| 1545 | amdgpu_context_handle context, |
| 1546 | amdgpu_bo_list_handle bo_list_handle, |
| 1547 | int num_chunks, |
| 1548 | struct drm_amdgpu_cs_chunk *chunks, |
| 1549 | uint64_t *seq_no); |
| 1550 | |
| 1551 | void amdgpu_cs_chunk_fence_to_dep(struct amdgpu_cs_fence *fence, |
| 1552 | struct drm_amdgpu_cs_chunk_dep *dep); |
| 1553 | void amdgpu_cs_chunk_fence_info_to_data(struct amdgpu_cs_fence_info *fence_info, |
| 1554 | struct drm_amdgpu_cs_chunk_data *data); |
| 1555 | |
Andrey Grodzovsky | 9b38ea8 | 2017-10-27 11:09:10 -0400 | [diff] [blame] | 1556 | /** |
| 1557 | * Reserve VMID |
| 1558 | * \param context - \c [in] GPU Context |
| 1559 | * \param flags - \c [in] TBD |
| 1560 | * |
| 1561 | * \return 0 on success otherwise POSIX Error code |
| 1562 | */ |
Andrey Grodzovsky | f3091ba | 2017-11-02 10:29:55 -0400 | [diff] [blame] | 1563 | int amdgpu_vm_reserve_vmid(amdgpu_device_handle dev, uint32_t flags); |
Andrey Grodzovsky | 9b38ea8 | 2017-10-27 11:09:10 -0400 | [diff] [blame] | 1564 | |
| 1565 | /** |
| 1566 | * Free reserved VMID |
| 1567 | * \param context - \c [in] GPU Context |
| 1568 | * \param flags - \c [in] TBD |
| 1569 | * |
| 1570 | * \return 0 on success otherwise POSIX Error code |
| 1571 | */ |
Andrey Grodzovsky | f3091ba | 2017-11-02 10:29:55 -0400 | [diff] [blame] | 1572 | int amdgpu_vm_unreserve_vmid(amdgpu_device_handle dev, uint32_t flags); |
Andrey Grodzovsky | 9b38ea8 | 2017-10-27 11:09:10 -0400 | [diff] [blame] | 1573 | |
Nicolai Hähnle | 41be41f | 2017-05-13 23:03:55 +0200 | [diff] [blame] | 1574 | #ifdef __cplusplus |
| 1575 | } |
| 1576 | #endif |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 1577 | #endif /* #ifdef _AMDGPU_H_ */ |