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 | * |
| 22 | */ |
| 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 | |
| 40 | struct drm_amdgpu_info_hw_ip; |
| 41 | |
| 42 | /*--------------------------------------------------------------------------*/ |
| 43 | /* --------------------------- Defines ------------------------------------ */ |
| 44 | /*--------------------------------------------------------------------------*/ |
| 45 | |
| 46 | /** |
| 47 | * Define max. number of Command Buffers (IB) which could be sent to the single |
| 48 | * hardware IP to accommodate CE/DE requirements |
| 49 | * |
| 50 | * \sa amdgpu_cs_ib_info |
| 51 | */ |
| 52 | #define AMDGPU_CS_MAX_IBS_PER_SUBMIT 4 |
| 53 | |
| 54 | /** |
Marek Olšák | 67c994f | 2015-06-26 21:58:17 +0200 | [diff] [blame] | 55 | * Special timeout value meaning that the timeout is infinite. |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 56 | */ |
| 57 | #define AMDGPU_TIMEOUT_INFINITE 0xffffffffffffffffull |
| 58 | |
Marek Olšák | 67c994f | 2015-06-26 21:58:17 +0200 | [diff] [blame] | 59 | /** |
| 60 | * Used in amdgpu_cs_query_fence::flags, meaning that the given timeout |
| 61 | * is absolute. |
| 62 | */ |
| 63 | #define AMDGPU_QUERY_FENCE_TIMEOUT_IS_ABSOLUTE (1 << 0) |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 64 | |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 65 | /*--------------------------------------------------------------------------*/ |
| 66 | /* ----------------------------- Enums ------------------------------------ */ |
| 67 | /*--------------------------------------------------------------------------*/ |
| 68 | |
| 69 | /** |
| 70 | * Enum describing possible handle types |
| 71 | * |
| 72 | * \sa amdgpu_bo_import, amdgpu_bo_export |
| 73 | * |
| 74 | */ |
| 75 | enum amdgpu_bo_handle_type { |
| 76 | /** GEM flink name (needs DRM authentication, used by DRI2) */ |
| 77 | amdgpu_bo_handle_type_gem_flink_name = 0, |
| 78 | |
| 79 | /** KMS handle which is used by all driver ioctls */ |
| 80 | amdgpu_bo_handle_type_kms = 1, |
| 81 | |
| 82 | /** DMA-buf fd handle */ |
| 83 | amdgpu_bo_handle_type_dma_buf_fd = 2 |
| 84 | }; |
| 85 | |
Sabre Shao | 23fab59 | 2015-07-09 13:50:36 +0800 | [diff] [blame] | 86 | /** Define known types of GPU VM VA ranges */ |
| 87 | enum amdgpu_gpu_va_range |
| 88 | { |
| 89 | /** Allocate from "normal"/general range */ |
| 90 | amdgpu_gpu_va_range_general = 0 |
| 91 | }; |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 92 | |
| 93 | /*--------------------------------------------------------------------------*/ |
| 94 | /* -------------------------- Datatypes ----------------------------------- */ |
| 95 | /*--------------------------------------------------------------------------*/ |
| 96 | |
| 97 | /** |
| 98 | * Define opaque pointer to context associated with fd. |
| 99 | * This context will be returned as the result of |
| 100 | * "initialize" function and should be pass as the first |
| 101 | * parameter to any API call |
| 102 | */ |
| 103 | typedef struct amdgpu_device *amdgpu_device_handle; |
| 104 | |
| 105 | /** |
| 106 | * Define GPU Context type as pointer to opaque structure |
| 107 | * Example of GPU Context is the "rendering" context associated |
| 108 | * with OpenGL context (glCreateContext) |
| 109 | */ |
| 110 | typedef struct amdgpu_context *amdgpu_context_handle; |
| 111 | |
| 112 | /** |
| 113 | * Define handle for amdgpu resources: buffer, GDS, etc. |
| 114 | */ |
| 115 | typedef struct amdgpu_bo *amdgpu_bo_handle; |
| 116 | |
| 117 | /** |
Christian König | 6dc2eaf | 2015-04-22 14:52:34 +0200 | [diff] [blame] | 118 | * Define handle for list of BOs |
| 119 | */ |
| 120 | typedef struct amdgpu_bo_list *amdgpu_bo_list_handle; |
| 121 | |
Sabre Shao | 23fab59 | 2015-07-09 13:50:36 +0800 | [diff] [blame] | 122 | /** |
| 123 | * Define handle to be used to work with VA allocated ranges |
| 124 | */ |
| 125 | typedef struct amdgpu_va *amdgpu_va_handle; |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 126 | |
| 127 | /*--------------------------------------------------------------------------*/ |
| 128 | /* -------------------------- Structures ---------------------------------- */ |
| 129 | /*--------------------------------------------------------------------------*/ |
| 130 | |
| 131 | /** |
| 132 | * Structure describing memory allocation request |
| 133 | * |
| 134 | * \sa amdgpu_bo_alloc() |
| 135 | * |
| 136 | */ |
| 137 | struct amdgpu_bo_alloc_request { |
| 138 | /** Allocation request. It must be aligned correctly. */ |
| 139 | uint64_t alloc_size; |
| 140 | |
| 141 | /** |
| 142 | * It may be required to have some specific alignment requirements |
| 143 | * for physical back-up storage (e.g. for displayable surface). |
| 144 | * If 0 there is no special alignment requirement |
| 145 | */ |
| 146 | uint64_t phys_alignment; |
| 147 | |
| 148 | /** |
| 149 | * UMD should specify where to allocate memory and how it |
| 150 | * will be accessed by the CPU. |
| 151 | */ |
| 152 | uint32_t preferred_heap; |
| 153 | |
| 154 | /** Additional flags passed on allocation */ |
| 155 | uint64_t flags; |
| 156 | }; |
| 157 | |
| 158 | /** |
| 159 | * Structure describing memory allocation request |
| 160 | * |
| 161 | * \sa amdgpu_bo_alloc() |
| 162 | */ |
| 163 | struct amdgpu_bo_alloc_result { |
| 164 | /** Assigned virtual MC Base Address */ |
| 165 | uint64_t virtual_mc_base_address; |
| 166 | |
| 167 | /** Handle of allocated memory to be used by the given process only. */ |
| 168 | amdgpu_bo_handle buf_handle; |
| 169 | }; |
| 170 | |
| 171 | /** |
| 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 | |
| 216 | /** |
| 217 | * Assigned virtual MC Base Address. |
| 218 | * \note This information will be returned only if this buffer was |
| 219 | * allocated in the same process otherwise 0 will be returned. |
| 220 | */ |
| 221 | uint64_t virtual_mc_base_address; |
| 222 | |
| 223 | /** Heap where to allocate memory. */ |
| 224 | uint32_t preferred_heap; |
| 225 | |
| 226 | /** Additional allocation flags. */ |
| 227 | uint64_t alloc_flags; |
| 228 | |
| 229 | /** Metadata associated with buffer if any. */ |
| 230 | struct amdgpu_bo_metadata metadata; |
| 231 | }; |
| 232 | |
| 233 | /** |
| 234 | * Structure with information about "imported" buffer |
| 235 | * |
| 236 | * \sa amdgpu_bo_import() |
| 237 | * |
| 238 | */ |
| 239 | struct amdgpu_bo_import_result { |
| 240 | /** Handle of memory/buffer to use */ |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 241 | amdgpu_bo_handle buf_handle; |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 242 | |
| 243 | /** Buffer size */ |
| 244 | uint64_t alloc_size; |
| 245 | |
| 246 | /** Assigned virtual MC Base Address */ |
| 247 | uint64_t virtual_mc_base_address; |
| 248 | }; |
| 249 | |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 250 | /** |
| 251 | * |
| 252 | * Structure to describe GDS partitioning information. |
| 253 | * \note OA and GWS resources are asscoiated with GDS partition |
| 254 | * |
| 255 | * \sa amdgpu_gpu_resource_query_gds_info |
| 256 | * |
| 257 | */ |
| 258 | struct amdgpu_gds_resource_info { |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 259 | uint32_t gds_gfx_partition_size; |
| 260 | uint32_t compute_partition_size; |
| 261 | uint32_t gds_total_size; |
| 262 | uint32_t gws_per_gfx_partition; |
| 263 | uint32_t gws_per_compute_partition; |
| 264 | uint32_t oa_per_gfx_partition; |
| 265 | uint32_t oa_per_compute_partition; |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 266 | }; |
| 267 | |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 268 | /** |
Christian König | 0f37bc9 | 2015-06-24 14:17:57 +0200 | [diff] [blame] | 269 | * Structure describing CS dependency |
| 270 | * |
| 271 | * \sa amdgpu_cs_request, amdgpu_cs_submit() |
| 272 | * |
| 273 | */ |
| 274 | struct amdgpu_cs_dep_info { |
| 275 | /** Context to which the fence belongs */ |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 276 | amdgpu_context_handle context; |
Christian König | 0f37bc9 | 2015-06-24 14:17:57 +0200 | [diff] [blame] | 277 | |
| 278 | /** To which HW IP type the fence belongs */ |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 279 | uint32_t ip_type; |
Christian König | 0f37bc9 | 2015-06-24 14:17:57 +0200 | [diff] [blame] | 280 | |
| 281 | /** 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] | 282 | uint32_t ip_instance; |
Christian König | 0f37bc9 | 2015-06-24 14:17:57 +0200 | [diff] [blame] | 283 | |
| 284 | /** Ring index of the HW IP */ |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 285 | uint32_t ring; |
Christian König | 0f37bc9 | 2015-06-24 14:17:57 +0200 | [diff] [blame] | 286 | |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 287 | /** Specify fence for which we need to check submission status.*/ |
| 288 | uint64_t fence; |
Christian König | 0f37bc9 | 2015-06-24 14:17:57 +0200 | [diff] [blame] | 289 | }; |
| 290 | |
| 291 | /** |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 292 | * Structure describing IB |
| 293 | * |
| 294 | * \sa amdgpu_cs_request, amdgpu_cs_submit() |
| 295 | * |
| 296 | */ |
| 297 | struct amdgpu_cs_ib_info { |
| 298 | /** Special flags */ |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 299 | uint64_t flags; |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 300 | |
Marek Olšák | 76af5c2 | 2015-06-02 13:05:41 +0200 | [diff] [blame] | 301 | /** Virtual MC address of the command buffer */ |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 302 | uint64_t ib_mc_address; |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 303 | |
| 304 | /** |
| 305 | * Size of Command Buffer to be submitted. |
| 306 | * - The size is in units of dwords (4 bytes). |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 307 | * - Could be 0 |
| 308 | */ |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 309 | uint32_t size; |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 310 | }; |
| 311 | |
| 312 | /** |
| 313 | * Structure describing submission request |
| 314 | * |
| 315 | * \note We could have several IBs as packet. e.g. CE, CE, DE case for gfx |
| 316 | * |
| 317 | * \sa amdgpu_cs_submit() |
| 318 | */ |
| 319 | struct amdgpu_cs_request { |
| 320 | /** Specify flags with additional information */ |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 321 | uint64_t flags; |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 322 | |
| 323 | /** Specify HW IP block type to which to send the IB. */ |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 324 | unsigned ip_type; |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 325 | |
| 326 | /** 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] | 327 | unsigned ip_instance; |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 328 | |
| 329 | /** |
| 330 | * Specify ring index of the IP. We could have several rings |
| 331 | * in the same IP. E.g. 0 for SDMA0 and 1 for SDMA1. |
| 332 | */ |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 333 | uint32_t ring; |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 334 | |
| 335 | /** |
Christian König | 6dc2eaf | 2015-04-22 14:52:34 +0200 | [diff] [blame] | 336 | * List handle with resources used by this request. |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 337 | */ |
Christian König | 6dc2eaf | 2015-04-22 14:52:34 +0200 | [diff] [blame] | 338 | amdgpu_bo_list_handle resources; |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 339 | |
Christian König | 0f37bc9 | 2015-06-24 14:17:57 +0200 | [diff] [blame] | 340 | /** |
| 341 | * Number of dependencies this Command submission needs to |
| 342 | * wait for before starting execution. |
| 343 | */ |
| 344 | uint32_t number_of_dependencies; |
| 345 | |
| 346 | /** |
| 347 | * Array of dependencies which need to be met before |
| 348 | * execution can start. |
| 349 | */ |
| 350 | struct amdgpu_cs_dep_info *dependencies; |
| 351 | |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 352 | /** Number of IBs to submit in the field ibs. */ |
| 353 | uint32_t number_of_ibs; |
| 354 | |
| 355 | /** |
| 356 | * IBs to submit. Those IBs will be submit together as single entity |
| 357 | */ |
| 358 | struct amdgpu_cs_ib_info *ibs; |
| 359 | }; |
| 360 | |
| 361 | /** |
| 362 | * Structure describing request to check submission state using fence |
| 363 | * |
| 364 | * \sa amdgpu_cs_query_fence_status() |
| 365 | * |
| 366 | */ |
| 367 | struct amdgpu_cs_query_fence { |
| 368 | |
| 369 | /** In which context IB was sent to execution */ |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 370 | amdgpu_context_handle context; |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 371 | |
| 372 | /** Timeout in nanoseconds. */ |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 373 | uint64_t timeout_ns; |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 374 | |
| 375 | /** To which HW IP type the fence belongs */ |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 376 | unsigned ip_type; |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 377 | |
| 378 | /** IP instance index if there are several IPs of the same type. */ |
| 379 | unsigned ip_instance; |
| 380 | |
| 381 | /** Ring index of the HW IP */ |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 382 | uint32_t ring; |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 383 | |
| 384 | /** Flags */ |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 385 | uint64_t flags; |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 386 | |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 387 | /** Specify fence for which we need to check submission status.*/ |
| 388 | uint64_t fence; |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 389 | }; |
| 390 | |
| 391 | /** |
| 392 | * Structure which provide information about GPU VM MC Address space |
| 393 | * alignments requirements |
| 394 | * |
| 395 | * \sa amdgpu_query_buffer_size_alignment |
| 396 | */ |
| 397 | struct amdgpu_buffer_size_alignments { |
| 398 | /** Size alignment requirement for allocation in |
| 399 | * local memory */ |
| 400 | uint64_t size_local; |
| 401 | |
| 402 | /** |
| 403 | * Size alignment requirement for allocation in remote memory |
| 404 | */ |
| 405 | uint64_t size_remote; |
| 406 | }; |
| 407 | |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 408 | /** |
| 409 | * Structure which provide information about heap |
| 410 | * |
| 411 | * \sa amdgpu_query_heap_info() |
| 412 | * |
| 413 | */ |
| 414 | struct amdgpu_heap_info { |
| 415 | /** Theoretical max. available memory in the given heap */ |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 416 | uint64_t heap_size; |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 417 | |
| 418 | /** |
| 419 | * Number of bytes allocated in the heap. This includes all processes |
| 420 | * and private allocations in the kernel. It changes when new buffers |
| 421 | * are allocated, freed, and moved. It cannot be larger than |
| 422 | * heap_size. |
| 423 | */ |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 424 | uint64_t heap_usage; |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 425 | |
| 426 | /** |
| 427 | * Theoretical possible max. size of buffer which |
| 428 | * could be allocated in the given heap |
| 429 | */ |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 430 | uint64_t max_allocation; |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 431 | }; |
| 432 | |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 433 | /** |
| 434 | * Describe GPU h/w info needed for UMD correct initialization |
| 435 | * |
| 436 | * \sa amdgpu_query_gpu_info() |
| 437 | */ |
| 438 | struct amdgpu_gpu_info { |
| 439 | /** Asic id */ |
| 440 | uint32_t asic_id; |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 441 | /** Chip revision */ |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 442 | uint32_t chip_rev; |
| 443 | /** Chip external revision */ |
| 444 | uint32_t chip_external_rev; |
| 445 | /** Family ID */ |
| 446 | uint32_t family_id; |
| 447 | /** Special flags */ |
| 448 | uint64_t ids_flags; |
| 449 | /** max engine clock*/ |
| 450 | uint64_t max_engine_clk; |
Ken Wang | fc9fc7d | 2015-06-03 17:07:44 +0800 | [diff] [blame] | 451 | /** max memory clock */ |
| 452 | uint64_t max_memory_clk; |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 453 | /** number of shader engines */ |
| 454 | uint32_t num_shader_engines; |
| 455 | /** number of shader arrays per engine */ |
| 456 | uint32_t num_shader_arrays_per_engine; |
| 457 | /** Number of available good shader pipes */ |
| 458 | uint32_t avail_quad_shader_pipes; |
| 459 | /** Max. number of shader pipes.(including good and bad pipes */ |
| 460 | uint32_t max_quad_shader_pipes; |
| 461 | /** Number of parameter cache entries per shader quad pipe */ |
| 462 | uint32_t cache_entries_per_quad_pipe; |
| 463 | /** Number of available graphics context */ |
| 464 | uint32_t num_hw_gfx_contexts; |
| 465 | /** Number of render backend pipes */ |
| 466 | uint32_t rb_pipes; |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 467 | /** Enabled render backend pipe mask */ |
| 468 | uint32_t enabled_rb_pipes_mask; |
| 469 | /** Frequency of GPU Counter */ |
| 470 | uint32_t gpu_counter_freq; |
| 471 | /** CC_RB_BACKEND_DISABLE.BACKEND_DISABLE per SE */ |
| 472 | uint32_t backend_disable[4]; |
| 473 | /** Value of MC_ARB_RAMCFG register*/ |
| 474 | uint32_t mc_arb_ramcfg; |
| 475 | /** Value of GB_ADDR_CONFIG */ |
| 476 | uint32_t gb_addr_cfg; |
| 477 | /** Values of the GB_TILE_MODE0..31 registers */ |
| 478 | uint32_t gb_tile_mode[32]; |
| 479 | /** Values of GB_MACROTILE_MODE0..15 registers */ |
| 480 | uint32_t gb_macro_tile_mode[16]; |
| 481 | /** Value of PA_SC_RASTER_CONFIG register per SE */ |
| 482 | uint32_t pa_sc_raster_cfg[4]; |
| 483 | /** Value of PA_SC_RASTER_CONFIG_1 register per SE */ |
| 484 | uint32_t pa_sc_raster_cfg1[4]; |
| 485 | /* CU info */ |
| 486 | uint32_t cu_active_number; |
| 487 | uint32_t cu_ao_mask; |
| 488 | uint32_t cu_bitmap[4][4]; |
Ken Wang | 4bf2941 | 2015-06-03 17:15:29 +0800 | [diff] [blame] | 489 | /* video memory type info*/ |
| 490 | uint32_t vram_type; |
| 491 | /* video memory bit width*/ |
| 492 | uint32_t vram_bit_width; |
Ken Wang | cdd1edc | 2015-06-03 17:21:27 +0800 | [diff] [blame] | 493 | /** constant engine ram size*/ |
| 494 | uint32_t ce_ram_size; |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 495 | }; |
| 496 | |
| 497 | |
| 498 | /*--------------------------------------------------------------------------*/ |
| 499 | /*------------------------- Functions --------------------------------------*/ |
| 500 | /*--------------------------------------------------------------------------*/ |
| 501 | |
| 502 | /* |
| 503 | * Initialization / Cleanup |
| 504 | * |
| 505 | */ |
| 506 | |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 507 | /** |
| 508 | * |
| 509 | * \param fd - \c [in] File descriptor for AMD GPU device |
| 510 | * received previously as the result of |
| 511 | * e.g. drmOpen() call. |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 512 | * For legacy fd type, the DRI2/DRI3 |
| 513 | * authentication should be done before |
| 514 | * calling this function. |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 515 | * \param major_version - \c [out] Major version of library. It is assumed |
| 516 | * that adding new functionality will cause |
| 517 | * increase in major version |
| 518 | * \param minor_version - \c [out] Minor version of library |
| 519 | * \param device_handle - \c [out] Pointer to opaque context which should |
| 520 | * be passed as the first parameter on each |
| 521 | * API call |
| 522 | * |
| 523 | * |
| 524 | * \return 0 on success\n |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 525 | * <0 - Negative POSIX Error code |
| 526 | * |
| 527 | * |
| 528 | * \sa amdgpu_device_deinitialize() |
| 529 | */ |
| 530 | int amdgpu_device_initialize(int fd, |
| 531 | uint32_t *major_version, |
| 532 | uint32_t *minor_version, |
| 533 | amdgpu_device_handle *device_handle); |
| 534 | |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 535 | /** |
| 536 | * |
| 537 | * When access to such library does not needed any more the special |
| 538 | * function must be call giving opportunity to clean up any |
| 539 | * resources if needed. |
| 540 | * |
| 541 | * \param device_handle - \c [in] Context associated with file |
| 542 | * descriptor for AMD GPU device |
| 543 | * received previously as the |
| 544 | * result e.g. of drmOpen() call. |
| 545 | * |
| 546 | * \return 0 on success\n |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 547 | * <0 - Negative POSIX Error code |
| 548 | * |
| 549 | * \sa amdgpu_device_initialize() |
| 550 | * |
| 551 | */ |
| 552 | int amdgpu_device_deinitialize(amdgpu_device_handle device_handle); |
| 553 | |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 554 | /* |
| 555 | * Memory Management |
| 556 | * |
| 557 | */ |
| 558 | |
| 559 | /** |
| 560 | * Allocate memory to be used by UMD for GPU related operations |
| 561 | * |
| 562 | * \param dev - \c [in] Device handle. |
| 563 | * See #amdgpu_device_initialize() |
| 564 | * \param alloc_buffer - \c [in] Pointer to the structure describing an |
| 565 | * allocation request |
| 566 | * \param info - \c [out] Pointer to structure which return |
| 567 | * information about allocated memory |
| 568 | * |
| 569 | * \return 0 on success\n |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 570 | * <0 - Negative POSIX Error code |
| 571 | * |
| 572 | * \sa amdgpu_bo_free() |
| 573 | */ |
| 574 | int amdgpu_bo_alloc(amdgpu_device_handle dev, |
| 575 | struct amdgpu_bo_alloc_request *alloc_buffer, |
| 576 | struct amdgpu_bo_alloc_result *info); |
| 577 | |
| 578 | /** |
| 579 | * Associate opaque data with buffer to be queried by another UMD |
| 580 | * |
| 581 | * \param dev - \c [in] Device handle. See #amdgpu_device_initialize() |
| 582 | * \param buf_handle - \c [in] Buffer handle |
| 583 | * \param info - \c [in] Metadata to associated with buffer |
| 584 | * |
| 585 | * \return 0 on success\n |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 586 | * <0 - Negative POSIX Error code |
| 587 | */ |
| 588 | int amdgpu_bo_set_metadata(amdgpu_bo_handle buf_handle, |
| 589 | struct amdgpu_bo_metadata *info); |
| 590 | |
| 591 | /** |
| 592 | * Query buffer information including metadata previusly associated with |
| 593 | * buffer. |
| 594 | * |
| 595 | * \param dev - \c [in] Device handle. |
| 596 | * See #amdgpu_device_initialize() |
| 597 | * \param buf_handle - \c [in] Buffer handle |
| 598 | * \param info - \c [out] Structure describing buffer |
| 599 | * |
| 600 | * \return 0 on success\n |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 601 | * <0 - Negative POSIX Error code |
| 602 | * |
| 603 | * \sa amdgpu_bo_set_metadata(), amdgpu_bo_alloc() |
| 604 | */ |
| 605 | int amdgpu_bo_query_info(amdgpu_bo_handle buf_handle, |
| 606 | struct amdgpu_bo_info *info); |
| 607 | |
| 608 | /** |
| 609 | * Allow others to get access to buffer |
| 610 | * |
| 611 | * \param dev - \c [in] Device handle. |
| 612 | * See #amdgpu_device_initialize() |
| 613 | * \param buf_handle - \c [in] Buffer handle |
| 614 | * \param type - \c [in] Type of handle requested |
| 615 | * \param shared_handle - \c [out] Special "shared" handle |
| 616 | * |
| 617 | * \return 0 on success\n |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 618 | * <0 - Negative POSIX Error code |
| 619 | * |
| 620 | * \sa amdgpu_bo_import() |
| 621 | * |
| 622 | */ |
| 623 | int amdgpu_bo_export(amdgpu_bo_handle buf_handle, |
| 624 | enum amdgpu_bo_handle_type type, |
| 625 | uint32_t *shared_handle); |
| 626 | |
| 627 | /** |
| 628 | * Request access to "shared" buffer |
| 629 | * |
| 630 | * \param dev - \c [in] Device handle. |
| 631 | * See #amdgpu_device_initialize() |
| 632 | * \param type - \c [in] Type of handle requested |
| 633 | * \param shared_handle - \c [in] Shared handle received as result "import" |
| 634 | * operation |
| 635 | * \param output - \c [out] Pointer to structure with information |
| 636 | * about imported buffer |
| 637 | * |
| 638 | * \return 0 on success\n |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 639 | * <0 - Negative POSIX Error code |
| 640 | * |
| 641 | * \note Buffer must be "imported" only using new "fd" (different from |
| 642 | * one used by "exporter"). |
| 643 | * |
| 644 | * \sa amdgpu_bo_export() |
| 645 | * |
| 646 | */ |
| 647 | int amdgpu_bo_import(amdgpu_device_handle dev, |
| 648 | enum amdgpu_bo_handle_type type, |
| 649 | uint32_t shared_handle, |
| 650 | struct amdgpu_bo_import_result *output); |
| 651 | |
| 652 | /** |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 653 | * Request GPU access to user allocated memory e.g. via "malloc" |
| 654 | * |
| 655 | * \param dev - [in] Device handle. See #amdgpu_device_initialize() |
| 656 | * \param cpu - [in] CPU address of user allocated memory which we |
| 657 | * want to map to GPU address space (make GPU accessible) |
| 658 | * (This address must be correctly aligned). |
| 659 | * \param size - [in] Size of allocation (must be correctly aligned) |
| 660 | * \param amdgpu_bo_alloc_result - [out] Handle of allocation to be passed as |
| 661 | * resource on submission and be used in other operations. |
| 662 | * |
| 663 | * |
Christian König | 28462eb | 2015-06-30 16:27:27 +0200 | [diff] [blame] | 664 | * \return 0 on success\n |
| 665 | * <0 - Negative POSIX Error code |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 666 | * |
| 667 | * \note |
| 668 | * This call doesn't guarantee that such memory will be persistently |
| 669 | * "locked" / make non-pageable. The purpose of this call is to provide |
| 670 | * opportunity for GPU get access to this resource during submission. |
| 671 | * |
| 672 | * The maximum amount of memory which could be mapped in this call depends |
| 673 | * if overcommit is disabled or not. If overcommit is disabled than the max. |
| 674 | * amount of memory to be pinned will be limited by left "free" size in total |
| 675 | * amount of memory which could be locked simultaneously ("GART" size). |
| 676 | * |
| 677 | * Supported (theoretical) max. size of mapping is restricted only by |
| 678 | * "GART" size. |
| 679 | * |
| 680 | * It is responsibility of caller to correctly specify access rights |
| 681 | * on VA assignment. |
| 682 | */ |
| 683 | int amdgpu_create_bo_from_user_mem(amdgpu_device_handle dev, |
| 684 | void *cpu, uint64_t size, |
| 685 | struct amdgpu_bo_alloc_result *info); |
| 686 | |
| 687 | /** |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 688 | * Free previosuly allocated memory |
| 689 | * |
| 690 | * \param dev - \c [in] Device handle. See #amdgpu_device_initialize() |
| 691 | * \param buf_handle - \c [in] Buffer handle to free |
| 692 | * |
| 693 | * \return 0 on success\n |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 694 | * <0 - Negative POSIX Error code |
| 695 | * |
| 696 | * \note In the case of memory shared between different applications all |
| 697 | * resources will be “physically” freed only all such applications |
| 698 | * will be terminated |
| 699 | * \note If is UMD responsibility to ‘free’ buffer only when there is no |
| 700 | * more GPU access |
| 701 | * |
| 702 | * \sa amdgpu_bo_set_metadata(), amdgpu_bo_alloc() |
| 703 | * |
| 704 | */ |
| 705 | int amdgpu_bo_free(amdgpu_bo_handle buf_handle); |
| 706 | |
| 707 | /** |
| 708 | * Request CPU access to GPU accessable memory |
| 709 | * |
| 710 | * \param buf_handle - \c [in] Buffer handle |
| 711 | * \param cpu - \c [out] CPU address to be used for access |
| 712 | * |
| 713 | * \return 0 on success\n |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 714 | * <0 - Negative POSIX Error code |
| 715 | * |
| 716 | * \sa amdgpu_bo_cpu_unmap() |
| 717 | * |
| 718 | */ |
| 719 | int amdgpu_bo_cpu_map(amdgpu_bo_handle buf_handle, void **cpu); |
| 720 | |
| 721 | /** |
| 722 | * Release CPU access to GPU memory |
| 723 | * |
| 724 | * \param buf_handle - \c [in] Buffer handle |
| 725 | * |
| 726 | * \return 0 on success\n |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 727 | * <0 - Negative POSIX Error code |
| 728 | * |
| 729 | * \sa amdgpu_bo_cpu_map() |
| 730 | * |
| 731 | */ |
| 732 | int amdgpu_bo_cpu_unmap(amdgpu_bo_handle buf_handle); |
| 733 | |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 734 | /** |
| 735 | * Wait until a buffer is not used by the device. |
| 736 | * |
| 737 | * \param dev - \c [in] Device handle. See #amdgpu_lib_initialize() |
| 738 | * \param buf_handle - \c [in] Buffer handle. |
| 739 | * \param timeout_ns - Timeout in nanoseconds. |
| 740 | * \param buffer_busy - 0 if buffer is idle, all GPU access was completed |
| 741 | * and no GPU access is scheduled. |
| 742 | * 1 GPU access is in fly or scheduled |
| 743 | * |
| 744 | * \return 0 - on success |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 745 | * <0 - Negative POSIX Error code |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 746 | */ |
| 747 | int amdgpu_bo_wait_for_idle(amdgpu_bo_handle buf_handle, |
| 748 | uint64_t timeout_ns, |
| 749 | bool *buffer_busy); |
| 750 | |
Christian König | 6dc2eaf | 2015-04-22 14:52:34 +0200 | [diff] [blame] | 751 | /** |
| 752 | * Creates a BO list handle for command submission. |
| 753 | * |
| 754 | * \param dev - \c [in] Device handle. |
| 755 | * See #amdgpu_device_initialize() |
| 756 | * \param number_of_resources - \c [in] Number of BOs in the list |
| 757 | * \param resources - \c [in] List of BO handles |
| 758 | * \param resource_prios - \c [in] Optional priority for each handle |
| 759 | * \param result - \c [out] Created BO list handle |
| 760 | * |
| 761 | * \return 0 on success\n |
Christian König | 6dc2eaf | 2015-04-22 14:52:34 +0200 | [diff] [blame] | 762 | * <0 - Negative POSIX Error code |
| 763 | * |
| 764 | * \sa amdgpu_bo_list_destroy() |
| 765 | */ |
| 766 | int amdgpu_bo_list_create(amdgpu_device_handle dev, |
| 767 | uint32_t number_of_resources, |
| 768 | amdgpu_bo_handle *resources, |
| 769 | uint8_t *resource_prios, |
| 770 | amdgpu_bo_list_handle *result); |
| 771 | |
| 772 | /** |
| 773 | * Destroys a BO list handle. |
| 774 | * |
| 775 | * \param handle - \c [in] BO list handle. |
| 776 | * |
| 777 | * \return 0 on success\n |
Christian König | 6dc2eaf | 2015-04-22 14:52:34 +0200 | [diff] [blame] | 778 | * <0 - Negative POSIX Error code |
| 779 | * |
| 780 | * \sa amdgpu_bo_list_create() |
| 781 | */ |
| 782 | int amdgpu_bo_list_destroy(amdgpu_bo_list_handle handle); |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 783 | |
Jammy Zhou | 7244698 | 2015-05-18 20:27:24 +0800 | [diff] [blame] | 784 | /** |
| 785 | * Update resources for existing BO list |
| 786 | * |
| 787 | * \param handle - \c [in] BO list handle |
| 788 | * \param number_of_resources - \c [in] Number of BOs in the list |
| 789 | * \param resources - \c [in] List of BO handles |
| 790 | * \param resource_prios - \c [in] Optional priority for each handle |
| 791 | * |
| 792 | * \return 0 on success\n |
Jammy Zhou | 7244698 | 2015-05-18 20:27:24 +0800 | [diff] [blame] | 793 | * <0 - Negative POSIX Error code |
| 794 | * |
| 795 | * \sa amdgpu_bo_list_update() |
| 796 | */ |
| 797 | int amdgpu_bo_list_update(amdgpu_bo_list_handle handle, |
| 798 | uint32_t number_of_resources, |
| 799 | amdgpu_bo_handle *resources, |
| 800 | uint8_t *resource_prios); |
| 801 | |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 802 | /* |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 803 | * GPU Execution context |
| 804 | * |
| 805 | */ |
| 806 | |
| 807 | /** |
| 808 | * Create GPU execution Context |
| 809 | * |
| 810 | * For the purpose of GPU Scheduler and GPU Robustness extensions it is |
| 811 | * necessary to have information/identify rendering/compute contexts. |
| 812 | * It also may be needed to associate some specific requirements with such |
| 813 | * contexts. Kernel driver will guarantee that submission from the same |
| 814 | * context will always be executed in order (first come, first serve). |
| 815 | * |
| 816 | * |
| 817 | * \param dev - \c [in] Device handle. See #amdgpu_device_initialize() |
| 818 | * \param context - \c [out] GPU Context handle |
| 819 | * |
| 820 | * \return 0 on success\n |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 821 | * <0 - Negative POSIX Error code |
| 822 | * |
| 823 | * \sa amdgpu_cs_ctx_free() |
| 824 | * |
| 825 | */ |
| 826 | int amdgpu_cs_ctx_create(amdgpu_device_handle dev, |
| 827 | amdgpu_context_handle *context); |
| 828 | |
| 829 | /** |
| 830 | * |
| 831 | * Destroy GPU execution context when not needed any more |
| 832 | * |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 833 | * \param context - \c [in] GPU Context handle |
| 834 | * |
| 835 | * \return 0 on success\n |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 836 | * <0 - Negative POSIX Error code |
| 837 | * |
| 838 | * \sa amdgpu_cs_ctx_create() |
| 839 | * |
| 840 | */ |
Christian König | 9c2afff | 2015-04-22 12:21:13 +0200 | [diff] [blame] | 841 | int amdgpu_cs_ctx_free(amdgpu_context_handle context); |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 842 | |
| 843 | /** |
| 844 | * Query reset state for the specific GPU Context |
| 845 | * |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 846 | * \param context - \c [in] GPU Context handle |
Marek Olšák | 4b39a8e | 2015-05-05 21:23:02 +0200 | [diff] [blame] | 847 | * \param state - \c [out] One of AMDGPU_CTX_*_RESET |
| 848 | * \param hangs - \c [out] Number of hangs caused by the context. |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 849 | * |
| 850 | * \return 0 on success\n |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 851 | * <0 - Negative POSIX Error code |
| 852 | * |
| 853 | * \sa amdgpu_cs_ctx_create() |
| 854 | * |
| 855 | */ |
Christian König | 9c2afff | 2015-04-22 12:21:13 +0200 | [diff] [blame] | 856 | int amdgpu_cs_query_reset_state(amdgpu_context_handle context, |
Marek Olšák | 4b39a8e | 2015-05-05 21:23:02 +0200 | [diff] [blame] | 857 | uint32_t *state, uint32_t *hangs); |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 858 | |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 859 | /* |
| 860 | * Command Buffers Management |
| 861 | * |
| 862 | */ |
| 863 | |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 864 | /** |
| 865 | * Send request to submit command buffers to hardware. |
| 866 | * |
| 867 | * Kernel driver could use GPU Scheduler to make decision when physically |
| 868 | * sent this request to the hardware. Accordingly this request could be put |
| 869 | * in queue and sent for execution later. The only guarantee is that request |
| 870 | * from the same GPU context to the same ip:ip_instance:ring will be executed in |
| 871 | * order. |
| 872 | * |
| 873 | * |
| 874 | * \param dev - \c [in] Device handle. |
| 875 | * See #amdgpu_device_initialize() |
| 876 | * \param context - \c [in] GPU Context |
| 877 | * \param flags - \c [in] Global submission flags |
| 878 | * \param ibs_request - \c [in] Pointer to submission requests. |
| 879 | * We could submit to the several |
| 880 | * engines/rings simulteniously as |
| 881 | * 'atomic' operation |
| 882 | * \param number_of_requests - \c [in] Number of submission requests |
| 883 | * \param fences - \c [out] Pointer to array of data to get |
| 884 | * fences to identify submission |
| 885 | * requests. Timestamps are valid |
| 886 | * in this GPU context and could be used |
| 887 | * to identify/detect completion of |
| 888 | * submission request |
| 889 | * |
| 890 | * \return 0 on success\n |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 891 | * <0 - Negative POSIX Error code |
| 892 | * |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 893 | * \note It is required to pass correct resource list with buffer handles |
| 894 | * which will be accessible by command buffers from submission |
| 895 | * This will allow kernel driver to correctly implement "paging". |
| 896 | * Failure to do so will have unpredictable results. |
| 897 | * |
| 898 | * \sa amdgpu_command_buffer_alloc(), amdgpu_command_buffer_free(), |
| 899 | * amdgpu_cs_query_fence_status() |
| 900 | * |
| 901 | */ |
Christian König | 9c2afff | 2015-04-22 12:21:13 +0200 | [diff] [blame] | 902 | int amdgpu_cs_submit(amdgpu_context_handle context, |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 903 | uint64_t flags, |
| 904 | struct amdgpu_cs_request *ibs_request, |
| 905 | uint32_t number_of_requests, |
| 906 | uint64_t *fences); |
| 907 | |
| 908 | /** |
| 909 | * Query status of Command Buffer Submission |
| 910 | * |
| 911 | * \param dev - \c [in] Device handle. See #amdgpu_device_initialize() |
| 912 | * \param fence - \c [in] Structure describing fence to query |
| 913 | * \param expired - \c [out] If fence expired or not.\n |
| 914 | * 0 – if fence is not expired\n |
| 915 | * !0 - otherwise |
| 916 | * |
| 917 | * \return 0 on success\n |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 918 | * <0 - Negative POSIX Error code |
| 919 | * |
| 920 | * \note If UMD wants only to check operation status and returned immediately |
| 921 | * then timeout value as 0 must be passed. In this case success will be |
| 922 | * returned in the case if submission was completed or timeout error |
| 923 | * code. |
| 924 | * |
| 925 | * \sa amdgpu_cs_submit() |
| 926 | */ |
Christian König | 9c2afff | 2015-04-22 12:21:13 +0200 | [diff] [blame] | 927 | int amdgpu_cs_query_fence_status(struct amdgpu_cs_query_fence *fence, |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 928 | uint32_t *expired); |
| 929 | |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 930 | /* |
| 931 | * Query / Info API |
| 932 | * |
| 933 | */ |
| 934 | |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 935 | /** |
| 936 | * Query allocation size alignments |
| 937 | * |
| 938 | * UMD should query information about GPU VM MC size alignments requirements |
| 939 | * to be able correctly choose required allocation size and implement |
| 940 | * internal optimization if needed. |
| 941 | * |
| 942 | * \param dev - \c [in] Device handle. See #amdgpu_device_initialize() |
| 943 | * \param info - \c [out] Pointer to structure to get size alignment |
| 944 | * requirements |
| 945 | * |
| 946 | * \return 0 on success\n |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 947 | * <0 - Negative POSIX Error code |
| 948 | * |
| 949 | */ |
| 950 | int amdgpu_query_buffer_size_alignment(amdgpu_device_handle dev, |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 951 | struct amdgpu_buffer_size_alignments |
| 952 | *info); |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 953 | |
| 954 | /** |
| 955 | * Query firmware versions |
| 956 | * |
| 957 | * \param dev - \c [in] Device handle. See #amdgpu_device_initialize() |
| 958 | * \param fw_type - \c [in] AMDGPU_INFO_FW_* |
| 959 | * \param ip_instance - \c [in] Index of the IP block of the same type. |
| 960 | * \param index - \c [in] Index of the engine. (for SDMA and MEC) |
| 961 | * \param version - \c [out] Pointer to to the "version" return value |
| 962 | * \param feature - \c [out] Pointer to to the "feature" return value |
| 963 | * |
| 964 | * \return 0 on success\n |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 965 | * <0 - Negative POSIX Error code |
| 966 | * |
| 967 | */ |
| 968 | int amdgpu_query_firmware_version(amdgpu_device_handle dev, unsigned fw_type, |
| 969 | unsigned ip_instance, unsigned index, |
| 970 | uint32_t *version, uint32_t *feature); |
| 971 | |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 972 | /** |
| 973 | * Query the number of HW IP instances of a certain type. |
| 974 | * |
| 975 | * \param dev - \c [in] Device handle. See #amdgpu_device_initialize() |
| 976 | * \param type - \c [in] Hardware IP block type = AMDGPU_HW_IP_* |
| 977 | * \param count - \c [out] Pointer to structure to get information |
| 978 | * |
| 979 | * \return 0 on success\n |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 980 | * <0 - Negative POSIX Error code |
| 981 | */ |
| 982 | int amdgpu_query_hw_ip_count(amdgpu_device_handle dev, unsigned type, |
| 983 | uint32_t *count); |
| 984 | |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 985 | /** |
| 986 | * Query engine information |
| 987 | * |
| 988 | * This query allows UMD to query information different engines and their |
| 989 | * capabilities. |
| 990 | * |
| 991 | * \param dev - \c [in] Device handle. See #amdgpu_device_initialize() |
| 992 | * \param type - \c [in] Hardware IP block type = AMDGPU_HW_IP_* |
| 993 | * \param ip_instance - \c [in] Index of the IP block of the same type. |
| 994 | * \param info - \c [out] Pointer to structure to get information |
| 995 | * |
| 996 | * \return 0 on success\n |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 997 | * <0 - Negative POSIX Error code |
| 998 | */ |
| 999 | int amdgpu_query_hw_ip_info(amdgpu_device_handle dev, unsigned type, |
| 1000 | unsigned ip_instance, |
| 1001 | struct drm_amdgpu_info_hw_ip *info); |
| 1002 | |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 1003 | /** |
| 1004 | * Query heap information |
| 1005 | * |
| 1006 | * This query allows UMD to query potentially available memory resources and |
| 1007 | * adjust their logic if necessary. |
| 1008 | * |
| 1009 | * \param dev - \c [in] Device handle. See #amdgpu_device_initialize() |
| 1010 | * \param heap - \c [in] Heap type |
| 1011 | * \param info - \c [in] Pointer to structure to get needed information |
| 1012 | * |
| 1013 | * \return 0 on success\n |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 1014 | * <0 - Negative POSIX Error code |
| 1015 | * |
| 1016 | */ |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 1017 | int amdgpu_query_heap_info(amdgpu_device_handle dev, uint32_t heap, |
| 1018 | uint32_t flags, struct amdgpu_heap_info *info); |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 1019 | |
| 1020 | /** |
| 1021 | * Get the CRTC ID from the mode object ID |
| 1022 | * |
| 1023 | * \param dev - \c [in] Device handle. See #amdgpu_device_initialize() |
| 1024 | * \param id - \c [in] Mode object ID |
| 1025 | * \param result - \c [in] Pointer to the CRTC ID |
| 1026 | * |
| 1027 | * \return 0 on success\n |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 1028 | * <0 - Negative POSIX Error code |
| 1029 | * |
| 1030 | */ |
| 1031 | int amdgpu_query_crtc_from_id(amdgpu_device_handle dev, unsigned id, |
| 1032 | int32_t *result); |
| 1033 | |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 1034 | /** |
| 1035 | * Query GPU H/w Info |
| 1036 | * |
| 1037 | * Query hardware specific information |
| 1038 | * |
| 1039 | * \param dev - \c [in] Device handle. See #amdgpu_device_initialize() |
| 1040 | * \param heap - \c [in] Heap type |
| 1041 | * \param info - \c [in] Pointer to structure to get needed information |
| 1042 | * |
| 1043 | * \return 0 on success\n |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 1044 | * <0 - Negative POSIX Error code |
| 1045 | * |
| 1046 | */ |
| 1047 | int amdgpu_query_gpu_info(amdgpu_device_handle dev, |
| 1048 | struct amdgpu_gpu_info *info); |
| 1049 | |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 1050 | /** |
| 1051 | * Query hardware or driver information. |
| 1052 | * |
| 1053 | * The return size is query-specific and depends on the "info_id" parameter. |
| 1054 | * No more than "size" bytes is returned. |
| 1055 | * |
| 1056 | * \param dev - \c [in] Device handle. See #amdgpu_device_initialize() |
| 1057 | * \param info_id - \c [in] AMDGPU_INFO_* |
| 1058 | * \param size - \c [in] Size of the returned value. |
| 1059 | * \param value - \c [out] Pointer to the return value. |
| 1060 | * |
| 1061 | * \return 0 on success\n |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 1062 | * <0 - Negative POSIX error code |
| 1063 | * |
| 1064 | */ |
| 1065 | int amdgpu_query_info(amdgpu_device_handle dev, unsigned info_id, |
| 1066 | unsigned size, void *value); |
| 1067 | |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 1068 | /** |
| 1069 | * Query information about GDS |
| 1070 | * |
| 1071 | * \param dev - \c [in] Device handle. See #amdgpu_device_initialize() |
| 1072 | * \param gds_info - \c [out] Pointer to structure to get GDS information |
| 1073 | * |
| 1074 | * \return 0 on success\n |
Christian König | 558e129 | 2015-06-30 16:04:44 +0200 | [diff] [blame] | 1075 | * <0 - Negative POSIX Error code |
| 1076 | * |
| 1077 | */ |
| 1078 | int amdgpu_query_gds_info(amdgpu_device_handle dev, |
| 1079 | struct amdgpu_gds_resource_info *gds_info); |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 1080 | |
| 1081 | /** |
| 1082 | * Read a set of consecutive memory-mapped registers. |
| 1083 | * Not all registers are allowed to be read by userspace. |
| 1084 | * |
| 1085 | * \param dev - \c [in] Device handle. See #amdgpu_device_initialize( |
| 1086 | * \param dword_offset - \c [in] Register offset in dwords |
| 1087 | * \param count - \c [in] The number of registers to read starting |
| 1088 | * from the offset |
| 1089 | * \param instance - \c [in] GRBM_GFX_INDEX selector. It may have other |
| 1090 | * uses. Set it to 0xffffffff if unsure. |
| 1091 | * \param flags - \c [in] Flags with additional information. |
| 1092 | * \param values - \c [out] The pointer to return values. |
| 1093 | * |
| 1094 | * \return 0 on success\n |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 1095 | * <0 - Negative POSIX error code |
| 1096 | * |
| 1097 | */ |
| 1098 | int amdgpu_read_mm_registers(amdgpu_device_handle dev, unsigned dword_offset, |
| 1099 | unsigned count, uint32_t instance, uint32_t flags, |
| 1100 | uint32_t *values); |
| 1101 | |
Sabre Shao | 23fab59 | 2015-07-09 13:50:36 +0800 | [diff] [blame] | 1102 | /** |
| 1103 | * Allocate virtual address range |
| 1104 | * |
| 1105 | * \param dev - [in] Device handle. See #amdgpu_device_initialize() |
| 1106 | * \param va_range_type - \c [in] Type of MC va range from which to allocate |
| 1107 | * \param size - \c [in] Size of range. Size must be correctly* aligned. |
| 1108 | * It is client responsibility to correctly aligned size based on the future |
| 1109 | * usage of allocated range. |
| 1110 | * \param va_base_alignment - \c [in] Overwrite base address alignment |
| 1111 | * requirement for GPU VM MC virtual |
| 1112 | * address assignment. Must be multiple of size alignments received as |
| 1113 | * 'amdgpu_buffer_size_alignments'. |
| 1114 | * If 0 use the default one. |
| 1115 | * \param va_base_required - \c [in] Specified required va base address. |
| 1116 | * If 0 then library choose available one. |
| 1117 | * If !0 value will be passed and those value already "in use" then |
| 1118 | * corresponding error status will be returned. |
| 1119 | * \param va_base_allocated - \c [out] On return: Allocated VA base to be used |
| 1120 | * by client. |
| 1121 | * \param va_range_handle - \c [out] On return: Handle assigned to allocation |
| 1122 | * |
| 1123 | * \return 0 on success\n |
| 1124 | * >0 - AMD specific error code\n |
| 1125 | * <0 - Negative POSIX Error code |
| 1126 | * |
| 1127 | * \notes \n |
| 1128 | * It is client responsibility to correctly handle VA assignments and usage. |
| 1129 | * Neither kernel driver nor libdrm_amdpgu are able to prevent and |
| 1130 | * detect wrong va assignemnt. |
| 1131 | * |
| 1132 | * It is client responsibility to correctly handle multi-GPU cases and to pass |
| 1133 | * the corresponding arrays of all devices handles where corresponding VA will |
| 1134 | * be used. |
| 1135 | * |
| 1136 | */ |
| 1137 | int amdgpu_va_range_alloc(amdgpu_device_handle dev, |
| 1138 | enum amdgpu_gpu_va_range va_range_type, |
| 1139 | uint64_t size, |
| 1140 | uint64_t va_base_alignment, |
| 1141 | uint64_t va_base_required, |
| 1142 | uint64_t *va_base_allocated, |
| 1143 | amdgpu_va_handle *va_range_handle); |
| 1144 | |
| 1145 | /** |
| 1146 | * Free previously allocated virtual address range |
| 1147 | * |
| 1148 | * |
| 1149 | * \param va_range_handle - \c [in] Handle assigned to VA allocation |
| 1150 | * |
| 1151 | * \return 0 on success\n |
| 1152 | * >0 - AMD specific error code\n |
| 1153 | * <0 - Negative POSIX Error code |
| 1154 | * |
| 1155 | */ |
| 1156 | int amdgpu_va_range_free(amdgpu_va_handle va_range_handle); |
| 1157 | |
Sabre Shao | 12802da | 2015-07-09 13:53:24 +0800 | [diff] [blame^] | 1158 | /** |
| 1159 | * Query virtual address range |
| 1160 | * |
| 1161 | * UMD can query GPU VM range supported by each device |
| 1162 | * to initialize its own VAM accordingly. |
| 1163 | * |
| 1164 | * \param dev - [in] Device handle. See #amdgpu_device_initialize() |
| 1165 | * \param type - \c [in] Type of virtual address range |
| 1166 | * \param offset - \c [out] Start offset of virtual address range |
| 1167 | * \param size - \c [out] Size of virtual address range |
| 1168 | * |
| 1169 | * \return 0 on success\n |
| 1170 | * <0 - Negative POSIX Error code |
| 1171 | * |
| 1172 | */ |
| 1173 | |
| 1174 | int amdgpu_va_range_query(amdgpu_device_handle dev, |
| 1175 | enum amdgpu_gpu_va_range type, |
| 1176 | uint64_t *start, |
| 1177 | uint64_t *end); |
| 1178 | |
Alex Deucher | 0936139 | 2015-04-20 12:04:22 -0400 | [diff] [blame] | 1179 | #endif /* #ifdef _AMDGPU_H_ */ |