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 * For performance reasons and to simplify logic libdrm_amdgpu will handle
83 * IBs only some pre-defined sizes.
85 * \sa amdgpu_cs_alloc_ib()
87 enum amdgpu_cs_ib_size {
88 amdgpu_cs_ib_size_4K = 0,
89 amdgpu_cs_ib_size_16K = 1,
90 amdgpu_cs_ib_size_32K = 2,
91 amdgpu_cs_ib_size_64K = 3,
92 amdgpu_cs_ib_size_128K = 4
95 /** The number of different IB sizes */
96 #define AMDGPU_CS_IB_SIZE_NUM 5
99 /*--------------------------------------------------------------------------*/
100 /* -------------------------- Datatypes ----------------------------------- */
101 /*--------------------------------------------------------------------------*/
104 * Define opaque pointer to context associated with fd.
105 * This context will be returned as the result of
106 * "initialize" function and should be pass as the first
107 * parameter to any API call
109 typedef struct amdgpu_device *amdgpu_device_handle;
112 * Define GPU Context type as pointer to opaque structure
113 * Example of GPU Context is the "rendering" context associated
114 * with OpenGL context (glCreateContext)
116 typedef struct amdgpu_context *amdgpu_context_handle;
119 * Define handle for amdgpu resources: buffer, GDS, etc.
121 typedef struct amdgpu_bo *amdgpu_bo_handle;
124 * Define handle for list of BOs
126 typedef struct amdgpu_bo_list *amdgpu_bo_list_handle;
129 /*--------------------------------------------------------------------------*/
130 /* -------------------------- Structures ---------------------------------- */
131 /*--------------------------------------------------------------------------*/
134 * Structure describing memory allocation request
136 * \sa amdgpu_bo_alloc()
139 struct amdgpu_bo_alloc_request {
140 /** Allocation request. It must be aligned correctly. */
144 * It may be required to have some specific alignment requirements
145 * for physical back-up storage (e.g. for displayable surface).
146 * If 0 there is no special alignment requirement
148 uint64_t phys_alignment;
151 * UMD should specify where to allocate memory and how it
152 * will be accessed by the CPU.
154 uint32_t preferred_heap;
156 /** Additional flags passed on allocation */
161 * Structure describing memory allocation request
163 * \sa amdgpu_bo_alloc()
165 struct amdgpu_bo_alloc_result {
166 /** Assigned virtual MC Base Address */
167 uint64_t virtual_mc_base_address;
169 /** Handle of allocated memory to be used by the given process only. */
170 amdgpu_bo_handle buf_handle;
174 * Special UMD specific information associated with buffer.
176 * It may be need to pass some buffer charactersitic as part
177 * of buffer sharing. Such information are defined UMD and
178 * opaque for libdrm_amdgpu as well for kernel driver.
180 * \sa amdgpu_bo_set_metadata(), amdgpu_bo_query_info,
181 * amdgpu_bo_import(), amdgpu_bo_export
184 struct amdgpu_bo_metadata {
185 /** Special flag associated with surface */
189 * ASIC-specific tiling information (also used by DCE).
190 * The encoding is defined by the AMDGPU_TILING_* definitions.
192 uint64_t tiling_info;
194 /** Size of metadata associated with the buffer, in bytes. */
195 uint32_t size_metadata;
197 /** UMD specific metadata. Opaque for kernel */
198 uint32_t umd_metadata[64];
202 * Structure describing allocated buffer. Client may need
203 * to query such information as part of 'sharing' buffers mechanism
205 * \sa amdgpu_bo_set_metadata(), amdgpu_bo_query_info(),
206 * amdgpu_bo_import(), amdgpu_bo_export()
208 struct amdgpu_bo_info {
209 /** Allocated memory size */
213 * It may be required to have some specific alignment requirements
214 * for physical back-up storage.
216 uint64_t phys_alignment;
219 * Assigned virtual MC Base Address.
220 * \note This information will be returned only if this buffer was
221 * allocated in the same process otherwise 0 will be returned.
223 uint64_t virtual_mc_base_address;
225 /** Heap where to allocate memory. */
226 uint32_t preferred_heap;
228 /** Additional allocation flags. */
229 uint64_t alloc_flags;
231 /** Metadata associated with buffer if any. */
232 struct amdgpu_bo_metadata metadata;
236 * Structure with information about "imported" buffer
238 * \sa amdgpu_bo_import()
241 struct amdgpu_bo_import_result {
242 /** Handle of memory/buffer to use */
243 amdgpu_bo_handle buf_handle;
248 /** Assigned virtual MC Base Address */
249 uint64_t virtual_mc_base_address;
255 * Structure to describe GDS partitioning information.
256 * \note OA and GWS resources are asscoiated with GDS partition
258 * \sa amdgpu_gpu_resource_query_gds_info
261 struct amdgpu_gds_resource_info {
262 uint32_t gds_gfx_partition_size;
263 uint32_t compute_partition_size;
264 uint32_t gds_total_size;
265 uint32_t gws_per_gfx_partition;
266 uint32_t gws_per_compute_partition;
267 uint32_t oa_per_gfx_partition;
268 uint32_t oa_per_compute_partition;
274 * Structure describing result of request to allocate GDS
276 * \sa amdgpu_gpu_resource_gds_alloc
279 struct amdgpu_gds_alloc_info {
280 /** Handle assigned to gds allocation */
281 amdgpu_bo_handle resource_handle;
283 /** How much was really allocated */
284 uint32_t gds_memory_size;
286 /** Number of GWS resources allocated */
289 /** Number of OA resources allocated */
294 * Structure to described allocated command buffer (a.k.a. IB)
296 * \sa amdgpu_cs_alloc_ib()
299 struct amdgpu_cs_ib_alloc_result {
300 /** IB allocation handle */
301 amdgpu_bo_handle handle;
303 /** Assigned GPU VM MC Address of command buffer */
306 /** Address to be used for CPU access */
311 * Structure describing IB
313 * \sa amdgpu_cs_request, amdgpu_cs_submit()
316 struct amdgpu_cs_ib_info {
320 /** Handle of command buffer */
321 amdgpu_bo_handle bo_handle;
324 * Size of Command Buffer to be submitted.
325 * - The size is in units of dwords (4 bytes).
326 * - Must be less or equal to the size of allocated IB
331 /** Offset in the IB buffer object (in unit of dwords) */
336 * Structure describing submission request
338 * \note We could have several IBs as packet. e.g. CE, CE, DE case for gfx
340 * \sa amdgpu_cs_submit()
342 struct amdgpu_cs_request {
343 /** Specify flags with additional information */
346 /** Specify HW IP block type to which to send the IB. */
349 /** IP instance index if there are several IPs of the same type. */
350 unsigned ip_instance;
353 * Specify ring index of the IP. We could have several rings
354 * in the same IP. E.g. 0 for SDMA0 and 1 for SDMA1.
359 * List handle with resources used by this request.
361 amdgpu_bo_list_handle resources;
363 /** Number of IBs to submit in the field ibs. */
364 uint32_t number_of_ibs;
367 * IBs to submit. Those IBs will be submit together as single entity
369 struct amdgpu_cs_ib_info *ibs;
373 * Structure describing request to check submission state using fence
375 * \sa amdgpu_cs_query_fence_status()
378 struct amdgpu_cs_query_fence {
380 /** In which context IB was sent to execution */
381 amdgpu_context_handle context;
383 /** Timeout in nanoseconds. */
386 /** To which HW IP type the fence belongs */
389 /** IP instance index if there are several IPs of the same type. */
390 unsigned ip_instance;
392 /** Ring index of the HW IP */
398 /** Specify fence for which we need to check
399 * submission status.*/
404 * Structure which provide information about GPU VM MC Address space
405 * alignments requirements
407 * \sa amdgpu_query_buffer_size_alignment
409 struct amdgpu_buffer_size_alignments {
410 /** Size alignment requirement for allocation in
415 * Size alignment requirement for allocation in remote memory
417 uint64_t size_remote;
422 * Structure which provide information about heap
424 * \sa amdgpu_query_heap_info()
427 struct amdgpu_heap_info {
428 /** Theoretical max. available memory in the given heap */
432 * Number of bytes allocated in the heap. This includes all processes
433 * and private allocations in the kernel. It changes when new buffers
434 * are allocated, freed, and moved. It cannot be larger than
440 * Theoretical possible max. size of buffer which
441 * could be allocated in the given heap
443 uint64_t max_allocation;
449 * Describe GPU h/w info needed for UMD correct initialization
451 * \sa amdgpu_query_gpu_info()
453 struct amdgpu_gpu_info {
456 /**< Chip revision */
458 /** Chip external revision */
459 uint32_t chip_external_rev;
464 /** max engine clock*/
465 uint64_t max_engine_clk;
466 /** max memory clock */
467 uint64_t max_memory_clk;
468 /** number of shader engines */
469 uint32_t num_shader_engines;
470 /** number of shader arrays per engine */
471 uint32_t num_shader_arrays_per_engine;
472 /** Number of available good shader pipes */
473 uint32_t avail_quad_shader_pipes;
474 /** Max. number of shader pipes.(including good and bad pipes */
475 uint32_t max_quad_shader_pipes;
476 /** Number of parameter cache entries per shader quad pipe */
477 uint32_t cache_entries_per_quad_pipe;
478 /** Number of available graphics context */
479 uint32_t num_hw_gfx_contexts;
480 /** Number of render backend pipes */
482 /** Enabled render backend pipe mask */
483 uint32_t enabled_rb_pipes_mask;
484 /** Frequency of GPU Counter */
485 uint32_t gpu_counter_freq;
486 /** CC_RB_BACKEND_DISABLE.BACKEND_DISABLE per SE */
487 uint32_t backend_disable[4];
488 /** Value of MC_ARB_RAMCFG register*/
489 uint32_t mc_arb_ramcfg;
490 /** Value of GB_ADDR_CONFIG */
491 uint32_t gb_addr_cfg;
492 /** Values of the GB_TILE_MODE0..31 registers */
493 uint32_t gb_tile_mode[32];
494 /** Values of GB_MACROTILE_MODE0..15 registers */
495 uint32_t gb_macro_tile_mode[16];
496 /** Value of PA_SC_RASTER_CONFIG register per SE */
497 uint32_t pa_sc_raster_cfg[4];
498 /** Value of PA_SC_RASTER_CONFIG_1 register per SE */
499 uint32_t pa_sc_raster_cfg1[4];
501 uint32_t cu_active_number;
503 uint32_t cu_bitmap[4][4];
504 /* video memory type info*/
506 /* video memory bit width*/
507 uint32_t vram_bit_width;
508 /** constant engine ram size*/
509 uint32_t ce_ram_size;
513 /*--------------------------------------------------------------------------*/
514 /*------------------------- Functions --------------------------------------*/
515 /*--------------------------------------------------------------------------*/
518 * Initialization / Cleanup
525 * \param fd - \c [in] File descriptor for AMD GPU device
526 * received previously as the result of
527 * e.g. drmOpen() call.
528 * For legacy fd type, the DRI2/DRI3 authentication
529 * should be done before calling this function.
530 * \param major_version - \c [out] Major version of library. It is assumed
531 * that adding new functionality will cause
532 * increase in major version
533 * \param minor_version - \c [out] Minor version of library
534 * \param device_handle - \c [out] Pointer to opaque context which should
535 * be passed as the first parameter on each
539 * \return 0 on success\n
540 * >0 - AMD specific error code\n
541 * <0 - Negative POSIX Error code
544 * \sa amdgpu_device_deinitialize()
546 int amdgpu_device_initialize(int fd,
547 uint32_t *major_version,
548 uint32_t *minor_version,
549 amdgpu_device_handle *device_handle);
555 * When access to such library does not needed any more the special
556 * function must be call giving opportunity to clean up any
557 * resources if needed.
559 * \param device_handle - \c [in] Context associated with file
560 * descriptor for AMD GPU device
561 * received previously as the
562 * result e.g. of drmOpen() call.
564 * \return 0 on success\n
565 * >0 - AMD specific error code\n
566 * <0 - Negative POSIX Error code
568 * \sa amdgpu_device_initialize()
571 int amdgpu_device_deinitialize(amdgpu_device_handle device_handle);
580 * Allocate memory to be used by UMD for GPU related operations
582 * \param dev - \c [in] Device handle.
583 * See #amdgpu_device_initialize()
584 * \param alloc_buffer - \c [in] Pointer to the structure describing an
586 * \param info - \c [out] Pointer to structure which return
587 * information about allocated memory
589 * \return 0 on success\n
590 * >0 - AMD specific error code\n
591 * <0 - Negative POSIX Error code
593 * \sa amdgpu_bo_free()
595 int amdgpu_bo_alloc(amdgpu_device_handle dev,
596 struct amdgpu_bo_alloc_request *alloc_buffer,
597 struct amdgpu_bo_alloc_result *info);
600 * Associate opaque data with buffer to be queried by another UMD
602 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
603 * \param buf_handle - \c [in] Buffer handle
604 * \param info - \c [in] Metadata to associated with buffer
606 * \return 0 on success\n
607 * >0 - AMD specific error code\n
608 * <0 - Negative POSIX Error code
610 int amdgpu_bo_set_metadata(amdgpu_bo_handle buf_handle,
611 struct amdgpu_bo_metadata *info);
614 * Query buffer information including metadata previusly associated with
617 * \param dev - \c [in] Device handle.
618 * See #amdgpu_device_initialize()
619 * \param buf_handle - \c [in] Buffer handle
620 * \param info - \c [out] Structure describing buffer
622 * \return 0 on success\n
623 * >0 - AMD specific error code\n
624 * <0 - Negative POSIX Error code
626 * \sa amdgpu_bo_set_metadata(), amdgpu_bo_alloc()
628 int amdgpu_bo_query_info(amdgpu_bo_handle buf_handle,
629 struct amdgpu_bo_info *info);
632 * Allow others to get access to buffer
634 * \param dev - \c [in] Device handle.
635 * See #amdgpu_device_initialize()
636 * \param buf_handle - \c [in] Buffer handle
637 * \param type - \c [in] Type of handle requested
638 * \param shared_handle - \c [out] Special "shared" handle
640 * \return 0 on success\n
641 * >0 - AMD specific error code\n
642 * <0 - Negative POSIX Error code
644 * \sa amdgpu_bo_import()
647 int amdgpu_bo_export(amdgpu_bo_handle buf_handle,
648 enum amdgpu_bo_handle_type type,
649 uint32_t *shared_handle);
652 * Request access to "shared" buffer
654 * \param dev - \c [in] Device handle.
655 * See #amdgpu_device_initialize()
656 * \param type - \c [in] Type of handle requested
657 * \param shared_handle - \c [in] Shared handle received as result "import"
659 * \param output - \c [out] Pointer to structure with information
660 * about imported buffer
662 * \return 0 on success\n
663 * >0 - AMD specific error code\n
664 * <0 - Negative POSIX Error code
666 * \note Buffer must be "imported" only using new "fd" (different from
667 * one used by "exporter").
669 * \sa amdgpu_bo_export()
672 int amdgpu_bo_import(amdgpu_device_handle dev,
673 enum amdgpu_bo_handle_type type,
674 uint32_t shared_handle,
675 struct amdgpu_bo_import_result *output);
678 * Free previosuly allocated memory
680 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
681 * \param buf_handle - \c [in] Buffer handle to free
683 * \return 0 on success\n
684 * >0 - AMD specific error code\n
685 * <0 - Negative POSIX Error code
687 * \note In the case of memory shared between different applications all
688 * resources will be “physically” freed only all such applications
690 * \note If is UMD responsibility to ‘free’ buffer only when there is no
693 * \sa amdgpu_bo_set_metadata(), amdgpu_bo_alloc()
696 int amdgpu_bo_free(amdgpu_bo_handle buf_handle);
699 * Request CPU access to GPU accessable memory
701 * \param buf_handle - \c [in] Buffer handle
702 * \param cpu - \c [out] CPU address to be used for access
704 * \return 0 on success\n
705 * >0 - AMD specific error code\n
706 * <0 - Negative POSIX Error code
708 * \sa amdgpu_bo_cpu_unmap()
711 int amdgpu_bo_cpu_map(amdgpu_bo_handle buf_handle, void **cpu);
714 * Release CPU access to GPU memory
716 * \param buf_handle - \c [in] Buffer handle
718 * \return 0 on success\n
719 * >0 - AMD specific error code\n
720 * <0 - Negative POSIX Error code
722 * \sa amdgpu_bo_cpu_map()
725 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 - AMD specific 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 - AMD specific error code\n
757 * <0 - Negative POSIX Error code
759 * \sa amdgpu_bo_list_destroy()
761 int amdgpu_bo_list_create(amdgpu_device_handle dev,
762 uint32_t number_of_resources,
763 amdgpu_bo_handle *resources,
764 uint8_t *resource_prios,
765 amdgpu_bo_list_handle *result);
768 * Destroys a BO list handle.
770 * \param handle - \c [in] BO list handle.
772 * \return 0 on success\n
773 * >0 - AMD specific error code\n
774 * <0 - Negative POSIX Error code
776 * \sa amdgpu_bo_list_create()
778 int amdgpu_bo_list_destroy(amdgpu_bo_list_handle handle);
781 * Update resources for existing BO list
783 * \param handle - \c [in] BO list handle
784 * \param number_of_resources - \c [in] Number of BOs in the list
785 * \param resources - \c [in] List of BO handles
786 * \param resource_prios - \c [in] Optional priority for each handle
788 * \return 0 on success\n
789 * >0 - AMD specific error code\n
790 * <0 - Negative POSIX Error code
792 * \sa amdgpu_bo_list_update()
794 int amdgpu_bo_list_update(amdgpu_bo_list_handle handle,
795 uint32_t number_of_resources,
796 amdgpu_bo_handle *resources,
797 uint8_t *resource_prios);
800 * Special GPU Resources
807 * Query information about GDS
809 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
810 * \param gds_info - \c [out] Pointer to structure to get GDS information
812 * \return 0 on success\n
813 * >0 - AMD specific error code\n
814 * <0 - Negative POSIX Error code
817 int amdgpu_gpu_resource_query_gds_info(amdgpu_device_handle dev,
818 struct amdgpu_gds_resource_info *
823 * Allocate GDS partitions
825 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
826 * \param gds_size - \c [in] Size of gds allocation. Must be aligned
828 * \param alloc_info - \c [out] Pointer to structure to receive information
831 * \return 0 on success\n
832 * >0 - AMD specific error code\n
833 * <0 - Negative POSIX Error code
837 int amdgpu_gpu_resource_gds_alloc(amdgpu_device_handle dev,
839 struct amdgpu_gds_alloc_info *alloc_info);
845 * Release GDS resource. When GDS and associated resources not needed any
846 * more UMD should free them
848 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
849 * \param handle - \c [in] Handle assigned to GDS allocation
851 * \return 0 on success\n
852 * >0 - AMD specific error code\n
853 * <0 - Negative POSIX Error code
856 int amdgpu_gpu_resource_gds_free(amdgpu_bo_handle handle);
861 * GPU Execution context
866 * Create GPU execution Context
868 * For the purpose of GPU Scheduler and GPU Robustness extensions it is
869 * necessary to have information/identify rendering/compute contexts.
870 * It also may be needed to associate some specific requirements with such
871 * contexts. Kernel driver will guarantee that submission from the same
872 * context will always be executed in order (first come, first serve).
875 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
876 * \param context - \c [out] GPU Context handle
878 * \return 0 on success\n
879 * >0 - AMD specific error code\n
880 * <0 - Negative POSIX Error code
882 * \sa amdgpu_cs_ctx_free()
885 int amdgpu_cs_ctx_create(amdgpu_device_handle dev,
886 amdgpu_context_handle *context);
890 * Destroy GPU execution context when not needed any more
892 * \param context - \c [in] GPU Context handle
894 * \return 0 on success\n
895 * >0 - AMD specific error code\n
896 * <0 - Negative POSIX Error code
898 * \sa amdgpu_cs_ctx_create()
901 int amdgpu_cs_ctx_free(amdgpu_context_handle context);
904 * Query reset state for the specific GPU Context
906 * \param context - \c [in] GPU Context handle
907 * \param state - \c [out] One of AMDGPU_CTX_*_RESET
908 * \param hangs - \c [out] Number of hangs caused by the context.
910 * \return 0 on success\n
911 * >0 - AMD specific error code\n
912 * <0 - Negative POSIX Error code
914 * \sa amdgpu_cs_ctx_create()
917 int amdgpu_cs_query_reset_state(amdgpu_context_handle context,
918 uint32_t *state, uint32_t *hangs);
922 * Command Buffers Management
928 * Allocate memory to be filled with PM4 packets and be served as the first
929 * entry point of execution (a.k.a. Indirect Buffer)
931 * \param context - \c [in] GPU Context which will use IB
932 * \param ib_size - \c [in] Size of allocation
933 * \param output - \c [out] Pointer to structure to get information about
936 * \return 0 on success\n
937 * >0 - AMD specific error code\n
938 * <0 - Negative POSIX Error code
940 * \sa amdgpu_cs_free_ib()
943 int amdgpu_cs_alloc_ib(amdgpu_context_handle context,
944 enum amdgpu_cs_ib_size ib_size,
945 struct amdgpu_cs_ib_alloc_result *output);
948 * If UMD has allocates IBs which doesn’t need any more than those IBs must
949 * be explicitly freed
951 * \param handle - \c [in] IB handle
953 * \return 0 on success\n
954 * >0 - AMD specific error code\n
955 * <0 - Negative POSIX Error code
957 * \sa amdgpu_cs_alloc_ib()
960 int amdgpu_cs_free_ib(amdgpu_bo_handle handle);
963 * Send request to submit command buffers to hardware.
965 * Kernel driver could use GPU Scheduler to make decision when physically
966 * sent this request to the hardware. Accordingly this request could be put
967 * in queue and sent for execution later. The only guarantee is that request
968 * from the same GPU context to the same ip:ip_instance:ring will be executed in
972 * \param dev - \c [in] Device handle.
973 * See #amdgpu_device_initialize()
974 * \param context - \c [in] GPU Context
975 * \param flags - \c [in] Global submission flags
976 * \param ibs_request - \c [in] Pointer to submission requests.
977 * We could submit to the several
978 * engines/rings simulteniously as
980 * \param number_of_requests - \c [in] Number of submission requests
981 * \param fences - \c [out] Pointer to array of data to get
982 * fences to identify submission
983 * requests. Timestamps are valid
984 * in this GPU context and could be used
985 * to identify/detect completion of
988 * \return 0 on success\n
989 * >0 - AMD specific error code\n
990 * <0 - Negative POSIX Error code
992 * \note It is required to pass correct resource list with buffer handles
993 * which will be accessible by command buffers from submission
994 * This will allow kernel driver to correctly implement "paging".
995 * Failure to do so will have unpredictable results.
997 * \sa amdgpu_command_buffer_alloc(), amdgpu_command_buffer_free(),
998 * amdgpu_cs_query_fence_status()
1001 int amdgpu_cs_submit(amdgpu_context_handle context,
1003 struct amdgpu_cs_request *ibs_request,
1004 uint32_t number_of_requests,
1008 * Query status of Command Buffer Submission
1010 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
1011 * \param fence - \c [in] Structure describing fence to query
1012 * \param expired - \c [out] If fence expired or not.\n
1013 * 0 – if fence is not expired\n
1016 * \return 0 on success\n
1017 * >0 - AMD specific error code\n
1018 * <0 - Negative POSIX Error code
1020 * \note If UMD wants only to check operation status and returned immediately
1021 * then timeout value as 0 must be passed. In this case success will be
1022 * returned in the case if submission was completed or timeout error
1025 * \sa amdgpu_cs_submit()
1027 int amdgpu_cs_query_fence_status(struct amdgpu_cs_query_fence *fence,
1038 * Query allocation size alignments
1040 * UMD should query information about GPU VM MC size alignments requirements
1041 * to be able correctly choose required allocation size and implement
1042 * internal optimization if needed.
1044 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
1045 * \param info - \c [out] Pointer to structure to get size alignment
1048 * \return 0 on success\n
1049 * >0 - AMD specific error code\n
1050 * <0 - Negative POSIX Error code
1053 int amdgpu_query_buffer_size_alignment(amdgpu_device_handle dev,
1054 struct amdgpu_buffer_size_alignments
1060 * Query firmware versions
1062 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
1063 * \param fw_type - \c [in] AMDGPU_INFO_FW_*
1064 * \param ip_instance - \c [in] Index of the IP block of the same type.
1065 * \param index - \c [in] Index of the engine. (for SDMA and MEC)
1066 * \param version - \c [out] Pointer to to the "version" return value
1067 * \param feature - \c [out] Pointer to to the "feature" return value
1069 * \return 0 on success\n
1070 * >0 - AMD specific error code\n
1071 * <0 - Negative POSIX Error code
1074 int amdgpu_query_firmware_version(amdgpu_device_handle dev, unsigned fw_type,
1075 unsigned ip_instance, unsigned index,
1076 uint32_t *version, uint32_t *feature);
1081 * Query the number of HW IP instances of a certain type.
1083 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
1084 * \param type - \c [in] Hardware IP block type = AMDGPU_HW_IP_*
1085 * \param count - \c [out] Pointer to structure to get information
1087 * \return 0 on success\n
1088 * >0 - AMD specific error code\n
1089 * <0 - Negative POSIX Error code
1091 int amdgpu_query_hw_ip_count(amdgpu_device_handle dev, unsigned type,
1097 * Query engine information
1099 * This query allows UMD to query information different engines and their
1102 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
1103 * \param type - \c [in] Hardware IP block type = AMDGPU_HW_IP_*
1104 * \param ip_instance - \c [in] Index of the IP block of the same type.
1105 * \param info - \c [out] Pointer to structure to get information
1107 * \return 0 on success\n
1108 * >0 - AMD specific error code\n
1109 * <0 - Negative POSIX Error code
1111 int amdgpu_query_hw_ip_info(amdgpu_device_handle dev, unsigned type,
1112 unsigned ip_instance,
1113 struct drm_amdgpu_info_hw_ip *info);
1119 * Query heap information
1121 * This query allows UMD to query potentially available memory resources and
1122 * adjust their logic if necessary.
1124 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
1125 * \param heap - \c [in] Heap type
1126 * \param info - \c [in] Pointer to structure to get needed information
1128 * \return 0 on success\n
1129 * >0 - AMD specific error code\n
1130 * <0 - Negative POSIX Error code
1133 int amdgpu_query_heap_info(amdgpu_device_handle dev,
1136 struct amdgpu_heap_info *info);
1141 * Get the CRTC ID from the mode object ID
1143 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
1144 * \param id - \c [in] Mode object ID
1145 * \param result - \c [in] Pointer to the CRTC ID
1147 * \return 0 on success\n
1148 * >0 - AMD specific error code\n
1149 * <0 - Negative POSIX Error code
1152 int amdgpu_query_crtc_from_id(amdgpu_device_handle dev, unsigned id,
1158 * Query GPU H/w Info
1160 * Query hardware specific information
1162 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
1163 * \param heap - \c [in] Heap type
1164 * \param info - \c [in] Pointer to structure to get needed information
1166 * \return 0 on success\n
1167 * >0 - AMD specific error code\n
1168 * <0 - Negative POSIX Error code
1171 int amdgpu_query_gpu_info(amdgpu_device_handle dev,
1172 struct amdgpu_gpu_info *info);
1177 * Query hardware or driver information.
1179 * The return size is query-specific and depends on the "info_id" parameter.
1180 * No more than "size" bytes is returned.
1182 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
1183 * \param info_id - \c [in] AMDGPU_INFO_*
1184 * \param size - \c [in] Size of the returned value.
1185 * \param value - \c [out] Pointer to the return value.
1187 * \return 0 on success\n
1188 * >0 - AMD specific error code\n
1189 * <0 - Negative POSIX error code
1192 int amdgpu_query_info(amdgpu_device_handle dev, unsigned info_id,
1193 unsigned size, void *value);
1198 * Read a set of consecutive memory-mapped registers.
1199 * Not all registers are allowed to be read by userspace.
1201 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize(
1202 * \param dword_offset - \c [in] Register offset in dwords
1203 * \param count - \c [in] The number of registers to read starting
1205 * \param instance - \c [in] GRBM_GFX_INDEX selector. It may have other
1206 * uses. Set it to 0xffffffff if unsure.
1207 * \param flags - \c [in] Flags with additional information.
1208 * \param values - \c [out] The pointer to return values.
1210 * \return 0 on success\n
1211 * >0 - AMD specific error code\n
1212 * <0 - Negative POSIX error code
1215 int amdgpu_read_mm_registers(amdgpu_device_handle dev, unsigned dword_offset,
1216 unsigned count, uint32_t instance, uint32_t flags,
1222 * Request GPU access to user allocated memory e.g. via "malloc"
1224 * \param dev - [in] Device handle. See #amdgpu_device_initialize()
1225 * \param cpu - [in] CPU address of user allocated memory which we
1226 * want to map to GPU address space (make GPU accessible)
1227 * (This address must be correctly aligned).
1228 * \param size - [in] Size of allocation (must be correctly aligned)
1229 * \param amdgpu_bo_alloc_result - [out] Handle of allocation to be passed as resource
1230 * on submission and be used in other operations.(e.g. for VA submission)
1231 * ( Temporally defined amdgpu_bo_alloc_result as parameter for return mc address. )
1234 * \return 0 on success
1235 * >0 - AMD specific error code
1236 * <0 - Negative POSIX Error code
1240 * This call doesn't guarantee that such memory will be persistently
1241 * "locked" / make non-pageable. The purpose of this call is to provide
1242 * opportunity for GPU get access to this resource during submission.
1244 * The maximum amount of memory which could be mapped in this call depends
1245 * if overcommit is disabled or not. If overcommit is disabled than the max.
1246 * amount of memory to be pinned will be limited by left "free" size in total
1247 * amount of memory which could be locked simultaneously ("GART" size).
1249 * Supported (theoretical) max. size of mapping is restricted only by
1252 * It is responsibility of caller to correctly specify access rights
1255 int amdgpu_create_bo_from_user_mem(amdgpu_device_handle dev,
1258 struct amdgpu_bo_alloc_result *info);
1261 #endif /* #ifdef _AMDGPU_H_ */