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 * Define handle to be used when dealing with command
130 * buffers (a.k.a. ibs)
133 typedef struct amdgpu_ib *amdgpu_ib_handle;
136 /*--------------------------------------------------------------------------*/
137 /* -------------------------- Structures ---------------------------------- */
138 /*--------------------------------------------------------------------------*/
141 * Structure describing memory allocation request
143 * \sa amdgpu_bo_alloc()
146 struct amdgpu_bo_alloc_request {
147 /** Allocation request. It must be aligned correctly. */
151 * It may be required to have some specific alignment requirements
152 * for physical back-up storage (e.g. for displayable surface).
153 * If 0 there is no special alignment requirement
155 uint64_t phys_alignment;
158 * UMD should specify where to allocate memory and how it
159 * will be accessed by the CPU.
161 uint32_t preferred_heap;
163 /** Additional flags passed on allocation */
168 * Structure describing memory allocation request
170 * \sa amdgpu_bo_alloc()
172 struct amdgpu_bo_alloc_result {
173 /** Assigned virtual MC Base Address */
174 uint64_t virtual_mc_base_address;
176 /** Handle of allocated memory to be used by the given process only. */
177 amdgpu_bo_handle buf_handle;
181 * Special UMD specific information associated with buffer.
183 * It may be need to pass some buffer charactersitic as part
184 * of buffer sharing. Such information are defined UMD and
185 * opaque for libdrm_amdgpu as well for kernel driver.
187 * \sa amdgpu_bo_set_metadata(), amdgpu_bo_query_info,
188 * amdgpu_bo_import(), amdgpu_bo_export
191 struct amdgpu_bo_metadata {
192 /** Special flag associated with surface */
196 * ASIC-specific tiling information (also used by DCE).
197 * The encoding is defined by the AMDGPU_TILING_* definitions.
199 uint64_t tiling_info;
201 /** Size of metadata associated with the buffer, in bytes. */
202 uint32_t size_metadata;
204 /** UMD specific metadata. Opaque for kernel */
205 uint32_t umd_metadata[64];
209 * Structure describing allocated buffer. Client may need
210 * to query such information as part of 'sharing' buffers mechanism
212 * \sa amdgpu_bo_set_metadata(), amdgpu_bo_query_info(),
213 * amdgpu_bo_import(), amdgpu_bo_export()
215 struct amdgpu_bo_info {
216 /** Allocated memory size */
220 * It may be required to have some specific alignment requirements
221 * for physical back-up storage.
223 uint64_t phys_alignment;
226 * Assigned virtual MC Base Address.
227 * \note This information will be returned only if this buffer was
228 * allocated in the same process otherwise 0 will be returned.
230 uint64_t virtual_mc_base_address;
232 /** Heap where to allocate memory. */
233 uint32_t preferred_heap;
235 /** Additional allocation flags. */
236 uint64_t alloc_flags;
238 /** Metadata associated with buffer if any. */
239 struct amdgpu_bo_metadata metadata;
243 * Structure with information about "imported" buffer
245 * \sa amdgpu_bo_import()
248 struct amdgpu_bo_import_result {
249 /** Handle of memory/buffer to use */
250 amdgpu_bo_handle buf_handle;
255 /** Assigned virtual MC Base Address */
256 uint64_t virtual_mc_base_address;
262 * Structure to describe GDS partitioning information.
263 * \note OA and GWS resources are asscoiated with GDS partition
265 * \sa amdgpu_gpu_resource_query_gds_info
268 struct amdgpu_gds_resource_info {
269 uint32_t gds_gfx_partition_size;
270 uint32_t compute_partition_size;
271 uint32_t gds_total_size;
272 uint32_t gws_per_gfx_partition;
273 uint32_t gws_per_compute_partition;
274 uint32_t oa_per_gfx_partition;
275 uint32_t oa_per_compute_partition;
281 * Structure describing result of request to allocate GDS
283 * \sa amdgpu_gpu_resource_gds_alloc
286 struct amdgpu_gds_alloc_info {
287 /** Handle assigned to gds allocation */
288 amdgpu_bo_handle resource_handle;
290 /** How much was really allocated */
291 uint32_t gds_memory_size;
293 /** Number of GWS resources allocated */
296 /** Number of OA resources allocated */
301 * Structure to described allocated command buffer (a.k.a. IB)
303 * \sa amdgpu_cs_alloc_ib()
306 struct amdgpu_cs_ib_alloc_result {
307 /** IB allocation handle */
308 amdgpu_ib_handle handle;
310 /** Assigned GPU VM MC Address of command buffer */
313 /** Address to be used for CPU access */
318 * Structure describing IB
320 * \sa amdgpu_cs_request, amdgpu_cs_submit()
323 struct amdgpu_cs_ib_info {
327 /** Handle of command buffer */
328 amdgpu_ib_handle ib_handle;
331 * Size of Command Buffer to be submitted.
332 * - The size is in units of dwords (4 bytes).
333 * - Must be less or equal to the size of allocated IB
338 /** Offset in the IB buffer object (in unit of dwords) */
343 * Structure describing submission request
345 * \note We could have several IBs as packet. e.g. CE, CE, DE case for gfx
347 * \sa amdgpu_cs_submit()
349 struct amdgpu_cs_request {
350 /** Specify flags with additional information */
353 /** Specify HW IP block type to which to send the IB. */
356 /** IP instance index if there are several IPs of the same type. */
357 unsigned ip_instance;
360 * Specify ring index of the IP. We could have several rings
361 * in the same IP. E.g. 0 for SDMA0 and 1 for SDMA1.
366 * List handle with resources used by this request.
368 amdgpu_bo_list_handle resources;
370 /** Number of IBs to submit in the field ibs. */
371 uint32_t number_of_ibs;
374 * IBs to submit. Those IBs will be submit together as single entity
376 struct amdgpu_cs_ib_info *ibs;
380 * Structure describing request to check submission state using fence
382 * \sa amdgpu_cs_query_fence_status()
385 struct amdgpu_cs_query_fence {
387 /** In which context IB was sent to execution */
388 amdgpu_context_handle context;
390 /** Timeout in nanoseconds. */
393 /** To which HW IP type the fence belongs */
396 /** IP instance index if there are several IPs of the same type. */
397 unsigned ip_instance;
399 /** Ring index of the HW IP */
405 /** Specify fence for which we need to check
406 * submission status.*/
411 * Structure which provide information about GPU VM MC Address space
412 * alignments requirements
414 * \sa amdgpu_query_buffer_size_alignment
416 struct amdgpu_buffer_size_alignments {
417 /** Size alignment requirement for allocation in
422 * Size alignment requirement for allocation in remote memory
424 uint64_t size_remote;
429 * Structure which provide information about heap
431 * \sa amdgpu_query_heap_info()
434 struct amdgpu_heap_info {
435 /** Theoretical max. available memory in the given heap */
439 * Number of bytes allocated in the heap. This includes all processes
440 * and private allocations in the kernel. It changes when new buffers
441 * are allocated, freed, and moved. It cannot be larger than
447 * Theoretical possible max. size of buffer which
448 * could be allocated in the given heap
450 uint64_t max_allocation;
456 * Describe GPU h/w info needed for UMD correct initialization
458 * \sa amdgpu_query_gpu_info()
460 struct amdgpu_gpu_info {
463 /**< Chip revision */
465 /** Chip external revision */
466 uint32_t chip_external_rev;
471 /** max engine clock*/
472 uint64_t max_engine_clk;
473 /** max memory clock */
474 uint64_t max_memory_clk;
475 /** number of shader engines */
476 uint32_t num_shader_engines;
477 /** number of shader arrays per engine */
478 uint32_t num_shader_arrays_per_engine;
479 /** Number of available good shader pipes */
480 uint32_t avail_quad_shader_pipes;
481 /** Max. number of shader pipes.(including good and bad pipes */
482 uint32_t max_quad_shader_pipes;
483 /** Number of parameter cache entries per shader quad pipe */
484 uint32_t cache_entries_per_quad_pipe;
485 /** Number of available graphics context */
486 uint32_t num_hw_gfx_contexts;
487 /** Number of render backend pipes */
489 /** Enabled render backend pipe mask */
490 uint32_t enabled_rb_pipes_mask;
491 /** Frequency of GPU Counter */
492 uint32_t gpu_counter_freq;
493 /** CC_RB_BACKEND_DISABLE.BACKEND_DISABLE per SE */
494 uint32_t backend_disable[4];
495 /** Value of MC_ARB_RAMCFG register*/
496 uint32_t mc_arb_ramcfg;
497 /** Value of GB_ADDR_CONFIG */
498 uint32_t gb_addr_cfg;
499 /** Values of the GB_TILE_MODE0..31 registers */
500 uint32_t gb_tile_mode[32];
501 /** Values of GB_MACROTILE_MODE0..15 registers */
502 uint32_t gb_macro_tile_mode[16];
503 /** Value of PA_SC_RASTER_CONFIG register per SE */
504 uint32_t pa_sc_raster_cfg[4];
505 /** Value of PA_SC_RASTER_CONFIG_1 register per SE */
506 uint32_t pa_sc_raster_cfg1[4];
508 uint32_t cu_active_number;
510 uint32_t cu_bitmap[4][4];
511 /* video memory type info*/
513 /* video memory bit width*/
514 uint32_t vram_bit_width;
515 /** constant engine ram size*/
516 uint32_t ce_ram_size;
520 /*--------------------------------------------------------------------------*/
521 /*------------------------- Functions --------------------------------------*/
522 /*--------------------------------------------------------------------------*/
525 * Initialization / Cleanup
532 * \param fd - \c [in] File descriptor for AMD GPU device
533 * received previously as the result of
534 * e.g. drmOpen() call.
535 * For legacy fd type, the DRI2/DRI3 authentication
536 * should be done before calling this function.
537 * \param major_version - \c [out] Major version of library. It is assumed
538 * that adding new functionality will cause
539 * increase in major version
540 * \param minor_version - \c [out] Minor version of library
541 * \param device_handle - \c [out] Pointer to opaque context which should
542 * be passed as the first parameter on each
546 * \return 0 on success\n
547 * >0 - AMD specific error code\n
548 * <0 - Negative POSIX Error code
551 * \sa amdgpu_device_deinitialize()
553 int amdgpu_device_initialize(int fd,
554 uint32_t *major_version,
555 uint32_t *minor_version,
556 amdgpu_device_handle *device_handle);
562 * When access to such library does not needed any more the special
563 * function must be call giving opportunity to clean up any
564 * resources if needed.
566 * \param device_handle - \c [in] Context associated with file
567 * descriptor for AMD GPU device
568 * received previously as the
569 * result e.g. of drmOpen() call.
571 * \return 0 on success\n
572 * >0 - AMD specific error code\n
573 * <0 - Negative POSIX Error code
575 * \sa amdgpu_device_initialize()
578 int amdgpu_device_deinitialize(amdgpu_device_handle device_handle);
587 * Allocate memory to be used by UMD for GPU related operations
589 * \param dev - \c [in] Device handle.
590 * See #amdgpu_device_initialize()
591 * \param alloc_buffer - \c [in] Pointer to the structure describing an
593 * \param info - \c [out] Pointer to structure which return
594 * information about allocated memory
596 * \return 0 on success\n
597 * >0 - AMD specific error code\n
598 * <0 - Negative POSIX Error code
600 * \sa amdgpu_bo_free()
602 int amdgpu_bo_alloc(amdgpu_device_handle dev,
603 struct amdgpu_bo_alloc_request *alloc_buffer,
604 struct amdgpu_bo_alloc_result *info);
607 * Associate opaque data with buffer to be queried by another UMD
609 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
610 * \param buf_handle - \c [in] Buffer handle
611 * \param info - \c [in] Metadata to associated with buffer
613 * \return 0 on success\n
614 * >0 - AMD specific error code\n
615 * <0 - Negative POSIX Error code
617 int amdgpu_bo_set_metadata(amdgpu_bo_handle buf_handle,
618 struct amdgpu_bo_metadata *info);
621 * Query buffer information including metadata previusly associated with
624 * \param dev - \c [in] Device handle.
625 * See #amdgpu_device_initialize()
626 * \param buf_handle - \c [in] Buffer handle
627 * \param info - \c [out] Structure describing buffer
629 * \return 0 on success\n
630 * >0 - AMD specific error code\n
631 * <0 - Negative POSIX Error code
633 * \sa amdgpu_bo_set_metadata(), amdgpu_bo_alloc()
635 int amdgpu_bo_query_info(amdgpu_bo_handle buf_handle,
636 struct amdgpu_bo_info *info);
639 * Allow others to get access to buffer
641 * \param dev - \c [in] Device handle.
642 * See #amdgpu_device_initialize()
643 * \param buf_handle - \c [in] Buffer handle
644 * \param type - \c [in] Type of handle requested
645 * \param shared_handle - \c [out] Special "shared" handle
647 * \return 0 on success\n
648 * >0 - AMD specific error code\n
649 * <0 - Negative POSIX Error code
651 * \sa amdgpu_bo_import()
654 int amdgpu_bo_export(amdgpu_bo_handle buf_handle,
655 enum amdgpu_bo_handle_type type,
656 uint32_t *shared_handle);
659 * Request access to "shared" buffer
661 * \param dev - \c [in] Device handle.
662 * See #amdgpu_device_initialize()
663 * \param type - \c [in] Type of handle requested
664 * \param shared_handle - \c [in] Shared handle received as result "import"
666 * \param output - \c [out] Pointer to structure with information
667 * about imported buffer
669 * \return 0 on success\n
670 * >0 - AMD specific error code\n
671 * <0 - Negative POSIX Error code
673 * \note Buffer must be "imported" only using new "fd" (different from
674 * one used by "exporter").
676 * \sa amdgpu_bo_export()
679 int amdgpu_bo_import(amdgpu_device_handle dev,
680 enum amdgpu_bo_handle_type type,
681 uint32_t shared_handle,
682 struct amdgpu_bo_import_result *output);
685 * Free previosuly allocated memory
687 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
688 * \param buf_handle - \c [in] Buffer handle to free
690 * \return 0 on success\n
691 * >0 - AMD specific error code\n
692 * <0 - Negative POSIX Error code
694 * \note In the case of memory shared between different applications all
695 * resources will be “physically” freed only all such applications
697 * \note If is UMD responsibility to ‘free’ buffer only when there is no
700 * \sa amdgpu_bo_set_metadata(), amdgpu_bo_alloc()
703 int amdgpu_bo_free(amdgpu_bo_handle buf_handle);
706 * Request CPU access to GPU accessable memory
708 * \param buf_handle - \c [in] Buffer handle
709 * \param cpu - \c [out] CPU address to be used for access
711 * \return 0 on success\n
712 * >0 - AMD specific error code\n
713 * <0 - Negative POSIX Error code
715 * \sa amdgpu_bo_cpu_unmap()
718 int amdgpu_bo_cpu_map(amdgpu_bo_handle buf_handle, void **cpu);
721 * Release CPU access to GPU memory
723 * \param buf_handle - \c [in] Buffer handle
725 * \return 0 on success\n
726 * >0 - AMD specific error code\n
727 * <0 - Negative POSIX Error code
729 * \sa amdgpu_bo_cpu_map()
732 int amdgpu_bo_cpu_unmap(amdgpu_bo_handle buf_handle);
736 * Wait until a buffer is not used by the device.
738 * \param dev - \c [in] Device handle. See #amdgpu_lib_initialize()
739 * \param buf_handle - \c [in] Buffer handle.
740 * \param timeout_ns - Timeout in nanoseconds.
741 * \param buffer_busy - 0 if buffer is idle, all GPU access was completed
742 * and no GPU access is scheduled.
743 * 1 GPU access is in fly or scheduled
745 * \return 0 - on success
746 * <0 - AMD specific error code
748 int amdgpu_bo_wait_for_idle(amdgpu_bo_handle buf_handle,
753 * Creates a BO list handle for command submission.
755 * \param dev - \c [in] Device handle.
756 * See #amdgpu_device_initialize()
757 * \param number_of_resources - \c [in] Number of BOs in the list
758 * \param resources - \c [in] List of BO handles
759 * \param resource_prios - \c [in] Optional priority for each handle
760 * \param result - \c [out] Created BO list handle
762 * \return 0 on success\n
763 * >0 - AMD specific error code\n
764 * <0 - Negative POSIX Error code
766 * \sa amdgpu_bo_list_destroy()
768 int amdgpu_bo_list_create(amdgpu_device_handle dev,
769 uint32_t number_of_resources,
770 amdgpu_bo_handle *resources,
771 uint8_t *resource_prios,
772 amdgpu_bo_list_handle *result);
775 * Destroys a BO list handle.
777 * \param handle - \c [in] BO list handle.
779 * \return 0 on success\n
780 * >0 - AMD specific error code\n
781 * <0 - Negative POSIX Error code
783 * \sa amdgpu_bo_list_create()
785 int amdgpu_bo_list_destroy(amdgpu_bo_list_handle handle);
788 * Update resources for existing BO list
790 * \param handle - \c [in] BO list handle
791 * \param number_of_resources - \c [in] Number of BOs in the list
792 * \param resources - \c [in] List of BO handles
793 * \param resource_prios - \c [in] Optional priority for each handle
795 * \return 0 on success\n
796 * >0 - AMD specific error code\n
797 * <0 - Negative POSIX Error code
799 * \sa amdgpu_bo_list_update()
801 int amdgpu_bo_list_update(amdgpu_bo_list_handle handle,
802 uint32_t number_of_resources,
803 amdgpu_bo_handle *resources,
804 uint8_t *resource_prios);
807 * Special GPU Resources
814 * Query information about GDS
816 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
817 * \param gds_info - \c [out] Pointer to structure to get GDS information
819 * \return 0 on success\n
820 * >0 - AMD specific error code\n
821 * <0 - Negative POSIX Error code
824 int amdgpu_gpu_resource_query_gds_info(amdgpu_device_handle dev,
825 struct amdgpu_gds_resource_info *
830 * Allocate GDS partitions
832 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
833 * \param gds_size - \c [in] Size of gds allocation. Must be aligned
835 * \param alloc_info - \c [out] Pointer to structure to receive information
838 * \return 0 on success\n
839 * >0 - AMD specific error code\n
840 * <0 - Negative POSIX Error code
844 int amdgpu_gpu_resource_gds_alloc(amdgpu_device_handle dev,
846 struct amdgpu_gds_alloc_info *alloc_info);
852 * Release GDS resource. When GDS and associated resources not needed any
853 * more UMD should free them
855 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
856 * \param handle - \c [in] Handle assigned to GDS allocation
858 * \return 0 on success\n
859 * >0 - AMD specific error code\n
860 * <0 - Negative POSIX Error code
863 int amdgpu_gpu_resource_gds_free(amdgpu_bo_handle handle);
868 * GPU Execution context
873 * Create GPU execution Context
875 * For the purpose of GPU Scheduler and GPU Robustness extensions it is
876 * necessary to have information/identify rendering/compute contexts.
877 * It also may be needed to associate some specific requirements with such
878 * contexts. Kernel driver will guarantee that submission from the same
879 * context will always be executed in order (first come, first serve).
882 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
883 * \param context - \c [out] GPU Context handle
885 * \return 0 on success\n
886 * >0 - AMD specific error code\n
887 * <0 - Negative POSIX Error code
889 * \sa amdgpu_cs_ctx_free()
892 int amdgpu_cs_ctx_create(amdgpu_device_handle dev,
893 amdgpu_context_handle *context);
897 * Destroy GPU execution context when not needed any more
899 * \param context - \c [in] GPU Context handle
901 * \return 0 on success\n
902 * >0 - AMD specific error code\n
903 * <0 - Negative POSIX Error code
905 * \sa amdgpu_cs_ctx_create()
908 int amdgpu_cs_ctx_free(amdgpu_context_handle context);
911 * Query reset state for the specific GPU Context
913 * \param context - \c [in] GPU Context handle
914 * \param state - \c [out] One of AMDGPU_CTX_*_RESET
915 * \param hangs - \c [out] Number of hangs caused by the context.
917 * \return 0 on success\n
918 * >0 - AMD specific error code\n
919 * <0 - Negative POSIX Error code
921 * \sa amdgpu_cs_ctx_create()
924 int amdgpu_cs_query_reset_state(amdgpu_context_handle context,
925 uint32_t *state, uint32_t *hangs);
929 * Command Buffers Management
935 * Allocate memory to be filled with PM4 packets and be served as the first
936 * entry point of execution (a.k.a. Indirect Buffer)
938 * \param context - \c [in] GPU Context which will use IB
939 * \param ib_size - \c [in] Size of allocation
940 * \param output - \c [out] Pointer to structure to get information about
943 * \return 0 on success\n
944 * >0 - AMD specific error code\n
945 * <0 - Negative POSIX Error code
947 * \sa amdgpu_cs_free_ib()
950 int amdgpu_cs_alloc_ib(amdgpu_context_handle context,
951 enum amdgpu_cs_ib_size ib_size,
952 struct amdgpu_cs_ib_alloc_result *output);
955 * If UMD has allocates IBs which doesn’t need any more than those IBs must
956 * be explicitly freed
958 * \param handle - \c [in] IB handle
960 * \return 0 on success\n
961 * >0 - AMD specific error code\n
962 * <0 - Negative POSIX Error code
964 * \sa amdgpu_cs_alloc_ib()
967 int amdgpu_cs_free_ib(amdgpu_ib_handle handle);
970 * Send request to submit command buffers to hardware.
972 * Kernel driver could use GPU Scheduler to make decision when physically
973 * sent this request to the hardware. Accordingly this request could be put
974 * in queue and sent for execution later. The only guarantee is that request
975 * from the same GPU context to the same ip:ip_instance:ring will be executed in
979 * \param dev - \c [in] Device handle.
980 * See #amdgpu_device_initialize()
981 * \param context - \c [in] GPU Context
982 * \param flags - \c [in] Global submission flags
983 * \param ibs_request - \c [in] Pointer to submission requests.
984 * We could submit to the several
985 * engines/rings simulteniously as
987 * \param number_of_requests - \c [in] Number of submission requests
988 * \param fences - \c [out] Pointer to array of data to get
989 * fences to identify submission
990 * requests. Timestamps are valid
991 * in this GPU context and could be used
992 * to identify/detect completion of
995 * \return 0 on success\n
996 * >0 - AMD specific error code\n
997 * <0 - Negative POSIX Error code
999 * \note It is required to pass correct resource list with buffer handles
1000 * which will be accessible by command buffers from submission
1001 * This will allow kernel driver to correctly implement "paging".
1002 * Failure to do so will have unpredictable results.
1004 * \sa amdgpu_command_buffer_alloc(), amdgpu_command_buffer_free(),
1005 * amdgpu_cs_query_fence_status()
1008 int amdgpu_cs_submit(amdgpu_context_handle context,
1010 struct amdgpu_cs_request *ibs_request,
1011 uint32_t number_of_requests,
1015 * Query status of Command Buffer Submission
1017 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
1018 * \param fence - \c [in] Structure describing fence to query
1019 * \param expired - \c [out] If fence expired or not.\n
1020 * 0 – if fence is not expired\n
1023 * \return 0 on success\n
1024 * >0 - AMD specific error code\n
1025 * <0 - Negative POSIX Error code
1027 * \note If UMD wants only to check operation status and returned immediately
1028 * then timeout value as 0 must be passed. In this case success will be
1029 * returned in the case if submission was completed or timeout error
1032 * \sa amdgpu_cs_submit()
1034 int amdgpu_cs_query_fence_status(struct amdgpu_cs_query_fence *fence,
1045 * Query allocation size alignments
1047 * UMD should query information about GPU VM MC size alignments requirements
1048 * to be able correctly choose required allocation size and implement
1049 * internal optimization if needed.
1051 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
1052 * \param info - \c [out] Pointer to structure to get size alignment
1055 * \return 0 on success\n
1056 * >0 - AMD specific error code\n
1057 * <0 - Negative POSIX Error code
1060 int amdgpu_query_buffer_size_alignment(amdgpu_device_handle dev,
1061 struct amdgpu_buffer_size_alignments
1067 * Query firmware versions
1069 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
1070 * \param fw_type - \c [in] AMDGPU_INFO_FW_*
1071 * \param ip_instance - \c [in] Index of the IP block of the same type.
1072 * \param index - \c [in] Index of the engine. (for SDMA and MEC)
1073 * \param version - \c [out] Pointer to to the "version" return value
1074 * \param feature - \c [out] Pointer to to the "feature" return value
1076 * \return 0 on success\n
1077 * >0 - AMD specific error code\n
1078 * <0 - Negative POSIX Error code
1081 int amdgpu_query_firmware_version(amdgpu_device_handle dev, unsigned fw_type,
1082 unsigned ip_instance, unsigned index,
1083 uint32_t *version, uint32_t *feature);
1088 * Query the number of HW IP instances of a certain type.
1090 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
1091 * \param type - \c [in] Hardware IP block type = AMDGPU_HW_IP_*
1092 * \param count - \c [out] Pointer to structure to get information
1094 * \return 0 on success\n
1095 * >0 - AMD specific error code\n
1096 * <0 - Negative POSIX Error code
1098 int amdgpu_query_hw_ip_count(amdgpu_device_handle dev, unsigned type,
1104 * Query engine information
1106 * This query allows UMD to query information different engines and their
1109 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
1110 * \param type - \c [in] Hardware IP block type = AMDGPU_HW_IP_*
1111 * \param ip_instance - \c [in] Index of the IP block of the same type.
1112 * \param info - \c [out] Pointer to structure to get information
1114 * \return 0 on success\n
1115 * >0 - AMD specific error code\n
1116 * <0 - Negative POSIX Error code
1118 int amdgpu_query_hw_ip_info(amdgpu_device_handle dev, unsigned type,
1119 unsigned ip_instance,
1120 struct drm_amdgpu_info_hw_ip *info);
1126 * Query heap information
1128 * This query allows UMD to query potentially available memory resources and
1129 * adjust their logic if necessary.
1131 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
1132 * \param heap - \c [in] Heap type
1133 * \param info - \c [in] Pointer to structure to get needed information
1135 * \return 0 on success\n
1136 * >0 - AMD specific error code\n
1137 * <0 - Negative POSIX Error code
1140 int amdgpu_query_heap_info(amdgpu_device_handle dev,
1143 struct amdgpu_heap_info *info);
1148 * Get the CRTC ID from the mode object ID
1150 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
1151 * \param id - \c [in] Mode object ID
1152 * \param result - \c [in] Pointer to the CRTC ID
1154 * \return 0 on success\n
1155 * >0 - AMD specific error code\n
1156 * <0 - Negative POSIX Error code
1159 int amdgpu_query_crtc_from_id(amdgpu_device_handle dev, unsigned id,
1165 * Query GPU H/w Info
1167 * Query hardware specific information
1169 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
1170 * \param heap - \c [in] Heap type
1171 * \param info - \c [in] Pointer to structure to get needed information
1173 * \return 0 on success\n
1174 * >0 - AMD specific error code\n
1175 * <0 - Negative POSIX Error code
1178 int amdgpu_query_gpu_info(amdgpu_device_handle dev,
1179 struct amdgpu_gpu_info *info);
1184 * Query hardware or driver information.
1186 * The return size is query-specific and depends on the "info_id" parameter.
1187 * No more than "size" bytes is returned.
1189 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize()
1190 * \param info_id - \c [in] AMDGPU_INFO_*
1191 * \param size - \c [in] Size of the returned value.
1192 * \param value - \c [out] Pointer to the return value.
1194 * \return 0 on success\n
1195 * >0 - AMD specific error code\n
1196 * <0 - Negative POSIX error code
1199 int amdgpu_query_info(amdgpu_device_handle dev, unsigned info_id,
1200 unsigned size, void *value);
1205 * Read a set of consecutive memory-mapped registers.
1206 * Not all registers are allowed to be read by userspace.
1208 * \param dev - \c [in] Device handle. See #amdgpu_device_initialize(
1209 * \param dword_offset - \c [in] Register offset in dwords
1210 * \param count - \c [in] The number of registers to read starting
1212 * \param instance - \c [in] GRBM_GFX_INDEX selector. It may have other
1213 * uses. Set it to 0xffffffff if unsure.
1214 * \param flags - \c [in] Flags with additional information.
1215 * \param values - \c [out] The pointer to return values.
1217 * \return 0 on success\n
1218 * >0 - AMD specific error code\n
1219 * <0 - Negative POSIX error code
1222 int amdgpu_read_mm_registers(amdgpu_device_handle dev, unsigned dword_offset,
1223 unsigned count, uint32_t instance, uint32_t flags,
1229 * Request GPU access to user allocated memory e.g. via "malloc"
1231 * \param dev - [in] Device handle. See #amdgpu_device_initialize()
1232 * \param cpu - [in] CPU address of user allocated memory which we
1233 * want to map to GPU address space (make GPU accessible)
1234 * (This address must be correctly aligned).
1235 * \param size - [in] Size of allocation (must be correctly aligned)
1236 * \param amdgpu_bo_alloc_result - [out] Handle of allocation to be passed as resource
1237 * on submission and be used in other operations.(e.g. for VA submission)
1238 * ( Temporally defined amdgpu_bo_alloc_result as parameter for return mc address. )
1241 * \return 0 on success
1242 * >0 - AMD specific error code
1243 * <0 - Negative POSIX Error code
1247 * This call doesn't guarantee that such memory will be persistently
1248 * "locked" / make non-pageable. The purpose of this call is to provide
1249 * opportunity for GPU get access to this resource during submission.
1251 * The maximum amount of memory which could be mapped in this call depends
1252 * if overcommit is disabled or not. If overcommit is disabled than the max.
1253 * amount of memory to be pinned will be limited by left "free" size in total
1254 * amount of memory which could be locked simultaneously ("GART" size).
1256 * Supported (theoretical) max. size of mapping is restricted only by
1259 * It is responsibility of caller to correctly specify access rights
1262 int amdgpu_create_bo_from_user_mem(amdgpu_device_handle dev,
1265 struct amdgpu_bo_alloc_result *info);
1268 #endif /* #ifdef _AMDGPU_H_ */