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
55 * Special timeout value meaning that the timeout is infinite.
57 #define AMDGPU_TIMEOUT_INFINITE 0xffffffffffffffffull
60 * Used in amdgpu_cs_query_fence::flags, meaning that the given timeout
63 #define AMDGPU_QUERY_FENCE_TIMEOUT_IS_ABSOLUTE (1 << 0)
65 /*--------------------------------------------------------------------------*/
66 /* ----------------------------- Enums ------------------------------------ */
67 /*--------------------------------------------------------------------------*/
70 * Enum describing possible handle types
72 * \sa amdgpu_bo_import, amdgpu_bo_export
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,
79 /** KMS handle which is used by all driver ioctls */
80 amdgpu_bo_handle_type_kms = 1,
82 /** DMA-buf fd handle */
83 amdgpu_bo_handle_type_dma_buf_fd = 2
86 /** Define known types of GPU VM VA ranges */
87 enum amdgpu_gpu_va_range
89 /** Allocate from "normal"/general range */
90 amdgpu_gpu_va_range_general = 0
93 /*--------------------------------------------------------------------------*/
94 /* -------------------------- Datatypes ----------------------------------- */
95 /*--------------------------------------------------------------------------*/
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
103 typedef struct amdgpu_device *amdgpu_device_handle;
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)
110 typedef struct amdgpu_context *amdgpu_context_handle;
113 * Define handle for amdgpu resources: buffer, GDS, etc.
115 typedef struct amdgpu_bo *amdgpu_bo_handle;
118 * Define handle for list of BOs
120 typedef struct amdgpu_bo_list *amdgpu_bo_list_handle;
123 * Define handle to be used to work with VA allocated ranges
125 typedef struct amdgpu_va *amdgpu_va_handle;
127 /*--------------------------------------------------------------------------*/
128 /* -------------------------- Structures ---------------------------------- */
129 /*--------------------------------------------------------------------------*/
132 * Structure describing memory allocation request
134 * \sa amdgpu_bo_alloc()
137 struct amdgpu_bo_alloc_request {
138 /** Allocation request. It must be aligned correctly. */
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
146 uint64_t phys_alignment;
149 * UMD should specify where to allocate memory and how it
150 * will be accessed by the CPU.
152 uint32_t preferred_heap;
154 /** Additional flags passed on allocation */
159 * Structure describing memory allocation request
161 * \sa amdgpu_bo_alloc()
163 struct amdgpu_bo_alloc_result {
164 /** Assigned virtual MC Base Address */
165 uint64_t virtual_mc_base_address;
167 /** Handle of allocated memory to be used by the given process only. */
168 amdgpu_bo_handle buf_handle;
172 * Special UMD specific information associated with buffer.
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.
178 * \sa amdgpu_bo_set_metadata(), amdgpu_bo_query_info,
179 * amdgpu_bo_import(), amdgpu_bo_export
182 struct amdgpu_bo_metadata {
183 /** Special flag associated with surface */
187 * ASIC-specific tiling information (also used by DCE).
188 * The encoding is defined by the AMDGPU_TILING_* definitions.
190 uint64_t tiling_info;
192 /** Size of metadata associated with the buffer, in bytes. */
193 uint32_t size_metadata;
195 /** UMD specific metadata. Opaque for kernel */
196 uint32_t umd_metadata[64];
200 * Structure describing allocated buffer. Client may need
201 * to query such information as part of 'sharing' buffers mechanism
203 * \sa amdgpu_bo_set_metadata(), amdgpu_bo_query_info(),
204 * amdgpu_bo_import(), amdgpu_bo_export()
206 struct amdgpu_bo_info {
207 /** Allocated memory size */
211 * It may be required to have some specific alignment requirements
212 * for physical back-up storage.
214 uint64_t phys_alignment;
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.
221 uint64_t virtual_mc_base_address;
223 /** Heap where to allocate memory. */
224 uint32_t preferred_heap;
226 /** Additional allocation flags. */
227 uint64_t alloc_flags;
229 /** Metadata associated with buffer if any. */
230 struct amdgpu_bo_metadata metadata;
234 * Structure with information about "imported" buffer
236 * \sa amdgpu_bo_import()
239 struct amdgpu_bo_import_result {
240 /** Handle of memory/buffer to use */
241 amdgpu_bo_handle buf_handle;
246 /** Assigned virtual MC Base Address */
247 uint64_t virtual_mc_base_address;
252 * Structure to describe GDS partitioning information.
253 * \note OA and GWS resources are asscoiated with GDS partition
255 * \sa amdgpu_gpu_resource_query_gds_info
258 struct amdgpu_gds_resource_info {
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;
269 * Structure describing CS dependency
271 * \sa amdgpu_cs_request, amdgpu_cs_submit()
274 struct amdgpu_cs_dep_info {
275 /** Context to which the fence belongs */
276 amdgpu_context_handle context;
278 /** To which HW IP type the fence belongs */
281 /** IP instance index if there are several IPs of the same type. */
282 uint32_t ip_instance;
284 /** Ring index of the HW IP */
287 /** Specify fence for which we need to check submission status.*/
292 * Structure describing IB
294 * \sa amdgpu_cs_request, amdgpu_cs_submit()
297 struct amdgpu_cs_ib_info {
301 /** Virtual MC address of the command buffer */
302 uint64_t ib_mc_address;
305 * Size of Command Buffer to be submitted.
306 * - The size is in units of dwords (4 bytes).
313 * Structure describing submission request
315 * \note We could have several IBs as packet. e.g. CE, CE, DE case for gfx
317 * \sa amdgpu_cs_submit()
319 struct amdgpu_cs_request {
320 /** Specify flags with additional information */
323 /** Specify HW IP block type to which to send the IB. */
326 /** IP instance index if there are several IPs of the same type. */
327 unsigned ip_instance;
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.
336 * List handle with resources used by this request.
338 amdgpu_bo_list_handle resources;
341 * Number of dependencies this Command submission needs to
342 * wait for before starting execution.
344 uint32_t number_of_dependencies;
347 * Array of dependencies which need to be met before
348 * execution can start.
350 struct amdgpu_cs_dep_info *dependencies;
352 /** Number of IBs to submit in the field ibs. */
353 uint32_t number_of_ibs;
356 * IBs to submit. Those IBs will be submit together as single entity
358 struct amdgpu_cs_ib_info *ibs;
362 * Structure describing request to check submission state using fence
364 * \sa amdgpu_cs_query_fence_status()
367 struct amdgpu_cs_query_fence {
369 /** In which context IB was sent to execution */
370 amdgpu_context_handle context;
372 /** To which HW IP type the fence belongs */
375 /** IP instance index if there are several IPs of the same type. */
376 unsigned ip_instance;
378 /** Ring index of the HW IP */
381 /** Specify fence for which we need to check submission status.*/
386 * Structure which provide information about GPU VM MC Address space
387 * alignments requirements
389 * \sa amdgpu_query_buffer_size_alignment
391 struct amdgpu_buffer_size_alignments {
392 /** Size alignment requirement for allocation in
397 * Size alignment requirement for allocation in remote memory
399 uint64_t size_remote;
403 * Structure which provide information about heap
405 * \sa amdgpu_query_heap_info()
408 struct amdgpu_heap_info {
409 /** Theoretical max. available memory in the given heap */
413 * Number of bytes allocated in the heap. This includes all processes
414 * and private allocations in the kernel. It changes when new buffers
415 * are allocated, freed, and moved. It cannot be larger than
421 * Theoretical possible max. size of buffer which
422 * could be allocated in the given heap
424 uint64_t max_allocation;
428 * Describe GPU h/w info needed for UMD correct initialization
430 * \sa amdgpu_query_gpu_info()
432 struct amdgpu_gpu_info {
437 /** Chip external revision */
438 uint32_t chip_external_rev;
443 /** max engine clock*/
444 uint64_t max_engine_clk;
445 /** max memory clock */
446 uint64_t max_memory_clk;
447 /** number of shader engines */
448 uint32_t num_shader_engines;
449 /** number of shader arrays per engine */
450 uint32_t num_shader_arrays_per_engine;
451 /** Number of available good shader pipes */
452 uint32_t avail_quad_shader_pipes;
453 /** Max. number of shader pipes.(including good and bad pipes */
454 uint32_t max_quad_shader_pipes;
455 /** Number of parameter cache entries per shader quad pipe */
456 uint32_t cache_entries_per_quad_pipe;
457 /** Number of available graphics context */
458 uint32_t num_hw_gfx_contexts;
459 /** Number of render backend pipes */
461 /** Enabled render backend pipe mask */
462 uint32_t enabled_rb_pipes_mask;
463 /** Frequency of GPU Counter */
464 uint32_t gpu_counter_freq;
465 /** CC_RB_BACKEND_DISABLE.BACKEND_DISABLE per SE */
466 uint32_t backend_disable[4];
467 /** Value of MC_ARB_RAMCFG register*/
468 uint32_t mc_arb_ramcfg;
469 /** Value of GB_ADDR_CONFIG */
470 uint32_t gb_addr_cfg;
471 /** Values of the GB_TILE_MODE0..31 registers */
472 uint32_t gb_tile_mode[32];
473 /** Values of GB_MACROTILE_MODE0..15 registers */
474 uint32_t gb_macro_tile_mode[16];
475 /** Value of PA_SC_RASTER_CONFIG register per SE */
476 uint32_t pa_sc_raster_cfg[4];
477 /** Value of PA_SC_RASTER_CONFIG_1 register per SE */
478 uint32_t pa_sc_raster_cfg1[4];
480 uint32_t cu_active_number;
482 uint32_t cu_bitmap[4][4];
483 /* video memory type info*/
485 /* video memory bit width*/
486 uint32_t vram_bit_width;
487 /** constant engine ram size*/
488 uint32_t ce_ram_size;
492 /*--------------------------------------------------------------------------*/
493 /*------------------------- Functions --------------------------------------*/
494 /*--------------------------------------------------------------------------*/
497 * Initialization / Cleanup
503 * \param fd - \c [in] File descriptor for AMD GPU device
504 * received previously as the result of
505 * e.g. drmOpen() call.
506 * For legacy fd type, the DRI2/DRI3
507 * authentication should be done before
508 * calling this function.
509 * \param major_version - \c [out] Major version of library. It is assumed
510 * that adding new functionality will cause
511 * increase in major version
512 * \param minor_version - \c [out] Minor version of library
513 * \param device_handle - \c [out] Pointer to opaque context which should
514 * be passed as the first parameter on each
518 * \return 0 on success\n
519 * <0 - Negative POSIX Error code
522 * \sa amdgpu_device_deinitialize()
524 int amdgpu_device_initialize(int fd,
525 uint32_t *major_version,
526 uint32_t *minor_version,
527 amdgpu_device_handle *device_handle);
531 * When access to such library does not needed any more the special
532 * function must be call giving opportunity to clean up any
533 * resources if needed.
535 * \param device_handle - \c [in] Context associated with file
536 * descriptor for AMD GPU device
537 * received previously as the
538 * result e.g. of drmOpen() call.
540 * \return 0 on success\n
541 * <0 - Negative POSIX Error code
543 * \sa amdgpu_device_initialize()
546 int amdgpu_device_deinitialize(amdgpu_device_handle device_handle);
554 * Allocate memory to be used by UMD for GPU related operations
556 * \param dev - \c [in] Device handle.
557 * See #amdgpu_device_initialize()
558 * \param alloc_buffer - \c [in] Pointer to the structure describing an
560 * \param info - \c [out] Pointer to structure which return
561 * information about allocated memory
563 * \return 0 on success\n
564 * <0 - Negative POSIX Error code
566 * \sa amdgpu_bo_free()
568 int amdgpu_bo_alloc(amdgpu_device_handle dev,
569 struct amdgpu_bo_alloc_request *alloc_buffer,
570 struct amdgpu_bo_alloc_result *info);
573 * Associate opaque data with buffer to be queried by another UMD
575 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
576 * \param buf_handle - \c [in] Buffer handle
577 * \param info - \c [in] Metadata to associated with buffer
579 * \return 0 on success\n
580 * <0 - Negative POSIX Error code
582 int amdgpu_bo_set_metadata(amdgpu_bo_handle buf_handle,
583 struct amdgpu_bo_metadata *info);
586 * Query buffer information including metadata previusly associated with
589 * \param dev - \c [in] Device handle.
590 * See #amdgpu_device_initialize()
591 * \param buf_handle - \c [in] Buffer handle
592 * \param info - \c [out] Structure describing buffer
594 * \return 0 on success\n
595 * <0 - Negative POSIX Error code
597 * \sa amdgpu_bo_set_metadata(), amdgpu_bo_alloc()
599 int amdgpu_bo_query_info(amdgpu_bo_handle buf_handle,
600 struct amdgpu_bo_info *info);
603 * Allow others to get access to buffer
605 * \param dev - \c [in] Device handle.
606 * See #amdgpu_device_initialize()
607 * \param buf_handle - \c [in] Buffer handle
608 * \param type - \c [in] Type of handle requested
609 * \param shared_handle - \c [out] Special "shared" handle
611 * \return 0 on success\n
612 * <0 - Negative POSIX Error code
614 * \sa amdgpu_bo_import()
617 int amdgpu_bo_export(amdgpu_bo_handle buf_handle,
618 enum amdgpu_bo_handle_type type,
619 uint32_t *shared_handle);
622 * Request access to "shared" buffer
624 * \param dev - \c [in] Device handle.
625 * See #amdgpu_device_initialize()
626 * \param type - \c [in] Type of handle requested
627 * \param shared_handle - \c [in] Shared handle received as result "import"
629 * \param output - \c [out] Pointer to structure with information
630 * about imported buffer
632 * \return 0 on success\n
633 * <0 - Negative POSIX Error code
635 * \note Buffer must be "imported" only using new "fd" (different from
636 * one used by "exporter").
638 * \sa amdgpu_bo_export()
641 int amdgpu_bo_import(amdgpu_device_handle dev,
642 enum amdgpu_bo_handle_type type,
643 uint32_t shared_handle,
644 struct amdgpu_bo_import_result *output);
647 * Request GPU access to user allocated memory e.g. via "malloc"
649 * \param dev - [in] Device handle. See #amdgpu_device_initialize()
650 * \param cpu - [in] CPU address of user allocated memory which we
651 * want to map to GPU address space (make GPU accessible)
652 * (This address must be correctly aligned).
653 * \param size - [in] Size of allocation (must be correctly aligned)
654 * \param amdgpu_bo_alloc_result - [out] Handle of allocation to be passed as
655 * resource on submission and be used in other operations.
658 * \return 0 on success\n
659 * <0 - Negative POSIX Error code
662 * This call doesn't guarantee that such memory will be persistently
663 * "locked" / make non-pageable. The purpose of this call is to provide
664 * opportunity for GPU get access to this resource during submission.
666 * The maximum amount of memory which could be mapped in this call depends
667 * if overcommit is disabled or not. If overcommit is disabled than the max.
668 * amount of memory to be pinned will be limited by left "free" size in total
669 * amount of memory which could be locked simultaneously ("GART" size).
671 * Supported (theoretical) max. size of mapping is restricted only by
674 * It is responsibility of caller to correctly specify access rights
677 int amdgpu_create_bo_from_user_mem(amdgpu_device_handle dev,
678 void *cpu, uint64_t size,
679 struct amdgpu_bo_alloc_result *info);
682 * Free previosuly allocated memory
684 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
685 * \param buf_handle - \c [in] Buffer handle to free
687 * \return 0 on success\n
688 * <0 - Negative POSIX Error code
690 * \note In the case of memory shared between different applications all
691 * resources will be “physically” freed only all such applications
693 * \note If is UMD responsibility to ‘free’ buffer only when there is no
696 * \sa amdgpu_bo_set_metadata(), amdgpu_bo_alloc()
699 int amdgpu_bo_free(amdgpu_bo_handle buf_handle);
702 * Request CPU access to GPU accessable memory
704 * \param buf_handle - \c [in] Buffer handle
705 * \param cpu - \c [out] CPU address to be used for access
707 * \return 0 on success\n
708 * <0 - Negative POSIX Error code
710 * \sa amdgpu_bo_cpu_unmap()
713 int amdgpu_bo_cpu_map(amdgpu_bo_handle buf_handle, void **cpu);
716 * Release CPU access to GPU memory
718 * \param buf_handle - \c [in] Buffer handle
720 * \return 0 on success\n
721 * <0 - Negative POSIX Error code
723 * \sa amdgpu_bo_cpu_map()
726 int amdgpu_bo_cpu_unmap(amdgpu_bo_handle buf_handle);
729 * Wait until a buffer is not used by the device.
731 * \param dev - \c [in] Device handle. See #amdgpu_lib_initialize()
732 * \param buf_handle - \c [in] Buffer handle.
733 * \param timeout_ns - Timeout in nanoseconds.
734 * \param buffer_busy - 0 if buffer is idle, all GPU access was completed
735 * and no GPU access is scheduled.
736 * 1 GPU access is in fly or scheduled
738 * \return 0 - on success
739 * <0 - Negative POSIX Error code
741 int amdgpu_bo_wait_for_idle(amdgpu_bo_handle buf_handle,
746 * Creates a BO list handle for command submission.
748 * \param dev - \c [in] Device handle.
749 * See #amdgpu_device_initialize()
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
753 * \param result - \c [out] Created BO list handle
755 * \return 0 on success\n
756 * <0 - Negative POSIX Error code
758 * \sa amdgpu_bo_list_destroy()
760 int amdgpu_bo_list_create(amdgpu_device_handle dev,
761 uint32_t number_of_resources,
762 amdgpu_bo_handle *resources,
763 uint8_t *resource_prios,
764 amdgpu_bo_list_handle *result);
767 * Destroys a BO list handle.
769 * \param handle - \c [in] BO list handle.
771 * \return 0 on success\n
772 * <0 - Negative POSIX Error code
774 * \sa amdgpu_bo_list_create()
776 int amdgpu_bo_list_destroy(amdgpu_bo_list_handle handle);
779 * Update resources for existing BO list
781 * \param handle - \c [in] BO list handle
782 * \param number_of_resources - \c [in] Number of BOs in the list
783 * \param resources - \c [in] List of BO handles
784 * \param resource_prios - \c [in] Optional priority for each handle
786 * \return 0 on success\n
787 * <0 - Negative POSIX Error code
789 * \sa amdgpu_bo_list_update()
791 int amdgpu_bo_list_update(amdgpu_bo_list_handle handle,
792 uint32_t number_of_resources,
793 amdgpu_bo_handle *resources,
794 uint8_t *resource_prios);
797 * GPU Execution context
802 * Create GPU execution Context
804 * For the purpose of GPU Scheduler and GPU Robustness extensions it is
805 * necessary to have information/identify rendering/compute contexts.
806 * It also may be needed to associate some specific requirements with such
807 * contexts. Kernel driver will guarantee that submission from the same
808 * context will always be executed in order (first come, first serve).
811 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
812 * \param context - \c [out] GPU Context handle
814 * \return 0 on success\n
815 * <0 - Negative POSIX Error code
817 * \sa amdgpu_cs_ctx_free()
820 int amdgpu_cs_ctx_create(amdgpu_device_handle dev,
821 amdgpu_context_handle *context);
825 * Destroy GPU execution context when not needed any more
827 * \param context - \c [in] GPU Context handle
829 * \return 0 on success\n
830 * <0 - Negative POSIX Error code
832 * \sa amdgpu_cs_ctx_create()
835 int amdgpu_cs_ctx_free(amdgpu_context_handle context);
838 * Query reset state for the specific GPU Context
840 * \param context - \c [in] GPU Context handle
841 * \param state - \c [out] One of AMDGPU_CTX_*_RESET
842 * \param hangs - \c [out] Number of hangs caused by the context.
844 * \return 0 on success\n
845 * <0 - Negative POSIX Error code
847 * \sa amdgpu_cs_ctx_create()
850 int amdgpu_cs_query_reset_state(amdgpu_context_handle context,
851 uint32_t *state, uint32_t *hangs);
854 * Command Buffers Management
859 * Send request to submit command buffers to hardware.
861 * Kernel driver could use GPU Scheduler to make decision when physically
862 * sent this request to the hardware. Accordingly this request could be put
863 * in queue and sent for execution later. The only guarantee is that request
864 * from the same GPU context to the same ip:ip_instance:ring will be executed in
868 * \param dev - \c [in] Device handle.
869 * See #amdgpu_device_initialize()
870 * \param context - \c [in] GPU Context
871 * \param flags - \c [in] Global submission flags
872 * \param ibs_request - \c [in] Pointer to submission requests.
873 * We could submit to the several
874 * engines/rings simulteniously as
876 * \param number_of_requests - \c [in] Number of submission requests
877 * \param fences - \c [out] Pointer to array of data to get
878 * fences to identify submission
879 * requests. Timestamps are valid
880 * in this GPU context and could be used
881 * to identify/detect completion of
884 * \return 0 on success\n
885 * <0 - Negative POSIX Error code
887 * \note It is required to pass correct resource list with buffer handles
888 * which will be accessible by command buffers from submission
889 * This will allow kernel driver to correctly implement "paging".
890 * Failure to do so will have unpredictable results.
892 * \sa amdgpu_command_buffer_alloc(), amdgpu_command_buffer_free(),
893 * amdgpu_cs_query_fence_status()
896 int amdgpu_cs_submit(amdgpu_context_handle context,
898 struct amdgpu_cs_request *ibs_request,
899 uint32_t number_of_requests,
903 * Query status of Command Buffer Submission
905 * \param fence - \c [in] Structure describing fence to query
906 * \param timeout_ns - \c [in] Timeout value to wait
907 * \param flags - \c [in] Flags for the query
908 * \param expired - \c [out] If fence expired or not.\n
909 * 0 – if fence is not expired\n
912 * \return 0 on success\n
913 * <0 - Negative POSIX Error code
915 * \note If UMD wants only to check operation status and returned immediately
916 * then timeout value as 0 must be passed. In this case success will be
917 * returned in the case if submission was completed or timeout error
920 * \sa amdgpu_cs_submit()
922 int amdgpu_cs_query_fence_status(struct amdgpu_cs_query_fence *fence,
933 * Query allocation size alignments
935 * UMD should query information about GPU VM MC size alignments requirements
936 * to be able correctly choose required allocation size and implement
937 * internal optimization if needed.
939 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
940 * \param info - \c [out] Pointer to structure to get size alignment
943 * \return 0 on success\n
944 * <0 - Negative POSIX Error code
947 int amdgpu_query_buffer_size_alignment(amdgpu_device_handle dev,
948 struct amdgpu_buffer_size_alignments
952 * Query firmware versions
954 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
955 * \param fw_type - \c [in] AMDGPU_INFO_FW_*
956 * \param ip_instance - \c [in] Index of the IP block of the same type.
957 * \param index - \c [in] Index of the engine. (for SDMA and MEC)
958 * \param version - \c [out] Pointer to to the "version" return value
959 * \param feature - \c [out] Pointer to to the "feature" return value
961 * \return 0 on success\n
962 * <0 - Negative POSIX Error code
965 int amdgpu_query_firmware_version(amdgpu_device_handle dev, unsigned fw_type,
966 unsigned ip_instance, unsigned index,
967 uint32_t *version, uint32_t *feature);
970 * Query the number of HW IP instances of a certain type.
972 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
973 * \param type - \c [in] Hardware IP block type = AMDGPU_HW_IP_*
974 * \param count - \c [out] Pointer to structure to get information
976 * \return 0 on success\n
977 * <0 - Negative POSIX Error code
979 int amdgpu_query_hw_ip_count(amdgpu_device_handle dev, unsigned type,
983 * Query engine information
985 * This query allows UMD to query information different engines and their
988 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
989 * \param type - \c [in] Hardware IP block type = AMDGPU_HW_IP_*
990 * \param ip_instance - \c [in] Index of the IP block of the same type.
991 * \param info - \c [out] Pointer to structure to get information
993 * \return 0 on success\n
994 * <0 - Negative POSIX Error code
996 int amdgpu_query_hw_ip_info(amdgpu_device_handle dev, unsigned type,
997 unsigned ip_instance,
998 struct drm_amdgpu_info_hw_ip *info);
1001 * Query heap information
1003 * This query allows UMD to query potentially available memory resources and
1004 * adjust their logic if necessary.
1006 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
1007 * \param heap - \c [in] Heap type
1008 * \param info - \c [in] Pointer to structure to get needed information
1010 * \return 0 on success\n
1011 * <0 - Negative POSIX Error code
1014 int amdgpu_query_heap_info(amdgpu_device_handle dev, uint32_t heap,
1015 uint32_t flags, struct amdgpu_heap_info *info);
1018 * Get the CRTC ID from the mode object ID
1020 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
1021 * \param id - \c [in] Mode object ID
1022 * \param result - \c [in] Pointer to the CRTC ID
1024 * \return 0 on success\n
1025 * <0 - Negative POSIX Error code
1028 int amdgpu_query_crtc_from_id(amdgpu_device_handle dev, unsigned id,
1032 * Query GPU H/w Info
1034 * Query hardware specific information
1036 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
1037 * \param heap - \c [in] Heap type
1038 * \param info - \c [in] Pointer to structure to get needed information
1040 * \return 0 on success\n
1041 * <0 - Negative POSIX Error code
1044 int amdgpu_query_gpu_info(amdgpu_device_handle dev,
1045 struct amdgpu_gpu_info *info);
1048 * Query hardware or driver information.
1050 * The return size is query-specific and depends on the "info_id" parameter.
1051 * No more than "size" bytes is returned.
1053 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
1054 * \param info_id - \c [in] AMDGPU_INFO_*
1055 * \param size - \c [in] Size of the returned value.
1056 * \param value - \c [out] Pointer to the return value.
1058 * \return 0 on success\n
1059 * <0 - Negative POSIX error code
1062 int amdgpu_query_info(amdgpu_device_handle dev, unsigned info_id,
1063 unsigned size, void *value);
1066 * Query information about GDS
1068 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
1069 * \param gds_info - \c [out] Pointer to structure to get GDS information
1071 * \return 0 on success\n
1072 * <0 - Negative POSIX Error code
1075 int amdgpu_query_gds_info(amdgpu_device_handle dev,
1076 struct amdgpu_gds_resource_info *gds_info);
1079 * Read a set of consecutive memory-mapped registers.
1080 * Not all registers are allowed to be read by userspace.
1082 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize(
1083 * \param dword_offset - \c [in] Register offset in dwords
1084 * \param count - \c [in] The number of registers to read starting
1086 * \param instance - \c [in] GRBM_GFX_INDEX selector. It may have other
1087 * uses. Set it to 0xffffffff if unsure.
1088 * \param flags - \c [in] Flags with additional information.
1089 * \param values - \c [out] The pointer to return values.
1091 * \return 0 on success\n
1092 * <0 - Negative POSIX error code
1095 int amdgpu_read_mm_registers(amdgpu_device_handle dev, unsigned dword_offset,
1096 unsigned count, uint32_t instance, uint32_t flags,
1100 * Allocate virtual address range
1102 * \param dev - [in] Device handle. See #amdgpu_device_initialize()
1103 * \param va_range_type - \c [in] Type of MC va range from which to allocate
1104 * \param size - \c [in] Size of range. Size must be correctly* aligned.
1105 * It is client responsibility to correctly aligned size based on the future
1106 * usage of allocated range.
1107 * \param va_base_alignment - \c [in] Overwrite base address alignment
1108 * requirement for GPU VM MC virtual
1109 * address assignment. Must be multiple of size alignments received as
1110 * 'amdgpu_buffer_size_alignments'.
1111 * If 0 use the default one.
1112 * \param va_base_required - \c [in] Specified required va base address.
1113 * If 0 then library choose available one.
1114 * If !0 value will be passed and those value already "in use" then
1115 * corresponding error status will be returned.
1116 * \param va_base_allocated - \c [out] On return: Allocated VA base to be used
1118 * \param va_range_handle - \c [out] On return: Handle assigned to allocation
1120 * \return 0 on success\n
1121 * >0 - AMD specific error code\n
1122 * <0 - Negative POSIX Error code
1125 * It is client responsibility to correctly handle VA assignments and usage.
1126 * Neither kernel driver nor libdrm_amdpgu are able to prevent and
1127 * detect wrong va assignemnt.
1129 * It is client responsibility to correctly handle multi-GPU cases and to pass
1130 * the corresponding arrays of all devices handles where corresponding VA will
1134 int amdgpu_va_range_alloc(amdgpu_device_handle dev,
1135 enum amdgpu_gpu_va_range va_range_type,
1137 uint64_t va_base_alignment,
1138 uint64_t va_base_required,
1139 uint64_t *va_base_allocated,
1140 amdgpu_va_handle *va_range_handle);
1143 * Free previously allocated virtual address range
1146 * \param va_range_handle - \c [in] Handle assigned to VA allocation
1148 * \return 0 on success\n
1149 * >0 - AMD specific error code\n
1150 * <0 - Negative POSIX Error code
1153 int amdgpu_va_range_free(amdgpu_va_handle va_range_handle);
1156 * Query virtual address range
1158 * UMD can query GPU VM range supported by each device
1159 * to initialize its own VAM accordingly.
1161 * \param dev - [in] Device handle. See #amdgpu_device_initialize()
1162 * \param type - \c [in] Type of virtual address range
1163 * \param offset - \c [out] Start offset of virtual address range
1164 * \param size - \c [out] Size of virtual address range
1166 * \return 0 on success\n
1167 * <0 - Negative POSIX Error code
1171 int amdgpu_va_range_query(amdgpu_device_handle dev,
1172 enum amdgpu_gpu_va_range type,
1176 #endif /* #ifdef _AMDGPU_H_ */