Skip to contentSkip to conversation

amdgpu: add a faster BO list API

PATCH In review Marek Olšák 5 participants 23 messages Jan 7, 2019 – Jan 16, 2019 19 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 amdgpu: add a faster BO list API

From: Marek Olšák <[email protected]>

---
 amdgpu/amdgpu-symbol-check |  3 ++
 amdgpu/amdgpu.h            | 56 +++++++++++++++++++++++++++++++++++++-
 amdgpu/amdgpu_bo.c         | 36 ++++++++++++++++++++++++
 amdgpu/amdgpu_cs.c         | 25 +++++++++++++++++
 4 files changed, 119 insertions(+), 1 deletion(-)
amdgpu/amdgpu-symbol-check +3 -0
index 6f5e0f95..96a44b40 100755
@@ -12,20 +12,22 @@ _edata
 _end
 _fini
 _init
 amdgpu_bo_alloc
 amdgpu_bo_cpu_map
 amdgpu_bo_cpu_unmap
 amdgpu_bo_export
 amdgpu_bo_free
 amdgpu_bo_import
 amdgpu_bo_inc_ref
+amdgpu_bo_list_create_raw
+amdgpu_bo_list_destroy_raw
 amdgpu_bo_list_create
 amdgpu_bo_list_destroy
 amdgpu_bo_list_update
 amdgpu_bo_query_info
 amdgpu_bo_set_metadata
 amdgpu_bo_va_op
 amdgpu_bo_va_op_raw
 amdgpu_bo_wait_for_idle
 amdgpu_create_bo_from_user_mem
 amdgpu_cs_chunk_fence_info_to_data
@@ -40,20 +42,21 @@ amdgpu_cs_destroy_semaphore
 amdgpu_cs_destroy_syncobj
 amdgpu_cs_export_syncobj
 amdgpu_cs_fence_to_handle
 amdgpu_cs_import_syncobj
 amdgpu_cs_query_fence_status
 amdgpu_cs_query_reset_state
 amdgpu_query_sw_info
 amdgpu_cs_signal_semaphore
 amdgpu_cs_submit
 amdgpu_cs_submit_raw
+amdgpu_cs_submit_raw2
 amdgpu_cs_syncobj_export_sync_file
 amdgpu_cs_syncobj_import_sync_file
 amdgpu_cs_syncobj_reset
 amdgpu_cs_syncobj_signal
 amdgpu_cs_syncobj_wait
 amdgpu_cs_wait_fences
 amdgpu_cs_wait_semaphore
 amdgpu_device_deinitialize
 amdgpu_device_initialize
 amdgpu_find_bo_by_cpu_mapping
amdgpu/amdgpu.h +55 -1

129 lines not on this page · raw message

amdgpu/amdgpu_bo.c +36 -0
index c0f42e81..21bc73aa 100644
@@ -611,20 +611,56 @@ drm_public int amdgpu_create_bo_from_user_mem(amdgpu_device_handle dev,
 	pthread_mutex_lock(&dev->bo_table_mutex);
 	r = handle_table_insert(&dev->bo_handles, (*buf_handle)->handle,
 				*buf_handle);
 	pthread_mutex_unlock(&dev->bo_table_mutex);
 	if (r)
 		amdgpu_bo_free(*buf_handle);
 out:
 	return r;
 }
 
+drm_public int amdgpu_bo_list_create_raw(amdgpu_device_handle dev,
+					 uint32_t number_of_buffers,
+					 struct drm_amdgpu_bo_list_entry *buffers,
+					 uint32_t *result)
+{
+	union drm_amdgpu_bo_list args;
+	int r;
+
+	memset(&args, 0, sizeof(args));
+	args.in.operation = AMDGPU_BO_LIST_OP_CREATE;
+	args.in.bo_number = number_of_buffers;
+	args.in.bo_info_size = sizeof(struct drm_amdgpu_bo_list_entry);
+	args.in.bo_info_ptr = (uint64_t)(uintptr_t)buffers;
+
+	r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_BO_LIST,
+				&args, sizeof(args));
+	if (r)
+		return r;
+
+	*result = args.out.list_handle;
+	return 0;
+}
+
+drm_public int amdgpu_bo_list_destroy_raw(amdgpu_device_handle dev,
+					  uint32_t bo_list)
+{
+	union drm_amdgpu_bo_list args;
+
+	memset(&args, 0, sizeof(args));
+	args.in.operation = AMDGPU_BO_LIST_OP_DESTROY;
+	args.in.list_handle = bo_list;
+
+	return drmCommandWriteRead(dev->fd, DRM_AMDGPU_BO_LIST,
+				   &args, sizeof(args));
+}
+
 drm_public int amdgpu_bo_list_create(amdgpu_device_handle dev,
 				     uint32_t number_of_resources,
 				     amdgpu_bo_handle *resources,
 				     uint8_t *resource_prios,
 				     amdgpu_bo_list_handle *result)
 {
 	struct drm_amdgpu_bo_list_entry *list;
 	union drm_amdgpu_bo_list args;
 	unsigned i;
 	int r;
amdgpu/amdgpu_cs.c +25 -0
index 3b8231aa..5bedf748 100644
@@ -724,20 +724,45 @@ drm_public int amdgpu_cs_submit_raw(amdgpu_device_handle dev,
 	r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_CS,
 				&cs, sizeof(cs));
 	if (r)
 		return r;
 
 	if (seq_no)
 		*seq_no = cs.out.handle;
 	return 0;
 }
 
+drm_public int amdgpu_cs_submit_raw2(amdgpu_device_handle dev,
+				     amdgpu_context_handle context,
+				     uint32_t bo_list_handle,
+				     int num_chunks,
+				     struct drm_amdgpu_cs_chunk *chunks,
+				     uint64_t *seq_no)
+{
+	union drm_amdgpu_cs cs = {0};
+	uint64_t *chunk_array;
+	int i, r;
+
+	chunk_array = alloca(sizeof(uint64_t) * num_chunks);
+	for (i = 0; i < num_chunks; i++)
+		chunk_array[i] = (uint64_t)(uintptr_t)&chunks[i];
+	cs.in.chunks = (uint64_t)(uintptr_t)chunk_array;
+	cs.in.ctx_id = context->id;
+	cs.in.bo_list_handle = bo_list_handle;
+	cs.in.num_chunks = num_chunks;
+	r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_CS,
+				&cs, sizeof(cs));
+	if (!r && seq_no)
+		*seq_no = cs.out.handle;
+	return r;
+}
+
 drm_public void amdgpu_cs_chunk_fence_info_to_data(struct amdgpu_cs_fence_info *fence_info,
 					struct drm_amdgpu_cs_chunk_data *data)
 {
 	data->fence_data.handle = fence_info->handle->handle;
 	data->fence_data.offset = fence_info->offset * sizeof(uint64_t);
 }
 
 drm_public void amdgpu_cs_chunk_fence_to_dep(struct amdgpu_cs_fence *fence,
 					struct drm_amdgpu_cs_chunk_dep *dep)
 {
Signature · 6 lines
2.17.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 20190107193104.4361-1-maraeo-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#2 lore raw

Looks good to me, Reviewed-by: Chunming Zhou <[email protected]>

Quoted 316 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Marek Ol?ák
Sent: Tuesday, January 08, 2019 3:31 AM
To: [email protected]
Subject: [PATCH libdrm] amdgpu: add a faster BO list API

From: Marek Olšák <[email protected]>

---
 amdgpu/amdgpu-symbol-check |  3 ++
 amdgpu/amdgpu.h            | 56
+++++++++++++++++++++++++++++++++++++-
 amdgpu/amdgpu_bo.c         | 36 ++++++++++++++++++++++++
 amdgpu/amdgpu_cs.c         | 25 +++++++++++++++++
 4 files changed, 119 insertions(+), 1 deletion(-)
amdgpu/amdgpu-symbol- renamed from amdgpu/amdgpu-symbol-check +0 -0

check index 6f5e0f95..96a44b40 100755

amdgpu/amdgpu-symbol-check +2 -0
@@ -12,20 +12,22 @@ _edata
 _end
 _fini
 _init
 amdgpu_bo_alloc
 amdgpu_bo_cpu_map
 amdgpu_bo_cpu_unmap
 amdgpu_bo_export
 amdgpu_bo_free
 amdgpu_bo_import
 amdgpu_bo_inc_ref
+amdgpu_bo_list_create_raw
+amdgpu_bo_list_destroy_raw
 amdgpu_bo_list_create
 amdgpu_bo_list_destroy
 amdgpu_bo_list_update
 amdgpu_bo_query_info
 amdgpu_bo_set_metadata
 amdgpu_bo_va_op
 amdgpu_bo_va_op_raw
 amdgpu_bo_wait_for_idle
 amdgpu_create_bo_from_user_mem
 amdgpu_cs_chunk_fence_info_to_data
@@ -40,20 +42,21 @@ amdgpu_cs_destroy_semaphore

amdgpu_cs_destroy_syncobj amdgpu_cs_export_syncobj amdgpu_cs_fence_to_handle amdgpu_cs_import_syncobj amdgpu_cs_query_fence_status amdgpu_cs_query_reset_state amdgpu_query_sw_info amdgpu_cs_signal_semaphore amdgpu_cs_submit amdgpu_cs_submit_raw

amdgpu/amdgpu-symbol-check +1 -0
+amdgpu_cs_submit_raw2
 amdgpu_cs_syncobj_export_sync_file
 amdgpu_cs_syncobj_import_sync_file
 amdgpu_cs_syncobj_reset
 amdgpu_cs_syncobj_signal
 amdgpu_cs_syncobj_wait
 amdgpu_cs_wait_fences
 amdgpu_cs_wait_semaphore
 amdgpu_device_deinitialize
 amdgpu_device_initialize
 amdgpu_find_bo_by_cpu_mapping
amdgpu/amdgpu.h index renamed from amdgpu/amdgpu.h +0 -0

dc51659a..5b800033 100644

amdgpu/amdgpu.h +1 -1
@@ -35,20 +35,21 @@
 #define _AMDGPU_H_
 
 #include <stdint.h>
 #include <stdbool.h>
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
 struct drm_amdgpu_info_hw_ip;
+struct drm_amdgpu_bo_list_entry;
 
 /*--------------------------------------------------------------------------*/
 /* --------------------------- Defines ------------------------------------ */  /*---------
-----------------------------------------------------------------*/
 
 /**
  * Define max. number of Command Buffers (IB) which could be sent to the

single
* hardware IP to accommodate CE/DE requirements
*
* \sa amdgpu_cs_ib_info

amdgpu/amdgpu.h +52 -1
@@ -767,34 +768,65 @@ int amdgpu_bo_cpu_unmap(amdgpu_bo_handle
 buf_handle);
  *                            and no GPU access is scheduled.
  *                          1 GPU access is in fly or scheduled
  *
  * \return   0 - on success
  *          <0 - Negative POSIX Error code
  */
 int amdgpu_bo_wait_for_idle(amdgpu_bo_handle buf_handle,
 			    uint64_t timeout_ns,
 			    bool *buffer_busy);
 
+/**
+ * Creates a BO list handle for command submission.
+ *
+ * \param   dev			- \c [in] Device handle.
+ *				   See #amdgpu_device_initialize()
+ * \param   number_of_buffers	- \c [in] Number of BOs in the list
+ * \param   buffers		- \c [in] List of BO handles
+ * \param   result		- \c [out] Created BO list handle
+ *
+ * \return   0 on success\n
+ *          <0 - Negative POSIX Error code
+ *
+ * \sa amdgpu_bo_list_destroy_raw()
+*/
+int amdgpu_bo_list_create_raw(amdgpu_device_handle dev,
+			      uint32_t number_of_buffers,
+			      struct drm_amdgpu_bo_list_entry *buffers,
+			      uint32_t *result);
+
+/**
+ * Destroys a BO list handle.
+ *
+ * \param   bo_list	- \c [in] BO list handle.
+ *
+ * \return   0 on success\n
+ *          <0 - Negative POSIX Error code
+ *
+ * \sa amdgpu_bo_list_create_raw(), amdgpu_cs_submit_raw2() */ int
+amdgpu_bo_list_destroy_raw(amdgpu_device_handle dev, uint32_t
 bo_list);
+
 /**
  * Creates a BO list handle for command submission.
  *
  * \param   dev			- \c [in] Device handle.
  *				   See #amdgpu_device_initialize()
  * \param   number_of_resources	- \c [in] Number of BOs in the list
  * \param   resources		- \c [in] List of BO handles
  * \param   resource_prios	- \c [in] Optional priority for each handle
  * \param   result		- \c [out] Created BO list handle
  *
  * \return   0 on success\n
  *          <0 - Negative POSIX Error code
  *
- * \sa amdgpu_bo_list_destroy()
+ * \sa amdgpu_bo_list_destroy(), amdgpu_cs_submit_raw2()
 */
 int amdgpu_bo_list_create(amdgpu_device_handle dev,
 			  uint32_t number_of_resources,
 			  amdgpu_bo_handle *resources,
 			  uint8_t *resource_prios,
 			  amdgpu_bo_list_handle *result);
 
 /**
  * Destroys a BO list handle.
  *
@@ -1580,20 +1612,42 @@ struct drm_amdgpu_cs_chunk;  struct
 drm_amdgpu_cs_chunk_dep;  struct drm_amdgpu_cs_chunk_data;
 
 int amdgpu_cs_submit_raw(amdgpu_device_handle dev,
 			 amdgpu_context_handle context,
 			 amdgpu_bo_list_handle bo_list_handle,
 			 int num_chunks,
 			 struct drm_amdgpu_cs_chunk *chunks,
 			 uint64_t *seq_no);
 
+/**
+ * Submit raw command submission to the kernel with a raw BO list handle.
+ *
+ * \param   dev	       - \c [in] device handle
+ * \param   context    - \c [in] context handle for context id
+ * \param   bo_list_handle - \c [in] raw bo list handle (0 for none)
+ * \param   num_chunks - \c [in] number of CS chunks to submit
+ * \param   chunks     - \c [in] array of CS chunks
+ * \param   seq_no     - \c [out] output sequence number for submission.
+ *
+ * \return   0 on success\n
+ *          <0 - Negative POSIX Error code
+ *
+ * \sa amdgpu_bo_list_create_raw(), amdgpu_bo_list_destroy_raw()  */
+int amdgpu_cs_submit_raw2(amdgpu_device_handle dev,
+			  amdgpu_context_handle context,
+			  uint32_t bo_list_handle,
+			  int num_chunks,
+			  struct drm_amdgpu_cs_chunk *chunks,
+			  uint64_t *seq_no);
+
 void amdgpu_cs_chunk_fence_to_dep(struct amdgpu_cs_fence *fence,
 				  struct drm_amdgpu_cs_chunk_dep *dep);

void amdgpu_cs_chunk_fence_info_to_data(struct amdgpu_cs_fence_info *fence_info,
struct drm_amdgpu_cs_chunk_data
*data);

/**
* Reserve VMID
* \param context - \c [in] GPU Context
* \param flags - \c [in] TBD
*

amdgpu/amdgpu_bo.c index renamed from amdgpu/amdgpu_bo.c +0 -0

c0f42e81..21bc73aa 100644

amdgpu/amdgpu_bo.c +36 -0
@@ -611,20 +611,56 @@ drm_public int
 amdgpu_create_bo_from_user_mem(amdgpu_device_handle dev,
 	pthread_mutex_lock(&dev->bo_table_mutex);
 	r = handle_table_insert(&dev->bo_handles, (*buf_handle)->handle,
 				*buf_handle);
 	pthread_mutex_unlock(&dev->bo_table_mutex);
 	if (r)
 		amdgpu_bo_free(*buf_handle);
 out:
 	return r;
 }
 
+drm_public int amdgpu_bo_list_create_raw(amdgpu_device_handle dev,
+					 uint32_t number_of_buffers,
+					 struct drm_amdgpu_bo_list_entry
 *buffers,
+					 uint32_t *result)
+{
+	union drm_amdgpu_bo_list args;
+	int r;
+
+	memset(&args, 0, sizeof(args));
+	args.in.operation = AMDGPU_BO_LIST_OP_CREATE;
+	args.in.bo_number = number_of_buffers;
+	args.in.bo_info_size = sizeof(struct drm_amdgpu_bo_list_entry);
+	args.in.bo_info_ptr = (uint64_t)(uintptr_t)buffers;
+
+	r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_BO_LIST,
+				&args, sizeof(args));
+	if (r)
+		return r;
+
+	*result = args.out.list_handle;
+	return 0;
+}
+
+drm_public int amdgpu_bo_list_destroy_raw(amdgpu_device_handle dev,
+					  uint32_t bo_list)
+{
+	union drm_amdgpu_bo_list args;
+
+	memset(&args, 0, sizeof(args));
+	args.in.operation = AMDGPU_BO_LIST_OP_DESTROY;
+	args.in.list_handle = bo_list;
+
+	return drmCommandWriteRead(dev->fd, DRM_AMDGPU_BO_LIST,
+				   &args, sizeof(args));
+}
+
 drm_public int amdgpu_bo_list_create(amdgpu_device_handle dev,
 				     uint32_t number_of_resources,
 				     amdgpu_bo_handle *resources,
 				     uint8_t *resource_prios,
 				     amdgpu_bo_list_handle *result)  {
 	struct drm_amdgpu_bo_list_entry *list;
 	union drm_amdgpu_bo_list args;
 	unsigned i;
amdgpu/amdgpu_bo.c +0 -0
 	int r;
amdgpu/amdgpu_cs.c index renamed from amdgpu/amdgpu_cs.c +0 -0

3b8231aa..5bedf748 100644

amdgpu/amdgpu_cs.c +25 -0
@@ -724,20 +724,45 @@ drm_public int
 amdgpu_cs_submit_raw(amdgpu_device_handle dev,
 	r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_CS,
 				&cs, sizeof(cs));
 	if (r)
 		return r;
 
 	if (seq_no)
 		*seq_no = cs.out.handle;
 	return 0;
 }
 
+drm_public int amdgpu_cs_submit_raw2(amdgpu_device_handle dev,
+				     amdgpu_context_handle context,
+				     uint32_t bo_list_handle,
+				     int num_chunks,
+				     struct drm_amdgpu_cs_chunk *chunks,
+				     uint64_t *seq_no)
+{
+	union drm_amdgpu_cs cs = {0};
+	uint64_t *chunk_array;
+	int i, r;
+
+	chunk_array = alloca(sizeof(uint64_t) * num_chunks);
+	for (i = 0; i < num_chunks; i++)
+		chunk_array[i] = (uint64_t)(uintptr_t)&chunks[i];
+	cs.in.chunks = (uint64_t)(uintptr_t)chunk_array;
+	cs.in.ctx_id = context->id;
+	cs.in.bo_list_handle = bo_list_handle;
+	cs.in.num_chunks = num_chunks;
+	r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_CS,
+				&cs, sizeof(cs));
+	if (!r && seq_no)
+		*seq_no = cs.out.handle;
+	return r;
+}
+
 drm_public void amdgpu_cs_chunk_fence_info_to_data(struct
 amdgpu_cs_fence_info *fence_info,
 					struct drm_amdgpu_cs_chunk_data
 *data)  {
 	data->fence_data.handle = fence_info->handle->handle;
 	data->fence_data.offset = fence_info->offset * sizeof(uint64_t);  }
 
 drm_public void amdgpu_cs_chunk_fence_to_dep(struct
 amdgpu_cs_fence *fence,

struct drm_amdgpu_cs_chunk_dep
*dep) {
--
2.17.1

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#3 lore raw
In reply to a message not in the archive

Looks good, but I'm wondering what's the actual improvement?

Christian.

Am 07.01.19 um 20:31 schrieb Marek Olšák:

Quoted 295 lines

From: Marek Olšák <[email protected]>

---
  amdgpu/amdgpu-symbol-check |  3 ++
  amdgpu/amdgpu.h            | 56 +++++++++++++++++++++++++++++++++++++-
  amdgpu/amdgpu_bo.c         | 36 ++++++++++++++++++++++++
  amdgpu/amdgpu_cs.c         | 25 +++++++++++++++++
  4 files changed, 119 insertions(+), 1 deletion(-)
amdgpu/amdgpu-symbol-check +3 -0
index 6f5e0f95..96a44b40 100755
@@ -12,20 +12,22 @@ _edata
  _end
  _fini
  _init
  amdgpu_bo_alloc
  amdgpu_bo_cpu_map
  amdgpu_bo_cpu_unmap
  amdgpu_bo_export
  amdgpu_bo_free
  amdgpu_bo_import
  amdgpu_bo_inc_ref
+amdgpu_bo_list_create_raw
+amdgpu_bo_list_destroy_raw
  amdgpu_bo_list_create
  amdgpu_bo_list_destroy
  amdgpu_bo_list_update
  amdgpu_bo_query_info
  amdgpu_bo_set_metadata
  amdgpu_bo_va_op
  amdgpu_bo_va_op_raw
  amdgpu_bo_wait_for_idle
  amdgpu_create_bo_from_user_mem
  amdgpu_cs_chunk_fence_info_to_data
@@ -40,20 +42,21 @@ amdgpu_cs_destroy_semaphore
  amdgpu_cs_destroy_syncobj
  amdgpu_cs_export_syncobj
  amdgpu_cs_fence_to_handle
  amdgpu_cs_import_syncobj
  amdgpu_cs_query_fence_status
  amdgpu_cs_query_reset_state
  amdgpu_query_sw_info
  amdgpu_cs_signal_semaphore
  amdgpu_cs_submit
  amdgpu_cs_submit_raw
+amdgpu_cs_submit_raw2
  amdgpu_cs_syncobj_export_sync_file
  amdgpu_cs_syncobj_import_sync_file
  amdgpu_cs_syncobj_reset
  amdgpu_cs_syncobj_signal
  amdgpu_cs_syncobj_wait
  amdgpu_cs_wait_fences
  amdgpu_cs_wait_semaphore
  amdgpu_device_deinitialize
  amdgpu_device_initialize
  amdgpu_find_bo_by_cpu_mapping
amdgpu/amdgpu.h +55 -1
index dc51659a..5b800033 100644
@@ -35,20 +35,21 @@
  #define _AMDGPU_H_
 
  #include <stdint.h>
  #include <stdbool.h>
 
  #ifdef __cplusplus
  extern "C" {
  #endif
 
  struct drm_amdgpu_info_hw_ip;
+struct drm_amdgpu_bo_list_entry;
 
  /*--------------------------------------------------------------------------*/
  /* --------------------------- Defines ------------------------------------ */
  /*--------------------------------------------------------------------------*/
 
  /**
   * Define max. number of Command Buffers (IB) which could be sent to the single
   * hardware IP to accommodate CE/DE requirements
   *
   * \sa amdgpu_cs_ib_info
@@ -767,34 +768,65 @@ int amdgpu_bo_cpu_unmap(amdgpu_bo_handle buf_handle);
   *                            and no GPU access is scheduled.
   *                          1 GPU access is in fly or scheduled
   *
   * \return   0 - on success
   *          <0 - Negative POSIX Error code
   */
  int amdgpu_bo_wait_for_idle(amdgpu_bo_handle buf_handle,
  			    uint64_t timeout_ns,
  			    bool *buffer_busy);
 
+/**
+ * Creates a BO list handle for command submission.
+ *
+ * \param   dev			- \c [in] Device handle.
+ *				   See #amdgpu_device_initialize()
+ * \param   number_of_buffers	- \c [in] Number of BOs in the list
+ * \param   buffers		- \c [in] List of BO handles
+ * \param   result		- \c [out] Created BO list handle
+ *
+ * \return   0 on success\n
+ *          <0 - Negative POSIX Error code
+ *
+ * \sa amdgpu_bo_list_destroy_raw()
+*/
+int amdgpu_bo_list_create_raw(amdgpu_device_handle dev,
+			      uint32_t number_of_buffers,
+			      struct drm_amdgpu_bo_list_entry *buffers,
+			      uint32_t *result);
+
+/**
+ * Destroys a BO list handle.
+ *
+ * \param   bo_list	- \c [in] BO list handle.
+ *
+ * \return   0 on success\n
+ *          <0 - Negative POSIX Error code
+ *
+ * \sa amdgpu_bo_list_create_raw(), amdgpu_cs_submit_raw2()
+*/
+int amdgpu_bo_list_destroy_raw(amdgpu_device_handle dev, uint32_t bo_list);
+
  /**
   * Creates a BO list handle for command submission.
   *
   * \param   dev			- \c [in] Device handle.
   *				   See #amdgpu_device_initialize()
   * \param   number_of_resources	- \c [in] Number of BOs in the list
   * \param   resources		- \c [in] List of BO handles
   * \param   resource_prios	- \c [in] Optional priority for each handle
   * \param   result		- \c [out] Created BO list handle
   *
   * \return   0 on success\n
   *          <0 - Negative POSIX Error code
   *
- * \sa amdgpu_bo_list_destroy()
+ * \sa amdgpu_bo_list_destroy(), amdgpu_cs_submit_raw2()
  */
  int amdgpu_bo_list_create(amdgpu_device_handle dev,
  			  uint32_t number_of_resources,
  			  amdgpu_bo_handle *resources,
  			  uint8_t *resource_prios,
  			  amdgpu_bo_list_handle *result);
 
  /**
   * Destroys a BO list handle.
   *
@@ -1580,20 +1612,42 @@ struct drm_amdgpu_cs_chunk;
  struct drm_amdgpu_cs_chunk_dep;
  struct drm_amdgpu_cs_chunk_data;
 
  int amdgpu_cs_submit_raw(amdgpu_device_handle dev,
  			 amdgpu_context_handle context,
  			 amdgpu_bo_list_handle bo_list_handle,
  			 int num_chunks,
  			 struct drm_amdgpu_cs_chunk *chunks,
  			 uint64_t *seq_no);
 
+/**
+ * Submit raw command submission to the kernel with a raw BO list handle.
+ *
+ * \param   dev	       - \c [in] device handle
+ * \param   context    - \c [in] context handle for context id
+ * \param   bo_list_handle - \c [in] raw bo list handle (0 for none)
+ * \param   num_chunks - \c [in] number of CS chunks to submit
+ * \param   chunks     - \c [in] array of CS chunks
+ * \param   seq_no     - \c [out] output sequence number for submission.
+ *
+ * \return   0 on success\n
+ *          <0 - Negative POSIX Error code
+ *
+ * \sa amdgpu_bo_list_create_raw(), amdgpu_bo_list_destroy_raw()
+ */
+int amdgpu_cs_submit_raw2(amdgpu_device_handle dev,
+			  amdgpu_context_handle context,
+			  uint32_t bo_list_handle,
+			  int num_chunks,
+			  struct drm_amdgpu_cs_chunk *chunks,
+			  uint64_t *seq_no);
+
  void amdgpu_cs_chunk_fence_to_dep(struct amdgpu_cs_fence *fence,
  				  struct drm_amdgpu_cs_chunk_dep *dep);
  void amdgpu_cs_chunk_fence_info_to_data(struct amdgpu_cs_fence_info *fence_info,
  					struct drm_amdgpu_cs_chunk_data *data);
 
  /**
   * Reserve VMID
   * \param   context - \c [in]  GPU Context
   * \param   flags - \c [in]  TBD
   *
amdgpu/amdgpu_bo.c +36 -0
index c0f42e81..21bc73aa 100644
@@ -611,20 +611,56 @@ drm_public int amdgpu_create_bo_from_user_mem(amdgpu_device_handle dev,
  	pthread_mutex_lock(&dev->bo_table_mutex);
  	r = handle_table_insert(&dev->bo_handles, (*buf_handle)->handle,
  				*buf_handle);
  	pthread_mutex_unlock(&dev->bo_table_mutex);
  	if (r)
  		amdgpu_bo_free(*buf_handle);
  out:
  	return r;
  }
 
+drm_public int amdgpu_bo_list_create_raw(amdgpu_device_handle dev,
+					 uint32_t number_of_buffers,
+					 struct drm_amdgpu_bo_list_entry *buffers,
+					 uint32_t *result)
+{
+	union drm_amdgpu_bo_list args;
+	int r;
+
+	memset(&args, 0, sizeof(args));
+	args.in.operation = AMDGPU_BO_LIST_OP_CREATE;
+	args.in.bo_number = number_of_buffers;
+	args.in.bo_info_size = sizeof(struct drm_amdgpu_bo_list_entry);
+	args.in.bo_info_ptr = (uint64_t)(uintptr_t)buffers;
+
+	r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_BO_LIST,
+				&args, sizeof(args));
+	if (r)
+		return r;
+
+	*result = args.out.list_handle;
+	return 0;
+}
+
+drm_public int amdgpu_bo_list_destroy_raw(amdgpu_device_handle dev,
+					  uint32_t bo_list)
+{
+	union drm_amdgpu_bo_list args;
+
+	memset(&args, 0, sizeof(args));
+	args.in.operation = AMDGPU_BO_LIST_OP_DESTROY;
+	args.in.list_handle = bo_list;
+
+	return drmCommandWriteRead(dev->fd, DRM_AMDGPU_BO_LIST,
+				   &args, sizeof(args));
+}
+
  drm_public int amdgpu_bo_list_create(amdgpu_device_handle dev,
  				     uint32_t number_of_resources,
  				     amdgpu_bo_handle *resources,
  				     uint8_t *resource_prios,
  				     amdgpu_bo_list_handle *result)
  {
  	struct drm_amdgpu_bo_list_entry *list;
  	union drm_amdgpu_bo_list args;
  	unsigned i;
  	int r;
amdgpu/amdgpu_cs.c +25 -0
index 3b8231aa..5bedf748 100644
@@ -724,20 +724,45 @@ drm_public int amdgpu_cs_submit_raw(amdgpu_device_handle dev,
  	r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_CS,
  				&cs, sizeof(cs));
  	if (r)
  		return r;
 
  	if (seq_no)
  		*seq_no = cs.out.handle;
  	return 0;
  }
 
+drm_public int amdgpu_cs_submit_raw2(amdgpu_device_handle dev,
+				     amdgpu_context_handle context,
+				     uint32_t bo_list_handle,
+				     int num_chunks,
+				     struct drm_amdgpu_cs_chunk *chunks,
+				     uint64_t *seq_no)
+{
+	union drm_amdgpu_cs cs = {0};
+	uint64_t *chunk_array;
+	int i, r;
+
+	chunk_array = alloca(sizeof(uint64_t) * num_chunks);
+	for (i = 0; i < num_chunks; i++)
+		chunk_array[i] = (uint64_t)(uintptr_t)&chunks[i];
+	cs.in.chunks = (uint64_t)(uintptr_t)chunk_array;
+	cs.in.ctx_id = context->id;
+	cs.in.bo_list_handle = bo_list_handle;
+	cs.in.num_chunks = num_chunks;
+	r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_CS,
+				&cs, sizeof(cs));
+	if (!r && seq_no)
+		*seq_no = cs.out.handle;
+	return r;
+}
+

amdgpu/amdgpu_cs.c drm_public int amdgpu_cs_submit_raw(amdgpu_device_handle dev, · line 768

Quoted 10 lines
amdgpu/amdgpu_cs.c +0 -0
  drm_public void amdgpu_cs_chunk_fence_info_to_data(struct amdgpu_cs_fence_info *fence_info,
  					struct drm_amdgpu_cs_chunk_data *data)
  {
  	data->fence_data.handle = fence_info->handle->handle;
  	data->fence_data.offset = fence_info->offset * sizeof(uint64_t);
  }
 
  drm_public void amdgpu_cs_chunk_fence_to_dep(struct amdgpu_cs_fence *fence,
  					struct drm_amdgpu_cs_chunk_dep *dep)
  {

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): a0a15ed6-eb1a-fbbe-7c1b-e3b9a64c1008-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#5 lore raw
Quoted 2 lines · On Wed, Jan 9, 2019, 5:28 AM Christian König <…

Looks good, but I'm wondering what's the actual improvement?

No malloc calls and 1 less for loop copying the bo list.

Marek

Quoted 319 lines

Christian.

Am 07.01.19 um 20:31 schrieb Marek Olšák:

Quoted 66 lines

From: Marek Olšák <[email protected]>

---
  amdgpu/amdgpu-symbol-check |  3 ++
  amdgpu/amdgpu.h            | 56 +++++++++++++++++++++++++++++++++++++-
  amdgpu/amdgpu_bo.c         | 36 ++++++++++++++++++++++++
  amdgpu/amdgpu_cs.c         | 25 +++++++++++++++++
  4 files changed, 119 insertions(+), 1 deletion(-)
amdgpu/amdgpu-symbol-check +3 -0
index 6f5e0f95..96a44b40 100755
@@ -12,20 +12,22 @@ _edata
  _end
  _fini
  _init
  amdgpu_bo_alloc
  amdgpu_bo_cpu_map
  amdgpu_bo_cpu_unmap
  amdgpu_bo_export
  amdgpu_bo_free
  amdgpu_bo_import
  amdgpu_bo_inc_ref
+amdgpu_bo_list_create_raw
+amdgpu_bo_list_destroy_raw
  amdgpu_bo_list_create
  amdgpu_bo_list_destroy
  amdgpu_bo_list_update
  amdgpu_bo_query_info
  amdgpu_bo_set_metadata
  amdgpu_bo_va_op
  amdgpu_bo_va_op_raw
  amdgpu_bo_wait_for_idle
  amdgpu_create_bo_from_user_mem
  amdgpu_cs_chunk_fence_info_to_data
@@ -40,20 +42,21 @@ amdgpu_cs_destroy_semaphore
  amdgpu_cs_destroy_syncobj
  amdgpu_cs_export_syncobj
  amdgpu_cs_fence_to_handle
  amdgpu_cs_import_syncobj
  amdgpu_cs_query_fence_status
  amdgpu_cs_query_reset_state
  amdgpu_query_sw_info
  amdgpu_cs_signal_semaphore
  amdgpu_cs_submit
  amdgpu_cs_submit_raw
+amdgpu_cs_submit_raw2
  amdgpu_cs_syncobj_export_sync_file
  amdgpu_cs_syncobj_import_sync_file
  amdgpu_cs_syncobj_reset
  amdgpu_cs_syncobj_signal
  amdgpu_cs_syncobj_wait
  amdgpu_cs_wait_fences
  amdgpu_cs_wait_semaphore
  amdgpu_device_deinitialize
  amdgpu_device_initialize
  amdgpu_find_bo_by_cpu_mapping
amdgpu/amdgpu.h +0 -0
index dc51659a..5b800033 100644
@@ -35,20 +35,21 @@
  #define _AMDGPU_H_
 
  #include <stdint.h>

amdgpu/amdgpu.h line 47

Quoted 10 lines
amdgpu/amdgpu.h +1 -0
  #include <stdbool.h>
 
  #ifdef __cplusplus
  extern "C" {
  #endif
 
  struct drm_amdgpu_info_hw_ip;
+struct drm_amdgpu_bo_list_entry;
 
 

/*--------------------------------------------------------------------------*/

amdgpu/amdgpu.h line 48

Quoted 1 line
amdgpu/amdgpu.h +0 -0
  /* --------------------------- Defines

------------------------------------ */

Quoted 1 line

/*--------------------------------------------------------------------------*/

Quoted 3 lines

/**
* Define max. number of Command Buffers (IB) which could be sent to

the single

amdgpu/amdgpu.h int amdgpu_bo_cpu_unmap(amdgpu_bo_handle

Quoted 4 lines

* hardware IP to accommodate CE/DE requirements *
* \sa amdgpu_cs_ib_info

amdgpu/amdgpu.h +0 -0
@@ -767,34 +768,65 @@ int amdgpu_bo_cpu_unmap(amdgpu_bo_handle

buf_handle);

Quoted 30 lines
amdgpu/amdgpu.h +20 -0
   *                            and no GPU access is scheduled.
   *                          1 GPU access is in fly or scheduled
   *
   * \return   0 - on success
   *          <0 - Negative POSIX Error code
   */
  int amdgpu_bo_wait_for_idle(amdgpu_bo_handle buf_handle,
                          uint64_t timeout_ns,
                          bool *buffer_busy);
 
+/**
+ * Creates a BO list handle for command submission.
+ *
+ * \param   dev                      - \c [in] Device handle.
+ *                              See #amdgpu_device_initialize()
+ * \param   number_of_buffers        - \c [in] Number of BOs in the list
+ * \param   buffers          - \c [in] List of BO handles
+ * \param   result           - \c [out] Created BO list handle
+ *
+ * \return   0 on success\n
+ *          <0 - Negative POSIX Error code
+ *
+ * \sa amdgpu_bo_list_destroy_raw()
+*/
+int amdgpu_bo_list_create_raw(amdgpu_device_handle dev,
+                           uint32_t number_of_buffers,
+                           struct drm_amdgpu_bo_list_entry *buffers,
+                           uint32_t *result);
+
+/**

amdgpu/amdgpu.h int amdgpu_bo_cpu_unmap(amdgpu_bo_handle buf_handle);

Quoted 10 lines
amdgpu/amdgpu.h +10 -0
+ * Destroys a BO list handle.
+ *
+ * \param   bo_list  - \c [in] BO list handle.
+ *
+ * \return   0 on success\n
+ *          <0 - Negative POSIX Error code
+ *
+ * \sa amdgpu_bo_list_create_raw(), amdgpu_cs_submit_raw2()
+*/
+int amdgpu_bo_list_destroy_raw(amdgpu_device_handle dev, uint32_t

bo_list);

Quoted 29 lines
amdgpu/amdgpu.h +2 -1
+
  /**
   * Creates a BO list handle for command submission.
   *
   * \param   dev                     - \c [in] Device handle.
   *                             See #amdgpu_device_initialize()
   * \param   number_of_resources     - \c [in] Number of BOs in the list
   * \param   resources               - \c [in] List of BO handles
   * \param   resource_prios  - \c [in] Optional priority for each handle
   * \param   result          - \c [out] Created BO list handle
   *
   * \return   0 on success\n
   *          <0 - Negative POSIX Error code
   *
- * \sa amdgpu_bo_list_destroy()
+ * \sa amdgpu_bo_list_destroy(), amdgpu_cs_submit_raw2()
  */
  int amdgpu_bo_list_create(amdgpu_device_handle dev,
                        uint32_t number_of_resources,
                        amdgpu_bo_handle *resources,
                        uint8_t *resource_prios,
                        amdgpu_bo_list_handle *result);
 
  /**
   * Destroys a BO list handle.
   *
@@ -1580,20 +1612,42 @@ struct drm_amdgpu_cs_chunk;
  struct drm_amdgpu_cs_chunk_dep;
  struct drm_amdgpu_cs_chunk_data;

amdgpu/amdgpu.h struct drm_amdgpu_cs_chunk; · line 1623

Quoted 10 lines
amdgpu/amdgpu.h +2 -0
 
  int amdgpu_cs_submit_raw(amdgpu_device_handle dev,
                       amdgpu_context_handle context,
                       amdgpu_bo_list_handle bo_list_handle,
                       int num_chunks,
                       struct drm_amdgpu_cs_chunk *chunks,
                       uint64_t *seq_no);
 
+/**
+ * Submit raw command submission to the kernel with a raw BO list

handle.

Quoted 13 lines
amdgpu/amdgpu.h +13 -0
+ *
+ * \param   dev             - \c [in] device handle
+ * \param   context    - \c [in] context handle for context id
+ * \param   bo_list_handle - \c [in] raw bo list handle (0 for none)
+ * \param   num_chunks - \c [in] number of CS chunks to submit
+ * \param   chunks     - \c [in] array of CS chunks
+ * \param   seq_no     - \c [out] output sequence number for submission.
+ *
+ * \return   0 on success\n
+ *          <0 - Negative POSIX Error code
+ *
+ * \sa amdgpu_bo_list_create_raw(), amdgpu_bo_list_destroy_raw()
+ */

amdgpu/amdgpu.h struct drm_amdgpu_cs_chunk;

Quoted 10 lines
amdgpu/amdgpu.h +7 -0
+int amdgpu_cs_submit_raw2(amdgpu_device_handle dev,
+                       amdgpu_context_handle context,
+                       uint32_t bo_list_handle,
+                       int num_chunks,
+                       struct drm_amdgpu_cs_chunk *chunks,
+                       uint64_t *seq_no);
+
  void amdgpu_cs_chunk_fence_to_dep(struct amdgpu_cs_fence *fence,
                                struct drm_amdgpu_cs_chunk_dep *dep);
  void amdgpu_cs_chunk_fence_info_to_data(struct amdgpu_cs_fence_info

*fence_info,

amdgpu/amdgpu.h struct drm_amdgpu_cs_chunk; · line 1647

Quoted 1 line
amdgpu/amdgpu.h +0 -0
                                      struct drm_amdgpu_cs_chunk_data

*data);

amdgpu/amdgpu_bo.c drm_public int

Quoted 11 lines
amdgpu/amdgpu.h +0 -0
  /**
   * Reserve VMID
   * \param   context - \c [in]  GPU Context
   * \param   flags - \c [in]  TBD
   *
amdgpu/amdgpu_bo.c +0 -0
index c0f42e81..21bc73aa 100644
@@ -611,20 +611,56 @@ drm_public int

amdgpu_create_bo_from_user_mem(amdgpu_device_handle dev,

amdgpu/amdgpu_bo.c drm_public int amdgpu_create_bo_from_user_mem(amdgpu_device_handle dev,

Quoted 13 lines
amdgpu/amdgpu_bo.c +3 -0
      pthread_mutex_lock(&dev->bo_table_mutex);
      r = handle_table_insert(&dev->bo_handles, (*buf_handle)->handle,
                              *buf_handle);
      pthread_mutex_unlock(&dev->bo_table_mutex);
      if (r)
              amdgpu_bo_free(*buf_handle);
  out:
      return r;
  }
 
+drm_public int amdgpu_bo_list_create_raw(amdgpu_device_handle dev,
+                                      uint32_t number_of_buffers,
+                                      struct drm_amdgpu_bo_list_entry

*buffers,

amdgpu/amdgpu_cs.c drm_public int

Quoted 48 lines
amdgpu/amdgpu_bo.c +33 -0
+                                      uint32_t *result)
+{
+     union drm_amdgpu_bo_list args;
+     int r;
+
+     memset(&args, 0, sizeof(args));
+     args.in.operation = AMDGPU_BO_LIST_OP_CREATE;
+     args.in.bo_number = number_of_buffers;
+     args.in.bo_info_size = sizeof(struct drm_amdgpu_bo_list_entry);
+     args.in.bo_info_ptr = (uint64_t)(uintptr_t)buffers;
+
+     r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_BO_LIST,
+                             &args, sizeof(args));
+     if (r)
+             return r;
+
+     *result = args.out.list_handle;
+     return 0;
+}
+
+drm_public int amdgpu_bo_list_destroy_raw(amdgpu_device_handle dev,
+                                       uint32_t bo_list)
+{
+     union drm_amdgpu_bo_list args;
+
+     memset(&args, 0, sizeof(args));
+     args.in.operation = AMDGPU_BO_LIST_OP_DESTROY;
+     args.in.list_handle = bo_list;
+
+     return drmCommandWriteRead(dev->fd, DRM_AMDGPU_BO_LIST,
+                                &args, sizeof(args));
+}
+
  drm_public int amdgpu_bo_list_create(amdgpu_device_handle dev,
                                   uint32_t number_of_resources,
                                   amdgpu_bo_handle *resources,
                                   uint8_t *resource_prios,
                                   amdgpu_bo_list_handle *result)
  {
      struct drm_amdgpu_bo_list_entry *list;
      union drm_amdgpu_bo_list args;
      unsigned i;
      int r;
amdgpu/amdgpu_cs.c +0 -0
index 3b8231aa..5bedf748 100644
@@ -724,20 +724,45 @@ drm_public int

amdgpu_cs_submit_raw(amdgpu_device_handle dev,

Quoted 26 lines
amdgpu/amdgpu_cs.c +16 -0
      r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_CS,
                              &cs, sizeof(cs));
      if (r)
              return r;
 
      if (seq_no)
              *seq_no = cs.out.handle;
      return 0;
  }
 
+drm_public int amdgpu_cs_submit_raw2(amdgpu_device_handle dev,
+                                  amdgpu_context_handle context,
+                                  uint32_t bo_list_handle,
+                                  int num_chunks,
+                                  struct drm_amdgpu_cs_chunk *chunks,
+                                  uint64_t *seq_no)
+{
+     union drm_amdgpu_cs cs = {0};
+     uint64_t *chunk_array;
+     int i, r;
+
+     chunk_array = alloca(sizeof(uint64_t) * num_chunks);
+     for (i = 0; i < num_chunks; i++)
+             chunk_array[i] = (uint64_t)(uintptr_t)&chunks[i];
+     cs.in.chunks = (uint64_t)(uintptr_t)chunk_array;
+     cs.in.ctx_id = context->id;

amdgpu/amdgpu_cs.c drm_public int amdgpu_cs_submit_raw(amdgpu_device_handle dev,

Quoted 10 lines
amdgpu/amdgpu_cs.c +9 -0
+     cs.in.bo_list_handle = bo_list_handle;
+     cs.in.num_chunks = num_chunks;
+     r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_CS,
+                             &cs, sizeof(cs));
+     if (!r && seq_no)
+             *seq_no = cs.out.handle;
+     return r;
+}
+
  drm_public void amdgpu_cs_chunk_fence_info_to_data(struct

amdgpu_cs_fence_info *fence_info,

amdgpu/amdgpu_cs.c drm_public int · line 760

Quoted 1 line
amdgpu/amdgpu_cs.c +0 -0
                                      struct drm_amdgpu_cs_chunk_data

*data)

Quoted 5 lines
amdgpu/amdgpu_cs.c +0 -0
  {
      data->fence_data.handle = fence_info->handle->handle;
      data->fence_data.offset = fence_info->offset * sizeof(uint64_t);
  }
 
Quoted 7 lines

amdgpu/amdgpu_cs.c drm_public int · line 766

Quoted 1 line
amdgpu/amdgpu_cs.c +0 -0
  drm_public void amdgpu_cs_chunk_fence_to_dep(struct amdgpu_cs_fence

*fence,

amdgpu/amdgpu_cs.c drm_public int · line 767

Quoted 1 line
amdgpu/amdgpu_cs.c +0 -0
                                      struct drm_amdgpu_cs_chunk_dep

*dep)

Quoted 1 line
amdgpu/amdgpu_cs.c +0 -0
  {

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): CAAxE2A5M2WW6uPFo0a=+6ukbtgx5xHfkKUKOB9dgtB=qH88htQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#7 lore raw

Am 09.01.19 um 13:36 schrieb Marek Olšák:

Quoted 8 lines · On Wed, Jan 9, 2019, 5:28 AM Christian König…

Looks good, but I'm wondering what's the actual improvement?

No malloc calls and 1 less for loop copying the bo list.

Yeah, but didn't we want to get completely rid of the bo list?

Christian.

Quoted 342 lines

Marek

    Christian.

    Am 07.01.19 um 20:31 schrieb Marek Olšák:
    > From: Marek Olšák <[email protected] <mailto:[email protected]>>
    >
    > ---
    >   amdgpu/amdgpu-symbol-check |  3 ++
    >   amdgpu/amdgpu.h            | 56
    +++++++++++++++++++++++++++++++++++++-
    >   amdgpu/amdgpu_bo.c         | 36 ++++++++++++++++++++++++
    >   amdgpu/amdgpu_cs.c         | 25 +++++++++++++++++
    >   4 files changed, 119 insertions(+), 1 deletion(-)
    >
    > diff --git a/amdgpu/amdgpu-symbol-check b/amdgpu/amdgpu-symbol-check
    > index 6f5e0f95..96a44b40 100755
    > --- a/amdgpu/amdgpu-symbol-check
    > +++ b/amdgpu/amdgpu-symbol-check
    > @@ -12,20 +12,22 @@ _edata
    >   _end
    >   _fini
    >   _init
    >   amdgpu_bo_alloc
    >   amdgpu_bo_cpu_map
    >   amdgpu_bo_cpu_unmap
    >   amdgpu_bo_export
    >   amdgpu_bo_free
    >   amdgpu_bo_import
    >   amdgpu_bo_inc_ref
    > +amdgpu_bo_list_create_raw
    > +amdgpu_bo_list_destroy_raw
    >   amdgpu_bo_list_create
    >   amdgpu_bo_list_destroy
    >   amdgpu_bo_list_update
    >   amdgpu_bo_query_info
    >   amdgpu_bo_set_metadata
    >   amdgpu_bo_va_op
    >   amdgpu_bo_va_op_raw
    >   amdgpu_bo_wait_for_idle
    >   amdgpu_create_bo_from_user_mem
    >   amdgpu_cs_chunk_fence_info_to_data
    > @@ -40,20 +42,21 @@ amdgpu_cs_destroy_semaphore
    >   amdgpu_cs_destroy_syncobj
    >   amdgpu_cs_export_syncobj
    >   amdgpu_cs_fence_to_handle
    >   amdgpu_cs_import_syncobj
    >   amdgpu_cs_query_fence_status
    >   amdgpu_cs_query_reset_state
    >   amdgpu_query_sw_info
    >   amdgpu_cs_signal_semaphore
    >   amdgpu_cs_submit
    >   amdgpu_cs_submit_raw
    > +amdgpu_cs_submit_raw2
    >   amdgpu_cs_syncobj_export_sync_file
    >   amdgpu_cs_syncobj_import_sync_file
    >   amdgpu_cs_syncobj_reset
    >   amdgpu_cs_syncobj_signal
    >   amdgpu_cs_syncobj_wait
    >   amdgpu_cs_wait_fences
    >   amdgpu_cs_wait_semaphore
    >   amdgpu_device_deinitialize
    >   amdgpu_device_initialize
    >   amdgpu_find_bo_by_cpu_mapping
    > diff --git a/amdgpu/amdgpu.h b/amdgpu/amdgpu.h
    > index dc51659a..5b800033 100644
    > --- a/amdgpu/amdgpu.h
    > +++ b/amdgpu/amdgpu.h
    > @@ -35,20 +35,21 @@
    >   #define _AMDGPU_H_
    >
    >   #include <stdint.h>
    >   #include <stdbool.h>
    >
    >   #ifdef __cplusplus
    >   extern "C" {
    >   #endif
    >
    >   struct drm_amdgpu_info_hw_ip;
    > +struct drm_amdgpu_bo_list_entry;
    >
    >
     /*--------------------------------------------------------------------------*/
    >   /* --------------------------- Defines
    ------------------------------------ */
    >
     /*--------------------------------------------------------------------------*/
    >
    >   /**
    >    * Define max. number of Command Buffers (IB) which could be
    sent to the single
    >    * hardware IP to accommodate CE/DE requirements
    >    *
    >    * \sa amdgpu_cs_ib_info
    > @@ -767,34 +768,65 @@ int amdgpu_bo_cpu_unmap(amdgpu_bo_handle
    buf_handle);
    >    *                            and no GPU access is scheduled.
    >    *                          1 GPU access is in fly or scheduled
    >    *
    >    * \return   0 - on success
    >    *          <0 - Negative POSIX Error code
    >    */
    >   int amdgpu_bo_wait_for_idle(amdgpu_bo_handle buf_handle,
    >                           uint64_t timeout_ns,
    >                           bool *buffer_busy);
    >
    > +/**
    > + * Creates a BO list handle for command submission.
    > + *
    > + * \param   dev                      - \c [in] Device handle.
    > + *                              See #amdgpu_device_initialize()
    > + * \param   number_of_buffers        - \c [in] Number of BOs in
    the list
    > + * \param   buffers          - \c [in] List of BO handles
    > + * \param   result           - \c [out] Created BO list handle
    > + *
    > + * \return   0 on success\n
    > + *          <0 - Negative POSIX Error code
    > + *
    > + * \sa amdgpu_bo_list_destroy_raw()
    > +*/
    > +int amdgpu_bo_list_create_raw(amdgpu_device_handle dev,
    > +                           uint32_t number_of_buffers,
    > +                           struct drm_amdgpu_bo_list_entry
    *buffers,
    > +                           uint32_t *result);
    > +
    > +/**
    > + * Destroys a BO list handle.
    > + *
    > + * \param   bo_list  - \c [in] BO list handle.
    > + *
    > + * \return   0 on success\n
    > + *          <0 - Negative POSIX Error code
    > + *
    > + * \sa amdgpu_bo_list_create_raw(), amdgpu_cs_submit_raw2()
    > +*/
    > +int amdgpu_bo_list_destroy_raw(amdgpu_device_handle dev,
    uint32_t bo_list);
    > +
    >   /**
    >    * Creates a BO list handle for command submission.
    >    *
    >    * \param   dev                     - \c [in] Device handle.
    >    *                             See #amdgpu_device_initialize()
    >    * \param   number_of_resources     - \c [in] Number of BOs in
    the list
    >    * \param   resources               - \c [in] List of BO handles
    >    * \param   resource_prios  - \c [in] Optional priority for
    each handle
    >    * \param   result          - \c [out] Created BO list handle
    >    *
    >    * \return   0 on success\n
    >    *          <0 - Negative POSIX Error code
    >    *
    > - * \sa amdgpu_bo_list_destroy()
    > + * \sa amdgpu_bo_list_destroy(), amdgpu_cs_submit_raw2()
    >   */
    >   int amdgpu_bo_list_create(amdgpu_device_handle dev,
    >                         uint32_t number_of_resources,
    >                         amdgpu_bo_handle *resources,
    >                         uint8_t *resource_prios,
    >                         amdgpu_bo_list_handle *result);
    >
    >   /**
    >    * Destroys a BO list handle.
    >    *
    > @@ -1580,20 +1612,42 @@ struct drm_amdgpu_cs_chunk;
    >   struct drm_amdgpu_cs_chunk_dep;
    >   struct drm_amdgpu_cs_chunk_data;
    >
    >   int amdgpu_cs_submit_raw(amdgpu_device_handle dev,
    >                        amdgpu_context_handle context,
    >                        amdgpu_bo_list_handle bo_list_handle,
    >                        int num_chunks,
    >                        struct drm_amdgpu_cs_chunk *chunks,
    >                        uint64_t *seq_no);
    >
    > +/**
    > + * Submit raw command submission to the kernel with a raw BO
    list handle.
    > + *
    > + * \param   dev             - \c [in] device handle
    > + * \param   context    - \c [in] context handle for context id
    > + * \param   bo_list_handle - \c [in] raw bo list handle (0 for
    none)
    > + * \param   num_chunks - \c [in] number of CS chunks to submit
    > + * \param   chunks     - \c [in] array of CS chunks
    > + * \param   seq_no     - \c [out] output sequence number for
    submission.
    > + *
    > + * \return   0 on success\n
    > + *          <0 - Negative POSIX Error code
    > + *
    > + * \sa amdgpu_bo_list_create_raw(), amdgpu_bo_list_destroy_raw()
    > + */
    > +int amdgpu_cs_submit_raw2(amdgpu_device_handle dev,
    > +                       amdgpu_context_handle context,
    > +                       uint32_t bo_list_handle,
    > +                       int num_chunks,
    > +                       struct drm_amdgpu_cs_chunk *chunks,
    > +                       uint64_t *seq_no);
    > +
    >   void amdgpu_cs_chunk_fence_to_dep(struct amdgpu_cs_fence *fence,
    >                                 struct drm_amdgpu_cs_chunk_dep
    *dep);
    >   void amdgpu_cs_chunk_fence_info_to_data(struct
    amdgpu_cs_fence_info *fence_info,
    >                                       struct
    drm_amdgpu_cs_chunk_data *data);
    >
    >   /**
    >    * Reserve VMID
    >    * \param   context - \c [in]  GPU Context
    >    * \param   flags - \c [in]  TBD
    >    *
    > diff --git a/amdgpu/amdgpu_bo.c b/amdgpu/amdgpu_bo.c
    > index c0f42e81..21bc73aa 100644
    > --- a/amdgpu/amdgpu_bo.c
    > +++ b/amdgpu/amdgpu_bo.c
    > @@ -611,20 +611,56 @@ drm_public int
    amdgpu_create_bo_from_user_mem(amdgpu_device_handle dev,
    >  pthread_mutex_lock(&dev->bo_table_mutex);
    >       r = handle_table_insert(&dev->bo_handles,
    (*buf_handle)->handle,
    >                               *buf_handle);
    >  pthread_mutex_unlock(&dev->bo_table_mutex);
    >       if (r)
    >               amdgpu_bo_free(*buf_handle);
    >   out:
    >       return r;
    >   }
    >
    > +drm_public int amdgpu_bo_list_create_raw(amdgpu_device_handle dev,
    > +                                      uint32_t number_of_buffers,
    > +                                      struct
    drm_amdgpu_bo_list_entry *buffers,
    > +                                      uint32_t *result)
    > +{
    > +     union drm_amdgpu_bo_list args;
    > +     int r;
    > +
    > +     memset(&args, 0, sizeof(args));
    > +     args.in.operation = AMDGPU_BO_LIST_OP_CREATE;
    > +     args.in.bo_number = number_of_buffers;
    > +     args.in.bo_info_size = sizeof(struct
    drm_amdgpu_bo_list_entry);
    > +     args.in.bo_info_ptr = (uint64_t)(uintptr_t)buffers;
    > +
    > +     r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_BO_LIST,
    > +                             &args, sizeof(args));
    > +     if (r)
    > +             return r;
    > +
    > +     *result = args.out.list_handle;
    > +     return 0;
    > +}
    > +
    > +drm_public int amdgpu_bo_list_destroy_raw(amdgpu_device_handle dev,
    > +                                       uint32_t bo_list)
    > +{
    > +     union drm_amdgpu_bo_list args;
    > +
    > +     memset(&args, 0, sizeof(args));
    > +     args.in.operation = AMDGPU_BO_LIST_OP_DESTROY;
    > +     args.in.list_handle = bo_list;
    > +
    > +     return drmCommandWriteRead(dev->fd, DRM_AMDGPU_BO_LIST,
    > +                                &args, sizeof(args));
    > +}
    > +
    >   drm_public int amdgpu_bo_list_create(amdgpu_device_handle dev,
    >                                    uint32_t number_of_resources,
    >                                    amdgpu_bo_handle *resources,
    >                                    uint8_t *resource_prios,
    > amdgpu_bo_list_handle *result)
    >   {
    >       struct drm_amdgpu_bo_list_entry *list;
    >       union drm_amdgpu_bo_list args;
    >       unsigned i;
    >       int r;
    > diff --git a/amdgpu/amdgpu_cs.c b/amdgpu/amdgpu_cs.c
    > index 3b8231aa..5bedf748 100644
    > --- a/amdgpu/amdgpu_cs.c
    > +++ b/amdgpu/amdgpu_cs.c
    > @@ -724,20 +724,45 @@ drm_public int
    amdgpu_cs_submit_raw(amdgpu_device_handle dev,
    >       r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_CS,
    >                               &cs, sizeof(cs));
    >       if (r)
    >               return r;
    >
    >       if (seq_no)
    >               *seq_no = cs.out.handle;
    >       return 0;
    >   }
    >
    > +drm_public int amdgpu_cs_submit_raw2(amdgpu_device_handle dev,
    > + amdgpu_context_handle context,
    > +                                  uint32_t bo_list_handle,
    > +                                  int num_chunks,
    > +                                  struct drm_amdgpu_cs_chunk
    *chunks,
    > +                                  uint64_t *seq_no)
    > +{
    > +     union drm_amdgpu_cs cs = {0};
    > +     uint64_t *chunk_array;
    > +     int i, r;
    > +
    > +     chunk_array = alloca(sizeof(uint64_t) * num_chunks);
    > +     for (i = 0; i < num_chunks; i++)
    > +             chunk_array[i] = (uint64_t)(uintptr_t)&chunks[i];
    > +     cs.in.chunks = (uint64_t)(uintptr_t)chunk_array;
    > +     cs.in.ctx_id = context->id;
    > +     cs.in.bo_list_handle = bo_list_handle;
    > +     cs.in.num_chunks = num_chunks;
    > +     r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_CS,
    > +                             &cs, sizeof(cs));
    > +     if (!r && seq_no)
    > +             *seq_no = cs.out.handle;
    > +     return r;
    > +}
    > +
    >   drm_public void amdgpu_cs_chunk_fence_info_to_data(struct
    amdgpu_cs_fence_info *fence_info,
    >                                       struct
    drm_amdgpu_cs_chunk_data *data)
    >   {
    >       data->fence_data.handle = fence_info->handle->handle;
    >       data->fence_data.offset = fence_info->offset *
    sizeof(uint64_t);
    >   }
    >
    >   drm_public void amdgpu_cs_chunk_fence_to_dep(struct
    amdgpu_cs_fence *fence,
    >                                       struct
    drm_amdgpu_cs_chunk_dep *dep)
    >   {
Quoted 4 lines

_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 513ee137-7e99-c8fc-9e3b-e9077ead60a3-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#9 lore raw
Quoted 7 lines · Christian König

Am 09.01.19 um 13:36 schrieb Marek Olšák:

On Wed, Jan 9, 2019, 5:28 AM Christian König < [email protected] wrote:

Quoted 8 lines
Quoted 2 lines

Looks good, but I'm wondering what's the actual improvement?

No malloc calls and 1 less for loop copying the bo list.

Yeah, but didn't we want to get completely rid of the bo list?

If we have multiple IBs (e.g. gfx + compute) that share a BO list, I think it's faster to send the BO list to the kernel only once.

Marek

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): CAAxE2A5WYWCWAPA0K+vYDirtT6BV7QJoZSbEhh0Z57OF860mWQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#11 lore raw

Am 09.01.19 um 17:14 schrieb Marek Olšák:

Quoted 12 lines · On Wed, Jan 9, 2019 at 8:09 AM Christian König…
    Am 09.01.19 um 13:36 schrieb Marek Olšák:
Quoted 9 lines

On Wed, Jan 9, 2019, 5:28 AM Christian König <[email protected] <mailto:[email protected]> wrote:

Looks good, but I'm wondering what's the actual improvement?

Quoted 6 lines
Quoted 1 line

No malloc calls and 1 less for loop copying the bo list.

Yeah, but didn't we want to get completely rid of the bo list?

If we have multiple IBs (e.g. gfx + compute) that share a BO list, I think it's faster to send the BO list to the kernel only once.

That's not really faster.

The only thing we safe us is a single loop over all BOs to lockup the handle into a pointer and that is only a tiny fraction of the overhead.

The majority of the overhead is locking the BOs and reserving space for the submission.

What could really help here is to submit gfx+comput together in just one CS IOCTL. This way we would need the locking and space reservation only once.

It's a bit of work in the kernel side, but certainly doable.

Christian.

Quoted 7 lines

Marek

_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 7f85afd6-b17b-1c50-ba03-c03dd6e9a362-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#13 lore raw
Quoted 30 lines · Christian König

Am 09.01.19 um 17:14 schrieb Marek Olšák:

Quoted 7 lines · Christian König

Am 09.01.19 um 13:36 schrieb Marek Olšák:

On Wed, Jan 9, 2019, 5:28 AM Christian König < [email protected] wrote:

Quoted 8 lines
Quoted 2 lines

Looks good, but I'm wondering what's the actual improvement?

No malloc calls and 1 less for loop copying the bo list.

Yeah, but didn't we want to get completely rid of the bo list?

If we have multiple IBs (e.g. gfx + compute) that share a BO list, I think it's faster to send the BO list to the kernel only once.

That's not really faster.

The only thing we safe us is a single loop over all BOs to lockup the handle into a pointer and that is only a tiny fraction of the overhead.

Quoted 9 lines

The majority of the overhead is locking the BOs and reserving space for the submission.

What could really help here is to submit gfx+comput together in just one CS IOCTL. This way we would need the locking and space reservation only once.

It's a bit of work in the kernel side, but certainly doable.

OK. Any objections to this patch?

Thanks,
Marek

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): CAAxE2A5RjR=+2Rs5HDx1rV0ftdkZJX=6TQDkvRQSxfo++vnXOA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#15 lore raw

Am 10.01.19 um 00:39 schrieb Marek Olšák:
On Wed, Jan 9, 2019 at 1:41 PM Christian König <[email protected]<mailto:[email protected]>> wrote:
Am 09.01.19 um 17:14 schrieb Marek Olšák:
On Wed, Jan 9, 2019 at 8:09 AM Christian König <[email protected]<mailto:[email protected]>> wrote:
Am 09.01.19 um 13:36 schrieb Marek Olšák:

On Wed, Jan 9, 2019, 5:28 AM Christian König <[email protected]<mailto:[email protected]> wrote:
Looks good, but I'm wondering what's the actual improvement?

No malloc calls and 1 less for loop copying the bo list.

Yeah, but didn't we want to get completely rid of the bo list?

If we have multiple IBs (e.g. gfx + compute) that share a BO list, I think it's faster to send the BO list to the kernel only once.

That's not really faster.

The only thing we safe us is a single loop over all BOs to lockup the handle into a pointer and that is only a tiny fraction of the overhead.

The majority of the overhead is locking the BOs and reserving space for the submission.

What could really help here is to submit gfx+comput together in just one CS IOCTL. This way we would need the locking and space reservation only once.

It's a bit of work in the kernel side, but certainly doable.

OK. Any objections to this patch?

In general I'm wondering if we couldn't avoid adding so much new interface.

For example we can avoid the malloc() when we just cache the last freed bo_list structure in the device. We would just need an atomic pointer exchange operation for that.

This way we even don't need to change mesa at all.

Regarding optimization, this chunk can be replaced by a cast on 64bit:

+ chunk_array = alloca(sizeof(uint64_t) * num_chunks);
+ for (i = 0; i < num_chunks; i++)
+ chunk_array[i] = (uint64_t)(uintptr_t)&chunks[i];

Regards,
Christian.

Thanks,
Marek

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): e23ecf17-dbd4-ecef-f8fc-4dc849e7bddf-5C7GfCeVMHo@public.gmane.org

#17 lore raw
Quoted 42 lines · On Thu, Jan 10, 2019, 4:15 AM Koenig, Christian…

Am 10.01.19 um 00:39 schrieb Marek Olšák:

Quoted 37 lines · Christian König

Am 09.01.19 um 17:14 schrieb Marek Olšák:

Quoted 7 lines · Christian König

Am 09.01.19 um 13:36 schrieb Marek Olšák:

On Wed, Jan 9, 2019, 5:28 AM Christian König < [email protected] wrote:

Quoted 8 lines
Quoted 2 lines

Looks good, but I'm wondering what's the actual improvement?

No malloc calls and 1 less for loop copying the bo list.

Yeah, but didn't we want to get completely rid of the bo list?

If we have multiple IBs (e.g. gfx + compute) that share a BO list, I think it's faster to send the BO list to the kernel only once.

That's not really faster.

The only thing we safe us is a single loop over all BOs to lockup the handle into a pointer and that is only a tiny fraction of the overhead.

The majority of the overhead is locking the BOs and reserving space for the submission.

What could really help here is to submit gfx+comput together in just one CS IOCTL. This way we would need the locking and space reservation only once.

Quoted 8 lines
Quoted 2 lines

It's a bit of work in the kernel side, but certainly doable.

OK. Any objections to this patch?

In general I'm wondering if we couldn't avoid adding so much new interface.

There are Vulkan drivers that still use the bo_list interface.

Quoted 7 lines

For example we can avoid the malloc() when we just cache the last freed bo_list structure in the device. We would just need an atomic pointer exchange operation for that.

This way we even don't need to change mesa at all.

There is still the for loop that we need to get rid of.

Quoted 7 lines

Regarding optimization, this chunk can be replaced by a cast on 64bit:

(quoted diff) +3 -0
+	chunk_array = alloca(sizeof(uint64_t) * num_chunks);
+	for (i = 0; i < num_chunks; i++)
+		chunk_array[i] = (uint64_t)(uintptr_t)&chunks[i];

It can't. The input is an array of structures. The ioctl takes an array of

pointers.

Marek

Quoted 9 lines

Regards,
Christian.

Thanks,
Marek

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): CAAxE2A6z_LLzzsLqsBtLyXcFTsLG_8FQc7=oN2p_nLJGoXbmgg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#19 lore raw

Am 10.01.19 um 12:41 schrieb Marek Olšák:

Quoted 65 lines · On Thu, Jan 10, 2019, 4:15 AM Koenig, Christian…
    Am 10.01.19 um 00:39 schrieb Marek Olšák:
Quoted 39 lines

On Wed, Jan 9, 2019 at 1:41 PM Christian König <[email protected] <mailto:[email protected]>> wrote:

Am 09.01.19 um 17:14 schrieb Marek Olšák:

Quoted 17 lines

On Wed, Jan 9, 2019 at 8:09 AM Christian König <[email protected] <mailto:[email protected]>> wrote:

Am 09.01.19 um 13:36 schrieb Marek Olšák:

Quoted 11 lines

On Wed, Jan 9, 2019, 5:28 AM Christian König <[email protected] <mailto:[email protected]> wrote:

Looks good, but I'm wondering what's the actual improvement?

No malloc calls and 1 less for loop copying the bo list.

Quoted 7 lines

Yeah, but didn't we want to get completely rid of the bo list?

If we have multiple IBs (e.g. gfx + compute) that share a BO list, I think it's faster to send the BO list to the kernel only once.

That's not really faster.

The only thing we safe us is a single loop over all BOs to lockup the handle into a pointer and that is only a tiny fraction of the overhead.

The majority of the overhead is locking the BOs and reserving space for the submission.

Quoted 8 lines

What could really help here is to submit gfx+comput together in just one CS IOCTL. This way we would need the locking and space reservation only once.

It's a bit of work in the kernel side, but certainly doable.

OK. Any objections to this patch?

In general I'm wondering if we couldn't avoid adding so much new interface.

There are Vulkan drivers that still use the bo_list interface.

For example we can avoid the malloc() when we just cache the last freed bo_list structure in the device. We would just need an atomic pointer exchange operation for that.

Quoted 4 lines

This way we even don't need to change mesa at all.

There is still the for loop that we need to get rid of.

Yeah, but that I'm fine to handle with a amdgpu_bo_list_create_raw which only takes the handles and still returns the amdgpu_bo_list structure we are used to.

See what I'm mostly concerned about is having another CS function to maintain.

Quoted 8 lines

Regarding optimization, this chunk can be replaced by a cast on 64bit:

Quoted 3 lines
    +	chunk_array = alloca(sizeof(uint64_t) * num_chunks);
    +	for (i = 0; i < num_chunks; i++)
    +		chunk_array[i] = (uint64_t)(uintptr_t)&chunks[i];

It can't. The input is an array of structures. The ioctl takes an array of pointers.

Ah! Haven't seen this, sorry for the noise.

Christian.

Quoted 8 lines

Marek

Regards,
Christian.

Quoted 1 line
Quoted 8 lines
Quoted 2 lines

Thanks,
Marek

_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 7544c927-8b1f-c7d0-dd9d-21311ffca542-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#21 lore raw
Quoted 73 lines · On Thu, Jan 10, 2019, 6:51 AM Christian König <…

Am 10.01.19 um 12:41 schrieb Marek Olšák:

Quoted 42 lines · On Thu, Jan 10, 2019, 4:15 AM Koenig, Christian…

Am 10.01.19 um 00:39 schrieb Marek Olšák:

Quoted 37 lines · Christian König

Am 09.01.19 um 17:14 schrieb Marek Olšák:

Quoted 7 lines · Christian König

Am 09.01.19 um 13:36 schrieb Marek Olšák:

On Wed, Jan 9, 2019, 5:28 AM Christian König < [email protected] wrote:

Quoted 8 lines
Quoted 2 lines

Looks good, but I'm wondering what's the actual improvement?

No malloc calls and 1 less for loop copying the bo list.

Yeah, but didn't we want to get completely rid of the bo list?

If we have multiple IBs (e.g. gfx + compute) that share a BO list, I think it's faster to send the BO list to the kernel only once.

That's not really faster.

The only thing we safe us is a single loop over all BOs to lockup the handle into a pointer and that is only a tiny fraction of the overhead.

The majority of the overhead is locking the BOs and reserving space for the submission.

What could really help here is to submit gfx+comput together in just one CS IOCTL. This way we would need the locking and space reservation only once.

Quoted 9 lines
Quoted 2 lines

It's a bit of work in the kernel side, but certainly doable.

OK. Any objections to this patch?

In general I'm wondering if we couldn't avoid adding so much new interface.

There are Vulkan drivers that still use the bo_list interface.

Quoted 7 lines

For example we can avoid the malloc() when we just cache the last freed bo_list structure in the device. We would just need an atomic pointer exchange operation for that.

This way we even don't need to change mesa at all.

There is still the for loop that we need to get rid of.

Quoted 7 lines

Yeah, but that I'm fine to handle with a amdgpu_bo_list_create_raw which only takes the handles and still returns the amdgpu_bo_list structure we are used to.

See what I'm mostly concerned about is having another CS function to maintain.

There is no maintenance cost. It's just a wrapper. Eventually all drivers will switch to it.

Marek

Quoted 24 lines
Quoted 9 lines

Regarding optimization, this chunk can be replaced by a cast on 64bit:

(quoted diff) +3 -0
+	chunk_array = alloca(sizeof(uint64_t) * num_chunks);
+	for (i = 0; i < num_chunks; i++)
+		chunk_array[i] = (uint64_t)(uintptr_t)&chunks[i];

It can't. The input is an array of structures. The ioctl takes an array

of pointers.

Ah! Haven't seen this, sorry for the noise.

Christian.

Marek

Quoted 4 lines

Regards,
Christian.

Quoted 10 lines
Quoted 5 lines

Thanks,
Marek

_______________________________________________
amd-gfx mailing listamd-gfx-PD4FTy7X32lNgt0PjOBp934avgP/[email protected]://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#22 lore raw
In reply to a message not in the archive

So random questions:

1) In this discussion it was mentioned that some Vulkan drivers still use the bo_list interface. I think that implies radv as I think we're still using bo_list. Is there any other API we should be using? (Also, with VK_EXT_descriptor_indexing I suspect we'll be moving more towards a global bo list instead of a cmd buffer one, as we cannot know all the BOs referenced anymore, but not sure what end state here will be).

2) The other alternative mentioned was adding the buffers directly into the submit ioctl. Is this the desired end state (though as above I'm not sure how that works for vulkan)? If yes, what is the timeline for this that we need something in the interim?

3) Did we measure any performance benefit?

In general I'd like to to ack the raw bo list creation function as this interface seems easier to use. The two arrays thing has always been kind of a pain when we want to use e.g. builtin sort functions to make sure we have no duplicate BOs, but have some comments below.

Quoted 104 lines · Marek Olšák

From: Marek Olšák <[email protected]>

---
 amdgpu/amdgpu-symbol-check |  3 ++
 amdgpu/amdgpu.h            | 56 +++++++++++++++++++++++++++++++++++++-
 amdgpu/amdgpu_bo.c         | 36 ++++++++++++++++++++++++
 amdgpu/amdgpu_cs.c         | 25 +++++++++++++++++
 4 files changed, 119 insertions(+), 1 deletion(-)
amdgpu/amdgpu-symbol-check +3 -0
index 6f5e0f95..96a44b40 100755
@@ -12,20 +12,22 @@ _edata
 _end
 _fini
 _init
 amdgpu_bo_alloc
 amdgpu_bo_cpu_map
 amdgpu_bo_cpu_unmap
 amdgpu_bo_export
 amdgpu_bo_free
 amdgpu_bo_import
 amdgpu_bo_inc_ref
+amdgpu_bo_list_create_raw
+amdgpu_bo_list_destroy_raw
 amdgpu_bo_list_create
 amdgpu_bo_list_destroy
 amdgpu_bo_list_update
 amdgpu_bo_query_info
 amdgpu_bo_set_metadata
 amdgpu_bo_va_op
 amdgpu_bo_va_op_raw
 amdgpu_bo_wait_for_idle
 amdgpu_create_bo_from_user_mem
 amdgpu_cs_chunk_fence_info_to_data
@@ -40,20 +42,21 @@ amdgpu_cs_destroy_semaphore
 amdgpu_cs_destroy_syncobj
 amdgpu_cs_export_syncobj
 amdgpu_cs_fence_to_handle
 amdgpu_cs_import_syncobj
 amdgpu_cs_query_fence_status
 amdgpu_cs_query_reset_state
 amdgpu_query_sw_info
 amdgpu_cs_signal_semaphore
 amdgpu_cs_submit
 amdgpu_cs_submit_raw
+amdgpu_cs_submit_raw2
 amdgpu_cs_syncobj_export_sync_file
 amdgpu_cs_syncobj_import_sync_file
 amdgpu_cs_syncobj_reset
 amdgpu_cs_syncobj_signal
 amdgpu_cs_syncobj_wait
 amdgpu_cs_wait_fences
 amdgpu_cs_wait_semaphore
 amdgpu_device_deinitialize
 amdgpu_device_initialize
 amdgpu_find_bo_by_cpu_mapping
amdgpu/amdgpu.h +9 -0
index dc51659a..5b800033 100644
@@ -35,20 +35,21 @@
 #define _AMDGPU_H_
 
 #include <stdint.h>
 #include <stdbool.h>
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
 struct drm_amdgpu_info_hw_ip;
+struct drm_amdgpu_bo_list_entry;
 
 /*--------------------------------------------------------------------------*/
 /* --------------------------- Defines ------------------------------------ */
 /*--------------------------------------------------------------------------*/
 
 /**
  * Define max. number of Command Buffers (IB) which could be sent to the single
  * hardware IP to accommodate CE/DE requirements
  *
  * \sa amdgpu_cs_ib_info
@@ -767,34 +768,65 @@ int amdgpu_bo_cpu_unmap(amdgpu_bo_handle buf_handle);
  *                            and no GPU access is scheduled.
  *                          1 GPU access is in fly or scheduled
  *
  * \return   0 - on success
  *          <0 - Negative POSIX Error code
  */
 int amdgpu_bo_wait_for_idle(amdgpu_bo_handle buf_handle,
                            uint64_t timeout_ns,
                            bool *buffer_busy);
 
+/**
+ * Creates a BO list handle for command submission.
+ *
+ * \param   dev                        - \c [in] Device handle.
+ *                                See #amdgpu_device_initialize()
+ * \param   number_of_buffers  - \c [in] Number of BOs in the list
+ * \param   buffers            - \c [in] List of BO handles
+ * \param   result             - \c [out] Created BO list handle

amdgpu/amdgpu.h int amdgpu_bo_cpu_unmap(amdgpu_bo_handle buf_handle); · line 795

Quoted 10 lines
amdgpu/amdgpu.h +10 -0
+ *
+ * \return   0 on success\n
+ *          <0 - Negative POSIX Error code
+ *
+ * \sa amdgpu_bo_list_destroy_raw()
+*/
+int amdgpu_bo_list_create_raw(amdgpu_device_handle dev,
+                             uint32_t number_of_buffers,
+                             struct drm_amdgpu_bo_list_entry *buffers,
+                             uint32_t *result);

So AFAIU drm_amdgpu_bo_list_entry takes a raw bo handle while we never get a raw bo handle from libdrm_amdgpu. How are we supposed to fill it in?

What do we win by having the raw handle for the bo_list? If we would not return the raw handle we would not need the submit_raw2.

Quoted 195 lines
amdgpu/amdgpu.h +36 -1
+
+/**
+ * Destroys a BO list handle.
+ *
+ * \param   bo_list    - \c [in] BO list handle.
+ *
+ * \return   0 on success\n
+ *          <0 - Negative POSIX Error code
+ *
+ * \sa amdgpu_bo_list_create_raw(), amdgpu_cs_submit_raw2()
+*/
+int amdgpu_bo_list_destroy_raw(amdgpu_device_handle dev, uint32_t bo_list);
+
 /**
  * Creates a BO list handle for command submission.
  *
  * \param   dev                        - \c [in] Device handle.
  *                                See #amdgpu_device_initialize()
  * \param   number_of_resources        - \c [in] Number of BOs in the list
  * \param   resources          - \c [in] List of BO handles
  * \param   resource_prios     - \c [in] Optional priority for each handle
  * \param   result             - \c [out] Created BO list handle
  *
  * \return   0 on success\n
  *          <0 - Negative POSIX Error code
  *
- * \sa amdgpu_bo_list_destroy()
+ * \sa amdgpu_bo_list_destroy(), amdgpu_cs_submit_raw2()
 */
 int amdgpu_bo_list_create(amdgpu_device_handle dev,
                          uint32_t number_of_resources,
                          amdgpu_bo_handle *resources,
                          uint8_t *resource_prios,
                          amdgpu_bo_list_handle *result);
 
 /**
  * Destroys a BO list handle.
  *
@@ -1580,20 +1612,42 @@ struct drm_amdgpu_cs_chunk;
 struct drm_amdgpu_cs_chunk_dep;
 struct drm_amdgpu_cs_chunk_data;
 
 int amdgpu_cs_submit_raw(amdgpu_device_handle dev,
                         amdgpu_context_handle context,
                         amdgpu_bo_list_handle bo_list_handle,
                         int num_chunks,
                         struct drm_amdgpu_cs_chunk *chunks,
                         uint64_t *seq_no);
 
+/**
+ * Submit raw command submission to the kernel with a raw BO list handle.
+ *
+ * \param   dev               - \c [in] device handle
+ * \param   context    - \c [in] context handle for context id
+ * \param   bo_list_handle - \c [in] raw bo list handle (0 for none)
+ * \param   num_chunks - \c [in] number of CS chunks to submit
+ * \param   chunks     - \c [in] array of CS chunks
+ * \param   seq_no     - \c [out] output sequence number for submission.
+ *
+ * \return   0 on success\n
+ *          <0 - Negative POSIX Error code
+ *
+ * \sa amdgpu_bo_list_create_raw(), amdgpu_bo_list_destroy_raw()
+ */
+int amdgpu_cs_submit_raw2(amdgpu_device_handle dev,
+                         amdgpu_context_handle context,
+                         uint32_t bo_list_handle,
+                         int num_chunks,
+                         struct drm_amdgpu_cs_chunk *chunks,
+                         uint64_t *seq_no);
+
 void amdgpu_cs_chunk_fence_to_dep(struct amdgpu_cs_fence *fence,
                                  struct drm_amdgpu_cs_chunk_dep *dep);
 void amdgpu_cs_chunk_fence_info_to_data(struct amdgpu_cs_fence_info *fence_info,
                                        struct drm_amdgpu_cs_chunk_data *data);
 
 /**
  * Reserve VMID
  * \param   context - \c [in]  GPU Context
  * \param   flags - \c [in]  TBD
  *
amdgpu/amdgpu_bo.c +36 -0
index c0f42e81..21bc73aa 100644
@@ -611,20 +611,56 @@ drm_public int amdgpu_create_bo_from_user_mem(amdgpu_device_handle dev,
        pthread_mutex_lock(&dev->bo_table_mutex);
        r = handle_table_insert(&dev->bo_handles, (*buf_handle)->handle,
                                *buf_handle);
        pthread_mutex_unlock(&dev->bo_table_mutex);
        if (r)
                amdgpu_bo_free(*buf_handle);
 out:
        return r;
 }
 
+drm_public int amdgpu_bo_list_create_raw(amdgpu_device_handle dev,
+                                        uint32_t number_of_buffers,
+                                        struct drm_amdgpu_bo_list_entry *buffers,
+                                        uint32_t *result)
+{
+       union drm_amdgpu_bo_list args;
+       int r;
+
+       memset(&args, 0, sizeof(args));
+       args.in.operation = AMDGPU_BO_LIST_OP_CREATE;
+       args.in.bo_number = number_of_buffers;
+       args.in.bo_info_size = sizeof(struct drm_amdgpu_bo_list_entry);
+       args.in.bo_info_ptr = (uint64_t)(uintptr_t)buffers;
+
+       r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_BO_LIST,
+                               &args, sizeof(args));
+       if (r)
+               return r;
+
+       *result = args.out.list_handle;
+       return 0;
+}
+
+drm_public int amdgpu_bo_list_destroy_raw(amdgpu_device_handle dev,
+                                         uint32_t bo_list)
+{
+       union drm_amdgpu_bo_list args;
+
+       memset(&args, 0, sizeof(args));
+       args.in.operation = AMDGPU_BO_LIST_OP_DESTROY;
+       args.in.list_handle = bo_list;
+
+       return drmCommandWriteRead(dev->fd, DRM_AMDGPU_BO_LIST,
+                                  &args, sizeof(args));
+}
+
 drm_public int amdgpu_bo_list_create(amdgpu_device_handle dev,
                                     uint32_t number_of_resources,
                                     amdgpu_bo_handle *resources,
                                     uint8_t *resource_prios,
                                     amdgpu_bo_list_handle *result)
 {
        struct drm_amdgpu_bo_list_entry *list;
        union drm_amdgpu_bo_list args;
        unsigned i;
        int r;
amdgpu/amdgpu_cs.c +25 -1
index 3b8231aa..5bedf748 100644
@@ -724,20 +724,45 @@ drm_public int amdgpu_cs_submit_raw(amdgpu_device_handle dev,
        r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_CS,
                                &cs, sizeof(cs));
        if (r)
                return r;
 
        if (seq_no)
                *seq_no = cs.out.handle;
        return 0;
 }
 
+drm_public int amdgpu_cs_submit_raw2(amdgpu_device_handle dev,
+                                    amdgpu_context_handle context,
+                                    uint32_t bo_list_handle,
+                                    int num_chunks,
+                                    struct drm_amdgpu_cs_chunk *chunks,
+                                    uint64_t *seq_no)
+{
+       union drm_amdgpu_cs cs = {0};
+       uint64_t *chunk_array;
+       int i, r;
+
+       chunk_array = alloca(sizeof(uint64_t) * num_chunks);
+       for (i = 0; i < num_chunks; i++)
+               chunk_array[i] = (uint64_t)(uintptr_t)&chunks[i];
+       cs.in.chunks = (uint64_t)(uintptr_t)chunk_array;
+       cs.in.ctx_id = context->id;
+       cs.in.bo_list_handle = bo_list_handle;
+       cs.in.num_chunks = num_chunks;
+       r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_CS,
+                               &cs, sizeof(cs));
+       if (!r && seq_no)
+               *seq_no = cs.out.handle;
+       return r;
+}
+
 drm_public void amdgpu_cs_chunk_fence_info_to_data(struct amdgpu_cs_fence_info *fence_info,
                                        struct drm_amdgpu_cs_chunk_data *data)
 {
        data->fence_data.handle = fence_info->handle->handle;
        data->fence_data.offset = fence_info->offset * sizeof(uint64_t);
 }
 
 drm_public void amdgpu_cs_chunk_fence_to_dep(struct amdgpu_cs_fence *fence,
                                        struct drm_amdgpu_cs_chunk_dep *dep)
 {
--

2.17.1

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): CAP+8YyFD+LxEQOLOY+mDC5v3OOyh1De2DcXK0sRtMW0t7z20SQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#24 lore raw

Well if you ask me we should have the following interface for negotiating memory management with the kernel:

1. We have per process BOs which can't be shared between processes.

Those are always valid and don't need to be mentioned in any BO list whatsoever.

If we knew that a per process BO is currently not in use we can optionally tell that to the kernel to make memory management more efficient.

In other words instead of a list of stuff which is used we send down to the kernel a list of stuff which is not used any more and that only when we know that it is necessary, e.g. when a game or application overcommits.

2. We have shared BOs which are used by more than one process.

Those are rare and should be added to the per CS list of BOs in use.

The whole BO list interface Marek tries to optimize here should be deprecated and not used any more.

Regards,
Christian.

Am 16.01.19 um 13:46 schrieb Bas Nieuwenhuizen:

Quoted 337 lines

So random questions:

1) In this discussion it was mentioned that some Vulkan drivers still use the bo_list interface. I think that implies radv as I think we're still using bo_list. Is there any other API we should be using? (Also, with VK_EXT_descriptor_indexing I suspect we'll be moving more towards a global bo list instead of a cmd buffer one, as we cannot know all the BOs referenced anymore, but not sure what end state here will be).

2) The other alternative mentioned was adding the buffers directly into the submit ioctl. Is this the desired end state (though as above I'm not sure how that works for vulkan)? If yes, what is the timeline for this that we need something in the interim?

3) Did we measure any performance benefit?

In general I'd like to to ack the raw bo list creation function as this interface seems easier to use. The two arrays thing has always been kind of a pain when we want to use e.g. builtin sort functions to make sure we have no duplicate BOs, but have some comments below.

Quoted 103 lines · Marek Olšák

From: Marek Olšák <[email protected]>

---
  amdgpu/amdgpu-symbol-check |  3 ++
  amdgpu/amdgpu.h            | 56 +++++++++++++++++++++++++++++++++++++-
  amdgpu/amdgpu_bo.c         | 36 ++++++++++++++++++++++++
  amdgpu/amdgpu_cs.c         | 25 +++++++++++++++++
  4 files changed, 119 insertions(+), 1 deletion(-)
amdgpu/amdgpu-symbol-check +3 -0
index 6f5e0f95..96a44b40 100755
@@ -12,20 +12,22 @@ _edata
  _end
  _fini
  _init
  amdgpu_bo_alloc
  amdgpu_bo_cpu_map
  amdgpu_bo_cpu_unmap
  amdgpu_bo_export
  amdgpu_bo_free
  amdgpu_bo_import
  amdgpu_bo_inc_ref
+amdgpu_bo_list_create_raw
+amdgpu_bo_list_destroy_raw
  amdgpu_bo_list_create
  amdgpu_bo_list_destroy
  amdgpu_bo_list_update
  amdgpu_bo_query_info
  amdgpu_bo_set_metadata
  amdgpu_bo_va_op
  amdgpu_bo_va_op_raw
  amdgpu_bo_wait_for_idle
  amdgpu_create_bo_from_user_mem
  amdgpu_cs_chunk_fence_info_to_data
@@ -40,20 +42,21 @@ amdgpu_cs_destroy_semaphore
  amdgpu_cs_destroy_syncobj
  amdgpu_cs_export_syncobj
  amdgpu_cs_fence_to_handle
  amdgpu_cs_import_syncobj
  amdgpu_cs_query_fence_status
  amdgpu_cs_query_reset_state
  amdgpu_query_sw_info
  amdgpu_cs_signal_semaphore
  amdgpu_cs_submit
  amdgpu_cs_submit_raw
+amdgpu_cs_submit_raw2
  amdgpu_cs_syncobj_export_sync_file
  amdgpu_cs_syncobj_import_sync_file
  amdgpu_cs_syncobj_reset
  amdgpu_cs_syncobj_signal
  amdgpu_cs_syncobj_wait
  amdgpu_cs_wait_fences
  amdgpu_cs_wait_semaphore
  amdgpu_device_deinitialize
  amdgpu_device_initialize
  amdgpu_find_bo_by_cpu_mapping
amdgpu/amdgpu.h +9 -0
index dc51659a..5b800033 100644
@@ -35,20 +35,21 @@
  #define _AMDGPU_H_
 
  #include <stdint.h>
  #include <stdbool.h>
 
  #ifdef __cplusplus
  extern "C" {
  #endif
 
  struct drm_amdgpu_info_hw_ip;
+struct drm_amdgpu_bo_list_entry;
 
  /*--------------------------------------------------------------------------*/
  /* --------------------------- Defines ------------------------------------ */
  /*--------------------------------------------------------------------------*/
 
  /**
   * Define max. number of Command Buffers (IB) which could be sent to the single
   * hardware IP to accommodate CE/DE requirements
   *
   * \sa amdgpu_cs_ib_info
@@ -767,34 +768,65 @@ int amdgpu_bo_cpu_unmap(amdgpu_bo_handle buf_handle);
   *                            and no GPU access is scheduled.
   *                          1 GPU access is in fly or scheduled
   *
   * \return   0 - on success
   *          <0 - Negative POSIX Error code
   */
  int amdgpu_bo_wait_for_idle(amdgpu_bo_handle buf_handle,
                             uint64_t timeout_ns,
                             bool *buffer_busy);
 
+/**
+ * Creates a BO list handle for command submission.
+ *
+ * \param   dev                        - \c [in] Device handle.
+ *                                See #amdgpu_device_initialize()
+ * \param   number_of_buffers  - \c [in] Number of BOs in the list
+ * \param   buffers            - \c [in] List of BO handles
+ * \param   result             - \c [out] Created BO list handle

amdgpu/amdgpu.h int amdgpu_bo_cpu_unmap(amdgpu_bo_handle buf_handle); · line 795

Quoted 10 lines
amdgpu/amdgpu.h +10 -0
+ *
+ * \return   0 on success\n
+ *          <0 - Negative POSIX Error code
+ *
+ * \sa amdgpu_bo_list_destroy_raw()
+*/
+int amdgpu_bo_list_create_raw(amdgpu_device_handle dev,
+                             uint32_t number_of_buffers,
+                             struct drm_amdgpu_bo_list_entry *buffers,
+                             uint32_t *result);

So AFAIU drm_amdgpu_bo_list_entry takes a raw bo handle while we never get a raw bo handle from libdrm_amdgpu. How are we supposed to fill it in?

What do we win by having the raw handle for the bo_list? If we would not return the raw handle we would not need the submit_raw2.

Quoted 195 lines
amdgpu/amdgpu.h +36 -1
+
+/**
+ * Destroys a BO list handle.
+ *
+ * \param   bo_list    - \c [in] BO list handle.
+ *
+ * \return   0 on success\n
+ *          <0 - Negative POSIX Error code
+ *
+ * \sa amdgpu_bo_list_create_raw(), amdgpu_cs_submit_raw2()
+*/
+int amdgpu_bo_list_destroy_raw(amdgpu_device_handle dev, uint32_t bo_list);
+
  /**
   * Creates a BO list handle for command submission.
   *
   * \param   dev                        - \c [in] Device handle.
   *                                See #amdgpu_device_initialize()
   * \param   number_of_resources        - \c [in] Number of BOs in the list
   * \param   resources          - \c [in] List of BO handles
   * \param   resource_prios     - \c [in] Optional priority for each handle
   * \param   result             - \c [out] Created BO list handle
   *
   * \return   0 on success\n
   *          <0 - Negative POSIX Error code
   *
- * \sa amdgpu_bo_list_destroy()
+ * \sa amdgpu_bo_list_destroy(), amdgpu_cs_submit_raw2()
  */
  int amdgpu_bo_list_create(amdgpu_device_handle dev,
                           uint32_t number_of_resources,
                           amdgpu_bo_handle *resources,
                           uint8_t *resource_prios,
                           amdgpu_bo_list_handle *result);
 
  /**
   * Destroys a BO list handle.
   *
@@ -1580,20 +1612,42 @@ struct drm_amdgpu_cs_chunk;
  struct drm_amdgpu_cs_chunk_dep;
  struct drm_amdgpu_cs_chunk_data;
 
  int amdgpu_cs_submit_raw(amdgpu_device_handle dev,
                          amdgpu_context_handle context,
                          amdgpu_bo_list_handle bo_list_handle,
                          int num_chunks,
                          struct drm_amdgpu_cs_chunk *chunks,
                          uint64_t *seq_no);
 
+/**
+ * Submit raw command submission to the kernel with a raw BO list handle.
+ *
+ * \param   dev               - \c [in] device handle
+ * \param   context    - \c [in] context handle for context id
+ * \param   bo_list_handle - \c [in] raw bo list handle (0 for none)
+ * \param   num_chunks - \c [in] number of CS chunks to submit
+ * \param   chunks     - \c [in] array of CS chunks
+ * \param   seq_no     - \c [out] output sequence number for submission.
+ *
+ * \return   0 on success\n
+ *          <0 - Negative POSIX Error code
+ *
+ * \sa amdgpu_bo_list_create_raw(), amdgpu_bo_list_destroy_raw()
+ */
+int amdgpu_cs_submit_raw2(amdgpu_device_handle dev,
+                         amdgpu_context_handle context,
+                         uint32_t bo_list_handle,
+                         int num_chunks,
+                         struct drm_amdgpu_cs_chunk *chunks,
+                         uint64_t *seq_no);
+
  void amdgpu_cs_chunk_fence_to_dep(struct amdgpu_cs_fence *fence,
                                   struct drm_amdgpu_cs_chunk_dep *dep);
  void amdgpu_cs_chunk_fence_info_to_data(struct amdgpu_cs_fence_info *fence_info,
                                         struct drm_amdgpu_cs_chunk_data *data);
 
  /**
   * Reserve VMID
   * \param   context - \c [in]  GPU Context
   * \param   flags - \c [in]  TBD
   *
amdgpu/amdgpu_bo.c +36 -0
index c0f42e81..21bc73aa 100644
@@ -611,20 +611,56 @@ drm_public int amdgpu_create_bo_from_user_mem(amdgpu_device_handle dev,
         pthread_mutex_lock(&dev->bo_table_mutex);
         r = handle_table_insert(&dev->bo_handles, (*buf_handle)->handle,
                                 *buf_handle);
         pthread_mutex_unlock(&dev->bo_table_mutex);
         if (r)
                 amdgpu_bo_free(*buf_handle);
  out:
         return r;
  }
 
+drm_public int amdgpu_bo_list_create_raw(amdgpu_device_handle dev,
+                                        uint32_t number_of_buffers,
+                                        struct drm_amdgpu_bo_list_entry *buffers,
+                                        uint32_t *result)
+{
+       union drm_amdgpu_bo_list args;
+       int r;
+
+       memset(&args, 0, sizeof(args));
+       args.in.operation = AMDGPU_BO_LIST_OP_CREATE;
+       args.in.bo_number = number_of_buffers;
+       args.in.bo_info_size = sizeof(struct drm_amdgpu_bo_list_entry);
+       args.in.bo_info_ptr = (uint64_t)(uintptr_t)buffers;
+
+       r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_BO_LIST,
+                               &args, sizeof(args));
+       if (r)
+               return r;
+
+       *result = args.out.list_handle;
+       return 0;
+}
+
+drm_public int amdgpu_bo_list_destroy_raw(amdgpu_device_handle dev,
+                                         uint32_t bo_list)
+{
+       union drm_amdgpu_bo_list args;
+
+       memset(&args, 0, sizeof(args));
+       args.in.operation = AMDGPU_BO_LIST_OP_DESTROY;
+       args.in.list_handle = bo_list;
+
+       return drmCommandWriteRead(dev->fd, DRM_AMDGPU_BO_LIST,
+                                  &args, sizeof(args));
+}
+
  drm_public int amdgpu_bo_list_create(amdgpu_device_handle dev,
                                      uint32_t number_of_resources,
                                      amdgpu_bo_handle *resources,
                                      uint8_t *resource_prios,
                                      amdgpu_bo_list_handle *result)
  {
         struct drm_amdgpu_bo_list_entry *list;
         union drm_amdgpu_bo_list args;
         unsigned i;
         int r;
amdgpu/amdgpu_cs.c +25 -1
index 3b8231aa..5bedf748 100644
@@ -724,20 +724,45 @@ drm_public int amdgpu_cs_submit_raw(amdgpu_device_handle dev,
         r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_CS,
                                 &cs, sizeof(cs));
         if (r)
                 return r;
 
         if (seq_no)
                 *seq_no = cs.out.handle;
         return 0;
  }
 
+drm_public int amdgpu_cs_submit_raw2(amdgpu_device_handle dev,
+                                    amdgpu_context_handle context,
+                                    uint32_t bo_list_handle,
+                                    int num_chunks,
+                                    struct drm_amdgpu_cs_chunk *chunks,
+                                    uint64_t *seq_no)
+{
+       union drm_amdgpu_cs cs = {0};
+       uint64_t *chunk_array;
+       int i, r;
+
+       chunk_array = alloca(sizeof(uint64_t) * num_chunks);
+       for (i = 0; i < num_chunks; i++)
+               chunk_array[i] = (uint64_t)(uintptr_t)&chunks[i];
+       cs.in.chunks = (uint64_t)(uintptr_t)chunk_array;
+       cs.in.ctx_id = context->id;
+       cs.in.bo_list_handle = bo_list_handle;
+       cs.in.num_chunks = num_chunks;
+       r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_CS,
+                               &cs, sizeof(cs));
+       if (!r && seq_no)
+               *seq_no = cs.out.handle;
+       return r;
+}
+
  drm_public void amdgpu_cs_chunk_fence_info_to_data(struct amdgpu_cs_fence_info *fence_info,
                                         struct drm_amdgpu_cs_chunk_data *data)
  {
         data->fence_data.handle = fence_info->handle->handle;
         data->fence_data.offset = fence_info->offset * sizeof(uint64_t);
  }
 
  drm_public void amdgpu_cs_chunk_fence_to_dep(struct amdgpu_cs_fence *fence,
                                         struct drm_amdgpu_cs_chunk_dep *dep)
  {
--

2.17.1

Quoted 8 lines
Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 74054b1e-5211-3bfc-ab0f-27e8604759d1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#26 lore raw
Quoted 8 lines · On Wed, Jan 16, 2019, 7:55 AM Christian König <…

Well if you ask me we should have the following interface for negotiating memory management with the kernel:

1. We have per process BOs which can't be shared between processes.

Those are always valid and don't need to be mentioned in any BO list whatsoever.

Quoted 8 lines

If we knew that a per process BO is currently not in use we can optionally tell that to the kernel to make memory management more efficient.

In other words instead of a list of stuff which is used we send down to the kernel a list of stuff which is not used any more and that only when we know that it is necessary, e.g. when a game or application overcommits.

Radeonsi doesn't use this because this approach caused performance degradation and also drops BO priorities.

Marek

Quoted 359 lines

2. We have shared BOs which are used by more than one process.

Those are rare and should be added to the per CS list of BOs in use.

The whole BO list interface Marek tries to optimize here should be deprecated and not used any more.

Regards,
Christian.

Am 16.01.19 um 13:46 schrieb Bas Nieuwenhuizen:

Quoted 90 lines

So random questions:

1) In this discussion it was mentioned that some Vulkan drivers still use the bo_list interface. I think that implies radv as I think we're still using bo_list. Is there any other API we should be using? (Also, with VK_EXT_descriptor_indexing I suspect we'll be moving more towards a global bo list instead of a cmd buffer one, as we cannot know all the BOs referenced anymore, but not sure what end state here will be).

2) The other alternative mentioned was adding the buffers directly into the submit ioctl. Is this the desired end state (though as above I'm not sure how that works for vulkan)? If yes, what is the timeline for this that we need something in the interim?

3) Did we measure any performance benefit?

In general I'd like to to ack the raw bo list creation function as this interface seems easier to use. The two arrays thing has always been kind of a pain when we want to use e.g. builtin sort functions to make sure we have no duplicate BOs, but have some comments below.

Quoted 68 lines · Marek Olšák

From: Marek Olšák <[email protected]>

---
  amdgpu/amdgpu-symbol-check |  3 ++
  amdgpu/amdgpu.h            | 56 +++++++++++++++++++++++++++++++++++++-
  amdgpu/amdgpu_bo.c         | 36 ++++++++++++++++++++++++
  amdgpu/amdgpu_cs.c         | 25 +++++++++++++++++
  4 files changed, 119 insertions(+), 1 deletion(-)
amdgpu/amdgpu-symbol-check +3 -0
index 6f5e0f95..96a44b40 100755
@@ -12,20 +12,22 @@ _edata
  _end
  _fini
  _init
  amdgpu_bo_alloc
  amdgpu_bo_cpu_map
  amdgpu_bo_cpu_unmap
  amdgpu_bo_export
  amdgpu_bo_free
  amdgpu_bo_import
  amdgpu_bo_inc_ref
+amdgpu_bo_list_create_raw
+amdgpu_bo_list_destroy_raw
  amdgpu_bo_list_create
  amdgpu_bo_list_destroy
  amdgpu_bo_list_update
  amdgpu_bo_query_info
  amdgpu_bo_set_metadata
  amdgpu_bo_va_op
  amdgpu_bo_va_op_raw
  amdgpu_bo_wait_for_idle
  amdgpu_create_bo_from_user_mem
  amdgpu_cs_chunk_fence_info_to_data
@@ -40,20 +42,21 @@ amdgpu_cs_destroy_semaphore
  amdgpu_cs_destroy_syncobj
  amdgpu_cs_export_syncobj
  amdgpu_cs_fence_to_handle
  amdgpu_cs_import_syncobj
  amdgpu_cs_query_fence_status
  amdgpu_cs_query_reset_state
  amdgpu_query_sw_info
  amdgpu_cs_signal_semaphore
  amdgpu_cs_submit
  amdgpu_cs_submit_raw
+amdgpu_cs_submit_raw2
  amdgpu_cs_syncobj_export_sync_file
  amdgpu_cs_syncobj_import_sync_file
  amdgpu_cs_syncobj_reset
  amdgpu_cs_syncobj_signal
  amdgpu_cs_syncobj_wait
  amdgpu_cs_wait_fences
  amdgpu_cs_wait_semaphore
  amdgpu_device_deinitialize
  amdgpu_device_initialize
  amdgpu_find_bo_by_cpu_mapping
amdgpu/amdgpu.h +0 -0
index dc51659a..5b800033 100644
@@ -35,20 +35,21 @@
  #define _AMDGPU_H_
 
  #include <stdint.h>
  #include <stdbool.h>
 
Quoted 8 lines

amdgpu/amdgpu.h line 50

Quoted 8 lines
amdgpu/amdgpu.h +1 -0
  #ifdef __cplusplus
  extern "C" {
  #endif
 
  struct drm_amdgpu_info_hw_ip;
+struct drm_amdgpu_bo_list_entry;
 
 

/*--------------------------------------------------------------------------*/

Quoted 1 line

amdgpu/amdgpu.h line 48

Quoted 1 line
amdgpu/amdgpu.h +0 -0
  /* --------------------------- Defines

------------------------------------ */

Quoted 1 line
Quoted 1 line

/*--------------------------------------------------------------------------*/

Quoted 3 lines
Quoted 3 lines

/**
* Define max. number of Command Buffers (IB) which could be sent to

the single

Quoted 4 lines

amdgpu/amdgpu.h int amdgpu_bo_cpu_unmap(amdgpu_bo_handle

Quoted 4 lines

* hardware IP to accommodate CE/DE requirements *
* \sa amdgpu_cs_ib_info

amdgpu/amdgpu.h +0 -0
@@ -767,34 +768,65 @@ int amdgpu_bo_cpu_unmap(amdgpu_bo_handle

buf_handle);

Quoted 35 lines
Quoted 18 lines
amdgpu/amdgpu.h +8 -0
   *                            and no GPU access is scheduled.
   *                          1 GPU access is in fly or scheduled
   *
   * \return   0 - on success
   *          <0 - Negative POSIX Error code
   */
  int amdgpu_bo_wait_for_idle(amdgpu_bo_handle buf_handle,
                             uint64_t timeout_ns,
                             bool *buffer_busy);
 
+/**
+ * Creates a BO list handle for command submission.
+ *
+ * \param   dev                        - \c [in] Device handle.
+ *                                See #amdgpu_device_initialize()
+ * \param   number_of_buffers  - \c [in] Number of BOs in the list
+ * \param   buffers            - \c [in] List of BO handles
+ * \param   result             - \c [out] Created BO list handle

amdgpu/amdgpu.h int amdgpu_bo_cpu_unmap(amdgpu_bo_handle buf_handle); · line 795

Quoted 10 lines
amdgpu/amdgpu.h +10 -0
+ *
+ * \return   0 on success\n
+ *          <0 - Negative POSIX Error code
+ *
+ * \sa amdgpu_bo_list_destroy_raw()
+*/
+int amdgpu_bo_list_create_raw(amdgpu_device_handle dev,
+                             uint32_t number_of_buffers,
+                             struct drm_amdgpu_bo_list_entry *buffers,
+                             uint32_t *result);

So AFAIU drm_amdgpu_bo_list_entry takes a raw bo handle while we never get a raw bo handle from libdrm_amdgpu. How are we supposed to fill it in?

What do we win by having the raw handle for the bo_list? If we would not return the raw handle we would not need the submit_raw2.

Quoted 12 lines

amdgpu/amdgpu.h int amdgpu_bo_cpu_unmap(amdgpu_bo_handle buf_handle);

Quoted 12 lines
amdgpu/amdgpu.h +12 -0
+
+/**
+ * Destroys a BO list handle.
+ *
+ * \param   bo_list    - \c [in] BO list handle.
+ *
+ * \return   0 on success\n
+ *          <0 - Negative POSIX Error code
+ *
+ * \sa amdgpu_bo_list_create_raw(), amdgpu_cs_submit_raw2()
+*/
+int amdgpu_bo_list_destroy_raw(amdgpu_device_handle dev, uint32_t

bo_list);

Quoted 7 lines

amdgpu/amdgpu.h int amdgpu_bo_cpu_unmap(amdgpu_bo_handle buf_handle);

Quoted 7 lines
amdgpu/amdgpu.h +1 -0
+
  /**
   * Creates a BO list handle for command submission.
   *
   * \param   dev                        - \c [in] Device handle.
   *                                See #amdgpu_device_initialize()
   * \param   number_of_resources        - \c [in] Number of BOs in the

list

Quoted 2 lines

amdgpu/amdgpu.h int amdgpu_bo_cpu_unmap(amdgpu_bo_handle · line 816

Quoted 2 lines
amdgpu/amdgpu.h +0 -0
   * \param   resources          - \c [in] List of BO handles
   * \param   resource_prios     - \c [in] Optional priority for each

handle

Quoted 28 lines
Quoted 28 lines
amdgpu/amdgpu.h +1 -1
   * \param   result             - \c [out] Created BO list handle
   *
   * \return   0 on success\n
   *          <0 - Negative POSIX Error code
   *
- * \sa amdgpu_bo_list_destroy()
+ * \sa amdgpu_bo_list_destroy(), amdgpu_cs_submit_raw2()
  */
  int amdgpu_bo_list_create(amdgpu_device_handle dev,
                           uint32_t number_of_resources,
                           amdgpu_bo_handle *resources,
                           uint8_t *resource_prios,
                           amdgpu_bo_list_handle *result);
 
  /**
   * Destroys a BO list handle.
   *
@@ -1580,20 +1612,42 @@ struct drm_amdgpu_cs_chunk;
  struct drm_amdgpu_cs_chunk_dep;
  struct drm_amdgpu_cs_chunk_data;
 
  int amdgpu_cs_submit_raw(amdgpu_device_handle dev,
                          amdgpu_context_handle context,
                          amdgpu_bo_list_handle bo_list_handle,
                          int num_chunks,
                          struct drm_amdgpu_cs_chunk *chunks,
                          uint64_t *seq_no);
 
Quoted 2 lines

amdgpu/amdgpu.h struct drm_amdgpu_cs_chunk; · line 1623

Quoted 2 lines
amdgpu/amdgpu.h +2 -0
+/**
+ * Submit raw command submission to the kernel with a raw BO list

handle.

Quoted 7 lines

amdgpu/amdgpu.h struct drm_amdgpu_cs_chunk;

Quoted 7 lines
amdgpu/amdgpu.h +7 -0
+ *
+ * \param   dev               - \c [in] device handle
+ * \param   context    - \c [in] context handle for context id
+ * \param   bo_list_handle - \c [in] raw bo list handle (0 for none)
+ * \param   num_chunks - \c [in] number of CS chunks to submit
+ * \param   chunks     - \c [in] array of CS chunks
+ * \param   seq_no     - \c [out] output sequence number for

submission.

Quoted 8 lines
Quoted 8 lines
amdgpu/amdgpu.h +8 -0
+ *
+ * \return   0 on success\n
+ *          <0 - Negative POSIX Error code
+ *
+ * \sa amdgpu_bo_list_create_raw(), amdgpu_bo_list_destroy_raw()
+ */
+int amdgpu_cs_submit_raw2(amdgpu_device_handle dev,
+                         amdgpu_context_handle context,
Quoted 8 lines

amdgpu/amdgpu.h struct drm_amdgpu_cs_chunk;

Quoted 8 lines
amdgpu/amdgpu.h +5 -0
+                         uint32_t bo_list_handle,
+                         int num_chunks,
+                         struct drm_amdgpu_cs_chunk *chunks,
+                         uint64_t *seq_no);
+
  void amdgpu_cs_chunk_fence_to_dep(struct amdgpu_cs_fence *fence,
                                   struct drm_amdgpu_cs_chunk_dep *dep);
  void amdgpu_cs_chunk_fence_info_to_data(struct amdgpu_cs_fence_info

*fence_info,

Quoted 1 line

amdgpu/amdgpu.h struct drm_amdgpu_cs_chunk; · line 1647

Quoted 1 line
amdgpu/amdgpu.h +0 -0
                                         struct

drm_amdgpu_cs_chunk_data *data);

Quoted 11 lines

amdgpu/amdgpu_bo.c drm_public int

Quoted 11 lines
amdgpu/amdgpu.h +0 -0
  /**
   * Reserve VMID
   * \param   context - \c [in]  GPU Context
   * \param   flags - \c [in]  TBD
   *
amdgpu/amdgpu_bo.c +0 -0
index c0f42e81..21bc73aa 100644
@@ -611,20 +611,56 @@ drm_public int

amdgpu_create_bo_from_user_mem(amdgpu_device_handle dev,

Quoted 2 lines

amdgpu/amdgpu_bo.c drm_public int · line 612

Quoted 2 lines
amdgpu/amdgpu_bo.c +0 -0
         pthread_mutex_lock(&dev->bo_table_mutex);
         r = handle_table_insert(&dev->bo_handles,

(*buf_handle)->handle,

Quoted 11 lines

amdgpu/amdgpu_bo.c drm_public int amdgpu_create_bo_from_user_mem(amdgpu_device_handle dev,

Quoted 11 lines
amdgpu/amdgpu_bo.c +3 -0
                                 *buf_handle);
         pthread_mutex_unlock(&dev->bo_table_mutex);
         if (r)
                 amdgpu_bo_free(*buf_handle);
  out:
         return r;
  }
 
+drm_public int amdgpu_bo_list_create_raw(amdgpu_device_handle dev,
+                                        uint32_t number_of_buffers,
+                                        struct

drm_amdgpu_bo_list_entry *buffers,

Quoted 40 lines
Quoted 40 lines
amdgpu/amdgpu_bo.c +33 -0
+                                        uint32_t *result)
+{
+       union drm_amdgpu_bo_list args;
+       int r;
+
+       memset(&args, 0, sizeof(args));
+       args.in.operation = AMDGPU_BO_LIST_OP_CREATE;
+       args.in.bo_number = number_of_buffers;
+       args.in.bo_info_size = sizeof(struct drm_amdgpu_bo_list_entry);
+       args.in.bo_info_ptr = (uint64_t)(uintptr_t)buffers;
+
+       r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_BO_LIST,
+                               &args, sizeof(args));
+       if (r)
+               return r;
+
+       *result = args.out.list_handle;
+       return 0;
+}
+
+drm_public int amdgpu_bo_list_destroy_raw(amdgpu_device_handle dev,
+                                         uint32_t bo_list)
+{
+       union drm_amdgpu_bo_list args;
+
+       memset(&args, 0, sizeof(args));
+       args.in.operation = AMDGPU_BO_LIST_OP_DESTROY;
+       args.in.list_handle = bo_list;
+
+       return drmCommandWriteRead(dev->fd, DRM_AMDGPU_BO_LIST,
+                                  &args, sizeof(args));
+}
+
  drm_public int amdgpu_bo_list_create(amdgpu_device_handle dev,
                                      uint32_t number_of_resources,
                                      amdgpu_bo_handle *resources,
                                      uint8_t *resource_prios,
                                      amdgpu_bo_list_handle *result)
  {
         struct drm_amdgpu_bo_list_entry *list;
Quoted 8 lines

amdgpu/amdgpu_cs.c drm_public int

Quoted 8 lines
amdgpu/amdgpu_bo.c +0 -0
         union drm_amdgpu_bo_list args;
         unsigned i;
         int r;
amdgpu/amdgpu_cs.c +0 -0
index 3b8231aa..5bedf748 100644
@@ -724,20 +724,45 @@ drm_public int

amdgpu_cs_submit_raw(amdgpu_device_handle dev,

Quoted 28 lines
Quoted 28 lines
amdgpu/amdgpu_cs.c +18 -0
         r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_CS,
                                 &cs, sizeof(cs));
         if (r)
                 return r;
 
         if (seq_no)
                 *seq_no = cs.out.handle;
         return 0;
  }
 
+drm_public int amdgpu_cs_submit_raw2(amdgpu_device_handle dev,
+                                    amdgpu_context_handle context,
+                                    uint32_t bo_list_handle,
+                                    int num_chunks,
+                                    struct drm_amdgpu_cs_chunk *chunks,
+                                    uint64_t *seq_no)
+{
+       union drm_amdgpu_cs cs = {0};
+       uint64_t *chunk_array;
+       int i, r;
+
+       chunk_array = alloca(sizeof(uint64_t) * num_chunks);
+       for (i = 0; i < num_chunks; i++)
+               chunk_array[i] = (uint64_t)(uintptr_t)&chunks[i];
+       cs.in.chunks = (uint64_t)(uintptr_t)chunk_array;
+       cs.in.ctx_id = context->id;
+       cs.in.bo_list_handle = bo_list_handle;
+       cs.in.num_chunks = num_chunks;
Quoted 8 lines

amdgpu/amdgpu_cs.c drm_public int amdgpu_cs_submit_raw(amdgpu_device_handle dev,

Quoted 8 lines
amdgpu/amdgpu_cs.c +7 -0
+       r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_CS,
+                               &cs, sizeof(cs));
+       if (!r && seq_no)
+               *seq_no = cs.out.handle;
+       return r;
+}
+
  drm_public void amdgpu_cs_chunk_fence_info_to_data(struct

amdgpu_cs_fence_info *fence_info,

Quoted 1 line

amdgpu/amdgpu_cs.c drm_public int · line 760

Quoted 1 line
amdgpu/amdgpu_cs.c +0 -0
                                         struct

drm_amdgpu_cs_chunk_data *data)

Quoted 3 lines

amdgpu/amdgpu_cs.c drm_public int amdgpu_cs_submit_raw(amdgpu_device_handle dev,

Quoted 3 lines
amdgpu/amdgpu_cs.c +0 -0
  {
         data->fence_data.handle = fence_info->handle->handle;
         data->fence_data.offset = fence_info->offset *
Quoted 21 lines

sizeof(uint64_t);

Quoted 3 lines

amdgpu/amdgpu_cs.c drm_public int · line 766

Quoted 3 lines
amdgpu/amdgpu_cs.c +0 -0
  }
 
  drm_public void amdgpu_cs_chunk_fence_to_dep(struct amdgpu_cs_fence

*fence,

Quoted 1 line

amdgpu/amdgpu_cs.c drm_public int · line 767

Quoted 1 line
amdgpu/amdgpu_cs.c +0 -0
                                         struct drm_amdgpu_cs_chunk_dep

*dep)

Quoted 12 lines
Quoted 8 lines
amdgpu/amdgpu_cs.c +0 -1
  {
--

2.17.1

_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): CAAxE2A5ywFkNMtPbesU_kuSwKCmsPJ0D8wRFuSp14mpORcwYhg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#28 lore raw

Am 16.01.19 um 15:31 schrieb Marek Olšák:

On Wed, Jan 16, 2019, 7:55 AM Christian König <[email protected]<mailto:[email protected]> wrote:
Well if you ask me we should have the following interface for
negotiating memory management with the kernel:

1. We have per process BOs which can't be shared between processes.

Those are always valid and don't need to be mentioned in any BO list whatsoever.

If we knew that a per process BO is currently not in use we can optionally tell that to the kernel to make memory management more efficient.

In other words instead of a list of stuff which is used we send down to the kernel a list of stuff which is not used any more and that only when we know that it is necessary, e.g. when a game or application overcommits.

Radeonsi doesn't use this because this approach caused performance degradation and also drops BO priorities.

The performance degradation where mostly shortcomings with the LRU which by now have been fixed.

BO priorities are a different topic, but could be added to per VM BOs as well.

Christian.

Marek

2. We have shared BOs which are used by more than one process.

Those are rare and should be added to the per CS list of BOs in use.

The whole BO list interface Marek tries to optimize here should be deprecated and not used any more.

Regards,
Christian.

Am 16.01.19 um 13:46 schrieb Bas Nieuwenhuizen:

Quoted 337 lines

So random questions:

1) In this discussion it was mentioned that some Vulkan drivers still use the bo_list interface. I think that implies radv as I think we're still using bo_list. Is there any other API we should be using? (Also, with VK_EXT_descriptor_indexing I suspect we'll be moving more towards a global bo list instead of a cmd buffer one, as we cannot know all the BOs referenced anymore, but not sure what end state here will be).

2) The other alternative mentioned was adding the buffers directly into the submit ioctl. Is this the desired end state (though as above I'm not sure how that works for vulkan)? If yes, what is the timeline for this that we need something in the interim?

3) Did we measure any performance benefit?

In general I'd like to to ack the raw bo list creation function as this interface seems easier to use. The two arrays thing has always been kind of a pain when we want to use e.g. builtin sort functions to make sure we have no duplicate BOs, but have some comments below.

Quoted 103 lines · On Mon, Jan 7, 2019 at 8:31 PM Marek Olšák…

From: Marek Olšák <[email protected]<mailto:[email protected]>>

---
  amdgpu/amdgpu-symbol-check |  3 ++
  amdgpu/amdgpu.h            | 56 +++++++++++++++++++++++++++++++++++++-
  amdgpu/amdgpu_bo.c         | 36 ++++++++++++++++++++++++
  amdgpu/amdgpu_cs.c         | 25 +++++++++++++++++
  4 files changed, 119 insertions(+), 1 deletion(-)
amdgpu/amdgpu-symbol-check +3 -0
index 6f5e0f95..96a44b40 100755
@@ -12,20 +12,22 @@ _edata
  _end
  _fini
  _init
  amdgpu_bo_alloc
  amdgpu_bo_cpu_map
  amdgpu_bo_cpu_unmap
  amdgpu_bo_export
  amdgpu_bo_free
  amdgpu_bo_import
  amdgpu_bo_inc_ref
+amdgpu_bo_list_create_raw
+amdgpu_bo_list_destroy_raw
  amdgpu_bo_list_create
  amdgpu_bo_list_destroy
  amdgpu_bo_list_update
  amdgpu_bo_query_info
  amdgpu_bo_set_metadata
  amdgpu_bo_va_op
  amdgpu_bo_va_op_raw
  amdgpu_bo_wait_for_idle
  amdgpu_create_bo_from_user_mem
  amdgpu_cs_chunk_fence_info_to_data
@@ -40,20 +42,21 @@ amdgpu_cs_destroy_semaphore
  amdgpu_cs_destroy_syncobj
  amdgpu_cs_export_syncobj
  amdgpu_cs_fence_to_handle
  amdgpu_cs_import_syncobj
  amdgpu_cs_query_fence_status
  amdgpu_cs_query_reset_state
  amdgpu_query_sw_info
  amdgpu_cs_signal_semaphore
  amdgpu_cs_submit
  amdgpu_cs_submit_raw
+amdgpu_cs_submit_raw2
  amdgpu_cs_syncobj_export_sync_file
  amdgpu_cs_syncobj_import_sync_file
  amdgpu_cs_syncobj_reset
  amdgpu_cs_syncobj_signal
  amdgpu_cs_syncobj_wait
  amdgpu_cs_wait_fences
  amdgpu_cs_wait_semaphore
  amdgpu_device_deinitialize
  amdgpu_device_initialize
  amdgpu_find_bo_by_cpu_mapping
amdgpu/amdgpu.h +9 -0
index dc51659a..5b800033 100644
@@ -35,20 +35,21 @@
  #define _AMDGPU_H_
 
  #include <stdint.h>
  #include <stdbool.h>
 
  #ifdef __cplusplus
  extern "C" {
  #endif
 
  struct drm_amdgpu_info_hw_ip;
+struct drm_amdgpu_bo_list_entry;
 
  /*--------------------------------------------------------------------------*/
  /* --------------------------- Defines ------------------------------------ */
  /*--------------------------------------------------------------------------*/
 
  /**
   * Define max. number of Command Buffers (IB) which could be sent to the single
   * hardware IP to accommodate CE/DE requirements
   *
   * \sa amdgpu_cs_ib_info
@@ -767,34 +768,65 @@ int amdgpu_bo_cpu_unmap(amdgpu_bo_handle buf_handle);
   *                            and no GPU access is scheduled.
   *                          1 GPU access is in fly or scheduled
   *
   * \return   0 - on success
   *          <0 - Negative POSIX Error code
   */
  int amdgpu_bo_wait_for_idle(amdgpu_bo_handle buf_handle,
                             uint64_t timeout_ns,
                             bool *buffer_busy);
 
+/**
+ * Creates a BO list handle for command submission.
+ *
+ * \param   dev                        - \c [in] Device handle.
+ *                                See #amdgpu_device_initialize()
+ * \param   number_of_buffers  - \c [in] Number of BOs in the list
+ * \param   buffers            - \c [in] List of BO handles
+ * \param   result             - \c [out] Created BO list handle

amdgpu/amdgpu.h int amdgpu_bo_cpu_unmap(amdgpu_bo_handle buf_handle); · line 795

Quoted 10 lines
amdgpu/amdgpu.h +10 -0
+ *
+ * \return   0 on success\n
+ *          <0 - Negative POSIX Error code
+ *
+ * \sa amdgpu_bo_list_destroy_raw()
+*/
+int amdgpu_bo_list_create_raw(amdgpu_device_handle dev,
+                             uint32_t number_of_buffers,
+                             struct drm_amdgpu_bo_list_entry *buffers,
+                             uint32_t *result);

So AFAIU drm_amdgpu_bo_list_entry takes a raw bo handle while we never get a raw bo handle from libdrm_amdgpu. How are we supposed to fill it in?

What do we win by having the raw handle for the bo_list? If we would not return the raw handle we would not need the submit_raw2.

Quoted 195 lines
amdgpu/amdgpu.h +36 -1
+
+/**
+ * Destroys a BO list handle.
+ *
+ * \param   bo_list    - \c [in] BO list handle.
+ *
+ * \return   0 on success\n
+ *          <0 - Negative POSIX Error code
+ *
+ * \sa amdgpu_bo_list_create_raw(), amdgpu_cs_submit_raw2()
+*/
+int amdgpu_bo_list_destroy_raw(amdgpu_device_handle dev, uint32_t bo_list);
+
  /**
   * Creates a BO list handle for command submission.
   *
   * \param   dev                        - \c [in] Device handle.
   *                                See #amdgpu_device_initialize()
   * \param   number_of_resources        - \c [in] Number of BOs in the list
   * \param   resources          - \c [in] List of BO handles
   * \param   resource_prios     - \c [in] Optional priority for each handle
   * \param   result             - \c [out] Created BO list handle
   *
   * \return   0 on success\n
   *          <0 - Negative POSIX Error code
   *
- * \sa amdgpu_bo_list_destroy()
+ * \sa amdgpu_bo_list_destroy(), amdgpu_cs_submit_raw2()
  */
  int amdgpu_bo_list_create(amdgpu_device_handle dev,
                           uint32_t number_of_resources,
                           amdgpu_bo_handle *resources,
                           uint8_t *resource_prios,
                           amdgpu_bo_list_handle *result);
 
  /**
   * Destroys a BO list handle.
   *
@@ -1580,20 +1612,42 @@ struct drm_amdgpu_cs_chunk;
  struct drm_amdgpu_cs_chunk_dep;
  struct drm_amdgpu_cs_chunk_data;
 
  int amdgpu_cs_submit_raw(amdgpu_device_handle dev,
                          amdgpu_context_handle context,
                          amdgpu_bo_list_handle bo_list_handle,
                          int num_chunks,
                          struct drm_amdgpu_cs_chunk *chunks,
                          uint64_t *seq_no);
 
+/**
+ * Submit raw command submission to the kernel with a raw BO list handle.
+ *
+ * \param   dev               - \c [in] device handle
+ * \param   context    - \c [in] context handle for context id
+ * \param   bo_list_handle - \c [in] raw bo list handle (0 for none)
+ * \param   num_chunks - \c [in] number of CS chunks to submit
+ * \param   chunks     - \c [in] array of CS chunks
+ * \param   seq_no     - \c [out] output sequence number for submission.
+ *
+ * \return   0 on success\n
+ *          <0 - Negative POSIX Error code
+ *
+ * \sa amdgpu_bo_list_create_raw(), amdgpu_bo_list_destroy_raw()
+ */
+int amdgpu_cs_submit_raw2(amdgpu_device_handle dev,
+                         amdgpu_context_handle context,
+                         uint32_t bo_list_handle,
+                         int num_chunks,
+                         struct drm_amdgpu_cs_chunk *chunks,
+                         uint64_t *seq_no);
+
  void amdgpu_cs_chunk_fence_to_dep(struct amdgpu_cs_fence *fence,
                                   struct drm_amdgpu_cs_chunk_dep *dep);
  void amdgpu_cs_chunk_fence_info_to_data(struct amdgpu_cs_fence_info *fence_info,
                                         struct drm_amdgpu_cs_chunk_data *data);
 
  /**
   * Reserve VMID
   * \param   context - \c [in]  GPU Context
   * \param   flags - \c [in]  TBD
   *
amdgpu/amdgpu_bo.c +36 -0
index c0f42e81..21bc73aa 100644
@@ -611,20 +611,56 @@ drm_public int amdgpu_create_bo_from_user_mem(amdgpu_device_handle dev,
         pthread_mutex_lock(&dev->bo_table_mutex);
         r = handle_table_insert(&dev->bo_handles, (*buf_handle)->handle,
                                 *buf_handle);
         pthread_mutex_unlock(&dev->bo_table_mutex);
         if (r)
                 amdgpu_bo_free(*buf_handle);
  out:
         return r;
  }
 
+drm_public int amdgpu_bo_list_create_raw(amdgpu_device_handle dev,
+                                        uint32_t number_of_buffers,
+                                        struct drm_amdgpu_bo_list_entry *buffers,
+                                        uint32_t *result)
+{
+       union drm_amdgpu_bo_list args;
+       int r;
+
+       memset(&args, 0, sizeof(args));
+       args.in.operation = AMDGPU_BO_LIST_OP_CREATE;
+       args.in.bo_number = number_of_buffers;
+       args.in.bo_info_size = sizeof(struct drm_amdgpu_bo_list_entry);
+       args.in.bo_info_ptr = (uint64_t)(uintptr_t)buffers;
+
+       r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_BO_LIST,
+                               &args, sizeof(args));
+       if (r)
+               return r;
+
+       *result = args.out.list_handle;
+       return 0;
+}
+
+drm_public int amdgpu_bo_list_destroy_raw(amdgpu_device_handle dev,
+                                         uint32_t bo_list)
+{
+       union drm_amdgpu_bo_list args;
+
+       memset(&args, 0, sizeof(args));
+       args.in.operation = AMDGPU_BO_LIST_OP_DESTROY;
+       args.in.list_handle = bo_list;
+
+       return drmCommandWriteRead(dev->fd, DRM_AMDGPU_BO_LIST,
+                                  &args, sizeof(args));
+}
+
  drm_public int amdgpu_bo_list_create(amdgpu_device_handle dev,
                                      uint32_t number_of_resources,
                                      amdgpu_bo_handle *resources,
                                      uint8_t *resource_prios,
                                      amdgpu_bo_list_handle *result)
  {
         struct drm_amdgpu_bo_list_entry *list;
         union drm_amdgpu_bo_list args;
         unsigned i;
         int r;
amdgpu/amdgpu_cs.c +25 -1
index 3b8231aa..5bedf748 100644
@@ -724,20 +724,45 @@ drm_public int amdgpu_cs_submit_raw(amdgpu_device_handle dev,
         r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_CS,
                                 &cs, sizeof(cs));
         if (r)
                 return r;
 
         if (seq_no)
                 *seq_no = cs.out.handle;
         return 0;
  }
 
+drm_public int amdgpu_cs_submit_raw2(amdgpu_device_handle dev,
+                                    amdgpu_context_handle context,
+                                    uint32_t bo_list_handle,
+                                    int num_chunks,
+                                    struct drm_amdgpu_cs_chunk *chunks,
+                                    uint64_t *seq_no)
+{
+       union drm_amdgpu_cs cs = {0};
+       uint64_t *chunk_array;
+       int i, r;
+
+       chunk_array = alloca(sizeof(uint64_t) * num_chunks);
+       for (i = 0; i < num_chunks; i++)
+               chunk_array[i] = (uint64_t)(uintptr_t)&chunks[i];
+       cs.in.chunks = (uint64_t)(uintptr_t)chunk_array;
+       cs.in.ctx_id = context->id;
+       cs.in.bo_list_handle = bo_list_handle;
+       cs.in.num_chunks = num_chunks;
+       r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_CS,
+                               &cs, sizeof(cs));
+       if (!r && seq_no)
+               *seq_no = cs.out.handle;
+       return r;
+}
+
  drm_public void amdgpu_cs_chunk_fence_info_to_data(struct amdgpu_cs_fence_info *fence_info,
                                         struct drm_amdgpu_cs_chunk_data *data)
  {
         data->fence_data.handle = fence_info->handle->handle;
         data->fence_data.offset = fence_info->offset * sizeof(uint64_t);
  }
 
  drm_public void amdgpu_cs_chunk_fence_to_dep(struct amdgpu_cs_fence *fence,
                                         struct drm_amdgpu_cs_chunk_dep *dep)
  {
--

2.17.1

Quoted 8 lines
Quoted 4 lines

_______________________________________________
amd-gfx mailing list [email protected]<mailto:[email protected]>
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list [email protected]<mailto:[email protected]>
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): a550562a-7d36-9acf-3143-217c507e667a-5C7GfCeVMHo@public.gmane.org

#30 lore raw
Quoted 28 lines · On Wed, Jan 16, 2019, 9:34 AM Koenig, Christian…

Am 16.01.19 um 15:31 schrieb Marek Olšák:

Quoted 8 lines · On Wed, Jan 16, 2019, 7:55 AM Christian König <…

Well if you ask me we should have the following interface for negotiating memory management with the kernel:

1. We have per process BOs which can't be shared between processes.

Those are always valid and don't need to be mentioned in any BO list whatsoever.

Quoted 8 lines

If we knew that a per process BO is currently not in use we can optionally tell that to the kernel to make memory management more efficient.

In other words instead of a list of stuff which is used we send down to the kernel a list of stuff which is not used any more and that only when we know that it is necessary, e.g. when a game or application overcommits.

Radeonsi doesn't use this because this approach caused performance degradation and also drops BO priorities.

Quoted 6 lines

The performance degradation where mostly shortcomings with the LRU which by now have been fixed.

BO priorities are a different topic, but could be added to per VM BOs as well.

What's the minimum drm version that contains the fixes?

Marek

Quoted 390 lines

Christian.

Marek

Quoted 383 lines

2. We have shared BOs which are used by more than one process.

Those are rare and should be added to the per CS list of BOs in use.

The whole BO list interface Marek tries to optimize here should be deprecated and not used any more.

Regards,
Christian.

Am 16.01.19 um 13:46 schrieb Bas Nieuwenhuizen:

Quoted 14 lines

So random questions:

1) In this discussion it was mentioned that some Vulkan drivers still use the bo_list interface. I think that implies radv as I think we're still using bo_list. Is there any other API we should be using? (Also, with VK_EXT_descriptor_indexing I suspect we'll be moving more towards a global bo list instead of a cmd buffer one, as we cannot know all the BOs referenced anymore, but not sure what end state here will be).

2) The other alternative mentioned was adding the buffers directly into the submit ioctl. Is this the desired end state (though as above I'm not sure how that works for vulkan)? If yes, what is the timeline for this that we need something in the interim?

Quoted 13 lines

3) Did we measure any performance benefit?

In general I'd like to to ack the raw bo list creation function as this interface seems easier to use. The two arrays thing has always been kind of a pain when we want to use e.g. builtin sort functions to make sure we have no duplicate BOs, but have some comments below.

Quoted 5 lines · Marek Olšák

From: Marek Olšák <[email protected]>

---
  amdgpu/amdgpu-symbol-check |  3 ++
  amdgpu/amdgpu.h            | 56

+++++++++++++++++++++++++++++++++++++-

Quoted 63 lines
Quoted 63 lines
  amdgpu/amdgpu_bo.c         | 36 ++++++++++++++++++++++++
  amdgpu/amdgpu_cs.c         | 25 +++++++++++++++++
  4 files changed, 119 insertions(+), 1 deletion(-)
amdgpu/amdgpu-symbol-check +3 -0
index 6f5e0f95..96a44b40 100755
@@ -12,20 +12,22 @@ _edata
  _end
  _fini
  _init
  amdgpu_bo_alloc
  amdgpu_bo_cpu_map
  amdgpu_bo_cpu_unmap
  amdgpu_bo_export
  amdgpu_bo_free
  amdgpu_bo_import
  amdgpu_bo_inc_ref
+amdgpu_bo_list_create_raw
+amdgpu_bo_list_destroy_raw
  amdgpu_bo_list_create
  amdgpu_bo_list_destroy
  amdgpu_bo_list_update
  amdgpu_bo_query_info
  amdgpu_bo_set_metadata
  amdgpu_bo_va_op
  amdgpu_bo_va_op_raw
  amdgpu_bo_wait_for_idle
  amdgpu_create_bo_from_user_mem
  amdgpu_cs_chunk_fence_info_to_data
@@ -40,20 +42,21 @@ amdgpu_cs_destroy_semaphore
  amdgpu_cs_destroy_syncobj
  amdgpu_cs_export_syncobj
  amdgpu_cs_fence_to_handle
  amdgpu_cs_import_syncobj
  amdgpu_cs_query_fence_status
  amdgpu_cs_query_reset_state
  amdgpu_query_sw_info
  amdgpu_cs_signal_semaphore
  amdgpu_cs_submit
  amdgpu_cs_submit_raw
+amdgpu_cs_submit_raw2
  amdgpu_cs_syncobj_export_sync_file
  amdgpu_cs_syncobj_import_sync_file
  amdgpu_cs_syncobj_reset
  amdgpu_cs_syncobj_signal
  amdgpu_cs_syncobj_wait
  amdgpu_cs_wait_fences
  amdgpu_cs_wait_semaphore
  amdgpu_device_deinitialize
  amdgpu_device_initialize
  amdgpu_find_bo_by_cpu_mapping
amdgpu/amdgpu.h +0 -0
index dc51659a..5b800033 100644
@@ -35,20 +35,21 @@
  #define _AMDGPU_H_
 
  #include <stdint.h>
  #include <stdbool.h>
 
Quoted 8 lines

amdgpu/amdgpu.h line 47

Quoted 8 lines
amdgpu/amdgpu.h +1 -0
  #ifdef __cplusplus
  extern "C" {
  #endif
 
  struct drm_amdgpu_info_hw_ip;
+struct drm_amdgpu_bo_list_entry;
 
 

/*--------------------------------------------------------------------------*/

Quoted 1 line

amdgpu/amdgpu.h line 48

Quoted 1 line
amdgpu/amdgpu.h +0 -0
  /* --------------------------- Defines

------------------------------------ */

Quoted 1 line
Quoted 1 line

/*--------------------------------------------------------------------------*/

Quoted 3 lines
Quoted 3 lines

/**
* Define max. number of Command Buffers (IB) which could be sent to

the single

Quoted 4 lines

amdgpu/amdgpu.h int amdgpu_bo_cpu_unmap(amdgpu_bo_handle

Quoted 4 lines

* hardware IP to accommodate CE/DE requirements *
* \sa amdgpu_cs_ib_info

amdgpu/amdgpu.h +0 -0
@@ -767,34 +768,65 @@ int amdgpu_bo_cpu_unmap(amdgpu_bo_handle

buf_handle);

Quoted 35 lines
Quoted 18 lines
amdgpu/amdgpu.h +8 -0
   *                            and no GPU access is scheduled.
   *                          1 GPU access is in fly or scheduled
   *
   * \return   0 - on success
   *          <0 - Negative POSIX Error code
   */
  int amdgpu_bo_wait_for_idle(amdgpu_bo_handle buf_handle,
                             uint64_t timeout_ns,
                             bool *buffer_busy);
 
+/**
+ * Creates a BO list handle for command submission.
+ *
+ * \param   dev                        - \c [in] Device handle.
+ *                                See #amdgpu_device_initialize()
+ * \param   number_of_buffers  - \c [in] Number of BOs in the list
+ * \param   buffers            - \c [in] List of BO handles
+ * \param   result             - \c [out] Created BO list handle

amdgpu/amdgpu.h int amdgpu_bo_cpu_unmap(amdgpu_bo_handle · line 795

Quoted 10 lines
amdgpu/amdgpu.h +10 -0
+ *
+ * \return   0 on success\n
+ *          <0 - Negative POSIX Error code
+ *
+ * \sa amdgpu_bo_list_destroy_raw()
+*/
+int amdgpu_bo_list_create_raw(amdgpu_device_handle dev,
+                             uint32_t number_of_buffers,
+                             struct drm_amdgpu_bo_list_entry *buffers,
+                             uint32_t *result);

So AFAIU drm_amdgpu_bo_list_entry takes a raw bo handle while we never get a raw bo handle from libdrm_amdgpu. How are we supposed to fill it in?

What do we win by having the raw handle for the bo_list? If we would not return the raw handle we would not need the submit_raw2.

Quoted 12 lines

amdgpu/amdgpu.h int amdgpu_bo_cpu_unmap(amdgpu_bo_handle · line 807

Quoted 12 lines
amdgpu/amdgpu.h +12 -0
+
+/**
+ * Destroys a BO list handle.
+ *
+ * \param   bo_list    - \c [in] BO list handle.
+ *
+ * \return   0 on success\n
+ *          <0 - Negative POSIX Error code
+ *
+ * \sa amdgpu_bo_list_create_raw(), amdgpu_cs_submit_raw2()
+*/
+int amdgpu_bo_list_destroy_raw(amdgpu_device_handle dev, uint32_t

bo_list);

Quoted 7 lines

amdgpu/amdgpu.h int amdgpu_bo_cpu_unmap(amdgpu_bo_handle · line 814

Quoted 7 lines
amdgpu/amdgpu.h +1 -0
+
  /**
   * Creates a BO list handle for command submission.
   *
   * \param   dev                        - \c [in] Device handle.
   *                                See #amdgpu_device_initialize()
   * \param   number_of_resources        - \c [in] Number of BOs in

the list

Quoted 2 lines

amdgpu/amdgpu.h int amdgpu_bo_cpu_unmap(amdgpu_bo_handle · line 816

Quoted 2 lines
amdgpu/amdgpu.h +0 -0
   * \param   resources          - \c [in] List of BO handles
   * \param   resource_prios     - \c [in] Optional priority for each

handle

Quoted 28 lines
Quoted 28 lines
amdgpu/amdgpu.h +1 -1
   * \param   result             - \c [out] Created BO list handle
   *
   * \return   0 on success\n
   *          <0 - Negative POSIX Error code
   *
- * \sa amdgpu_bo_list_destroy()
+ * \sa amdgpu_bo_list_destroy(), amdgpu_cs_submit_raw2()
  */
  int amdgpu_bo_list_create(amdgpu_device_handle dev,
                           uint32_t number_of_resources,
                           amdgpu_bo_handle *resources,
                           uint8_t *resource_prios,
                           amdgpu_bo_list_handle *result);
 
  /**
   * Destroys a BO list handle.
   *
@@ -1580,20 +1612,42 @@ struct drm_amdgpu_cs_chunk;
  struct drm_amdgpu_cs_chunk_dep;
  struct drm_amdgpu_cs_chunk_data;
 
  int amdgpu_cs_submit_raw(amdgpu_device_handle dev,
                          amdgpu_context_handle context,
                          amdgpu_bo_list_handle bo_list_handle,
                          int num_chunks,
                          struct drm_amdgpu_cs_chunk *chunks,
                          uint64_t *seq_no);
 
Quoted 2 lines

amdgpu/amdgpu.h struct drm_amdgpu_cs_chunk; · line 1623

Quoted 2 lines
amdgpu/amdgpu.h +2 -0
+/**
+ * Submit raw command submission to the kernel with a raw BO list

handle.

Quoted 7 lines

amdgpu/amdgpu.h struct drm_amdgpu_cs_chunk; · line 1630

Quoted 7 lines
amdgpu/amdgpu.h +7 -0
+ *
+ * \param   dev               - \c [in] device handle
+ * \param   context    - \c [in] context handle for context id
+ * \param   bo_list_handle - \c [in] raw bo list handle (0 for none)
+ * \param   num_chunks - \c [in] number of CS chunks to submit
+ * \param   chunks     - \c [in] array of CS chunks
+ * \param   seq_no     - \c [out] output sequence number for

submission.

Quoted 7 lines
Quoted 7 lines
amdgpu/amdgpu.h +7 -0
+ *
+ * \return   0 on success\n
+ *          <0 - Negative POSIX Error code
+ *
+ * \sa amdgpu_bo_list_create_raw(), amdgpu_bo_list_destroy_raw()
+ */
+int amdgpu_cs_submit_raw2(amdgpu_device_handle dev,
Quoted 8 lines

amdgpu/amdgpu.h struct drm_amdgpu_cs_chunk; · line 1645

Quoted 8 lines
amdgpu/amdgpu.h +6 -0
+                         amdgpu_context_handle context,
+                         uint32_t bo_list_handle,
+                         int num_chunks,
+                         struct drm_amdgpu_cs_chunk *chunks,
+                         uint64_t *seq_no);
+
  void amdgpu_cs_chunk_fence_to_dep(struct amdgpu_cs_fence *fence,
                                   struct drm_amdgpu_cs_chunk_dep

*dep);

Quoted 1 line

amdgpu/amdgpu.h struct drm_amdgpu_cs_chunk; · line 1646

Quoted 1 line
amdgpu/amdgpu.h +0 -0
  void amdgpu_cs_chunk_fence_info_to_data(struct amdgpu_cs_fence_info

*fence_info,

Quoted 1 line

amdgpu/amdgpu.h struct drm_amdgpu_cs_chunk; · line 1647

Quoted 1 line
amdgpu/amdgpu.h +0 -0
                                         struct

drm_amdgpu_cs_chunk_data *data);

Quoted 11 lines

amdgpu/amdgpu_bo.c drm_public int

Quoted 11 lines
amdgpu/amdgpu.h +0 -0
  /**
   * Reserve VMID
   * \param   context - \c [in]  GPU Context
   * \param   flags - \c [in]  TBD
   *
amdgpu/amdgpu_bo.c +0 -0
index c0f42e81..21bc73aa 100644
@@ -611,20 +611,56 @@ drm_public int

amdgpu_create_bo_from_user_mem(amdgpu_device_handle dev,

Quoted 2 lines

amdgpu/amdgpu_bo.c drm_public int · line 612

Quoted 2 lines
amdgpu/amdgpu_bo.c +0 -0
         pthread_mutex_lock(&dev->bo_table_mutex);
         r = handle_table_insert(&dev->bo_handles,

(*buf_handle)->handle,

Quoted 11 lines

amdgpu/amdgpu_bo.c drm_public int · line 623

Quoted 11 lines
amdgpu/amdgpu_bo.c +3 -0
                                 *buf_handle);
         pthread_mutex_unlock(&dev->bo_table_mutex);
         if (r)
                 amdgpu_bo_free(*buf_handle);
  out:
         return r;
  }
 
+drm_public int amdgpu_bo_list_create_raw(amdgpu_device_handle dev,
+                                        uint32_t number_of_buffers,
+                                        struct

drm_amdgpu_bo_list_entry *buffers,

Quoted 40 lines
Quoted 40 lines
amdgpu/amdgpu_bo.c +33 -0
+                                        uint32_t *result)
+{
+       union drm_amdgpu_bo_list args;
+       int r;
+
+       memset(&args, 0, sizeof(args));
+       args.in.operation = AMDGPU_BO_LIST_OP_CREATE;
+       args.in.bo_number = number_of_buffers;
+       args.in.bo_info_size = sizeof(struct drm_amdgpu_bo_list_entry);
+       args.in.bo_info_ptr = (uint64_t)(uintptr_t)buffers;
+
+       r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_BO_LIST,
+                               &args, sizeof(args));
+       if (r)
+               return r;
+
+       *result = args.out.list_handle;
+       return 0;
+}
+
+drm_public int amdgpu_bo_list_destroy_raw(amdgpu_device_handle dev,
+                                         uint32_t bo_list)
+{
+       union drm_amdgpu_bo_list args;
+
+       memset(&args, 0, sizeof(args));
+       args.in.operation = AMDGPU_BO_LIST_OP_DESTROY;
+       args.in.list_handle = bo_list;
+
+       return drmCommandWriteRead(dev->fd, DRM_AMDGPU_BO_LIST,
+                                  &args, sizeof(args));
+}
+
  drm_public int amdgpu_bo_list_create(amdgpu_device_handle dev,
                                      uint32_t number_of_resources,
                                      amdgpu_bo_handle *resources,
                                      uint8_t *resource_prios,
                                      amdgpu_bo_list_handle *result)
  {
         struct drm_amdgpu_bo_list_entry *list;
Quoted 8 lines

amdgpu/amdgpu_cs.c drm_public int

Quoted 8 lines
amdgpu/amdgpu_bo.c +0 -0
         union drm_amdgpu_bo_list args;
         unsigned i;
         int r;
amdgpu/amdgpu_cs.c +0 -0
index 3b8231aa..5bedf748 100644
@@ -724,20 +724,45 @@ drm_public int

amdgpu_cs_submit_raw(amdgpu_device_handle dev,

Quoted 10 lines
Quoted 10 lines
amdgpu/amdgpu_cs.c +0 -0
         r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_CS,
                                 &cs, sizeof(cs));
         if (r)
                 return r;
 
         if (seq_no)
                 *seq_no = cs.out.handle;
         return 0;
  }
 
Quoted 5 lines

amdgpu/amdgpu_cs.c drm_public int · line 738

Quoted 5 lines
amdgpu/amdgpu_cs.c +5 -0
+drm_public int amdgpu_cs_submit_raw2(amdgpu_device_handle dev,
+                                    amdgpu_context_handle context,
+                                    uint32_t bo_list_handle,
+                                    int num_chunks,
+                                    struct drm_amdgpu_cs_chunk

*chunks,

Quoted 13 lines
Quoted 13 lines
amdgpu/amdgpu_cs.c +13 -0
+                                    uint64_t *seq_no)
+{
+       union drm_amdgpu_cs cs = {0};
+       uint64_t *chunk_array;
+       int i, r;
+
+       chunk_array = alloca(sizeof(uint64_t) * num_chunks);
+       for (i = 0; i < num_chunks; i++)
+               chunk_array[i] = (uint64_t)(uintptr_t)&chunks[i];
+       cs.in.chunks = (uint64_t)(uintptr_t)chunk_array;
+       cs.in.ctx_id = context->id;
+       cs.in.bo_list_handle = bo_list_handle;
+       cs.in.num_chunks = num_chunks;
Quoted 8 lines

amdgpu/amdgpu_cs.c drm_public int · line 759

Quoted 8 lines
amdgpu/amdgpu_cs.c +7 -0
+       r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_CS,
+                               &cs, sizeof(cs));
+       if (!r && seq_no)
+               *seq_no = cs.out.handle;
+       return r;
+}
+
  drm_public void amdgpu_cs_chunk_fence_info_to_data(struct

amdgpu_cs_fence_info *fence_info,

Quoted 1 line

amdgpu/amdgpu_cs.c drm_public int · line 760

Quoted 1 line
amdgpu/amdgpu_cs.c +0 -0
                                         struct

drm_amdgpu_cs_chunk_data *data)

Quoted 3 lines

amdgpu/amdgpu_cs.c drm_public int · line 763

Quoted 3 lines
amdgpu/amdgpu_cs.c +0 -0
  {
         data->fence_data.handle = fence_info->handle->handle;
         data->fence_data.offset = fence_info->offset *

sizeof(uint64_t);

Quoted 3 lines

amdgpu/amdgpu_cs.c drm_public int · line 766

Quoted 3 lines
amdgpu/amdgpu_cs.c +0 -0
  }
 
  drm_public void amdgpu_cs_chunk_fence_to_dep(struct amdgpu_cs_fence

*fence,

Quoted 1 line

amdgpu/amdgpu_cs.c drm_public int · line 767

Quoted 1 line
amdgpu/amdgpu_cs.c +0 -0
                                         struct

drm_amdgpu_cs_chunk_dep *dep)

Quoted 12 lines
Quoted 8 lines
amdgpu/amdgpu_cs.c +0 -1
  {
--

2.17.1

_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): CAAxE2A4k8JtkrS2XfgRdmYY3NVR4ges=Yqfh-TH9O=LnaVv02g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#32 lore raw

Am 16.01.19 um 15:39 schrieb Marek Olšák:

Quoted 36 lines · On Wed, Jan 16, 2019, 9:34 AM Koenig, Christian…
    Am 16.01.19 um 15:31 schrieb Marek Olšák:
Quoted 28 lines

On Wed, Jan 16, 2019, 7:55 AM Christian König <[email protected] <mailto:[email protected]> wrote:

Well if you ask me we should have the following interface for negotiating memory management with the kernel:

1. We have per process BOs which can't be shared between processes.

Those are always valid and don't need to be mentioned in any BO list
whatsoever.

If we knew that a per process BO is currently not in use we can optionally tell that to the kernel to make memory management more efficient.

In other words instead of a list of stuff which is used we send down to
the kernel a list of stuff which is not used any more and that only when
we know that it is necessary, e.g. when a game or application overcommits.

Quoted 2 lines

Radeonsi doesn't use this because this approach caused performance degradation and also drops BO priorities.

Quoted 8 lines

The performance degradation where mostly shortcomings with the LRU which by now have been fixed.

BO priorities are a different topic, but could be added to per VM BOs as well.

What's the minimum drm version that contains the fixes?

I've pushed the last optimization this morning. No idea when it really became useful, but the numbers from the closed source clients now look much better.

We should probably test and bump the drm version when we are sure that this now works as expected.

Christian.

Quoted 430 lines

Marek

Christian.

Quoted 413 lines
    Marek


        2. We have shared BOs which are used by more than one process.

        Those are rare and should be added to the per CS list of BOs
        in use.


        The whole BO list interface Marek tries to optimize here
        should be
        deprecated and not used any more.

        Regards,
        Christian.

        Am 16.01.19 um 13:46 schrieb Bas Nieuwenhuizen:
        > So random questions:
        >
        > 1) In this discussion it was mentioned that some Vulkan
        drivers still
        > use the bo_list interface. I think that implies radv as I
        think we're
        > still using bo_list. Is there any other API we should be
        using? (Also,
        > with VK_EXT_descriptor_indexing I suspect we'll be moving
        more towards
        > a global bo list instead of a cmd buffer one, as we cannot
        know all
        > the BOs referenced anymore, but not sure what end state
        here will be).
        >
        > 2) The other alternative mentioned was adding the buffers
        directly
        > into the submit ioctl. Is this the desired end state
        (though as above
        > I'm not sure how that works for vulkan)? If yes, what is
        the timeline
        > for this that we need something in the interim?
        >
        > 3) Did we measure any performance benefit?
        >
        > In general I'd like to to ack the raw bo list creation
        function as
        > this interface seems easier to use. The two arrays thing
        has always
        > been kind of a pain when we want to use e.g. builtin sort
        functions to
        > make sure we have no duplicate BOs, but have some comments
        below.
        >
        > On Mon, Jan 7, 2019 at 8:31 PM Marek Olšák
        <[email protected] <mailto:[email protected]>> wrote:
        >> From: Marek Olšák <[email protected]
        <mailto:[email protected]>>
        >>
        >> ---
        >>   amdgpu/amdgpu-symbol-check |  3 ++
        >>   amdgpu/amdgpu.h            | 56
        +++++++++++++++++++++++++++++++++++++-
        >>   amdgpu/amdgpu_bo.c         | 36 ++++++++++++++++++++++++
        >>   amdgpu/amdgpu_cs.c         | 25 +++++++++++++++++
        >>   4 files changed, 119 insertions(+), 1 deletion(-)
        >>
        >> diff --git a/amdgpu/amdgpu-symbol-check
        b/amdgpu/amdgpu-symbol-check
        >> index 6f5e0f95..96a44b40 100755
        >> --- a/amdgpu/amdgpu-symbol-check
        >> +++ b/amdgpu/amdgpu-symbol-check
        >> @@ -12,20 +12,22 @@ _edata
        >>   _end
        >>   _fini
        >>   _init
        >>   amdgpu_bo_alloc
        >>   amdgpu_bo_cpu_map
        >>   amdgpu_bo_cpu_unmap
        >>   amdgpu_bo_export
        >>   amdgpu_bo_free
        >>   amdgpu_bo_import
        >>   amdgpu_bo_inc_ref
        >> +amdgpu_bo_list_create_raw
        >> +amdgpu_bo_list_destroy_raw
        >>   amdgpu_bo_list_create
        >>   amdgpu_bo_list_destroy
        >>   amdgpu_bo_list_update
        >>   amdgpu_bo_query_info
        >>   amdgpu_bo_set_metadata
        >>   amdgpu_bo_va_op
        >>   amdgpu_bo_va_op_raw
        >>   amdgpu_bo_wait_for_idle
        >>   amdgpu_create_bo_from_user_mem
        >>   amdgpu_cs_chunk_fence_info_to_data
        >> @@ -40,20 +42,21 @@ amdgpu_cs_destroy_semaphore
        >>   amdgpu_cs_destroy_syncobj
        >>   amdgpu_cs_export_syncobj
        >>   amdgpu_cs_fence_to_handle
        >>   amdgpu_cs_import_syncobj
        >>   amdgpu_cs_query_fence_status
        >>   amdgpu_cs_query_reset_state
        >>   amdgpu_query_sw_info
        >>   amdgpu_cs_signal_semaphore
        >>   amdgpu_cs_submit
        >>   amdgpu_cs_submit_raw
        >> +amdgpu_cs_submit_raw2
        >>   amdgpu_cs_syncobj_export_sync_file
        >>   amdgpu_cs_syncobj_import_sync_file
        >>   amdgpu_cs_syncobj_reset
        >>   amdgpu_cs_syncobj_signal
        >>   amdgpu_cs_syncobj_wait
        >>   amdgpu_cs_wait_fences
        >>   amdgpu_cs_wait_semaphore
        >>   amdgpu_device_deinitialize
        >>   amdgpu_device_initialize
        >>   amdgpu_find_bo_by_cpu_mapping
        >> diff --git a/amdgpu/amdgpu.h b/amdgpu/amdgpu.h
        >> index dc51659a..5b800033 100644
        >> --- a/amdgpu/amdgpu.h
        >> +++ b/amdgpu/amdgpu.h
        >> @@ -35,20 +35,21 @@
        >>   #define _AMDGPU_H_
        >>
        >>   #include <stdint.h>
        >>   #include <stdbool.h>
        >>
        >>   #ifdef __cplusplus
        >>   extern "C" {
        >>   #endif
        >>
        >>   struct drm_amdgpu_info_hw_ip;
        >> +struct drm_amdgpu_bo_list_entry;
        >>
        >>
         /*--------------------------------------------------------------------------*/
        >>   /* --------------------------- Defines
        ------------------------------------ */
        >>
         /*--------------------------------------------------------------------------*/
        >>
        >>   /**
        >>    * Define max. number of Command Buffers (IB) which
        could be sent to the single
        >>    * hardware IP to accommodate CE/DE requirements
        >>    *
        >>    * \sa amdgpu_cs_ib_info
        >> @@ -767,34 +768,65 @@ int
        amdgpu_bo_cpu_unmap(amdgpu_bo_handle buf_handle);
        >>    *                            and no GPU access is
        scheduled.
        >>    *                          1 GPU access is in fly or
        scheduled
        >>    *
        >>    * \return   0 - on success
        >>    *          <0 - Negative POSIX Error code
        >>    */
        >>   int amdgpu_bo_wait_for_idle(amdgpu_bo_handle buf_handle,
        >>                              uint64_t timeout_ns,
        >>                              bool *buffer_busy);
        >>
        >> +/**
        >> + * Creates a BO list handle for command submission.
        >> + *
        >> + * \param   dev   - \c [in] Device handle.
        >> + * See #amdgpu_device_initialize()
        >> + * \param   number_of_buffers  - \c [in] Number of BOs in
        the list
        >> + * \param   buffers            - \c [in] List of BO handles
        >> + * \param   result             - \c [out] Created BO list
        handle
        >> + *
        >> + * \return   0 on success\n
        >> + *          <0 - Negative POSIX Error code
        >> + *
        >> + * \sa amdgpu_bo_list_destroy_raw()
        >> +*/
        >> +int amdgpu_bo_list_create_raw(amdgpu_device_handle dev,
        >> +  uint32_t number_of_buffers,
        >> +                             struct
        drm_amdgpu_bo_list_entry *buffers,
        >> +  uint32_t *result);
        > So AFAIU  drm_amdgpu_bo_list_entry takes a raw bo handle
        while we
        > never get a raw bo handle from libdrm_amdgpu. How are we
        supposed to
        > fill it in?
        >
        > What do we win by having the raw handle for the bo_list? If
        we would
        > not return the raw handle we would not need the submit_raw2.
        >
        >> +
        >> +/**
        >> + * Destroys a BO list handle.
        >> + *
        >> + * \param   bo_list    - \c [in] BO list handle.
        >> + *
        >> + * \return   0 on success\n
        >> + *          <0 - Negative POSIX Error code
        >> + *
        >> + * \sa amdgpu_bo_list_create_raw(), amdgpu_cs_submit_raw2()
        >> +*/
        >> +int amdgpu_bo_list_destroy_raw(amdgpu_device_handle dev,
        uint32_t bo_list);
        >> +
        >>   /**
        >>    * Creates a BO list handle for command submission.
        >>    *
        >>    * \param   dev     - \c [in] Device handle.
        >>    * See #amdgpu_device_initialize()
        >>    * \param   number_of_resources     - \c [in] Number of
        BOs in the list
        >>    * \param   resources          - \c [in] List of BO handles
        >>    * \param   resource_prios     - \c [in] Optional
        priority for each handle
        >>    * \param   result             - \c [out] Created BO
        list handle
        >>    *
        >>    * \return   0 on success\n
        >>    *          <0 - Negative POSIX Error code
        >>    *
        >> - * \sa amdgpu_bo_list_destroy()
        >> + * \sa amdgpu_bo_list_destroy(), amdgpu_cs_submit_raw2()
        >>   */
        >>   int amdgpu_bo_list_create(amdgpu_device_handle dev,
        >>                            uint32_t number_of_resources,
        >> amdgpu_bo_handle *resources,
        >>                            uint8_t *resource_prios,
        >> amdgpu_bo_list_handle *result);
        >>
        >>   /**
        >>    * Destroys a BO list handle.
        >>    *
        >> @@ -1580,20 +1612,42 @@ struct drm_amdgpu_cs_chunk;
        >>   struct drm_amdgpu_cs_chunk_dep;
        >>   struct drm_amdgpu_cs_chunk_data;
        >>
        >>   int amdgpu_cs_submit_raw(amdgpu_device_handle dev,
        >>  amdgpu_context_handle context,
        >>  amdgpu_bo_list_handle bo_list_handle,
        >>                           int num_chunks,
        >>                           struct drm_amdgpu_cs_chunk *chunks,
        >>                           uint64_t *seq_no);
        >>
        >> +/**
        >> + * Submit raw command submission to the kernel with a raw
        BO list handle.
        >> + *
        >> + * \param   dev               - \c [in] device handle
        >> + * \param   context    - \c [in] context handle for
        context id
        >> + * \param   bo_list_handle - \c [in] raw bo list handle
        (0 for none)
        >> + * \param   num_chunks - \c [in] number of CS chunks to
        submit
        >> + * \param   chunks     - \c [in] array of CS chunks
        >> + * \param   seq_no     - \c [out] output sequence number
        for submission.
        >> + *
        >> + * \return   0 on success\n
        >> + *          <0 - Negative POSIX Error code
        >> + *
        >> + * \sa amdgpu_bo_list_create_raw(),
        amdgpu_bo_list_destroy_raw()
        >> + */
        >> +int amdgpu_cs_submit_raw2(amdgpu_device_handle dev,
        >> +  amdgpu_context_handle context,
        >> +                         uint32_t bo_list_handle,
        >> +                         int num_chunks,
        >> +                         struct drm_amdgpu_cs_chunk *chunks,
        >> +                         uint64_t *seq_no);
        >> +
        >>   void amdgpu_cs_chunk_fence_to_dep(struct amdgpu_cs_fence
        *fence,
        >> struct drm_amdgpu_cs_chunk_dep *dep);
        >>   void amdgpu_cs_chunk_fence_info_to_data(struct
        amdgpu_cs_fence_info *fence_info,
        >>     struct drm_amdgpu_cs_chunk_data *data);
        >>
        >>   /**
        >>    * Reserve VMID
        >>    * \param   context - \c [in]  GPU Context
        >>    * \param   flags - \c [in]  TBD
        >>    *
        >> diff --git a/amdgpu/amdgpu_bo.c b/amdgpu/amdgpu_bo.c
        >> index c0f42e81..21bc73aa 100644
        >> --- a/amdgpu/amdgpu_bo.c
        >> +++ b/amdgpu/amdgpu_bo.c
        >> @@ -611,20 +611,56 @@ drm_public int
        amdgpu_create_bo_from_user_mem(amdgpu_device_handle dev,
        >> pthread_mutex_lock(&dev->bo_table_mutex);
        >>          r = handle_table_insert(&dev->bo_handles,
        (*buf_handle)->handle,
        >> *buf_handle);
        >> pthread_mutex_unlock(&dev->bo_table_mutex);
        >>          if (r)
        >> amdgpu_bo_free(*buf_handle);
        >>   out:
        >>          return r;
        >>   }
        >>
        >> +drm_public int
        amdgpu_bo_list_create_raw(amdgpu_device_handle dev,
        >> +     uint32_t number_of_buffers,
        >> +     struct drm_amdgpu_bo_list_entry *buffers,
        >> +     uint32_t *result)
        >> +{
        >> +       union drm_amdgpu_bo_list args;
        >> +       int r;
        >> +
        >> +       memset(&args, 0, sizeof(args));
        >> +       args.in.operation = AMDGPU_BO_LIST_OP_CREATE;
        >> +       args.in.bo_number = number_of_buffers;
        >> +       args.in.bo_info_size = sizeof(struct
        drm_amdgpu_bo_list_entry);
        >> +       args.in.bo_info_ptr = (uint64_t)(uintptr_t)buffers;
        >> +
        >> +       r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_BO_LIST,
        >> +  &args, sizeof(args));
        >> +       if (r)
        >> +               return r;
        >> +
        >> +       *result = args.out.list_handle;
        >> +       return 0;
        >> +}
        >> +
        >> +drm_public int
        amdgpu_bo_list_destroy_raw(amdgpu_device_handle dev,
        >> +      uint32_t bo_list)
        >> +{
        >> +       union drm_amdgpu_bo_list args;
        >> +
        >> +       memset(&args, 0, sizeof(args));
        >> +       args.in.operation = AMDGPU_BO_LIST_OP_DESTROY;
        >> +       args.in.list_handle = bo_list;
        >> +
        >> +       return drmCommandWriteRead(dev->fd,
        DRM_AMDGPU_BO_LIST,
        >> + &args, sizeof(args));
        >> +}
        >> +
        >>   drm_public int
        amdgpu_bo_list_create(amdgpu_device_handle dev,
        >>  uint32_t number_of_resources,
        >>  amdgpu_bo_handle *resources,
        >>  uint8_t *resource_prios,
        >>  amdgpu_bo_list_handle *result)
        >>   {
        >>          struct drm_amdgpu_bo_list_entry *list;
        >>          union drm_amdgpu_bo_list args;
        >>          unsigned i;
        >>          int r;
        >> diff --git a/amdgpu/amdgpu_cs.c b/amdgpu/amdgpu_cs.c
        >> index 3b8231aa..5bedf748 100644
        >> --- a/amdgpu/amdgpu_cs.c
        >> +++ b/amdgpu/amdgpu_cs.c
        >> @@ -724,20 +724,45 @@ drm_public int
        amdgpu_cs_submit_raw(amdgpu_device_handle dev,
        >>          r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_CS,
        >> &cs, sizeof(cs));
        >>          if (r)
        >>                  return r;
        >>
        >>          if (seq_no)
        >>                  *seq_no = cs.out.handle;
        >>          return 0;
        >>   }
        >>
        >> +drm_public int amdgpu_cs_submit_raw2(amdgpu_device_handle
        dev,
        >> + amdgpu_context_handle context,
        >> + uint32_t bo_list_handle,
        >> + int num_chunks,
        >> + struct drm_amdgpu_cs_chunk *chunks,
        >> + uint64_t *seq_no)
        >> +{
        >> +       union drm_amdgpu_cs cs = {0};
        >> +       uint64_t *chunk_array;
        >> +       int i, r;
        >> +
        >> +       chunk_array = alloca(sizeof(uint64_t) * num_chunks);
        >> +       for (i = 0; i < num_chunks; i++)
        >> +               chunk_array[i] =
        (uint64_t)(uintptr_t)&chunks[i];
        >> +       cs.in.chunks = (uint64_t)(uintptr_t)chunk_array;
        >> +       cs.in.ctx_id = context->id;
        >> +       cs.in.bo_list_handle = bo_list_handle;
        >> +       cs.in.num_chunks = num_chunks;
        >> +       r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_CS,
        >> +  &cs, sizeof(cs));
        >> +       if (!r && seq_no)
        >> +               *seq_no = cs.out.handle;
        >> +       return r;
        >> +}
        >> +
        >>   drm_public void
        amdgpu_cs_chunk_fence_info_to_data(struct
        amdgpu_cs_fence_info *fence_info,
        >>     struct drm_amdgpu_cs_chunk_data *data)
        >>   {
        >>          data->fence_data.handle = fence_info->handle->handle;
        >>          data->fence_data.offset = fence_info->offset *
        sizeof(uint64_t);
        >>   }
        >>
        >>   drm_public void amdgpu_cs_chunk_fence_to_dep(struct
        amdgpu_cs_fence *fence,
        >>     struct drm_amdgpu_cs_chunk_dep *dep)
        >>   {
        >> --
        >> 2.17.1
        >>
        >> _______________________________________________
        >> amd-gfx mailing list
Quoted 9 lines
        >> [email protected]
        <mailto:[email protected]>
        >> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
        > _______________________________________________
        > amd-gfx mailing list
        > [email protected]
        <mailto:[email protected]>
        > https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 4 lines

_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 3d525127-825b-efab-b0c8-76550634d1c1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#34 lore raw
Quoted 46 lines · Christian König

Am 16.01.19 um 15:39 schrieb Marek Olšák:

Quoted 29 lines · On Wed, Jan 16, 2019, 9:34 AM Koenig, Christian…

Am 16.01.19 um 15:31 schrieb Marek Olšák:

Quoted 8 lines · On Wed, Jan 16, 2019, 7:55 AM Christian König <…

Well if you ask me we should have the following interface for negotiating memory management with the kernel:

1. We have per process BOs which can't be shared between processes.

Those are always valid and don't need to be mentioned in any BO list whatsoever.

Quoted 9 lines

If we knew that a per process BO is currently not in use we can optionally tell that to the kernel to make memory management more efficient.

In other words instead of a list of stuff which is used we send down to the kernel a list of stuff which is not used any more and that only when we know that it is necessary, e.g. when a game or application overcommits.

Radeonsi doesn't use this because this approach caused performance degradation and also drops BO priorities.

Quoted 6 lines

The performance degradation where mostly shortcomings with the LRU which by now have been fixed.

BO priorities are a different topic, but could be added to per VM BOs as well.

What's the minimum drm version that contains the fixes?

Quoted 7 lines

I've pushed the last optimization this morning. No idea when it really became useful, but the numbers from the closed source clients now look much better.

We should probably test and bump the drm version when we are sure that this now works as expected.

We should, but AMD Mesa guys don't have any time.

Marek

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): CAAxE2A77=9-qpfUmt-PQf5=Gx72SLZ5QvNaSYLJ9D6o0fiEz4Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#36 lore raw

FYI, I've pushed the patch because it helps simplify our the amdgpu winsys code and I already have code that depends on it that I don't wanna rewrite.

Marek

Quoted 54 lines · Marek Olšák
Quoted 51 lines · Christian König

Am 16.01.19 um 15:39 schrieb Marek Olšák:

Quoted 30 lines · On Wed, Jan 16, 2019, 9:34 AM Koenig, Christian…

Am 16.01.19 um 15:31 schrieb Marek Olšák:

Quoted 12 lines · On Wed, Jan 16, 2019, 7:55 AM Christian König <…

Well if you ask me we should have the following interface for negotiating memory management with the kernel:

1. We have per process BOs which can't be shared between processes.

Those are always valid and don't need to be mentioned in any BO list whatsoever.

If we knew that a per process BO is currently not in use we can optionally tell that to the kernel to make memory management more efficient.

Quoted 6 lines

In other words instead of a list of stuff which is used we send down to the kernel a list of stuff which is not used any more and that only when
we know that it is necessary, e.g. when a game or application overcommits.

Radeonsi doesn't use this because this approach caused performance degradation and also drops BO priorities.

Quoted 6 lines

The performance degradation where mostly shortcomings with the LRU which by now have been fixed.

BO priorities are a different topic, but could be added to per VM BOs as well.

What's the minimum drm version that contains the fixes?

I've pushed the last optimization this morning. No idea when it really became useful, but the numbers from the closed source clients now look much better.

Quoted 8 lines
Quoted 3 lines

We should probably test and bump the drm version when we are sure that this now works as expected.

We should, but AMD Mesa guys don't have any time.

Marek

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#37 lore raw
In reply to a message not in the archive
Quoted 9 lines · On Wed, Jan 16, 2019, 7:46 AM Bas Nieuwenhuizen…

So random questions:

1) In this discussion it was mentioned that some Vulkan drivers still use the bo_list interface. I think that implies radv as I think we're still using bo_list. Is there any other API we should be using? (Also, with VK_EXT_descriptor_indexing I suspect we'll be moving more towards a global bo list instead of a cmd buffer one, as we cannot know all the BOs referenced anymore, but not sure what end state here will be).

Quoted 5 lines

2) The other alternative mentioned was adding the buffers directly into the submit ioctl. Is this the desired end state (though as above I'm not sure how that works for vulkan)? If yes, what is the timeline for this that we need something in the interim?

Radeonsi already uses this.

Quoted 7 lines

3) Did we measure any performance benefit?

In general I'd like to to ack the raw bo list creation function as this interface seems easier to use. The two arrays thing has always been kind of a pain when we want to use e.g. builtin sort functions to make sure we have no duplicate BOs, but have some comments below.

The reason amdgpu was slower than radeon was because of this inefficient bo list interface.

Quoted 116 lines · Marek Olšák
Quoted 67 lines

From: Marek Olšák <[email protected]>

---
 amdgpu/amdgpu-symbol-check |  3 ++
 amdgpu/amdgpu.h            | 56 +++++++++++++++++++++++++++++++++++++-
 amdgpu/amdgpu_bo.c         | 36 ++++++++++++++++++++++++
 amdgpu/amdgpu_cs.c         | 25 +++++++++++++++++
 4 files changed, 119 insertions(+), 1 deletion(-)
amdgpu/amdgpu-symbol-check +3 -0
index 6f5e0f95..96a44b40 100755
@@ -12,20 +12,22 @@ _edata
 _end
 _fini
 _init
 amdgpu_bo_alloc
 amdgpu_bo_cpu_map
 amdgpu_bo_cpu_unmap
 amdgpu_bo_export
 amdgpu_bo_free
 amdgpu_bo_import
 amdgpu_bo_inc_ref
+amdgpu_bo_list_create_raw
+amdgpu_bo_list_destroy_raw
 amdgpu_bo_list_create
 amdgpu_bo_list_destroy
 amdgpu_bo_list_update
 amdgpu_bo_query_info
 amdgpu_bo_set_metadata
 amdgpu_bo_va_op
 amdgpu_bo_va_op_raw
 amdgpu_bo_wait_for_idle
 amdgpu_create_bo_from_user_mem
 amdgpu_cs_chunk_fence_info_to_data
@@ -40,20 +42,21 @@ amdgpu_cs_destroy_semaphore
 amdgpu_cs_destroy_syncobj
 amdgpu_cs_export_syncobj
 amdgpu_cs_fence_to_handle
 amdgpu_cs_import_syncobj
 amdgpu_cs_query_fence_status
 amdgpu_cs_query_reset_state
 amdgpu_query_sw_info
 amdgpu_cs_signal_semaphore
 amdgpu_cs_submit
 amdgpu_cs_submit_raw
+amdgpu_cs_submit_raw2
 amdgpu_cs_syncobj_export_sync_file
 amdgpu_cs_syncobj_import_sync_file
 amdgpu_cs_syncobj_reset
 amdgpu_cs_syncobj_signal
 amdgpu_cs_syncobj_wait
 amdgpu_cs_wait_fences
 amdgpu_cs_wait_semaphore
 amdgpu_device_deinitialize
 amdgpu_device_initialize
 amdgpu_find_bo_by_cpu_mapping
amdgpu/amdgpu.h +0 -0
index dc51659a..5b800033 100644
@@ -35,20 +35,21 @@
 #define _AMDGPU_H_
 
 #include <stdint.h>

amdgpu/amdgpu.h line 47

Quoted 10 lines
amdgpu/amdgpu.h +1 -0
 #include <stdbool.h>
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
 struct drm_amdgpu_info_hw_ip;
+struct drm_amdgpu_bo_list_entry;
 
 

/*--------------------------------------------------------------------------*/

amdgpu/amdgpu.h line 48

Quoted 1 line
amdgpu/amdgpu.h +0 -0
 /* --------------------------- Defines

------------------------------------ */

Quoted 1 line

/*--------------------------------------------------------------------------*/

Quoted 3 lines

/**
* Define max. number of Command Buffers (IB) which could be sent to

the single

amdgpu/amdgpu.h int amdgpu_bo_cpu_unmap(amdgpu_bo_handle

Quoted 4 lines

* hardware IP to accommodate CE/DE requirements
*
* \sa amdgpu_cs_ib_info

amdgpu/amdgpu.h +0 -0
@@ -767,34 +768,65 @@ int amdgpu_bo_cpu_unmap(amdgpu_bo_handle

buf_handle);

Quoted 24 lines
amdgpu/amdgpu.h +14 -0
  *                            and no GPU access is scheduled.
  *                          1 GPU access is in fly or scheduled
  *
  * \return   0 - on success
  *          <0 - Negative POSIX Error code
  */
 int amdgpu_bo_wait_for_idle(amdgpu_bo_handle buf_handle,
                            uint64_t timeout_ns,
                            bool *buffer_busy);
 
+/**
+ * Creates a BO list handle for command submission.
+ *
+ * \param   dev                        - \c [in] Device handle.
+ *                                See #amdgpu_device_initialize()
+ * \param   number_of_buffers  - \c [in] Number of BOs in the list
+ * \param   buffers            - \c [in] List of BO handles
+ * \param   result             - \c [out] Created BO list handle
+ *
+ * \return   0 on success\n
+ *          <0 - Negative POSIX Error code
+ *
+ * \sa amdgpu_bo_list_destroy_raw()
+*/
Quoted 9 lines

amdgpu/amdgpu.h int amdgpu_bo_cpu_unmap(amdgpu_bo_handle buf_handle); · line 795

Quoted 4 lines
amdgpu/amdgpu.h +4 -0
+int amdgpu_bo_list_create_raw(amdgpu_device_handle dev,
+                             uint32_t number_of_buffers,
+                             struct drm_amdgpu_bo_list_entry *buffers,
+                             uint32_t *result);

So AFAIU drm_amdgpu_bo_list_entry takes a raw bo handle while we never get a raw bo handle from libdrm_amdgpu. How are we supposed to fill it in?

This function returns it.

Quoted 3 lines

What do we win by having the raw handle for the bo_list? If we would not return the raw handle we would not need the submit_raw2.

One less malloc call and pointer indirection.

Marek

Quoted 200 lines

amdgpu/amdgpu.h int amdgpu_bo_cpu_unmap(amdgpu_bo_handle buf_handle);

Quoted 12 lines
amdgpu/amdgpu.h +12 -0
+
+/**
+ * Destroys a BO list handle.
+ *
+ * \param   bo_list    - \c [in] BO list handle.
+ *
+ * \return   0 on success\n
+ *          <0 - Negative POSIX Error code
+ *
+ * \sa amdgpu_bo_list_create_raw(), amdgpu_cs_submit_raw2()
+*/
+int amdgpu_bo_list_destroy_raw(amdgpu_device_handle dev, uint32_t

bo_list);

amdgpu/amdgpu.h int amdgpu_bo_cpu_unmap(amdgpu_bo_handle buf_handle);

Quoted 7 lines
amdgpu/amdgpu.h +1 -0
+
 /**
  * Creates a BO list handle for command submission.
  *
  * \param   dev                        - \c [in] Device handle.
  *                                See #amdgpu_device_initialize()
  * \param   number_of_resources        - \c [in] Number of BOs in the

list

amdgpu/amdgpu.h int amdgpu_bo_cpu_unmap(amdgpu_bo_handle · line 816

Quoted 2 lines
amdgpu/amdgpu.h +0 -0
  * \param   resources          - \c [in] List of BO handles
  * \param   resource_prios     - \c [in] Optional priority for each

handle

Quoted 20 lines
amdgpu/amdgpu.h +1 -1
  * \param   result             - \c [out] Created BO list handle
  *
  * \return   0 on success\n
  *          <0 - Negative POSIX Error code
  *
- * \sa amdgpu_bo_list_destroy()
+ * \sa amdgpu_bo_list_destroy(), amdgpu_cs_submit_raw2()
 */
 int amdgpu_bo_list_create(amdgpu_device_handle dev,
                          uint32_t number_of_resources,
                          amdgpu_bo_handle *resources,
                          uint8_t *resource_prios,
                          amdgpu_bo_list_handle *result);
 
 /**
  * Destroys a BO list handle.
  *
@@ -1580,20 +1612,42 @@ struct drm_amdgpu_cs_chunk;
 struct drm_amdgpu_cs_chunk_dep;
 struct drm_amdgpu_cs_chunk_data;

amdgpu/amdgpu.h struct drm_amdgpu_cs_chunk; · line 1623

Quoted 10 lines
amdgpu/amdgpu.h +2 -0
 
 int amdgpu_cs_submit_raw(amdgpu_device_handle dev,
                         amdgpu_context_handle context,
                         amdgpu_bo_list_handle bo_list_handle,
                         int num_chunks,
                         struct drm_amdgpu_cs_chunk *chunks,
                         uint64_t *seq_no);
 
+/**
+ * Submit raw command submission to the kernel with a raw BO list

handle.

Quoted 13 lines
amdgpu/amdgpu.h +13 -0
+ *
+ * \param   dev               - \c [in] device handle
+ * \param   context    - \c [in] context handle for context id
+ * \param   bo_list_handle - \c [in] raw bo list handle (0 for none)
+ * \param   num_chunks - \c [in] number of CS chunks to submit
+ * \param   chunks     - \c [in] array of CS chunks
+ * \param   seq_no     - \c [out] output sequence number for submission.
+ *
+ * \return   0 on success\n
+ *          <0 - Negative POSIX Error code
+ *
+ * \sa amdgpu_bo_list_create_raw(), amdgpu_bo_list_destroy_raw()
+ */

amdgpu/amdgpu.h struct drm_amdgpu_cs_chunk;

Quoted 10 lines
amdgpu/amdgpu.h +7 -0
+int amdgpu_cs_submit_raw2(amdgpu_device_handle dev,
+                         amdgpu_context_handle context,
+                         uint32_t bo_list_handle,
+                         int num_chunks,
+                         struct drm_amdgpu_cs_chunk *chunks,
+                         uint64_t *seq_no);
+
 void amdgpu_cs_chunk_fence_to_dep(struct amdgpu_cs_fence *fence,
                                  struct drm_amdgpu_cs_chunk_dep *dep);
 void amdgpu_cs_chunk_fence_info_to_data(struct amdgpu_cs_fence_info

*fence_info,

amdgpu/amdgpu.h struct drm_amdgpu_cs_chunk; · line 1647

Quoted 1 line
amdgpu/amdgpu.h +0 -0
                                        struct drm_amdgpu_cs_chunk_data

*data);

amdgpu/amdgpu_bo.c drm_public int

Quoted 11 lines
amdgpu/amdgpu.h +0 -0
 /**
  * Reserve VMID
  * \param   context - \c [in]  GPU Context
  * \param   flags - \c [in]  TBD
  *
amdgpu/amdgpu_bo.c +0 -0
index c0f42e81..21bc73aa 100644
@@ -611,20 +611,56 @@ drm_public int

amdgpu_create_bo_from_user_mem(amdgpu_device_handle dev,

amdgpu/amdgpu_bo.c drm_public int amdgpu_create_bo_from_user_mem(amdgpu_device_handle dev,

Quoted 13 lines
amdgpu/amdgpu_bo.c +3 -0
        pthread_mutex_lock(&dev->bo_table_mutex);
        r = handle_table_insert(&dev->bo_handles, (*buf_handle)->handle,
                                *buf_handle);
        pthread_mutex_unlock(&dev->bo_table_mutex);
        if (r)
                amdgpu_bo_free(*buf_handle);
 out:
        return r;
 }
 
+drm_public int amdgpu_bo_list_create_raw(amdgpu_device_handle dev,
+                                        uint32_t number_of_buffers,
+                                        struct drm_amdgpu_bo_list_entry

*buffers,

amdgpu/amdgpu_cs.c drm_public int

Quoted 48 lines
amdgpu/amdgpu_bo.c +33 -0
+                                        uint32_t *result)
+{
+       union drm_amdgpu_bo_list args;
+       int r;
+
+       memset(&args, 0, sizeof(args));
+       args.in.operation = AMDGPU_BO_LIST_OP_CREATE;
+       args.in.bo_number = number_of_buffers;
+       args.in.bo_info_size = sizeof(struct drm_amdgpu_bo_list_entry);
+       args.in.bo_info_ptr = (uint64_t)(uintptr_t)buffers;
+
+       r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_BO_LIST,
+                               &args, sizeof(args));
+       if (r)
+               return r;
+
+       *result = args.out.list_handle;
+       return 0;
+}
+
+drm_public int amdgpu_bo_list_destroy_raw(amdgpu_device_handle dev,
+                                         uint32_t bo_list)
+{
+       union drm_amdgpu_bo_list args;
+
+       memset(&args, 0, sizeof(args));
+       args.in.operation = AMDGPU_BO_LIST_OP_DESTROY;
+       args.in.list_handle = bo_list;
+
+       return drmCommandWriteRead(dev->fd, DRM_AMDGPU_BO_LIST,
+                                  &args, sizeof(args));
+}
+
 drm_public int amdgpu_bo_list_create(amdgpu_device_handle dev,
                                     uint32_t number_of_resources,
                                     amdgpu_bo_handle *resources,
                                     uint8_t *resource_prios,
                                     amdgpu_bo_list_handle *result)
 {
        struct drm_amdgpu_bo_list_entry *list;
        union drm_amdgpu_bo_list args;
        unsigned i;
        int r;
amdgpu/amdgpu_cs.c +0 -0
index 3b8231aa..5bedf748 100644
@@ -724,20 +724,45 @@ drm_public int

amdgpu_cs_submit_raw(amdgpu_device_handle dev,

Quoted 26 lines
amdgpu/amdgpu_cs.c +16 -0
        r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_CS,
                                &cs, sizeof(cs));
        if (r)
                return r;
 
        if (seq_no)
                *seq_no = cs.out.handle;
        return 0;
 }
 
+drm_public int amdgpu_cs_submit_raw2(amdgpu_device_handle dev,
+                                    amdgpu_context_handle context,
+                                    uint32_t bo_list_handle,
+                                    int num_chunks,
+                                    struct drm_amdgpu_cs_chunk *chunks,
+                                    uint64_t *seq_no)
+{
+       union drm_amdgpu_cs cs = {0};
+       uint64_t *chunk_array;
+       int i, r;
+
+       chunk_array = alloca(sizeof(uint64_t) * num_chunks);
+       for (i = 0; i < num_chunks; i++)
+               chunk_array[i] = (uint64_t)(uintptr_t)&chunks[i];
+       cs.in.chunks = (uint64_t)(uintptr_t)chunk_array;
+       cs.in.ctx_id = context->id;

amdgpu/amdgpu_cs.c drm_public int amdgpu_cs_submit_raw(amdgpu_device_handle dev,

Quoted 10 lines
amdgpu/amdgpu_cs.c +9 -0
+       cs.in.bo_list_handle = bo_list_handle;
+       cs.in.num_chunks = num_chunks;
+       r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_CS,
+                               &cs, sizeof(cs));
+       if (!r && seq_no)
+               *seq_no = cs.out.handle;
+       return r;
+}
+
 drm_public void amdgpu_cs_chunk_fence_info_to_data(struct

amdgpu_cs_fence_info *fence_info,

amdgpu/amdgpu_cs.c drm_public int · line 760

Quoted 1 line
amdgpu/amdgpu_cs.c +0 -0
                                        struct drm_amdgpu_cs_chunk_data

*data)

Quoted 5 lines
amdgpu/amdgpu_cs.c +0 -0
 {
        data->fence_data.handle = fence_info->handle->handle;
        data->fence_data.offset = fence_info->offset * sizeof(uint64_t);
 }
 
Quoted 13 lines

amdgpu/amdgpu_cs.c drm_public int · line 766

Quoted 1 line
amdgpu/amdgpu_cs.c +0 -0
 drm_public void amdgpu_cs_chunk_fence_to_dep(struct amdgpu_cs_fence

*fence,

amdgpu/amdgpu_cs.c drm_public int · line 767

Quoted 1 line
amdgpu/amdgpu_cs.c +0 -0
                                        struct drm_amdgpu_cs_chunk_dep

*dep)

Quoted 8 lines
amdgpu/amdgpu_cs.c +0 -1
 {
--

2.17.1

_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): CAAxE2A5chwbGmQN2yqVCfvF=TPvFMN6Qu-iFUuRW-zBVm=AN9w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#39 lore raw
Quoted 155 lines · Marek Olšák
Quoted 10 lines · On Wed, Jan 16, 2019, 7:46 AM Bas Nieuwenhuizen <[email protected] wrote:

So random questions:

1) In this discussion it was mentioned that some Vulkan drivers still use the bo_list interface. I think that implies radv as I think we're still using bo_list. Is there any other API we should be using? (Also, with VK_EXT_descriptor_indexing I suspect we'll be moving more towards a global bo list instead of a cmd buffer one, as we cannot know all the BOs referenced anymore, but not sure what end state here will be).

Quoted 4 lines

2) The other alternative mentioned was adding the buffers directly into the submit ioctl. Is this the desired end state (though as above I'm not sure how that works for vulkan)? If yes, what is the timeline for this that we need something in the interim?

Radeonsi already uses this.

Quoted 7 lines

3) Did we measure any performance benefit?

In general I'd like to to ack the raw bo list creation function as this interface seems easier to use. The two arrays thing has always been kind of a pain when we want to use e.g. builtin sort functions to make sure we have no duplicate BOs, but have some comments below.

The reason amdgpu was slower than radeon was because of this inefficient bo list interface.

Quoted 112 lines · Marek Olšák
Quoted 110 lines

From: Marek Olšák <[email protected]>

---
 amdgpu/amdgpu-symbol-check |  3 ++
 amdgpu/amdgpu.h            | 56 +++++++++++++++++++++++++++++++++++++-
 amdgpu/amdgpu_bo.c         | 36 ++++++++++++++++++++++++
 amdgpu/amdgpu_cs.c         | 25 +++++++++++++++++
 4 files changed, 119 insertions(+), 1 deletion(-)
amdgpu/amdgpu-symbol-check +3 -0
index 6f5e0f95..96a44b40 100755
@@ -12,20 +12,22 @@ _edata
 _end
 _fini
 _init
 amdgpu_bo_alloc
 amdgpu_bo_cpu_map
 amdgpu_bo_cpu_unmap
 amdgpu_bo_export
 amdgpu_bo_free
 amdgpu_bo_import
 amdgpu_bo_inc_ref
+amdgpu_bo_list_create_raw
+amdgpu_bo_list_destroy_raw
 amdgpu_bo_list_create
 amdgpu_bo_list_destroy
 amdgpu_bo_list_update
 amdgpu_bo_query_info
 amdgpu_bo_set_metadata
 amdgpu_bo_va_op
 amdgpu_bo_va_op_raw
 amdgpu_bo_wait_for_idle
 amdgpu_create_bo_from_user_mem
 amdgpu_cs_chunk_fence_info_to_data
@@ -40,20 +42,21 @@ amdgpu_cs_destroy_semaphore
 amdgpu_cs_destroy_syncobj
 amdgpu_cs_export_syncobj
 amdgpu_cs_fence_to_handle
 amdgpu_cs_import_syncobj
 amdgpu_cs_query_fence_status
 amdgpu_cs_query_reset_state
 amdgpu_query_sw_info
 amdgpu_cs_signal_semaphore
 amdgpu_cs_submit
 amdgpu_cs_submit_raw
+amdgpu_cs_submit_raw2
 amdgpu_cs_syncobj_export_sync_file
 amdgpu_cs_syncobj_import_sync_file
 amdgpu_cs_syncobj_reset
 amdgpu_cs_syncobj_signal
 amdgpu_cs_syncobj_wait
 amdgpu_cs_wait_fences
 amdgpu_cs_wait_semaphore
 amdgpu_device_deinitialize
 amdgpu_device_initialize
 amdgpu_find_bo_by_cpu_mapping
amdgpu/amdgpu.h +15 -0
index dc51659a..5b800033 100644
@@ -35,20 +35,21 @@
 #define _AMDGPU_H_
 
 #include <stdint.h>
 #include <stdbool.h>
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
 struct drm_amdgpu_info_hw_ip;
+struct drm_amdgpu_bo_list_entry;
 
 /*--------------------------------------------------------------------------*/
 /* --------------------------- Defines ------------------------------------ */
 /*--------------------------------------------------------------------------*/
 
 /**
  * Define max. number of Command Buffers (IB) which could be sent to the single
  * hardware IP to accommodate CE/DE requirements
  *
  * \sa amdgpu_cs_ib_info
@@ -767,34 +768,65 @@ int amdgpu_bo_cpu_unmap(amdgpu_bo_handle buf_handle);
  *                            and no GPU access is scheduled.
  *                          1 GPU access is in fly or scheduled
  *
  * \return   0 - on success
  *          <0 - Negative POSIX Error code
  */
 int amdgpu_bo_wait_for_idle(amdgpu_bo_handle buf_handle,
                            uint64_t timeout_ns,
                            bool *buffer_busy);
 
+/**
+ * Creates a BO list handle for command submission.
+ *
+ * \param   dev                        - \c [in] Device handle.
+ *                                See #amdgpu_device_initialize()
+ * \param   number_of_buffers  - \c [in] Number of BOs in the list
+ * \param   buffers            - \c [in] List of BO handles
+ * \param   result             - \c [out] Created BO list handle
+ *
+ * \return   0 on success\n
+ *          <0 - Negative POSIX Error code
+ *
+ * \sa amdgpu_bo_list_destroy_raw()
+*/
Quoted 8 lines

amdgpu/amdgpu.h int amdgpu_bo_cpu_unmap(amdgpu_bo_handle buf_handle); · line 795

Quoted 4 lines
amdgpu/amdgpu.h +4 -0
+int amdgpu_bo_list_create_raw(amdgpu_device_handle dev,
+                             uint32_t number_of_buffers,
+                             struct drm_amdgpu_bo_list_entry *buffers,
+                             uint32_t *result);

So AFAIU drm_amdgpu_bo_list_entry takes a raw bo handle while we never get a raw bo handle from libdrm_amdgpu. How are we supposed to fill it in?

Quoted 1 line

This function returns it.

This function returns a bo_list handle right? I'm talking about the BO handles in buffers, where do we get them?

Quoted 206 lines
Quoted 4 lines

What do we win by having the raw handle for the bo_list? If we would not return the raw handle we would not need the submit_raw2.

One less malloc call and pointer indirection.

Marek

Quoted 196 lines
Quoted 196 lines
amdgpu/amdgpu.h +36 -1
+
+/**
+ * Destroys a BO list handle.
+ *
+ * \param   bo_list    - \c [in] BO list handle.
+ *
+ * \return   0 on success\n
+ *          <0 - Negative POSIX Error code
+ *
+ * \sa amdgpu_bo_list_create_raw(), amdgpu_cs_submit_raw2()
+*/
+int amdgpu_bo_list_destroy_raw(amdgpu_device_handle dev, uint32_t bo_list);
+
 /**
  * Creates a BO list handle for command submission.
  *
  * \param   dev                        - \c [in] Device handle.
  *                                See #amdgpu_device_initialize()
  * \param   number_of_resources        - \c [in] Number of BOs in the list
  * \param   resources          - \c [in] List of BO handles
  * \param   resource_prios     - \c [in] Optional priority for each handle
  * \param   result             - \c [out] Created BO list handle
  *
  * \return   0 on success\n
  *          <0 - Negative POSIX Error code
  *
- * \sa amdgpu_bo_list_destroy()
+ * \sa amdgpu_bo_list_destroy(), amdgpu_cs_submit_raw2()
 */
 int amdgpu_bo_list_create(amdgpu_device_handle dev,
                          uint32_t number_of_resources,
                          amdgpu_bo_handle *resources,
                          uint8_t *resource_prios,
                          amdgpu_bo_list_handle *result);
 
 /**
  * Destroys a BO list handle.
  *
@@ -1580,20 +1612,42 @@ struct drm_amdgpu_cs_chunk;
 struct drm_amdgpu_cs_chunk_dep;
 struct drm_amdgpu_cs_chunk_data;
 
 int amdgpu_cs_submit_raw(amdgpu_device_handle dev,
                         amdgpu_context_handle context,
                         amdgpu_bo_list_handle bo_list_handle,
                         int num_chunks,
                         struct drm_amdgpu_cs_chunk *chunks,
                         uint64_t *seq_no);
 
+/**
+ * Submit raw command submission to the kernel with a raw BO list handle.
+ *
+ * \param   dev               - \c [in] device handle
+ * \param   context    - \c [in] context handle for context id
+ * \param   bo_list_handle - \c [in] raw bo list handle (0 for none)
+ * \param   num_chunks - \c [in] number of CS chunks to submit
+ * \param   chunks     - \c [in] array of CS chunks
+ * \param   seq_no     - \c [out] output sequence number for submission.
+ *
+ * \return   0 on success\n
+ *          <0 - Negative POSIX Error code
+ *
+ * \sa amdgpu_bo_list_create_raw(), amdgpu_bo_list_destroy_raw()
+ */
+int amdgpu_cs_submit_raw2(amdgpu_device_handle dev,
+                         amdgpu_context_handle context,
+                         uint32_t bo_list_handle,
+                         int num_chunks,
+                         struct drm_amdgpu_cs_chunk *chunks,
+                         uint64_t *seq_no);
+
 void amdgpu_cs_chunk_fence_to_dep(struct amdgpu_cs_fence *fence,
                                  struct drm_amdgpu_cs_chunk_dep *dep);
 void amdgpu_cs_chunk_fence_info_to_data(struct amdgpu_cs_fence_info *fence_info,
                                        struct drm_amdgpu_cs_chunk_data *data);
 
 /**
  * Reserve VMID
  * \param   context - \c [in]  GPU Context
  * \param   flags - \c [in]  TBD
  *
amdgpu/amdgpu_bo.c +36 -0
index c0f42e81..21bc73aa 100644
@@ -611,20 +611,56 @@ drm_public int amdgpu_create_bo_from_user_mem(amdgpu_device_handle dev,
        pthread_mutex_lock(&dev->bo_table_mutex);
        r = handle_table_insert(&dev->bo_handles, (*buf_handle)->handle,
                                *buf_handle);
        pthread_mutex_unlock(&dev->bo_table_mutex);
        if (r)
                amdgpu_bo_free(*buf_handle);
 out:
        return r;
 }
 
+drm_public int amdgpu_bo_list_create_raw(amdgpu_device_handle dev,
+                                        uint32_t number_of_buffers,
+                                        struct drm_amdgpu_bo_list_entry *buffers,
+                                        uint32_t *result)
+{
+       union drm_amdgpu_bo_list args;
+       int r;
+
+       memset(&args, 0, sizeof(args));
+       args.in.operation = AMDGPU_BO_LIST_OP_CREATE;
+       args.in.bo_number = number_of_buffers;
+       args.in.bo_info_size = sizeof(struct drm_amdgpu_bo_list_entry);
+       args.in.bo_info_ptr = (uint64_t)(uintptr_t)buffers;
+
+       r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_BO_LIST,
+                               &args, sizeof(args));
+       if (r)
+               return r;
+
+       *result = args.out.list_handle;
+       return 0;
+}
+
+drm_public int amdgpu_bo_list_destroy_raw(amdgpu_device_handle dev,
+                                         uint32_t bo_list)
+{
+       union drm_amdgpu_bo_list args;
+
+       memset(&args, 0, sizeof(args));
+       args.in.operation = AMDGPU_BO_LIST_OP_DESTROY;
+       args.in.list_handle = bo_list;
+
+       return drmCommandWriteRead(dev->fd, DRM_AMDGPU_BO_LIST,
+                                  &args, sizeof(args));
+}
+
 drm_public int amdgpu_bo_list_create(amdgpu_device_handle dev,
                                     uint32_t number_of_resources,
                                     amdgpu_bo_handle *resources,
                                     uint8_t *resource_prios,
                                     amdgpu_bo_list_handle *result)
 {
        struct drm_amdgpu_bo_list_entry *list;
        union drm_amdgpu_bo_list args;
        unsigned i;
        int r;
amdgpu/amdgpu_cs.c +25 -1
index 3b8231aa..5bedf748 100644
@@ -724,20 +724,45 @@ drm_public int amdgpu_cs_submit_raw(amdgpu_device_handle dev,
        r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_CS,
                                &cs, sizeof(cs));
        if (r)
                return r;
 
        if (seq_no)
                *seq_no = cs.out.handle;
        return 0;
 }
 
+drm_public int amdgpu_cs_submit_raw2(amdgpu_device_handle dev,
+                                    amdgpu_context_handle context,
+                                    uint32_t bo_list_handle,
+                                    int num_chunks,
+                                    struct drm_amdgpu_cs_chunk *chunks,
+                                    uint64_t *seq_no)
+{
+       union drm_amdgpu_cs cs = {0};
+       uint64_t *chunk_array;
+       int i, r;
+
+       chunk_array = alloca(sizeof(uint64_t) * num_chunks);
+       for (i = 0; i < num_chunks; i++)
+               chunk_array[i] = (uint64_t)(uintptr_t)&chunks[i];
+       cs.in.chunks = (uint64_t)(uintptr_t)chunk_array;
+       cs.in.ctx_id = context->id;
+       cs.in.bo_list_handle = bo_list_handle;
+       cs.in.num_chunks = num_chunks;
+       r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_CS,
+                               &cs, sizeof(cs));
+       if (!r && seq_no)
+               *seq_no = cs.out.handle;
+       return r;
+}
+
 drm_public void amdgpu_cs_chunk_fence_info_to_data(struct amdgpu_cs_fence_info *fence_info,
                                        struct drm_amdgpu_cs_chunk_data *data)
 {
        data->fence_data.handle = fence_info->handle->handle;
        data->fence_data.offset = fence_info->offset * sizeof(uint64_t);
 }
 
 drm_public void amdgpu_cs_chunk_fence_to_dep(struct amdgpu_cs_fence *fence,
                                        struct drm_amdgpu_cs_chunk_dep *dep)
 {
--

2.17.1

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): CAP+8YyFhXpM8eHEjWwy+yAs4s7A7FyrkYO8=FA0tf6M6n-ka+g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#41 lore raw
Quoted 165 lines · Bas Nieuwenhuizen
Quoted 4 lines · Marek Olšák

On Wed, Jan 16, 2019, 7:46 AM Bas Nieuwenhuizen <[email protected]

Quoted 21 lines · wrote:
Quoted 10 lines

So random questions:

1) In this discussion it was mentioned that some Vulkan drivers still use the bo_list interface. I think that implies radv as I think we're still using bo_list. Is there any other API we should be using? (Also, with VK_EXT_descriptor_indexing I suspect we'll be moving more towards a global bo list instead of a cmd buffer one, as we cannot know all the BOs referenced anymore, but not sure what end state here will be).

Quoted 4 lines

2) The other alternative mentioned was adding the buffers directly into the submit ioctl. Is this the desired end state (though as above I'm not sure how that works for vulkan)? If yes, what is the timeline for this that we need something in the interim?

Radeonsi already uses this.

Quoted 3 lines

3) Did we measure any performance benefit?

Quoted 7 lines
Quoted 4 lines

In general I'd like to to ack the raw bo list creation function as this interface seems easier to use. The two arrays thing has always been kind of a pain when we want to use e.g. builtin sort functions to make sure we have no duplicate BOs, but have some comments below.

The reason amdgpu was slower than radeon was because of this inefficient

bo list interface.

Quoted 9 lines
Quoted 9 lines · Marek Olšák
Quoted 6 lines

From: Marek Olšák <[email protected]>

---
 amdgpu/amdgpu-symbol-check |  3 ++
 amdgpu/amdgpu.h            | 56

+++++++++++++++++++++++++++++++++++++-

Quoted 63 lines
Quoted 63 lines
Quoted 63 lines
 amdgpu/amdgpu_bo.c         | 36 ++++++++++++++++++++++++
 amdgpu/amdgpu_cs.c         | 25 +++++++++++++++++
 4 files changed, 119 insertions(+), 1 deletion(-)
amdgpu/amdgpu-symbol-check +3 -0
index 6f5e0f95..96a44b40 100755
@@ -12,20 +12,22 @@ _edata
 _end
 _fini
 _init
 amdgpu_bo_alloc
 amdgpu_bo_cpu_map
 amdgpu_bo_cpu_unmap
 amdgpu_bo_export
 amdgpu_bo_free
 amdgpu_bo_import
 amdgpu_bo_inc_ref
+amdgpu_bo_list_create_raw
+amdgpu_bo_list_destroy_raw
 amdgpu_bo_list_create
 amdgpu_bo_list_destroy
 amdgpu_bo_list_update
 amdgpu_bo_query_info
 amdgpu_bo_set_metadata
 amdgpu_bo_va_op
 amdgpu_bo_va_op_raw
 amdgpu_bo_wait_for_idle
 amdgpu_create_bo_from_user_mem
 amdgpu_cs_chunk_fence_info_to_data
@@ -40,20 +42,21 @@ amdgpu_cs_destroy_semaphore
 amdgpu_cs_destroy_syncobj
 amdgpu_cs_export_syncobj
 amdgpu_cs_fence_to_handle
 amdgpu_cs_import_syncobj
 amdgpu_cs_query_fence_status
 amdgpu_cs_query_reset_state
 amdgpu_query_sw_info
 amdgpu_cs_signal_semaphore
 amdgpu_cs_submit
 amdgpu_cs_submit_raw
+amdgpu_cs_submit_raw2
 amdgpu_cs_syncobj_export_sync_file
 amdgpu_cs_syncobj_import_sync_file
 amdgpu_cs_syncobj_reset
 amdgpu_cs_syncobj_signal
 amdgpu_cs_syncobj_wait
 amdgpu_cs_wait_fences
 amdgpu_cs_wait_semaphore
 amdgpu_device_deinitialize
 amdgpu_device_initialize
 amdgpu_find_bo_by_cpu_mapping
amdgpu/amdgpu.h +0 -0
index dc51659a..5b800033 100644
@@ -35,20 +35,21 @@
 #define _AMDGPU_H_
 
 #include <stdint.h>
 #include <stdbool.h>
 
Quoted 8 lines
Quoted 8 lines

amdgpu/amdgpu.h line 47

Quoted 8 lines
amdgpu/amdgpu.h +1 -0
 #ifdef __cplusplus
 extern "C" {
 #endif
 
 struct drm_amdgpu_info_hw_ip;
+struct drm_amdgpu_bo_list_entry;
 
 

/*--------------------------------------------------------------------------*/

Quoted 1 line
Quoted 1 line

amdgpu/amdgpu.h line 48

Quoted 1 line
amdgpu/amdgpu.h +0 -0
 /* --------------------------- Defines

------------------------------------ */

Quoted 1 line
Quoted 1 line
Quoted 1 line

/*--------------------------------------------------------------------------*/

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

/**
* Define max. number of Command Buffers (IB) which could be sent to

the single

Quoted 4 lines
Quoted 4 lines

amdgpu/amdgpu.h int amdgpu_bo_cpu_unmap(amdgpu_bo_handle

Quoted 4 lines

* hardware IP to accommodate CE/DE requirements
*
* \sa amdgpu_cs_ib_info

amdgpu/amdgpu.h +0 -0
@@ -767,34 +768,65 @@ int amdgpu_bo_cpu_unmap(amdgpu_bo_handle

buf_handle);

Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
amdgpu/amdgpu.h +9 -0
  *                            and no GPU access is scheduled.
  *                          1 GPU access is in fly or scheduled
  *
  * \return   0 - on success
  *          <0 - Negative POSIX Error code
  */
 int amdgpu_bo_wait_for_idle(amdgpu_bo_handle buf_handle,
                            uint64_t timeout_ns,
                            bool *buffer_busy);
 
+/**
+ * Creates a BO list handle for command submission.
+ *
+ * \param   dev                        - \c [in] Device handle.
+ *                                See #amdgpu_device_initialize()
+ * \param   number_of_buffers  - \c [in] Number of BOs in the list
+ * \param   buffers            - \c [in] List of BO handles
+ * \param   result             - \c [out] Created BO list handle
+ *
Quoted 8 lines
Quoted 8 lines

amdgpu/amdgpu.h int amdgpu_bo_cpu_unmap(amdgpu_bo_handle · line 794

Quoted 8 lines
amdgpu/amdgpu.h +8 -0
+ * \return   0 on success\n
+ *          <0 - Negative POSIX Error code
+ *
+ * \sa amdgpu_bo_list_destroy_raw()
+*/
+int amdgpu_bo_list_create_raw(amdgpu_device_handle dev,
+                             uint32_t number_of_buffers,
+                             struct drm_amdgpu_bo_list_entry

*buffers,

Quoted 7 lines
Quoted 5 lines

amdgpu/amdgpu.h int amdgpu_bo_cpu_unmap(amdgpu_bo_handle · line 795

Quoted 1 line
amdgpu/amdgpu.h +1 -0
+                             uint32_t *result);

So AFAIU drm_amdgpu_bo_list_entry takes a raw bo handle while we never get a raw bo handle from libdrm_amdgpu. How are we supposed to fill it in?

Quoted 5 lines
Quoted 1 line

This function returns it.

This function returns a bo_list handle right? I'm talking about the BO handles in buffers, where do we get them?

Query KMS handles using the export function.

Marek

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx