libdrm amdgpu patches
cover libdrm amdgpu patches
Hi,
These are libdrm_amdgpu patches harvested from an internal branch.
The first patch is a revert I had to make to fix the build. Yeah, sequence_mutex should be renamed to a more appropriate name. That can be done as a follow-up.
One notable change is the addition of DRM_IOCTL_AMDGPU_WAIT_FENCES. I hope the kernel contains (or will contain) the changes too, so that I don't push something that doesn't exist in the kernel.
Please let me know if these are okay to push.
Thanks,
Chunming Zhou (3):
amdgpu: add semaphore support
tests/amdgpu: add semaphore test
amdgpu: validate user memory for userptr
Junwei Zhang (3):
amdgpu: add the interface of waiting multiple fences amdgpu/tests: add multi-fence test in base test
amdgpu: list each entry safely for sw semaphore when submit ib
Marek Olšák (1):
Revert "amdgpu: remove sequence mutex"
Michel Dänzer (1):
amdgpu: Cast pointer to uintptr_t for assignment to unsigned integer
monk.liu (2):
amdgpu: drop address patching logics
amdgpu: cs_wait_fences now can return the first signaled fence index
amdgpu/amdgpu.h | 88 +++++++++++++++++++++++++++++++++++++++++ amdgpu/amdgpu_bo.c | 14 ++----- amdgpu/amdgpu_cs.c | 253 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- amdgpu/amdgpu_internal.h | 15 +++++++ include/drm/amdgpu_drm.h | 28 +++++++++++++ tests/amdgpu/basic_tests.c | 233 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 616 insertions(+), 15 deletions(-)
Marek
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 1/10 Revert "amdgpu: remove sequence mutex"
From: Marek Olšák <[email protected]>
This reverts commit f6f25d67a9c0d26be9b8021a45f2acf3a4042ade.
Required by the new semaphore patches.
--- amdgpu/amdgpu_cs.c | 10 ++++++++++ amdgpu/amdgpu_internal.h | 3 +++ 2 files changed, 13 insertions(+)
amdgpu/amdgpu_cs.c +10 -0
@@ -66,6 +66,10 @@ int amdgpu_cs_ctx_create(amdgpu_device_handle dev, gpu_context->dev = dev; + r =pthread_mutex_init (&gpu_context->sequence_mutex,NULL ); +if (r) + goto error; +/* Create the context */ memset (&args,0 ,sizeof (args)); args.in.op =AMDGPU_CTX_OP_ALLOC_CTX ;
@@ -79,6 +83,7 @@ int amdgpu_cs_ctx_create(amdgpu_device_handle dev,return 0 ; error: +pthread_mutex_destroy (&gpu_context->sequence_mutex);free (gpu_context);return r; }
@@ -99,6 +104,8 @@ int amdgpu_cs_ctx_free(amdgpu_context_handle context)if (NULL == context)return -EINVAL ; +pthread_mutex_destroy (&context->sequence_mutex); +/* now deal with kernel side */ memset (&args,0 ,sizeof (args)); args.in.op =AMDGPU_CTX_OP_FREE_CTX ;
@@ -196,6 +203,8 @@ static int amdgpu_cs_submit_one(amdgpu_context_handle context, chunk_data[i].ib_data.flags = ib->flags; } +pthread_mutex_lock (&context->sequence_mutex); +if (user_fence) { i = cs.in.num_chunks++;
@@ -248,6 +257,7 @@ static int amdgpu_cs_submit_one(amdgpu_context_handle context, ibs_request->seq_no = cs.out.handle; error_unlock: +pthread_mutex_unlock (&context->sequence_mutex);free (dependencies);return r; }
amdgpu/amdgpu_internal.h +3 -0
@@ -111,6 +111,9 @@ struct amdgpu_bo_list {struct amdgpu_context {struct amdgpu_device *dev; +/** Mutex for accessing fences and to maintain command submissions +in good sequence. */ +pthread_mutex_t sequence_mutex;/* context id*/ uint32_t id; };
Signature · 6 lines
2.1.4 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 2/10 amdgpu: add the interface of waiting multiple fences
In reply to Marek OlšákFrom: Junwei Zhang <[email protected]>
--- amdgpu/amdgpu.h | 22 +++++++++++++++ amdgpu/amdgpu_cs.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++ include/drm/amdgpu_drm.h | 27 ++++++++++++++++++ 3 files changed, 120 insertions(+)
amdgpu/amdgpu.h +22 -0
@@ -902,6 +902,28 @@ int amdgpu_cs_query_fence_status(struct amdgpu_cs_fence *fence,uint64_t flags, uint32_t *expired); +/** +* Wait for multiple fences +* +* \param fences - \c [in] The fence array to wait +* \param fence_count - \c [in] The fence count +* \param wait_all - \c [in] If true, wait all fences to be signaled, +* otherwise, wait at least one fence +* \param timeout_ns - \c [in] The timeout to wait, in nanoseconds +* \param status - \c [out] '1' for signaled, '0' for timeout +* +* \return 0 on success +* <0 - Negative POSIX Error code +* +* \note Currently it supports only one amdgpu_device. All fences come from +* the same amdgpu_device with the same fd. +*/ +int amdgpu_cs_wait_fences (struct amdgpu_cs_fence *fences, +uint32_t fence_count, +bool wait_all, +uint64_t timeout_ns, +uint32_t *status); +/* * Query / Info API *
amdgpu/amdgpu_cs.c +71 -0
74 lines not on this page · raw message
include/drm/amdgpu_drm.h +27 -0
@@ -46,6 +46,7 @@#define DRM_AMDGPU_WAIT_CS 0x09#define DRM_AMDGPU_GEM_OP 0x10#define DRM_AMDGPU_GEM_USERPTR 0x11 +#define DRM_AMDGPU_WAIT_FENCES 0x12#define DRM_IOCTL_AMDGPU_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_CREATE, union drm_amdgpu_gem_create)#define DRM_IOCTL_AMDGPU_GEM_MMAP DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_MMAP, union drm_amdgpu_gem_mmap)
@@ -59,6 +60,7 @@#define DRM_IOCTL_AMDGPU_WAIT_CS DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_WAIT_CS, union drm_amdgpu_wait_cs)#define DRM_IOCTL_AMDGPU_GEM_OP DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_OP, struct drm_amdgpu_gem_op)#define DRM_IOCTL_AMDGPU_GEM_USERPTR DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_USERPTR, struct drm_amdgpu_gem_userptr) +#define DRM_IOCTL_AMDGPU_WAIT_FENCES DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_WAIT_FENCES, union drm_amdgpu_wait_fences)#define AMDGPU_GEM_DOMAIN_CPU 0x1#define AMDGPU_GEM_DOMAIN_GTT 0x2
@@ -297,6 +299,31 @@ union drm_amdgpu_wait_cs {struct drm_amdgpu_wait_cs_out out; }; +struct drm_amdgpu_fence { +uint32_t ctx_id; +uint32_t ip_type; +uint32_t ip_instance; +uint32_t ring; +uint64_t seq_no; +}; + +struct drm_amdgpu_wait_fences_in { +/** This points to uint64_t * which points to fences */ +uint64_t fences; +uint32_t fence_count; +uint32_t wait_all; +uint64_t timeout_ns; +}; + +struct drm_amdgpu_wait_fences_out { +uint64_t status; +}; + +union drm_amdgpu_wait_fences { +struct drm_amdgpu_wait_fences_in in; +struct drm_amdgpu_wait_fences_out out; +}; +#define AMDGPU_GEM_OP_GET_GEM_CREATE_INFO 0#define AMDGPU_GEM_OP_SET_PLACEMENT 1
Signature · 6 lines
2.1.4 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 3/10 amdgpu: drop address patching logics
In reply to Marek OlšákFrom: "monk.liu" <[email protected]>
we don't support non-page-aligned cpu pointer anymore
--- amdgpu/amdgpu_bo.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-)
amdgpu/amdgpu_bo.c +1 -10
@@ -537,17 +537,8 @@ int amdgpu_create_bo_from_user_mem(amdgpu_device_handle dev,int r;struct amdgpu_bo *bo;struct drm_amdgpu_gem_userptr args; -uintptr_t cpu0; -uint32_t ps, off; -memset (&args,0 ,sizeof (args)); - ps =getpagesize (); - - cpu0 =ROUND_DOWN ((uintptr_t )cpu, ps); - off = (uintptr_t )cpu - cpu0; - size =ROUND_UP (size + off, ps); - - args.addr = cpu0; + args.addr = cpu; args.flags =AMDGPU_GEM_USERPTR_ANONONLY |AMDGPU_GEM_USERPTR_REGISTER ; args.size = size; r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_GEM_USERPTR,
Signature · 6 lines
2.1.4 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 4/10 amdgpu/tests: add multi-fence test in base test
In reply to Marek OlšákFrom: Junwei Zhang <[email protected]>
--- tests/amdgpu/basic_tests.c | 100 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+)
tests/amdgpu/basic_tests.c +100 -0
@@ -46,6 +46,7 @@ static void amdgpu_memory_alloc(void);static void amdgpu_command_submission_gfx (void );static void amdgpu_command_submission_compute (void );static void amdgpu_command_submission_sdma (void ); +static void amdgpu_command_submission_multi_fence (void );static void amdgpu_userptr_test (void );CU_TestInfo basic_tests[] = {
@@ -55,6 +56,7 @@ CU_TestInfo basic_tests[] = { { "Command submission Test (GFX)", amdgpu_command_submission_gfx }, { "Command submission Test (Compute)", amdgpu_command_submission_compute }, { "Command submission Test (SDMA)", amdgpu_command_submission_sdma }, + { "Command submission Test (Multi-fence)", amdgpu_command_submission_multi_fence }, CU_TEST_INFO_NULL, };#define BUFFER_SIZE (8 * 1024)
@@ -765,6 +767,104 @@ static void amdgpu_command_submission_sdma(void)amdgpu_command_submission_sdma_copy_linear (); } +static void amdgpu_command_submission_multi_fence_wait_all (bool wait_all) +{ +amdgpu_context_handle context_handle; +amdgpu_bo_handle ib_result_handle, ib_result_ce_handle; +void *ib_result_cpu, *ib_result_ce_cpu; +uint64_t ib_result_mc_address, ib_result_ce_mc_address; +struct amdgpu_cs_request ibs_request[2 ] = {0 }; +struct amdgpu_cs_ib_info ib_info[2 ]; +struct amdgpu_cs_fence fence_status[2 ] = {0 }; +uint32_t *ptr; +uint32_t expired; +amdgpu_bo_list_handle bo_list; +amdgpu_va_handle va_handle, va_handle_ce; +int r; +int i, ib_cs_num =2 ; + + r =amdgpu_cs_ctx_create (device_handle, &context_handle); +CU_ASSERT_EQUAL (r,0 ); + + r =amdgpu_bo_alloc_and_map (device_handle,4096 ,4096 , +AMDGPU_GEM_DOMAIN_GTT ,0 , + &ib_result_handle, &ib_result_cpu, + &ib_result_mc_address, &va_handle); +CU_ASSERT_EQUAL (r,0 ); + + r =amdgpu_bo_alloc_and_map (device_handle,4096 ,4096 , +AMDGPU_GEM_DOMAIN_GTT ,0 , + &ib_result_ce_handle, &ib_result_ce_cpu, + &ib_result_ce_mc_address, &va_handle_ce); +CU_ASSERT_EQUAL (r,0 ); + + r =amdgpu_get_bo_list (device_handle, ib_result_handle, + ib_result_ce_handle, &bo_list); +CU_ASSERT_EQUAL (r,0 ); + +memset (ib_info,0 ,2 *sizeof (struct amdgpu_cs_ib_info )); + +/* IT_SET_CE_DE_COUNTERS */ + ptr = ib_result_ce_cpu; + ptr[0 ] =0xc0008900 ; + ptr[1 ] =0 ; + ptr[2 ] =0xc0008400 ; + ptr[3 ] =1 ; + ib_info[0 ].ib_mc_address = ib_result_ce_mc_address; + ib_info[0 ].size =4 ; + ib_info[0 ].flags =AMDGPU_IB_FLAG_CE ; + +/* IT_WAIT_ON_CE_COUNTER */ + ptr = ib_result_cpu; + ptr[0 ] =0xc0008600 ; + ptr[1 ] =0x00000001 ; + ib_info[1 ].ib_mc_address = ib_result_mc_address; + ib_info[1 ].size =2 ; + +for (i =0 ; i < ib_cs_num; i++) { + ibs_request[i].ip_type =AMDGPU_HW_IP_GFX ; + ibs_request[i].number_of_ibs =2 ; + ibs_request[i].ibs = ib_info; + ibs_request[i].resources = bo_list; + ibs_request[i].fence_info.handle =NULL ; + } + + r =amdgpu_cs_submit (context_handle,0 ,ibs_request, ib_cs_num); + +CU_ASSERT_EQUAL (r,0 ); + +for (i =0 ; i < ib_cs_num; i++) { + fence_status[i].context = context_handle; + fence_status[i].ip_type =AMDGPU_HW_IP_GFX ; + fence_status[i].fence = ibs_request[i].seq_no; + } + + r =amdgpu_cs_wait_fences (fence_status, ib_cs_num, wait_all, +AMDGPU_TIMEOUT_INFINITE , + &expired); +CU_ASSERT_EQUAL (r,0 ); + + r =amdgpu_bo_unmap_and_free (ib_result_handle, va_handle, + ib_result_mc_address,4096 ); +CU_ASSERT_EQUAL (r,0 ); + + r =amdgpu_bo_unmap_and_free (ib_result_ce_handle, va_handle_ce, + ib_result_ce_mc_address,4096 ); +CU_ASSERT_EQUAL (r,0 ); + + r =amdgpu_bo_list_destroy (bo_list); +CU_ASSERT_EQUAL (r,0 ); + + r =amdgpu_cs_ctx_free (context_handle); +CU_ASSERT_EQUAL (r,0 ); +} + +static void amdgpu_command_submission_multi_fence (void ) +{ +amdgpu_command_submission_multi_fence_wait_all (true); +amdgpu_command_submission_multi_fence_wait_all (false); +} +static void amdgpu_userptr_test (void ) {int i, r, j;
Signature · 6 lines
2.1.4 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 5/10 amdgpu: Cast pointer to uintptr_t for assignment to unsigned integer
In reply to Marek OlšákFrom: Michel Dänzer <[email protected]>
CC amdgpu_bo.lo../../amdgpu/amdgpu_bo.c: In function 'amdgpu_create_bo_from_user_mem':../../amdgpu/amdgpu_bo.c:539:12: warning: assignment makes integer from pointer without a cast [-Wint-conversion]
args.addr = cpu;
^--- amdgpu/amdgpu_bo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
amdgpu/amdgpu_bo.c +1 -1
@@ -538,7 +538,7 @@ int amdgpu_create_bo_from_user_mem(amdgpu_device_handle dev,struct amdgpu_bo *bo;struct drm_amdgpu_gem_userptr args; - args.addr = cpu; + args.addr = (uintptr_t )cpu; args.flags =AMDGPU_GEM_USERPTR_ANONONLY |AMDGPU_GEM_USERPTR_REGISTER ; args.size = size; r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_GEM_USERPTR,
Signature · 6 lines
2.1.4 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 6/10 amdgpu: add semaphore support
In reply to Marek OlšákFrom: Chunming Zhou <[email protected]>
the semaphore is a binary semaphore. the work flow is:
1. create sem
2. signal sem
3. wait sem, reset sem after signalled
4. destroy sem.
--- amdgpu/amdgpu.h | 65 +++++++++++++++++++ amdgpu/amdgpu_cs.c | 166 +++++++++++++++++++++++++++++++++++++++++++++-- amdgpu/amdgpu_internal.h | 12 ++++ 3 files changed, 239 insertions(+), 4 deletions(-)
amdgpu/amdgpu.h +65 -0
@@ -124,6 +124,11 @@ typedef struct amdgpu_bo_list *amdgpu_bo_list_handle;*/ typedef struct amdgpu_va *amdgpu_va_handle ; +/** +* Define handle for semaphore +*/ +typedef struct amdgpu_semaphore *amdgpu_semaphore_handle ; +/*--------------------------------------------------------------------------*/ /* -------------------------- Structures ---------------------------------- */ /*--------------------------------------------------------------------------*/
@@ -1202,4 +1207,64 @@ int amdgpu_bo_va_op(amdgpu_bo_handle bo,uint64_t flags, uint32_t ops); +/** +* create semaphore +* +* \param sem - \c [out] semaphore handle +* +* \return 0 on success\n +* <0 - Negative POSIX Error code +* +*/ +int amdgpu_cs_create_semaphore (amdgpu_semaphore_handle *sem); + +/** +* signal semaphore +* +* \param context - \c [in] GPU Context +* \param ip_type - \c [in] Hardware IP block type = AMDGPU_HW_IP_* +* \param ip_instance - \c [in] Index of the IP block of the same type +* \param ring - \c [in] Specify ring index of the IP +* \param sem - \c [in] semaphore handle +* +* \return 0 on success\n +* <0 - Negative POSIX Error code +* +*/ +int amdgpu_cs_signal_semaphore (amdgpu_context_handle ctx, +uint32_t ip_type, +uint32_t ip_instance, +uint32_t ring, +amdgpu_semaphore_handle sem); + +/** +* wait semaphore +* +* \param context - \c [in] GPU Context +* \param ip_type - \c [in] Hardware IP block type = AMDGPU_HW_IP_* +* \param ip_instance - \c [in] Index of the IP block of the same type +* \param ring - \c [in] Specify ring index of the IP +* \param sem - \c [in] semaphore handle +* +* \return 0 on success\n +* <0 - Negative POSIX Error code +* +*/ +int amdgpu_cs_wait_semaphore (amdgpu_context_handle ctx, +uint32_t ip_type, +uint32_t ip_instance, +uint32_t ring, +amdgpu_semaphore_handle sem); + +/** +* destroy semaphore +* +* \param sem - \c [in] semaphore handle +* +* \return 0 on success\n +* <0 - Negative POSIX Error code +* +*/ +int amdgpu_cs_destroy_semaphore (amdgpu_semaphore_handle sem); +#endif /* #ifdef _AMDGPU_H_ */
amdgpu/amdgpu_cs.c +162 -4
226 lines not on this page · raw message
amdgpu/amdgpu_internal.h +12 -0
@@ -116,6 +116,18 @@ struct amdgpu_context {pthread_mutex_t sequence_mutex;/* context id*/ uint32_t id; +uint64_t last_seq[AMDGPU_HW_IP_NUM ][AMDGPU_HW_IP_INSTANCE_MAX_COUNT ][AMDGPU_CS_MAX_RINGS ]; +struct list_head sem_list[AMDGPU_HW_IP_NUM ][AMDGPU_HW_IP_INSTANCE_MAX_COUNT ][AMDGPU_CS_MAX_RINGS ]; +}; + +/** +* Structure describing sw semaphore based on scheduler +* +*/ +struct amdgpu_semaphore { +atomic_t refcount; +struct list_head list; +struct amdgpu_cs_fence signal_fence; };/**
Signature · 6 lines
2.1.4 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 7/10 tests/amdgpu: add semaphore test
In reply to Marek OlšákFrom: Chunming Zhou <[email protected]>
--- tests/amdgpu/basic_tests.c | 133 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+)
tests/amdgpu/basic_tests.c +133 -0
@@ -48,6 +48,7 @@ static void amdgpu_command_submission_compute(void);static void amdgpu_command_submission_sdma (void );static void amdgpu_command_submission_multi_fence (void );static void amdgpu_userptr_test (void ); +static void amdgpu_semaphore_test (void );CU_TestInfo basic_tests[] = { {"Query Info Test" , amdgpu_query_info_test },
@@ -57,6 +58,7 @@ CU_TestInfo basic_tests[] = { { "Command submission Test (Compute)", amdgpu_command_submission_compute }, { "Command submission Test (SDMA)", amdgpu_command_submission_sdma }, { "Command submission Test (Multi-fence)", amdgpu_command_submission_multi_fence }, + { "SW semaphore Test", amdgpu_semaphore_test }, CU_TEST_INFO_NULL, };#define BUFFER_SIZE (8 * 1024)
@@ -79,6 +81,9 @@ CU_TestInfo basic_tests[] = {#define SDMA_OPCODE_COPY 1# define SDMA_COPY_SUB_OPCODE_LINEAR 0 +#define GFX_COMPUTE_NOP 0xffff1000 +#define SDMA_NOP 0x0 +int suite_basic_tests_init (void ) {int r;
@@ -335,6 +340,134 @@ static void amdgpu_command_submission_gfx(void)amdgpu_command_submission_gfx_shared_ib (); } +static void amdgpu_semaphore_test (void ) +{ +amdgpu_context_handle context_handle[2 ]; +amdgpu_semaphore_handle sem; +amdgpu_bo_handle ib_result_handle[2 ]; +void *ib_result_cpu[2 ]; +uint64_t ib_result_mc_address[2 ]; +struct amdgpu_cs_request ibs_request[2 ] = {0 }; +struct amdgpu_cs_ib_info ib_info[2 ] = {0 }; +struct amdgpu_cs_fence fence_status = {0 }; +uint32_t *ptr; +uint32_t expired; +amdgpu_bo_list_handle bo_list[2 ]; +amdgpu_va_handle va_handle[2 ]; +int r, i; + + r =amdgpu_cs_create_semaphore (&sem); +CU_ASSERT_EQUAL (r,0 ); +for (i =0 ; i <2 ; i++) { + r =amdgpu_cs_ctx_create (device_handle, &context_handle[i]); +CU_ASSERT_EQUAL (r,0 ); + + r =amdgpu_bo_alloc_and_map (device_handle,4096 ,4096 , +AMDGPU_GEM_DOMAIN_GTT ,0 , + &ib_result_handle[i], &ib_result_cpu[i], + &ib_result_mc_address[i], &va_handle[i]); +CU_ASSERT_EQUAL (r,0 ); + + r =amdgpu_get_bo_list (device_handle, ib_result_handle[i], +NULL , &bo_list[i]); +CU_ASSERT_EQUAL (r,0 ); + } + +/* 1. same context different engine */ + ptr = ib_result_cpu[0 ]; + ptr[0 ] =SDMA_NOP ; + ib_info[0 ].ib_mc_address = ib_result_mc_address[0 ]; + ib_info[0 ].size =1 ; + + ibs_request[0 ].ip_type =AMDGPU_HW_IP_DMA ; + ibs_request[0 ].number_of_ibs =1 ; + ibs_request[0 ].ibs = &ib_info[0 ]; + ibs_request[0 ].resources = bo_list[0 ]; + ibs_request[0 ].fence_info.handle =NULL ; + r =amdgpu_cs_submit (context_handle[0 ],0 ,&ibs_request[0 ],1 ); +CU_ASSERT_EQUAL (r,0 ); + r =amdgpu_cs_signal_semaphore (context_handle[0 ],AMDGPU_HW_IP_DMA ,0 ,0 , sem); +CU_ASSERT_EQUAL (r,0 ); + + r =amdgpu_cs_wait_semaphore (context_handle[0 ],AMDGPU_HW_IP_GFX ,0 ,0 , sem); +CU_ASSERT_EQUAL (r,0 ); + ptr = ib_result_cpu[1 ]; + ptr[0 ] =GFX_COMPUTE_NOP ; + ib_info[1 ].ib_mc_address = ib_result_mc_address[1 ]; + ib_info[1 ].size =1 ; + + ibs_request[1 ].ip_type =AMDGPU_HW_IP_GFX ; + ibs_request[1 ].number_of_ibs =1 ; + ibs_request[1 ].ibs = &ib_info[1 ]; + ibs_request[1 ].resources = bo_list[1 ]; + ibs_request[1 ].fence_info.handle =NULL ; + + r =amdgpu_cs_submit (context_handle[0 ],0 ,&ibs_request[1 ],1 ); +CU_ASSERT_EQUAL (r,0 ); + + fence_status.context = context_handle[0 ]; + fence_status.ip_type =AMDGPU_HW_IP_GFX ; + fence_status.fence = ibs_request[1 ].seq_no; + r =amdgpu_cs_query_fence_status (&fence_status, +500000000 ,0 , &expired); +CU_ASSERT_EQUAL (r,0 ); +CU_ASSERT_EQUAL (expired, true); + +/* 2. same engine different context */ + ptr = ib_result_cpu[0 ]; + ptr[0 ] =GFX_COMPUTE_NOP ; + ib_info[0 ].ib_mc_address = ib_result_mc_address[0 ]; + ib_info[0 ].size =1 ; + + ibs_request[0 ].ip_type =AMDGPU_HW_IP_GFX ; + ibs_request[0 ].number_of_ibs =1 ; + ibs_request[0 ].ibs = &ib_info[0 ]; + ibs_request[0 ].resources = bo_list[0 ]; + ibs_request[0 ].fence_info.handle =NULL ; + r =amdgpu_cs_submit (context_handle[0 ],0 ,&ibs_request[0 ],1 ); +CU_ASSERT_EQUAL (r,0 ); + r =amdgpu_cs_signal_semaphore (context_handle[0 ],AMDGPU_HW_IP_GFX ,0 ,0 , sem); +CU_ASSERT_EQUAL (r,0 ); + + r =amdgpu_cs_wait_semaphore (context_handle[1 ],AMDGPU_HW_IP_GFX ,0 ,0 , sem); +CU_ASSERT_EQUAL (r,0 ); + ptr = ib_result_cpu[1 ]; + ptr[0 ] =GFX_COMPUTE_NOP ; + ib_info[1 ].ib_mc_address = ib_result_mc_address[1 ]; + ib_info[1 ].size =1 ; + + ibs_request[1 ].ip_type =AMDGPU_HW_IP_GFX ; + ibs_request[1 ].number_of_ibs =1 ; + ibs_request[1 ].ibs = &ib_info[1 ]; + ibs_request[1 ].resources = bo_list[1 ]; + ibs_request[1 ].fence_info.handle =NULL ; + r =amdgpu_cs_submit (context_handle[1 ],0 ,&ibs_request[1 ],1 ); + +CU_ASSERT_EQUAL (r,0 ); + + fence_status.context = context_handle[1 ]; + fence_status.ip_type =AMDGPU_HW_IP_GFX ; + fence_status.fence = ibs_request[1 ].seq_no; + r =amdgpu_cs_query_fence_status (&fence_status, +500000000 ,0 , &expired); +CU_ASSERT_EQUAL (r,0 ); +CU_ASSERT_EQUAL (expired, true); +for (i =0 ; i <2 ; i++) { + r =amdgpu_bo_unmap_and_free (ib_result_handle[i], va_handle[i], + ib_result_mc_address[i],4096 ); +CU_ASSERT_EQUAL (r,0 ); + + r =amdgpu_bo_list_destroy (bo_list[i]); +CU_ASSERT_EQUAL (r,0 ); + + r =amdgpu_cs_ctx_free (context_handle[i]); +CU_ASSERT_EQUAL (r,0 ); + } + + r =amdgpu_cs_destroy_semaphore (sem); +CU_ASSERT_EQUAL (r,0 ); +} +static void amdgpu_command_submission_compute (void ) {amdgpu_context_handle context_handle;
Signature · 6 lines
2.1.4 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 8/10 amdgpu: validate user memory for userptr
In reply to Marek OlšákFrom: Chunming Zhou <[email protected]>
--- amdgpu/amdgpu_bo.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
amdgpu/amdgpu_bo.c +2 -1
@@ -539,7 +539,8 @@ int amdgpu_create_bo_from_user_mem(amdgpu_device_handle dev,struct drm_amdgpu_gem_userptr args; args.addr = (uintptr_t )cpu; - args.flags =AMDGPU_GEM_USERPTR_ANONONLY |AMDGPU_GEM_USERPTR_REGISTER ; + args.flags =AMDGPU_GEM_USERPTR_ANONONLY |AMDGPU_GEM_USERPTR_REGISTER | +AMDGPU_GEM_USERPTR_VALIDATE ; args.size = size; r =drmCommandWriteRead (dev->fd,DRM_AMDGPU_GEM_USERPTR , &args,sizeof (args));
Signature · 6 lines
2.1.4 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 9/10 amdgpu: cs_wait_fences now can return the first signaled fence index
In reply to Marek OlšákFrom: "monk.liu" <[email protected]>
--- amdgpu/amdgpu.h | 3 ++- amdgpu/amdgpu_cs.c | 12 +++++++++--- include/drm/amdgpu_drm.h | 3 ++- tests/amdgpu/basic_tests.c | 2 +- 4 files changed, 14 insertions(+), 6 deletions(-)
amdgpu/amdgpu.h +2 -1
@@ -916,6 +916,7 @@ int amdgpu_cs_query_fence_status(struct amdgpu_cs_fence *fence,* otherwise, wait at least one fence * \param timeout_ns - \c [in] The timeout to wait, in nanoseconds * \param status - \c [out] '1' for signaled, '0' for timeout +* \param first - \c [out] the index of the first signaled fence from @fences * * \return 0 on success * <0 - Negative POSIX Error code
@@ -927,7 +928,7 @@ int amdgpu_cs_wait_fences(struct amdgpu_cs_fence *fences,uint32_t fence_count, bool wait_all, uint64_t timeout_ns, - uint32_t *status); + uint32_t *status, uint32_t *first);/* * Query / Info API
amdgpu/amdgpu_cs.c +9 -3
@@ -439,7 +439,8 @@ static int amdgpu_ioctl_wait_fences(struct amdgpu_cs_fence *fences,uint32_t fence_count, bool wait_all, uint64_t timeout_ns, - uint32_t *status) + uint32_t *status, + uint32_t *first) { struct drm_amdgpu_fence *drm_fences;amdgpu_device_handle dev = fences[0 ].context->dev;
@@ -467,6 +468,10 @@ static int amdgpu_ioctl_wait_fences(struct amdgpu_cs_fence *fences,return -errno; *status = args.out.status; + +if (first) + *first = args.out.first_signaled; +return 0 ; }
@@ -474,7 +479,8 @@ int amdgpu_cs_wait_fences(struct amdgpu_cs_fence *fences,uint32_t fence_count, bool wait_all, uint64_t timeout_ns, - uint32_t *status) + uint32_t *status, + uint32_t *first) { uint32_t ioctl_status = 0;uint32_t i;
@@ -499,7 +505,7 @@ int amdgpu_cs_wait_fences(struct amdgpu_cs_fence *fences, *status =0 ; r =amdgpu_ioctl_wait_fences (fences, fence_count, wait_all, timeout_ns, - &ioctl_status); + &ioctl_status, first);if (!r) *status = ioctl_status;
include/drm/amdgpu_drm.h +2 -1
@@ -316,7 +316,8 @@ struct drm_amdgpu_wait_fences_in { };struct drm_amdgpu_wait_fences_out { -uint64_t status; +uint32_t status; +uint32_t first_signaled; };union drm_amdgpu_wait_fences {
tests/amdgpu/basic_tests.c +1 -1
@@ -974,7 +974,7 @@ static void amdgpu_command_submission_multi_fence_wait_all(bool wait_all) r =amdgpu_cs_wait_fences (fence_status, ib_cs_num, wait_all,AMDGPU_TIMEOUT_INFINITE , - &expired); + &expired,NULL );CU_ASSERT_EQUAL (r,0 ); r = amdgpu_bo_unmap_and_free(ib_result_handle, va_handle,
Signature · 6 lines
2.1.4 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 10/10 amdgpu: list each entry safely for sw semaphore when submit ib
In reply to Marek OlšákFrom: Junwei Zhang <[email protected]>
--- amdgpu/amdgpu_cs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
amdgpu/amdgpu_cs.c +2 -2
@@ -179,7 +179,7 @@ static int amdgpu_cs_submit_one(amdgpu_context_handle context,struct drm_amdgpu_cs_chunk_dep *dependencies =NULL ;struct drm_amdgpu_cs_chunk_dep *sem_dependencies =NULL ;struct list_head *sem_list; -amdgpu_semaphore_handle sem; +amdgpu_semaphore_handle sem, tmp;uint32_t i, size, sem_count =0 ;bool user_fence;int r =0 ;
@@ -282,7 +282,7 @@ static int amdgpu_cs_submit_one(amdgpu_context_handle context, goto error_unlock; } sem_count =0 ; - LIST_FOR_EACH_ENTRY(sem, sem_list, list) { + LIST_FOR_EACH_ENTRY_SAFE(sem, tmp, sem_list, list) {struct amdgpu_cs_fence *info = &sem->signal_fence;struct drm_amdgpu_cs_chunk_dep *dep = &sem_dependencies[sem_count++]; dep->ip_type = info->ip_type;
Signature · 6 lines
2.1.4 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 7 lines · Marek Olšák
Hi,
These are
libdrm_amdgpupatches harvested from an internal branch.The first patch is a revert I had to make to fix the build. Yeah,
sequence_mutexshould be renamed to a more appropriate name. That can be done as a follow-up.One notable change is the addition of
DRM_IOCTL_AMDGPU_WAIT_FENCES. I hope the kernel contains (or will contain) the changes too, so that I don't push something that doesn't exist in the kernel.
We haven't pushed DRM_IOCTL_AMDGPU_WAIT_FENCES upstream yet so I would hold off on any changes that depend on that.
Alex
Quoted 33 lines
Please let me know if these are okay to push.
Thanks,
Chunming Zhou (3):
amdgpu: add semaphore support
tests/amdgpu: add semaphore test
amdgpu: validate user memory for userptrJunwei Zhang (3):
amdgpu: add the interface of waiting multiple fences amdgpu/tests: add multi-fence test in base test
amdgpu: list each entry safely for sw semaphore when submit ibMarek Olšák (1):
Revert "amdgpu: remove sequence mutex"Michel Dänzer (1):
amdgpu: Cast pointer touintptr_tfor assignment to unsigned integermonk.liu (2):
amdgpu: drop address patching logics
amdgpu:cs_wait_fencesnow can return the first signaled fence indexamdgpu/amdgpu.h | 88 +++++++++++++++++++++++++++++++++++++++++ amdgpu/amdgpu_bo.c | 14 ++----- amdgpu/amdgpu_cs.c | 253 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- amdgpu/amdgpu_internal.h | 15 +++++++ include/drm/amdgpu_drm.h | 28 +++++++++++++ tests/amdgpu/basic_tests.c | 233 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 616 insertions(+), 15 deletions(-)
Quoted 5 lines
Marek
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 05/10] amdgpu: Cast pointer to uintptr_t for assignment to unsigned integer
In reply to Marek OlšákQuoted 19 lines · Marek Olšák
From: Michel Dänzer <[email protected]>
CC amdgpu_bo.lo
../../amdgpu/amdgpu_bo.c: In function 'amdgpu_create_bo_from_user_mem':../../amdgpu/amdgpu_bo.c:539:12: warning: assignment makes integer from pointer without a cast [-Wint-conversion]args.addr = cpu; ^Reviewed-by Jammy Zhou <[email protected]>--- amdgpu/amdgpu_bo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)amdgpu/amdgpu_bo.c +0
-0
amdgpu/amdgpu_bo.c int amdgpu_create_bo_from_user_mem(amdgpu_device_handle dev, · line 544
Quoted 8 lines
amdgpu/amdgpu_bo.c +1
-1@@ -538,7 +538,7 @@ int amdgpu_create_bo_from_user_mem(amdgpu_device_handle dev,struct amdgpu_bo *bo;struct drm_amdgpu_gem_userptr args; - args.addr = cpu; + args.addr = (uintptr_t )cpu; args.flags =AMDGPU_GEM_USERPTR_ANONONLY |AMDGPU_GEM_USERPTR_REGISTER ; args.size = size; r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_GEM_USERPTR,
This patch should be squashed into patch 3.
Signature · 6 lines
Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Am 12.01.2016 um 22:30 schrieb Alex Deucher:
Quoted 10 lines · Marek Olšák
Quoted 7 lines
Hi,
These are
libdrm_amdgpupatches harvested from an internal branch.The first patch is a revert I had to make to fix the build. Yeah,
sequence_mutexshould be renamed to a more appropriate name. That can be done as a follow-up.One notable change is the addition of
DRM_IOCTL_AMDGPU_WAIT_FENCES. I hope the kernel contains (or will contain) the changes too, so that I don't push something that doesn't exist in the kernel.We haven't pushed
DRM_IOCTL_AMDGPU_WAIT_FENCESupstream yet so I would hold off on any changes that depend on that.
Yeah, and do we really have patch #9 in our internal branch without an Review? Cause that one breaks the API.
Christian.
Quoted 40 lines
Alex
Quoted 32 lines
Please let me know if these are okay to push.
Thanks,
Chunming Zhou (3):
amdgpu: add semaphore support
tests/amdgpu: add semaphore test
amdgpu: validate user memory for userptrJunwei Zhang (3):
amdgpu: add the interface of waiting multiple fences amdgpu/tests: add multi-fence test in base test
amdgpu: list each entry safely for sw semaphore when submit ibMarek Olšák (1):
Revert "amdgpu: remove sequence mutex"Michel Dänzer (1):
amdgpu: Cast pointer touintptr_tfor assignment to unsigned integermonk.liu (2):
amdgpu: drop address patching logics
amdgpu:cs_wait_fencesnow can return the first signaled fence indexamdgpu/amdgpu.h | 88 +++++++++++++++++++++++++++++++++++++++++ amdgpu/amdgpu_bo.c | 14 ++----- amdgpu/amdgpu_cs.c | 253 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- amdgpu/amdgpu_internal.h | 15 +++++++ include/drm/amdgpu_drm.h | 28 +++++++++++++ tests/amdgpu/basic_tests.c | 233 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 616 insertions(+), 15 deletions(-)Quoted 5 lines
Marek
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 4 lines
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 16 lines · Christian König
Am 12.01.2016 um 22:30 schrieb Alex Deucher:
Quoted 15 lines · Marek Olšák
Quoted 12 lines
Hi,
These are
libdrm_amdgpupatches harvested from an internal branch.The first patch is a revert I had to make to fix the build. Yeah,
sequence_mutexshould be renamed to a more appropriate name. That can be done as a follow-up.One notable change is the addition of
DRM_IOCTL_AMDGPU_WAIT_FENCES. I hope the kernel contains (or will contain) the changes too, so that I don't push something that doesn't exist in the kernel.
Quoted 6 lines
Quoted 2 lines
We haven't pushed
DRM_IOCTL_AMDGPU_WAIT_FENCESupstream yet so I would hold off on any changes that depend on that.Yeah, and do we really have patch #9 in our internal branch without an Review? Cause that one breaks the API.
It doesn't break the API, because the API is added by this series in an earlier patch. The API would be broken if it was changed between two libdrm versions.
Marek
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Am 13.01.2016 um 12:15 schrieb Marek Olšák:
Quoted 15 lines
Quoted 13 lines · Christian König
Am 12.01.2016 um 22:30 schrieb Alex Deucher:
Quoted 12 lines · Marek Olšák
Quoted 11 lines
Hi,
These are
libdrm_amdgpupatches harvested from an internal branch.The first patch is a revert I had to make to fix the build. Yeah,
sequence_mutexshould be renamed to a more appropriate name. That can be done as a follow-up.One notable change is the addition of
DRM_IOCTL_AMDGPU_WAIT_FENCES. I hope the kernel contains (or will contain) the changes too, so that I don't push something that doesn't exist in the kernel.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
We haven't pushed
DRM_IOCTL_AMDGPU_WAIT_FENCESupstream yet so I would hold off on any changes that depend on that.Yeah, and do we really have patch #9 in our internal branch without an Review? Cause that one breaks the API.
It doesn't break the API, because the API is added by this series in an earlier patch. The API would be broken if it was changed between two libdrm versions.
Ah, in this case please squash the two patches together for upstreaming.
Regards,
Christian.
Quoted 2 lines
Marek
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel