Android-x86
Fork
Donation

  • R/O
  • HTTP
  • SSH
  • HTTPS

external-libdrm: Commit

external/libdrm


Commit MetaInfo

Revisionf19afaa519c2aa51d8449168fa83a98f2f04e0e5 (tree)
Time2019-01-17 06:39:25
AuthorMarek Olšák <marek.olsak@amd....>
CommiterMarek Olšák

Log Message

amdgpu: add a faster BO list API

Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
Signed-off-by: Marek Olšák <marek.olsak@amd.com>

Change Summary

Incremental Difference

--- a/amdgpu/amdgpu-symbol-check
+++ b/amdgpu/amdgpu-symbol-check
@@ -19,6 +19,8 @@ amdgpu_bo_export
1919 amdgpu_bo_free
2020 amdgpu_bo_import
2121 amdgpu_bo_inc_ref
22+amdgpu_bo_list_create_raw
23+amdgpu_bo_list_destroy_raw
2224 amdgpu_bo_list_create
2325 amdgpu_bo_list_destroy
2426 amdgpu_bo_list_update
@@ -47,6 +49,7 @@ amdgpu_query_sw_info
4749 amdgpu_cs_signal_semaphore
4850 amdgpu_cs_submit
4951 amdgpu_cs_submit_raw
52+amdgpu_cs_submit_raw2
5053 amdgpu_cs_syncobj_export_sync_file
5154 amdgpu_cs_syncobj_import_sync_file
5255 amdgpu_cs_syncobj_reset
--- a/amdgpu/amdgpu.h
+++ b/amdgpu/amdgpu.h
@@ -42,6 +42,7 @@ extern "C" {
4242 #endif
4343
4444 struct drm_amdgpu_info_hw_ip;
45+struct drm_amdgpu_bo_list_entry;
4546
4647 /*--------------------------------------------------------------------------*/
4748 /* --------------------------- Defines ------------------------------------ */
@@ -779,6 +780,37 @@ int amdgpu_bo_wait_for_idle(amdgpu_bo_handle buf_handle,
779780 *
780781 * \param dev - \c [in] Device handle.
781782 * See #amdgpu_device_initialize()
783+ * \param number_of_buffers - \c [in] Number of BOs in the list
784+ * \param buffers - \c [in] List of BO handles
785+ * \param result - \c [out] Created BO list handle
786+ *
787+ * \return 0 on success\n
788+ * <0 - Negative POSIX Error code
789+ *
790+ * \sa amdgpu_bo_list_destroy_raw(), amdgpu_cs_submit_raw2()
791+*/
792+int amdgpu_bo_list_create_raw(amdgpu_device_handle dev,
793+ uint32_t number_of_buffers,
794+ struct drm_amdgpu_bo_list_entry *buffers,
795+ uint32_t *result);
796+
797+/**
798+ * Destroys a BO list handle.
799+ *
800+ * \param bo_list - \c [in] BO list handle.
801+ *
802+ * \return 0 on success\n
803+ * <0 - Negative POSIX Error code
804+ *
805+ * \sa amdgpu_bo_list_create_raw(), amdgpu_cs_submit_raw2()
806+*/
807+int amdgpu_bo_list_destroy_raw(amdgpu_device_handle dev, uint32_t bo_list);
808+
809+/**
810+ * Creates a BO list handle for command submission.
811+ *
812+ * \param dev - \c [in] Device handle.
813+ * See #amdgpu_device_initialize()
782814 * \param number_of_resources - \c [in] Number of BOs in the list
783815 * \param resources - \c [in] List of BO handles
784816 * \param resource_prios - \c [in] Optional priority for each handle
@@ -1587,6 +1619,28 @@ int amdgpu_cs_submit_raw(amdgpu_device_handle dev,
15871619 struct drm_amdgpu_cs_chunk *chunks,
15881620 uint64_t *seq_no);
15891621
1622+/**
1623+ * Submit raw command submission to the kernel with a raw BO list handle.
1624+ *
1625+ * \param dev - \c [in] device handle
1626+ * \param context - \c [in] context handle for context id
1627+ * \param bo_list_handle - \c [in] raw bo list handle (0 for none)
1628+ * \param num_chunks - \c [in] number of CS chunks to submit
1629+ * \param chunks - \c [in] array of CS chunks
1630+ * \param seq_no - \c [out] output sequence number for submission.
1631+ *
1632+ * \return 0 on success\n
1633+ * <0 - Negative POSIX Error code
1634+ *
1635+ * \sa amdgpu_bo_list_create_raw(), amdgpu_bo_list_destroy_raw()
1636+ */
1637+int amdgpu_cs_submit_raw2(amdgpu_device_handle dev,
1638+ amdgpu_context_handle context,
1639+ uint32_t bo_list_handle,
1640+ int num_chunks,
1641+ struct drm_amdgpu_cs_chunk *chunks,
1642+ uint64_t *seq_no);
1643+
15901644 void amdgpu_cs_chunk_fence_to_dep(struct amdgpu_cs_fence *fence,
15911645 struct drm_amdgpu_cs_chunk_dep *dep);
15921646 void amdgpu_cs_chunk_fence_info_to_data(struct amdgpu_cs_fence_info *fence_info,
--- a/amdgpu/amdgpu_bo.c
+++ b/amdgpu/amdgpu_bo.c
@@ -618,6 +618,40 @@ out:
618618 return r;
619619 }
620620
621+drm_public int amdgpu_bo_list_create_raw(amdgpu_device_handle dev,
622+ uint32_t number_of_buffers,
623+ struct drm_amdgpu_bo_list_entry *buffers,
624+ uint32_t *result)
625+{
626+ union drm_amdgpu_bo_list args;
627+ int r;
628+
629+ memset(&args, 0, sizeof(args));
630+ args.in.operation = AMDGPU_BO_LIST_OP_CREATE;
631+ args.in.bo_number = number_of_buffers;
632+ args.in.bo_info_size = sizeof(struct drm_amdgpu_bo_list_entry);
633+ args.in.bo_info_ptr = (uint64_t)(uintptr_t)buffers;
634+
635+ r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_BO_LIST,
636+ &args, sizeof(args));
637+ if (!r)
638+ *result = args.out.list_handle;
639+ return r;
640+}
641+
642+drm_public int amdgpu_bo_list_destroy_raw(amdgpu_device_handle dev,
643+ uint32_t bo_list)
644+{
645+ union drm_amdgpu_bo_list args;
646+
647+ memset(&args, 0, sizeof(args));
648+ args.in.operation = AMDGPU_BO_LIST_OP_DESTROY;
649+ args.in.list_handle = bo_list;
650+
651+ return drmCommandWriteRead(dev->fd, DRM_AMDGPU_BO_LIST,
652+ &args, sizeof(args));
653+}
654+
621655 drm_public int amdgpu_bo_list_create(amdgpu_device_handle dev,
622656 uint32_t number_of_resources,
623657 amdgpu_bo_handle *resources,
--- a/amdgpu/amdgpu_cs.c
+++ b/amdgpu/amdgpu_cs.c
@@ -731,6 +731,31 @@ drm_public int amdgpu_cs_submit_raw(amdgpu_device_handle dev,
731731 return 0;
732732 }
733733
734+drm_public int amdgpu_cs_submit_raw2(amdgpu_device_handle dev,
735+ amdgpu_context_handle context,
736+ uint32_t bo_list_handle,
737+ int num_chunks,
738+ struct drm_amdgpu_cs_chunk *chunks,
739+ uint64_t *seq_no)
740+{
741+ union drm_amdgpu_cs cs = {0};
742+ uint64_t *chunk_array;
743+ int i, r;
744+
745+ chunk_array = alloca(sizeof(uint64_t) * num_chunks);
746+ for (i = 0; i < num_chunks; i++)
747+ chunk_array[i] = (uint64_t)(uintptr_t)&chunks[i];
748+ cs.in.chunks = (uint64_t)(uintptr_t)chunk_array;
749+ cs.in.ctx_id = context->id;
750+ cs.in.bo_list_handle = bo_list_handle;
751+ cs.in.num_chunks = num_chunks;
752+ r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_CS,
753+ &cs, sizeof(cs));
754+ if (!r && seq_no)
755+ *seq_no = cs.out.handle;
756+ return r;
757+}
758+
734759 drm_public void amdgpu_cs_chunk_fence_info_to_data(struct amdgpu_cs_fence_info *fence_info,
735760 struct drm_amdgpu_cs_chunk_data *data)
736761 {
Show on old repository browser