2 * Copyright 2014 Advanced Micro Devices, Inc.
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:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
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.
27 * Declare public libdrm_amdgpu API
29 * This file define API exposed by libdrm_amdgpu library.
30 * User wanted to use libdrm_amdgpu functionality must include
40 struct drm_amdgpu_info_hw_ip;
42 /*--------------------------------------------------------------------------*/
43 /* --------------------------- Defines ------------------------------------ */
44 /*--------------------------------------------------------------------------*/
47 * Define max. number of Command Buffers (IB) which could be sent to the single
48 * hardware IP to accommodate CE/DE requirements
50 * \sa amdgpu_cs_ib_info
52 #define AMDGPU_CS_MAX_IBS_PER_SUBMIT 4
57 #define AMDGPU_TIMEOUT_INFINITE 0xffffffffffffffffull
60 /*--------------------------------------------------------------------------*/
61 /* ----------------------------- Enums ------------------------------------ */
62 /*--------------------------------------------------------------------------*/
65 * Enum describing possible handle types
67 * \sa amdgpu_bo_import, amdgpu_bo_export
70 enum amdgpu_bo_handle_type {
71 /** GEM flink name (needs DRM authentication, used by DRI2) */
72 amdgpu_bo_handle_type_gem_flink_name = 0,
74 /** KMS handle which is used by all driver ioctls */
75 amdgpu_bo_handle_type_kms = 1,
77 /** DMA-buf fd handle */
78 amdgpu_bo_handle_type_dma_buf_fd = 2
82 /*--------------------------------------------------------------------------*/
83 /* -------------------------- Datatypes ----------------------------------- */
84 /*--------------------------------------------------------------------------*/
87 * Define opaque pointer to context associated with fd.
88 * This context will be returned as the result of
89 * "initialize" function and should be pass as the first
90 * parameter to any API call
92 typedef struct amdgpu_device *amdgpu_device_handle;
95 * Define GPU Context type as pointer to opaque structure
96 * Example of GPU Context is the "rendering" context associated
97 * with OpenGL context (glCreateContext)
99 typedef struct amdgpu_context *amdgpu_context_handle;
102 * Define handle for amdgpu resources: buffer, GDS, etc.
104 typedef struct amdgpu_bo *amdgpu_bo_handle;
107 * Define handle for list of BOs
109 typedef struct amdgpu_bo_list *amdgpu_bo_list_handle;
112 /*--------------------------------------------------------------------------*/
113 /* -------------------------- Structures ---------------------------------- */
114 /*--------------------------------------------------------------------------*/
117 * Structure describing memory allocation request
119 * \sa amdgpu_bo_alloc()
122 struct amdgpu_bo_alloc_request {
123 /** Allocation request. It must be aligned correctly. */
127 * It may be required to have some specific alignment requirements
128 * for physical back-up storage (e.g. for displayable surface).
129 * If 0 there is no special alignment requirement
131 uint64_t phys_alignment;
134 * UMD should specify where to allocate memory and how it
135 * will be accessed by the CPU.
137 uint32_t preferred_heap;
139 /** Additional flags passed on allocation */
144 * Structure describing memory allocation request
146 * \sa amdgpu_bo_alloc()
148 struct amdgpu_bo_alloc_result {
149 /** Assigned virtual MC Base Address */
150 uint64_t virtual_mc_base_address;
152 /** Handle of allocated memory to be used by the given process only. */
153 amdgpu_bo_handle buf_handle;
157 * Special UMD specific information associated with buffer.
159 * It may be need to pass some buffer charactersitic as part
160 * of buffer sharing. Such information are defined UMD and
161 * opaque for libdrm_amdgpu as well for kernel driver.
163 * \sa amdgpu_bo_set_metadata(), amdgpu_bo_query_info,
164 * amdgpu_bo_import(), amdgpu_bo_export
167 struct amdgpu_bo_metadata {
168 /** Special flag associated with surface */
172 * ASIC-specific tiling information (also used by DCE).
173 * The encoding is defined by the AMDGPU_TILING_* definitions.
175 uint64_t tiling_info;
177 /** Size of metadata associated with the buffer, in bytes. */
178 uint32_t size_metadata;
180 /** UMD specific metadata. Opaque for kernel */
181 uint32_t umd_metadata[64];
185 * Structure describing allocated buffer. Client may need
186 * to query such information as part of 'sharing' buffers mechanism
188 * \sa amdgpu_bo_set_metadata(), amdgpu_bo_query_info(),
189 * amdgpu_bo_import(), amdgpu_bo_export()
191 struct amdgpu_bo_info {
192 /** Allocated memory size */
196 * It may be required to have some specific alignment requirements
197 * for physical back-up storage.
199 uint64_t phys_alignment;
202 * Assigned virtual MC Base Address.
203 * \note This information will be returned only if this buffer was
204 * allocated in the same process otherwise 0 will be returned.
206 uint64_t virtual_mc_base_address;
208 /** Heap where to allocate memory. */
209 uint32_t preferred_heap;
211 /** Additional allocation flags. */
212 uint64_t alloc_flags;
214 /** Metadata associated with buffer if any. */
215 struct amdgpu_bo_metadata metadata;
219 * Structure with information about "imported" buffer
221 * \sa amdgpu_bo_import()
224 struct amdgpu_bo_import_result {
225 /** Handle of memory/buffer to use */
226 amdgpu_bo_handle buf_handle;
231 /** Assigned virtual MC Base Address */
232 uint64_t virtual_mc_base_address;
238 * Structure to describe GDS partitioning information.
239 * \note OA and GWS resources are asscoiated with GDS partition
241 * \sa amdgpu_gpu_resource_query_gds_info
244 struct amdgpu_gds_resource_info {
245 uint32_t gds_gfx_partition_size;
246 uint32_t compute_partition_size;
247 uint32_t gds_total_size;
248 uint32_t gws_per_gfx_partition;
249 uint32_t gws_per_compute_partition;
250 uint32_t oa_per_gfx_partition;
251 uint32_t oa_per_compute_partition;
257 * Structure describing result of request to allocate GDS
259 * \sa amdgpu_gpu_resource_gds_alloc
262 struct amdgpu_gds_alloc_info {
263 /** Handle assigned to gds allocation */
264 amdgpu_bo_handle resource_handle;
266 /** How much was really allocated */
267 uint32_t gds_memory_size;
269 /** Number of GWS resources allocated */
272 /** Number of OA resources allocated */
277 * Structure describing IB
279 * \sa amdgpu_cs_request, amdgpu_cs_submit()
282 struct amdgpu_cs_ib_info {
286 /** Handle of command buffer */
287 amdgpu_bo_handle bo_handle;
290 * Size of Command Buffer to be submitted.
291 * - The size is in units of dwords (4 bytes).
292 * - Must be less or equal to the size of allocated IB
297 /** Offset in the IB buffer object (in unit of dwords) */
302 * Structure describing submission request
304 * \note We could have several IBs as packet. e.g. CE, CE, DE case for gfx
306 * \sa amdgpu_cs_submit()
308 struct amdgpu_cs_request {
309 /** Specify flags with additional information */
312 /** Specify HW IP block type to which to send the IB. */
315 /** IP instance index if there are several IPs of the same type. */
316 unsigned ip_instance;
319 * Specify ring index of the IP. We could have several rings
320 * in the same IP. E.g. 0 for SDMA0 and 1 for SDMA1.
325 * List handle with resources used by this request.
327 amdgpu_bo_list_handle resources;
329 /** Number of IBs to submit in the field ibs. */
330 uint32_t number_of_ibs;
333 * IBs to submit. Those IBs will be submit together as single entity
335 struct amdgpu_cs_ib_info *ibs;
339 * Structure describing request to check submission state using fence
341 * \sa amdgpu_cs_query_fence_status()
344 struct amdgpu_cs_query_fence {
346 /** In which context IB was sent to execution */
347 amdgpu_context_handle context;
349 /** Timeout in nanoseconds. */
352 /** To which HW IP type the fence belongs */
355 /** IP instance index if there are several IPs of the same type. */
356 unsigned ip_instance;
358 /** Ring index of the HW IP */
364 /** Specify fence for which we need to check
365 * submission status.*/
370 * Structure which provide information about GPU VM MC Address space
371 * alignments requirements
373 * \sa amdgpu_query_buffer_size_alignment
375 struct amdgpu_buffer_size_alignments {
376 /** Size alignment requirement for allocation in
381 * Size alignment requirement for allocation in remote memory
383 uint64_t size_remote;
388 * Structure which provide information about heap
390 * \sa amdgpu_query_heap_info()
393 struct amdgpu_heap_info {
394 /** Theoretical max. available memory in the given heap */
398 * Number of bytes allocated in the heap. This includes all processes
399 * and private allocations in the kernel. It changes when new buffers
400 * are allocated, freed, and moved. It cannot be larger than
406 * Theoretical possible max. size of buffer which
407 * could be allocated in the given heap
409 uint64_t max_allocation;
415 * Describe GPU h/w info needed for UMD correct initialization
417 * \sa amdgpu_query_gpu_info()
419 struct amdgpu_gpu_info {
422 /**< Chip revision */
424 /** Chip external revision */
425 uint32_t chip_external_rev;
430 /** max engine clock*/
431 uint64_t max_engine_clk;
432 /** max memory clock */
433 uint64_t max_memory_clk;
434 /** number of shader engines */
435 uint32_t num_shader_engines;
436 /** number of shader arrays per engine */
437 uint32_t num_shader_arrays_per_engine;
438 /** Number of available good shader pipes */
439 uint32_t avail_quad_shader_pipes;
440 /** Max. number of shader pipes.(including good and bad pipes */
441 uint32_t max_quad_shader_pipes;
442 /** Number of parameter cache entries per shader quad pipe */
443 uint32_t cache_entries_per_quad_pipe;
444 /** Number of available graphics context */
445 uint32_t num_hw_gfx_contexts;
446 /** Number of render backend pipes */
448 /** Enabled render backend pipe mask */
449 uint32_t enabled_rb_pipes_mask;
450 /** Frequency of GPU Counter */
451 uint32_t gpu_counter_freq;
452 /** CC_RB_BACKEND_DISABLE.BACKEND_DISABLE per SE */
453 uint32_t backend_disable[4];
454 /** Value of MC_ARB_RAMCFG register*/
455 uint32_t mc_arb_ramcfg;
456 /** Value of GB_ADDR_CONFIG */
457 uint32_t gb_addr_cfg;
458 /** Values of the GB_TILE_MODE0..31 registers */
459 uint32_t gb_tile_mode[32];
460 /** Values of GB_MACROTILE_MODE0..15 registers */
461 uint32_t gb_macro_tile_mode[16];
462 /** Value of PA_SC_RASTER_CONFIG register per SE */
463 uint32_t pa_sc_raster_cfg[4];
464 /** Value of PA_SC_RASTER_CONFIG_1 register per SE */
465 uint32_t pa_sc_raster_cfg1[4];
467 uint32_t cu_active_number;
469 uint32_t cu_bitmap[4][4];
470 /* video memory type info*/
472 /* video memory bit width*/
473 uint32_t vram_bit_width;
474 /** constant engine ram size*/
475 uint32_t ce_ram_size;
479 /*--------------------------------------------------------------------------*/
480 /*------------------------- Functions --------------------------------------*/
481 /*--------------------------------------------------------------------------*/
484 * Initialization / Cleanup
491 * \param fd - \c [in] File descriptor for AMD GPU device
492 * received previously as the result of
493 * e.g. drmOpen() call.
494 * For legacy fd type, the DRI2/DRI3 authentication
495 * should be done before calling this function.
496 * \param major_version - \c [out] Major version of library. It is assumed
497 * that adding new functionality will cause
498 * increase in major version
499 * \param minor_version - \c [out] Minor version of library
500 * \param device_handle - \c [out] Pointer to opaque context which should
501 * be passed as the first parameter on each
505 * \return 0 on success\n
506 * >0 - AMD specific error code\n
507 * <0 - Negative POSIX Error code
510 * \sa amdgpu_device_deinitialize()
512 int amdgpu_device_initialize(int fd,
513 uint32_t *major_version,
514 uint32_t *minor_version,
515 amdgpu_device_handle *device_handle);
521 * When access to such library does not needed any more the special
522 * function must be call giving opportunity to clean up any
523 * resources if needed.
525 * \param device_handle - \c [in] Context associated with file
526 * descriptor for AMD GPU device
527 * received previously as the
528 * result e.g. of drmOpen() call.
530 * \return 0 on success\n
531 * >0 - AMD specific error code\n
532 * <0 - Negative POSIX Error code
534 * \sa amdgpu_device_initialize()
537 int amdgpu_device_deinitialize(amdgpu_device_handle device_handle);
546 * Allocate memory to be used by UMD for GPU related operations
548 * \param dev - \c [in] Device handle.
549 * See #amdgpu_device_initialize()
550 * \param alloc_buffer - \c [in] Pointer to the structure describing an
552 * \param info - \c [out] Pointer to structure which return
553 * information about allocated memory
555 * \return 0 on success\n
556 * >0 - AMD specific error code\n
557 * <0 - Negative POSIX Error code
559 * \sa amdgpu_bo_free()
561 int amdgpu_bo_alloc(amdgpu_device_handle dev,
562 struct amdgpu_bo_alloc_request *alloc_buffer,
563 struct amdgpu_bo_alloc_result *info);
566 * Associate opaque data with buffer to be queried by another UMD
568 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
569 * \param buf_handle - \c [in] Buffer handle
570 * \param info - \c [in] Metadata to associated with buffer
572 * \return 0 on success\n
573 * >0 - AMD specific error code\n
574 * <0 - Negative POSIX Error code
576 int amdgpu_bo_set_metadata(amdgpu_bo_handle buf_handle,
577 struct amdgpu_bo_metadata *info);
580 * Query buffer information including metadata previusly associated with
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
588 * \return 0 on success\n
589 * >0 - AMD specific error code\n
590 * <0 - Negative POSIX Error code
592 * \sa amdgpu_bo_set_metadata(), amdgpu_bo_alloc()
594 int amdgpu_bo_query_info(amdgpu_bo_handle buf_handle,
595 struct amdgpu_bo_info *info);
598 * Allow others to get access to buffer
600 * \param dev - \c [in] Device handle.
601 * See #amdgpu_device_initialize()
602 * \param buf_handle - \c [in] Buffer handle
603 * \param type - \c [in] Type of handle requested
604 * \param shared_handle - \c [out] Special "shared" handle
606 * \return 0 on success\n
607 * >0 - AMD specific error code\n
608 * <0 - Negative POSIX Error code
610 * \sa amdgpu_bo_import()
613 int amdgpu_bo_export(amdgpu_bo_handle buf_handle,
614 enum amdgpu_bo_handle_type type,
615 uint32_t *shared_handle);
618 * Request access to "shared" buffer
620 * \param dev - \c [in] Device handle.
621 * See #amdgpu_device_initialize()
622 * \param type - \c [in] Type of handle requested
623 * \param shared_handle - \c [in] Shared handle received as result "import"
625 * \param output - \c [out] Pointer to structure with information
626 * about imported buffer
628 * \return 0 on success\n
629 * >0 - AMD specific error code\n
630 * <0 - Negative POSIX Error code
632 * \note Buffer must be "imported" only using new "fd" (different from
633 * one used by "exporter").
635 * \sa amdgpu_bo_export()
638 int amdgpu_bo_import(amdgpu_device_handle dev,
639 enum amdgpu_bo_handle_type type,
640 uint32_t shared_handle,
641 struct amdgpu_bo_import_result *output);
644 * Free previosuly allocated memory
646 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
647 * \param buf_handle - \c [in] Buffer handle to free
649 * \return 0 on success\n
650 * >0 - AMD specific error code\n
651 * <0 - Negative POSIX Error code
653 * \note In the case of memory shared between different applications all
654 * resources will be “physically” freed only all such applications
656 * \note If is UMD responsibility to ‘free’ buffer only when there is no
659 * \sa amdgpu_bo_set_metadata(), amdgpu_bo_alloc()
662 int amdgpu_bo_free(amdgpu_bo_handle buf_handle);
665 * Request CPU access to GPU accessable memory
667 * \param buf_handle - \c [in] Buffer handle
668 * \param cpu - \c [out] CPU address to be used for access
670 * \return 0 on success\n
671 * >0 - AMD specific error code\n
672 * <0 - Negative POSIX Error code
674 * \sa amdgpu_bo_cpu_unmap()
677 int amdgpu_bo_cpu_map(amdgpu_bo_handle buf_handle, void **cpu);
680 * Release CPU access to GPU memory
682 * \param buf_handle - \c [in] Buffer handle
684 * \return 0 on success\n
685 * >0 - AMD specific error code\n
686 * <0 - Negative POSIX Error code
688 * \sa amdgpu_bo_cpu_map()
691 int amdgpu_bo_cpu_unmap(amdgpu_bo_handle buf_handle);
695 * Wait until a buffer is not used by the device.
697 * \param dev - \c [in] Device handle. See #amdgpu_lib_initialize()
698 * \param buf_handle - \c [in] Buffer handle.
699 * \param timeout_ns - Timeout in nanoseconds.
700 * \param buffer_busy - 0 if buffer is idle, all GPU access was completed
701 * and no GPU access is scheduled.
702 * 1 GPU access is in fly or scheduled
704 * \return 0 - on success
705 * <0 - AMD specific error code
707 int amdgpu_bo_wait_for_idle(amdgpu_bo_handle buf_handle,
712 * Creates a BO list handle for command submission.
714 * \param dev - \c [in] Device handle.
715 * See #amdgpu_device_initialize()
716 * \param number_of_resources - \c [in] Number of BOs in the list
717 * \param resources - \c [in] List of BO handles
718 * \param resource_prios - \c [in] Optional priority for each handle
719 * \param result - \c [out] Created BO list handle
721 * \return 0 on success\n
722 * >0 - AMD specific error code\n
723 * <0 - Negative POSIX Error code
725 * \sa amdgpu_bo_list_destroy()
727 int amdgpu_bo_list_create(amdgpu_device_handle dev,
728 uint32_t number_of_resources,
729 amdgpu_bo_handle *resources,
730 uint8_t *resource_prios,
731 amdgpu_bo_list_handle *result);
734 * Destroys a BO list handle.
736 * \param handle - \c [in] BO list handle.
738 * \return 0 on success\n
739 * >0 - AMD specific error code\n
740 * <0 - Negative POSIX Error code
742 * \sa amdgpu_bo_list_create()
744 int amdgpu_bo_list_destroy(amdgpu_bo_list_handle handle);
747 * Update resources for existing BO list
749 * \param handle - \c [in] BO list handle
750 * \param number_of_resources - \c [in] Number of BOs in the list
751 * \param resources - \c [in] List of BO handles
752 * \param resource_prios - \c [in] Optional priority for each handle
754 * \return 0 on success\n
755 * >0 - AMD specific error code\n
756 * <0 - Negative POSIX Error code
758 * \sa amdgpu_bo_list_update()
760 int amdgpu_bo_list_update(amdgpu_bo_list_handle handle,
761 uint32_t number_of_resources,
762 amdgpu_bo_handle *resources,
763 uint8_t *resource_prios);
766 * Special GPU Resources
773 * Query information about GDS
775 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
776 * \param gds_info - \c [out] Pointer to structure to get GDS information
778 * \return 0 on success\n
779 * >0 - AMD specific error code\n
780 * <0 - Negative POSIX Error code
783 int amdgpu_gpu_resource_query_gds_info(amdgpu_device_handle dev,
784 struct amdgpu_gds_resource_info *
789 * Allocate GDS partitions
791 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
792 * \param gds_size - \c [in] Size of gds allocation. Must be aligned
794 * \param alloc_info - \c [out] Pointer to structure to receive information
797 * \return 0 on success\n
798 * >0 - AMD specific error code\n
799 * <0 - Negative POSIX Error code
803 int amdgpu_gpu_resource_gds_alloc(amdgpu_device_handle dev,
805 struct amdgpu_gds_alloc_info *alloc_info);
811 * Release GDS resource. When GDS and associated resources not needed any
812 * more UMD should free them
814 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
815 * \param handle - \c [in] Handle assigned to GDS allocation
817 * \return 0 on success\n
818 * >0 - AMD specific error code\n
819 * <0 - Negative POSIX Error code
822 int amdgpu_gpu_resource_gds_free(amdgpu_bo_handle handle);
827 * GPU Execution context
832 * Create GPU execution Context
834 * For the purpose of GPU Scheduler and GPU Robustness extensions it is
835 * necessary to have information/identify rendering/compute contexts.
836 * It also may be needed to associate some specific requirements with such
837 * contexts. Kernel driver will guarantee that submission from the same
838 * context will always be executed in order (first come, first serve).
841 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
842 * \param context - \c [out] GPU Context handle
844 * \return 0 on success\n
845 * >0 - AMD specific error code\n
846 * <0 - Negative POSIX Error code
848 * \sa amdgpu_cs_ctx_free()
851 int amdgpu_cs_ctx_create(amdgpu_device_handle dev,
852 amdgpu_context_handle *context);
856 * Destroy GPU execution context when not needed any more
858 * \param context - \c [in] GPU Context handle
860 * \return 0 on success\n
861 * >0 - AMD specific error code\n
862 * <0 - Negative POSIX Error code
864 * \sa amdgpu_cs_ctx_create()
867 int amdgpu_cs_ctx_free(amdgpu_context_handle context);
870 * Query reset state for the specific GPU Context
872 * \param context - \c [in] GPU Context handle
873 * \param state - \c [out] One of AMDGPU_CTX_*_RESET
874 * \param hangs - \c [out] Number of hangs caused by the context.
876 * \return 0 on success\n
877 * >0 - AMD specific error code\n
878 * <0 - Negative POSIX Error code
880 * \sa amdgpu_cs_ctx_create()
883 int amdgpu_cs_query_reset_state(amdgpu_context_handle context,
884 uint32_t *state, uint32_t *hangs);
888 * Command Buffers Management
893 * Send request to submit command buffers to hardware.
895 * Kernel driver could use GPU Scheduler to make decision when physically
896 * sent this request to the hardware. Accordingly this request could be put
897 * in queue and sent for execution later. The only guarantee is that request
898 * from the same GPU context to the same ip:ip_instance:ring will be executed in
902 * \param dev - \c [in] Device handle.
903 * See #amdgpu_device_initialize()
904 * \param context - \c [in] GPU Context
905 * \param flags - \c [in] Global submission flags
906 * \param ibs_request - \c [in] Pointer to submission requests.
907 * We could submit to the several
908 * engines/rings simulteniously as
910 * \param number_of_requests - \c [in] Number of submission requests
911 * \param fences - \c [out] Pointer to array of data to get
912 * fences to identify submission
913 * requests. Timestamps are valid
914 * in this GPU context and could be used
915 * to identify/detect completion of
918 * \return 0 on success\n
919 * >0 - AMD specific error code\n
920 * <0 - Negative POSIX Error code
922 * \note It is required to pass correct resource list with buffer handles
923 * which will be accessible by command buffers from submission
924 * This will allow kernel driver to correctly implement "paging".
925 * Failure to do so will have unpredictable results.
927 * \sa amdgpu_command_buffer_alloc(), amdgpu_command_buffer_free(),
928 * amdgpu_cs_query_fence_status()
931 int amdgpu_cs_submit(amdgpu_context_handle context,
933 struct amdgpu_cs_request *ibs_request,
934 uint32_t number_of_requests,
938 * Query status of Command Buffer Submission
940 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
941 * \param fence - \c [in] Structure describing fence to query
942 * \param expired - \c [out] If fence expired or not.\n
943 * 0 – if fence is not expired\n
946 * \return 0 on success\n
947 * >0 - AMD specific error code\n
948 * <0 - Negative POSIX Error code
950 * \note If UMD wants only to check operation status and returned immediately
951 * then timeout value as 0 must be passed. In this case success will be
952 * returned in the case if submission was completed or timeout error
955 * \sa amdgpu_cs_submit()
957 int amdgpu_cs_query_fence_status(struct amdgpu_cs_query_fence *fence,
968 * Query allocation size alignments
970 * UMD should query information about GPU VM MC size alignments requirements
971 * to be able correctly choose required allocation size and implement
972 * internal optimization if needed.
974 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
975 * \param info - \c [out] Pointer to structure to get size alignment
978 * \return 0 on success\n
979 * >0 - AMD specific error code\n
980 * <0 - Negative POSIX Error code
983 int amdgpu_query_buffer_size_alignment(amdgpu_device_handle dev,
984 struct amdgpu_buffer_size_alignments
990 * Query firmware versions
992 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
993 * \param fw_type - \c [in] AMDGPU_INFO_FW_*
994 * \param ip_instance - \c [in] Index of the IP block of the same type.
995 * \param index - \c [in] Index of the engine. (for SDMA and MEC)
996 * \param version - \c [out] Pointer to to the "version" return value
997 * \param feature - \c [out] Pointer to to the "feature" return value
999 * \return 0 on success\n
1000 * >0 - AMD specific error code\n
1001 * <0 - Negative POSIX Error code
1004 int amdgpu_query_firmware_version(amdgpu_device_handle dev, unsigned fw_type,
1005 unsigned ip_instance, unsigned index,
1006 uint32_t *version, uint32_t *feature);
1011 * Query the number of HW IP instances of a certain type.
1013 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
1014 * \param type - \c [in] Hardware IP block type = AMDGPU_HW_IP_*
1015 * \param count - \c [out] Pointer to structure to get information
1017 * \return 0 on success\n
1018 * >0 - AMD specific error code\n
1019 * <0 - Negative POSIX Error code
1021 int amdgpu_query_hw_ip_count(amdgpu_device_handle dev, unsigned type,
1027 * Query engine information
1029 * This query allows UMD to query information different engines and their
1032 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
1033 * \param type - \c [in] Hardware IP block type = AMDGPU_HW_IP_*
1034 * \param ip_instance - \c [in] Index of the IP block of the same type.
1035 * \param info - \c [out] Pointer to structure to get information
1037 * \return 0 on success\n
1038 * >0 - AMD specific error code\n
1039 * <0 - Negative POSIX Error code
1041 int amdgpu_query_hw_ip_info(amdgpu_device_handle dev, unsigned type,
1042 unsigned ip_instance,
1043 struct drm_amdgpu_info_hw_ip *info);
1049 * Query heap information
1051 * This query allows UMD to query potentially available memory resources and
1052 * adjust their logic if necessary.
1054 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
1055 * \param heap - \c [in] Heap type
1056 * \param info - \c [in] Pointer to structure to get needed information
1058 * \return 0 on success\n
1059 * >0 - AMD specific error code\n
1060 * <0 - Negative POSIX Error code
1063 int amdgpu_query_heap_info(amdgpu_device_handle dev,
1066 struct amdgpu_heap_info *info);
1071 * Get the CRTC ID from the mode object ID
1073 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
1074 * \param id - \c [in] Mode object ID
1075 * \param result - \c [in] Pointer to the CRTC ID
1077 * \return 0 on success\n
1078 * >0 - AMD specific error code\n
1079 * <0 - Negative POSIX Error code
1082 int amdgpu_query_crtc_from_id(amdgpu_device_handle dev, unsigned id,
1088 * Query GPU H/w Info
1090 * Query hardware specific information
1092 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
1093 * \param heap - \c [in] Heap type
1094 * \param info - \c [in] Pointer to structure to get needed information
1096 * \return 0 on success\n
1097 * >0 - AMD specific error code\n
1098 * <0 - Negative POSIX Error code
1101 int amdgpu_query_gpu_info(amdgpu_device_handle dev,
1102 struct amdgpu_gpu_info *info);
1107 * Query hardware or driver information.
1109 * The return size is query-specific and depends on the "info_id" parameter.
1110 * No more than "size" bytes is returned.
1112 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
1113 * \param info_id - \c [in] AMDGPU_INFO_*
1114 * \param size - \c [in] Size of the returned value.
1115 * \param value - \c [out] Pointer to the return value.
1117 * \return 0 on success\n
1118 * >0 - AMD specific error code\n
1119 * <0 - Negative POSIX error code
1122 int amdgpu_query_info(amdgpu_device_handle dev, unsigned info_id,
1123 unsigned size, void *value);
1128 * Read a set of consecutive memory-mapped registers.
1129 * Not all registers are allowed to be read by userspace.
1131 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize(
1132 * \param dword_offset - \c [in] Register offset in dwords
1133 * \param count - \c [in] The number of registers to read starting
1135 * \param instance - \c [in] GRBM_GFX_INDEX selector. It may have other
1136 * uses. Set it to 0xffffffff if unsure.
1137 * \param flags - \c [in] Flags with additional information.
1138 * \param values - \c [out] The pointer to return values.
1140 * \return 0 on success\n
1141 * >0 - AMD specific error code\n
1142 * <0 - Negative POSIX error code
1145 int amdgpu_read_mm_registers(amdgpu_device_handle dev, unsigned dword_offset,
1146 unsigned count, uint32_t instance, uint32_t flags,
1152 * Request GPU access to user allocated memory e.g. via "malloc"
1154 * \param dev - [in] Device handle. See #amdgpu_device_initialize()
1155 * \param cpu - [in] CPU address of user allocated memory which we
1156 * want to map to GPU address space (make GPU accessible)
1157 * (This address must be correctly aligned).
1158 * \param size - [in] Size of allocation (must be correctly aligned)
1159 * \param amdgpu_bo_alloc_result - [out] Handle of allocation to be passed as resource
1160 * on submission and be used in other operations.(e.g. for VA submission)
1161 * ( Temporally defined amdgpu_bo_alloc_result as parameter for return mc address. )
1164 * \return 0 on success
1165 * >0 - AMD specific error code
1166 * <0 - Negative POSIX Error code
1170 * This call doesn't guarantee that such memory will be persistently
1171 * "locked" / make non-pageable. The purpose of this call is to provide
1172 * opportunity for GPU get access to this resource during submission.
1174 * The maximum amount of memory which could be mapped in this call depends
1175 * if overcommit is disabled or not. If overcommit is disabled than the max.
1176 * amount of memory to be pinned will be limited by left "free" size in total
1177 * amount of memory which could be locked simultaneously ("GART" size).
1179 * Supported (theoretical) max. size of mapping is restricted only by
1182 * It is responsibility of caller to correctly specify access rights
1185 int amdgpu_create_bo_from_user_mem(amdgpu_device_handle dev,
1188 struct amdgpu_bo_alloc_result *info);
1191 #endif /* #ifdef _AMDGPU_H_ */