All of lore.kernel.org
 help / color / mirror / Atom feed
* libdrm/amdgpu - Fixup typedef not to hide pointer type
@ 2016-09-16  8:46 Edward O'Callaghan
       [not found] ` <1474015570-30928-1-git-send-email-funfunctor-dczkZgxz+BNUPWh3PAxdjQ@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Edward O'Callaghan @ 2016-09-16  8:46 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

Oops, turns out I mailed to dri-devel by mistake so resending here.

The following series fixes up libdrm/amdgpu such that to not hide
a pointer type behind a typedef.

Please Review,

Edward O'Callaghan (3):
 [PATCH 1/3] amdgpu: Fix amdgpu_va_handle typedef not to hide pointer
 [PATCH 2/3] amdgpu: Fix amdgpu_semaphore_handle typedef not to hide
 [PATCH 3/3] amdgpu: Fix amdgpu_bo_list_handle typedef not to hide
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/3] amdgpu: Fix amdgpu_va_handle typedef not to hide pointer type
       [not found] ` <1474015570-30928-1-git-send-email-funfunctor-dczkZgxz+BNUPWh3PAxdjQ@public.gmane.org>
@ 2016-09-16  8:46   ` Edward O'Callaghan
  2016-09-16  8:46   ` [PATCH 2/3] amdgpu: Fix amdgpu_semaphore_handle " Edward O'Callaghan
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: Edward O'Callaghan @ 2016-09-16  8:46 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

Fundamentally this change stops us hiding the following pointer
type behind a typedef:

 -typedef struct amdgpu_va *amdgpu_va_handle;
 +typedef struct amdgpu_va amdgpu_va_handle_t;

Signed-off-by: Edward O'Callaghan <funfunctor@folklore1984.net>
---
 amdgpu/amdgpu.h            |  6 +++---
 amdgpu/amdgpu_vamgr.c      |  4 ++--
 tests/amdgpu/amdgpu_test.h | 10 +++++-----
 tests/amdgpu/basic_tests.c | 20 ++++++++++----------
 tests/amdgpu/bo_tests.c    |  2 +-
 tests/amdgpu/cs_tests.c    | 10 +++++-----
 tests/amdgpu/vce_tests.c   |  6 +++---
 7 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/amdgpu/amdgpu.h b/amdgpu/amdgpu.h
index 5d5a2c6..f322497 100644
--- a/amdgpu/amdgpu.h
+++ b/amdgpu/amdgpu.h
@@ -122,7 +122,7 @@ typedef struct amdgpu_bo_list *amdgpu_bo_list_handle;
 /**
  * Define handle to be used to work with VA allocated ranges
  */
-typedef struct amdgpu_va *amdgpu_va_handle;
+typedef struct amdgpu_va amdgpu_va_handle_t;
 
 /**
  * Define handle for semaphore
@@ -1126,7 +1126,7 @@ int amdgpu_va_range_alloc(amdgpu_device_handle dev,
 			   uint64_t va_base_alignment,
 			   uint64_t va_base_required,
 			   uint64_t *va_base_allocated,
-			   amdgpu_va_handle *va_range_handle,
+			   amdgpu_va_handle_t ** va_range_handle,
 			   uint64_t flags);
 
 /**
@@ -1140,7 +1140,7 @@ int amdgpu_va_range_alloc(amdgpu_device_handle dev,
  * <0 - Negative POSIX Error code
  *
 */
-int amdgpu_va_range_free(amdgpu_va_handle va_range_handle);
+int amdgpu_va_range_free(amdgpu_va_handle_t * va_range_handle);
 
 /**
 * Query virtual address range
diff --git a/amdgpu/amdgpu_vamgr.c b/amdgpu/amdgpu_vamgr.c
index 8a707cb..7fae7cf 100644
--- a/amdgpu/amdgpu_vamgr.c
+++ b/amdgpu/amdgpu_vamgr.c
@@ -230,7 +230,7 @@ int amdgpu_va_range_alloc(amdgpu_device_handle dev,
 			  uint64_t va_base_alignment,
 			  uint64_t va_base_required,
 			  uint64_t *va_base_allocated,
-			  amdgpu_va_handle *va_range_handle,
+			  amdgpu_va_handle_t ** va_range_handle,
 			  uint64_t flags)
 {
 	struct amdgpu_bo_va_mgr *vamgr;
@@ -274,7 +274,7 @@ int amdgpu_va_range_alloc(amdgpu_device_handle dev,
 	return 0;
 }
 
-int amdgpu_va_range_free(amdgpu_va_handle va_range_handle)
+int amdgpu_va_range_free(amdgpu_va_handle_t * va_range_handle)
 {
 	if(!va_range_handle || !va_range_handle->address)
 		return 0;
diff --git a/tests/amdgpu/amdgpu_test.h b/tests/amdgpu/amdgpu_test.h
index fca92ad..acf3359 100644
--- a/tests/amdgpu/amdgpu_test.h
+++ b/tests/amdgpu/amdgpu_test.h
@@ -111,7 +111,7 @@ static inline amdgpu_bo_handle gpu_mem_alloc(
 					uint32_t type,
 					uint64_t flags,
 					uint64_t *vmc_addr,
-					amdgpu_va_handle *va_handle)
+					amdgpu_va_handle_t ** va_handle)
 {
 	struct amdgpu_bo_alloc_request req = {0};
 	amdgpu_bo_handle buf_handle;
@@ -140,7 +140,7 @@ static inline amdgpu_bo_handle gpu_mem_alloc(
 }
 
 static inline int gpu_mem_free(amdgpu_bo_handle bo,
-			       amdgpu_va_handle va_handle,
+			       amdgpu_va_handle_t * va_handle,
 			       uint64_t vmc_addr,
 			       uint64_t size)
 {
@@ -162,11 +162,11 @@ static inline int
 amdgpu_bo_alloc_and_map(amdgpu_device_handle dev, unsigned size,
 			unsigned alignment, unsigned heap, uint64_t flags,
 			amdgpu_bo_handle *bo, void **cpu, uint64_t *mc_address,
-			amdgpu_va_handle *va_handle)
+			amdgpu_va_handle_t ** va_handle)
 {
 	struct amdgpu_bo_alloc_request request = {};
 	amdgpu_bo_handle buf_handle;
-	amdgpu_va_handle handle;
+	amdgpu_va_handle_t * handle;
 	uint64_t vmc_addr;
 	int r;
 
@@ -212,7 +212,7 @@ error_va_alloc:
 }
 
 static inline int
-amdgpu_bo_unmap_and_free(amdgpu_bo_handle bo, amdgpu_va_handle va_handle,
+amdgpu_bo_unmap_and_free(amdgpu_bo_handle bo, amdgpu_va_handle_t * va_handle,
 			 uint64_t mc_addr, uint64_t size)
 {
 	amdgpu_bo_cpu_unmap(bo);
diff --git a/tests/amdgpu/basic_tests.c b/tests/amdgpu/basic_tests.c
index 11f6a63..40e9ef1 100644
--- a/tests/amdgpu/basic_tests.c
+++ b/tests/amdgpu/basic_tests.c
@@ -237,7 +237,7 @@ static void amdgpu_query_info_test(void)
 static void amdgpu_memory_alloc(void)
 {
 	amdgpu_bo_handle bo;
-	amdgpu_va_handle va_handle;
+	amdgpu_va_handle_t * va_handle;
 	uint64_t bo_mc;
 	int r;
 
@@ -293,7 +293,7 @@ static void amdgpu_command_submission_gfx_separate_ibs(void)
 	uint32_t *ptr;
 	uint32_t expired;
 	amdgpu_bo_list_handle bo_list;
-	amdgpu_va_handle va_handle, va_handle_ce;
+	amdgpu_va_handle_t * va_handle, va_handle_ce;
 	int r;
 
 	r = amdgpu_cs_ctx_create(device_handle, &context_handle);
@@ -382,7 +382,7 @@ static void amdgpu_command_submission_gfx_shared_ib(void)
 	uint32_t *ptr;
 	uint32_t expired;
 	amdgpu_bo_list_handle bo_list;
-	amdgpu_va_handle va_handle;
+	amdgpu_va_handle_t * va_handle;
 	int r;
 
 	r = amdgpu_cs_ctx_create(device_handle, &context_handle);
@@ -489,7 +489,7 @@ static void amdgpu_semaphore_test(void)
 	uint32_t *ptr;
 	uint32_t expired;
 	amdgpu_bo_list_handle bo_list[2];
-	amdgpu_va_handle va_handle[2];
+	amdgpu_va_handle_t * va_handle[2];
 	int r, i;
 
 	r = amdgpu_cs_create_semaphore(&sem);
@@ -619,7 +619,7 @@ static void amdgpu_command_submission_compute_nop(void)
 	uint32_t expired;
 	int i, r, instance;
 	amdgpu_bo_list_handle bo_list;
-	amdgpu_va_handle va_handle;
+	amdgpu_va_handle_t * va_handle;
 
 	r = amdgpu_cs_ctx_create(device_handle, &context_handle);
 	CU_ASSERT_EQUAL(r, 0);
@@ -725,7 +725,7 @@ static void amdgpu_test_exec_cs_helper(amdgpu_context_handle context_handle,
 	uint64_t ib_result_mc_address;
 	struct amdgpu_cs_fence fence_status = {0};
 	amdgpu_bo_handle *all_res = alloca(sizeof(resources[0]) * (res_cnt + 1));
-	amdgpu_va_handle va_handle;
+	amdgpu_va_handle_t * va_handle;
 
 	/* prepare CS */
 	CU_ASSERT_NOT_EQUAL(pm4_src, NULL);
@@ -802,7 +802,7 @@ static void amdgpu_command_submission_write_linear_helper(unsigned ip_type)
 	volatile uint32_t *bo_cpu;
 	int i, j, r, loop;
 	uint64_t gtt_flags[2] = {0, AMDGPU_GEM_CREATE_CPU_GTT_USWC};
-	amdgpu_va_handle va_handle;
+	amdgpu_va_handle_t * va_handle;
 
 	pm4 = calloc(pm4_dw, sizeof(*pm4));
 	CU_ASSERT_NOT_EQUAL(pm4, NULL);
@@ -903,7 +903,7 @@ static void amdgpu_command_submission_const_fill_helper(unsigned ip_type)
 	volatile uint32_t *bo_cpu;
 	int i, j, r, loop;
 	uint64_t gtt_flags[2] = {0, AMDGPU_GEM_CREATE_CPU_GTT_USWC};
-	amdgpu_va_handle va_handle;
+	amdgpu_va_handle_t * va_handle;
 
 	pm4 = calloc(pm4_dw, sizeof(*pm4));
 	CU_ASSERT_NOT_EQUAL(pm4, NULL);
@@ -1006,7 +1006,7 @@ static void amdgpu_command_submission_copy_linear_helper(unsigned ip_type)
 	volatile unsigned char *bo1_cpu, *bo2_cpu;
 	int i, j, r, loop1, loop2;
 	uint64_t gtt_flags[2] = {0, AMDGPU_GEM_CREATE_CPU_GTT_USWC};
-	amdgpu_va_handle bo1_va_handle, bo2_va_handle;
+	amdgpu_va_handle_t * bo1_va_handle, bo2_va_handle;
 
 	pm4 = calloc(pm4_dw, sizeof(*pm4));
 	CU_ASSERT_NOT_EQUAL(pm4, NULL);
@@ -1136,7 +1136,7 @@ static void amdgpu_userptr_test(void)
 	struct amdgpu_cs_ib_info *ib_info;
 	struct amdgpu_cs_request *ibs_request;
 	amdgpu_bo_handle buf_handle;
-	amdgpu_va_handle va_handle;
+	amdgpu_va_handle_t * va_handle;
 
 	pm4 = calloc(pm4_dw, sizeof(*pm4));
 	CU_ASSERT_NOT_EQUAL(pm4, NULL);
diff --git a/tests/amdgpu/bo_tests.c b/tests/amdgpu/bo_tests.c
index 993895d..d1e5c22 100644
--- a/tests/amdgpu/bo_tests.c
+++ b/tests/amdgpu/bo_tests.c
@@ -41,7 +41,7 @@ static uint32_t minor_version;
 
 static amdgpu_bo_handle buffer_handle;
 static uint64_t virtual_mc_base_address;
-static amdgpu_va_handle va_handle;
+static amdgpu_va_handle_t * va_handle;
 
 static void amdgpu_bo_export_import(void);
 static void amdgpu_bo_metadata(void);
diff --git a/tests/amdgpu/cs_tests.c b/tests/amdgpu/cs_tests.c
index a01ee48..d774007 100644
--- a/tests/amdgpu/cs_tests.c
+++ b/tests/amdgpu/cs_tests.c
@@ -50,7 +50,7 @@ static amdgpu_context_handle context_handle;
 static amdgpu_bo_handle ib_handle;
 static uint64_t ib_mc_address;
 static uint32_t *ib_cpu;
-static amdgpu_va_handle ib_va_handle;
+static amdgpu_va_handle_t * ib_va_handle;
 
 static amdgpu_bo_handle resources[MAX_RESOURCES];
 static unsigned num_resources;
@@ -71,7 +71,7 @@ int suite_cs_tests_init(void)
 	amdgpu_bo_handle ib_result_handle;
 	void *ib_result_cpu;
 	uint64_t ib_result_mc_address;
-	amdgpu_va_handle ib_result_va_handle;
+	amdgpu_va_handle_t * ib_result_va_handle;
 	int r;
 
 	r = amdgpu_device_initialize(drm_amdgpu[0], &major_version,
@@ -182,7 +182,7 @@ static void amdgpu_cs_uvd_create(void)
 	struct amdgpu_bo_alloc_request req = {0};
 	amdgpu_bo_handle buf_handle;
 	uint64_t va = 0;
-	amdgpu_va_handle va_handle;
+	amdgpu_va_handle_t * va_handle;
 	void *msg;
 	int i, r;
 
@@ -248,7 +248,7 @@ static void amdgpu_cs_uvd_decode(void)
 	uint64_t msg_addr, fb_addr, bs_addr, dpb_addr, ctx_addr, dt_addr, it_addr;
 	struct amdgpu_bo_alloc_request req = {0};
 	amdgpu_bo_handle buf_handle;
-	amdgpu_va_handle va_handle;
+	amdgpu_va_handle_t * va_handle;
 	uint64_t va = 0;
 	uint64_t sum;
 	uint8_t *ptr;
@@ -377,7 +377,7 @@ static void amdgpu_cs_uvd_destroy(void)
 {
 	struct amdgpu_bo_alloc_request req = {0};
 	amdgpu_bo_handle buf_handle;
-	amdgpu_va_handle va_handle;
+	amdgpu_va_handle_t * va_handle;
 	uint64_t va = 0;
 	void *msg;
 	int i, r;
diff --git a/tests/amdgpu/vce_tests.c b/tests/amdgpu/vce_tests.c
index 4915170..4dcd801 100644
--- a/tests/amdgpu/vce_tests.c
+++ b/tests/amdgpu/vce_tests.c
@@ -44,7 +44,7 @@
 
 struct amdgpu_vce_bo {
 	amdgpu_bo_handle handle;
-	amdgpu_va_handle va_handle;
+	amdgpu_va_handle_t * va_handle;
 	uint64_t addr;
 	uint64_t size;
 	uint8_t *ptr;
@@ -69,7 +69,7 @@ static uint32_t vce_harvest_config;
 
 static amdgpu_context_handle context_handle;
 static amdgpu_bo_handle ib_handle;
-static amdgpu_va_handle ib_va_handle;
+static amdgpu_va_handle_t * ib_va_handle;
 static uint64_t ib_mc_address;
 static uint32_t *ib_cpu;
 
@@ -183,7 +183,7 @@ static void alloc_resource(struct amdgpu_vce_bo *vce_bo, unsigned size, unsigned
 {
 	struct amdgpu_bo_alloc_request req = {0};
 	amdgpu_bo_handle buf_handle;
-	amdgpu_va_handle va_handle;
+	amdgpu_va_handle_t * va_handle;
 	uint64_t va = 0;
 	int r;
 
-- 
2.7.4

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/3] amdgpu: Fix amdgpu_semaphore_handle typedef not to hide pointer type
       [not found] ` <1474015570-30928-1-git-send-email-funfunctor-dczkZgxz+BNUPWh3PAxdjQ@public.gmane.org>
  2016-09-16  8:46   ` [PATCH 1/3] amdgpu: Fix amdgpu_va_handle " Edward O'Callaghan
@ 2016-09-16  8:46   ` Edward O'Callaghan
  2016-09-16  8:46   ` [PATCH 3/3] amdgpu: Fix amdgpu_bo_list_handle " Edward O'Callaghan
  2016-09-16  8:49   ` libdrm/amdgpu - Fixup " Christian König
  3 siblings, 0 replies; 8+ messages in thread
From: Edward O'Callaghan @ 2016-09-16  8:46 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

Signed-off-by: Edward O'Callaghan <funfunctor@folklore1984.net>
---
 amdgpu/amdgpu.h            | 10 +++++-----
 amdgpu/amdgpu_cs.c         | 20 ++++++++++----------
 tests/amdgpu/basic_tests.c |  2 +-
 3 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/amdgpu/amdgpu.h b/amdgpu/amdgpu.h
index f322497..9332fab 100644
--- a/amdgpu/amdgpu.h
+++ b/amdgpu/amdgpu.h
@@ -127,7 +127,7 @@ typedef struct amdgpu_va amdgpu_va_handle_t;
 /**
  * Define handle for semaphore
  */
-typedef struct amdgpu_semaphore *amdgpu_semaphore_handle;
+typedef struct amdgpu_semaphore amdgpu_semaphore_handle_t;
 
 /*--------------------------------------------------------------------------*/
 /* -------------------------- Structures ---------------------------------- */
@@ -1194,7 +1194,7 @@ int amdgpu_bo_va_op(amdgpu_bo_handle bo,
  *          <0 - Negative POSIX Error code
  *
 */
-int amdgpu_cs_create_semaphore(amdgpu_semaphore_handle *sem);
+int amdgpu_cs_create_semaphore(amdgpu_semaphore_handle_t ** sem);
 
 /**
  *  signal semaphore
@@ -1213,7 +1213,7 @@ int amdgpu_cs_signal_semaphore(amdgpu_context_handle ctx,
 			       uint32_t ip_type,
 			       uint32_t ip_instance,
 			       uint32_t ring,
-			       amdgpu_semaphore_handle sem);
+			       amdgpu_semaphore_handle_t * sem);
 
 /**
  *  wait semaphore
@@ -1232,7 +1232,7 @@ int amdgpu_cs_wait_semaphore(amdgpu_context_handle ctx,
 			     uint32_t ip_type,
 			     uint32_t ip_instance,
 			     uint32_t ring,
-			     amdgpu_semaphore_handle sem);
+			     amdgpu_semaphore_handle_t * sem);
 
 /**
  *  destroy semaphore
@@ -1243,6 +1243,6 @@ int amdgpu_cs_wait_semaphore(amdgpu_context_handle ctx,
  *          <0 - Negative POSIX Error code
  *
 */
-int amdgpu_cs_destroy_semaphore(amdgpu_semaphore_handle sem);
+int amdgpu_cs_destroy_semaphore(amdgpu_semaphore_handle_t * sem);
 
 #endif /* #ifdef _AMDGPU_H_ */
diff --git a/amdgpu/amdgpu_cs.c b/amdgpu/amdgpu_cs.c
index fb5b3a8..c72825a 100644
--- a/amdgpu/amdgpu_cs.c
+++ b/amdgpu/amdgpu_cs.c
@@ -40,8 +40,8 @@
 #include "amdgpu_drm.h"
 #include "amdgpu_internal.h"
 
-static int amdgpu_cs_unreference_sem(amdgpu_semaphore_handle sem);
-static int amdgpu_cs_reset_sem(amdgpu_semaphore_handle sem);
+static int amdgpu_cs_unreference_sem(amdgpu_semaphore_handle_t * sem);
+static int amdgpu_cs_reset_sem(amdgpu_semaphore_handle_t * sem);
 
 /**
  * Create command submission context
@@ -124,7 +124,7 @@ int amdgpu_cs_ctx_free(amdgpu_context_handle context)
 	for (i = 0; i < AMDGPU_HW_IP_NUM; i++) {
 		for (j = 0; j < AMDGPU_HW_IP_INSTANCE_MAX_COUNT; j++) {
 			for (k = 0; k < AMDGPU_CS_MAX_RINGS; k++) {
-				amdgpu_semaphore_handle sem;
+				amdgpu_semaphore_handle_t * sem;
 				LIST_FOR_EACH_ENTRY(sem, &context->sem_list[i][j][k], list) {
 					list_del(&sem->list);
 					amdgpu_cs_reset_sem(sem);
@@ -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, tmp;
+	amdgpu_semaphore_handle_t * sem, * tmp;
 	uint32_t i, size, sem_count = 0;
 	bool user_fence;
 	int r = 0;
@@ -443,7 +443,7 @@ int amdgpu_cs_query_fence_status(struct amdgpu_cs_fence *fence,
 	return r;
 }
 
-int amdgpu_cs_create_semaphore(amdgpu_semaphore_handle *sem)
+int amdgpu_cs_create_semaphore(amdgpu_semaphore_handle_t ** sem)
 {
 	struct amdgpu_semaphore *gpu_semaphore;
 
@@ -464,7 +464,7 @@ int amdgpu_cs_signal_semaphore(amdgpu_context_handle ctx,
 			       uint32_t ip_type,
 			       uint32_t ip_instance,
 			       uint32_t ring,
-			       amdgpu_semaphore_handle sem)
+			       amdgpu_semaphore_handle_t * sem)
 {
 	if (NULL == ctx)
 		return -EINVAL;
@@ -492,7 +492,7 @@ int amdgpu_cs_wait_semaphore(amdgpu_context_handle ctx,
 			     uint32_t ip_type,
 			     uint32_t ip_instance,
 			     uint32_t ring,
-			     amdgpu_semaphore_handle sem)
+			     amdgpu_semaphore_handle_t * sem)
 {
 	if (NULL == ctx)
 		return -EINVAL;
@@ -512,7 +512,7 @@ int amdgpu_cs_wait_semaphore(amdgpu_context_handle ctx,
 	return 0;
 }
 
-static int amdgpu_cs_reset_sem(amdgpu_semaphore_handle sem)
+static int amdgpu_cs_reset_sem(amdgpu_semaphore_handle_t * sem)
 {
 	if (NULL == sem)
 		return -EINVAL;
@@ -528,7 +528,7 @@ static int amdgpu_cs_reset_sem(amdgpu_semaphore_handle sem)
 	return 0;
 }
 
-static int amdgpu_cs_unreference_sem(amdgpu_semaphore_handle sem)
+static int amdgpu_cs_unreference_sem(amdgpu_semaphore_handle_t * sem)
 {
 	if (NULL == sem)
 		return -EINVAL;
@@ -538,7 +538,7 @@ static int amdgpu_cs_unreference_sem(amdgpu_semaphore_handle sem)
 	return 0;
 }
 
-int amdgpu_cs_destroy_semaphore(amdgpu_semaphore_handle sem)
+int amdgpu_cs_destroy_semaphore(amdgpu_semaphore_handle_t * sem)
 {
 	return amdgpu_cs_unreference_sem(sem);
 }
diff --git a/tests/amdgpu/basic_tests.c b/tests/amdgpu/basic_tests.c
index 40e9ef1..7838249 100644
--- a/tests/amdgpu/basic_tests.c
+++ b/tests/amdgpu/basic_tests.c
@@ -479,7 +479,7 @@ static void amdgpu_command_submission_gfx(void)
 static void amdgpu_semaphore_test(void)
 {
 	amdgpu_context_handle context_handle[2];
-	amdgpu_semaphore_handle sem;
+	amdgpu_semaphore_handle_t * sem;
 	amdgpu_bo_handle ib_result_handle[2];
 	void *ib_result_cpu[2];
 	uint64_t ib_result_mc_address[2];
-- 
2.7.4

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/3] amdgpu: Fix amdgpu_bo_list_handle typedef not to hide pointer type
       [not found] ` <1474015570-30928-1-git-send-email-funfunctor-dczkZgxz+BNUPWh3PAxdjQ@public.gmane.org>
  2016-09-16  8:46   ` [PATCH 1/3] amdgpu: Fix amdgpu_va_handle " Edward O'Callaghan
  2016-09-16  8:46   ` [PATCH 2/3] amdgpu: Fix amdgpu_semaphore_handle " Edward O'Callaghan
@ 2016-09-16  8:46   ` Edward O'Callaghan
  2016-09-16  8:49   ` libdrm/amdgpu - Fixup " Christian König
  3 siblings, 0 replies; 8+ messages in thread
From: Edward O'Callaghan @ 2016-09-16  8:46 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

Signed-off-by: Edward O'Callaghan <funfunctor@folklore1984.net>
---
 amdgpu/amdgpu.h            | 10 +++++-----
 amdgpu/amdgpu_bo.c         |  6 +++---
 tests/amdgpu/amdgpu_test.h |  2 +-
 tests/amdgpu/basic_tests.c |  8 ++++----
 4 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/amdgpu/amdgpu.h b/amdgpu/amdgpu.h
index 9332fab..77ddb87 100644
--- a/amdgpu/amdgpu.h
+++ b/amdgpu/amdgpu.h
@@ -117,7 +117,7 @@ typedef struct amdgpu_bo *amdgpu_bo_handle;
 /**
  * Define handle for list of BOs
  */
-typedef struct amdgpu_bo_list *amdgpu_bo_list_handle;
+typedef struct amdgpu_bo_list amdgpu_bo_list_handle_t;
 
 /**
  * Define handle to be used to work with VA allocated ranges
@@ -332,7 +332,7 @@ struct amdgpu_cs_request {
 	/**
 	 * List handle with resources used by this request.
 	 */
-	amdgpu_bo_list_handle resources;
+	amdgpu_bo_list_handle_t * resources;
 
 	/**
 	 * Number of dependencies this Command submission needs to
@@ -747,7 +747,7 @@ 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);
+			  amdgpu_bo_list_handle_t ** result);
 
 /**
  * Destroys a BO list handle.
@@ -759,7 +759,7 @@ int amdgpu_bo_list_create(amdgpu_device_handle dev,
  *
  * \sa amdgpu_bo_list_create()
 */
-int amdgpu_bo_list_destroy(amdgpu_bo_list_handle handle);
+int amdgpu_bo_list_destroy(amdgpu_bo_list_handle_t * handle);
 
 /**
  * Update resources for existing BO list
@@ -774,7 +774,7 @@ int amdgpu_bo_list_destroy(amdgpu_bo_list_handle handle);
  *
  * \sa amdgpu_bo_list_update()
 */
-int amdgpu_bo_list_update(amdgpu_bo_list_handle handle,
+int amdgpu_bo_list_update(amdgpu_bo_list_handle_t * handle,
 			  uint32_t number_of_resources,
 			  amdgpu_bo_handle *resources,
 			  uint8_t *resource_prios);
diff --git a/amdgpu/amdgpu_bo.c b/amdgpu/amdgpu_bo.c
index d30fd1e..e57e733 100644
--- a/amdgpu/amdgpu_bo.c
+++ b/amdgpu/amdgpu_bo.c
@@ -565,7 +565,7 @@ 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)
+			  amdgpu_bo_list_handle_t ** result)
 {
 	struct drm_amdgpu_bo_list_entry *list;
 	union drm_amdgpu_bo_list args;
@@ -616,7 +616,7 @@ int amdgpu_bo_list_create(amdgpu_device_handle dev,
 	return 0;
 }
 
-int amdgpu_bo_list_destroy(amdgpu_bo_list_handle list)
+int amdgpu_bo_list_destroy(amdgpu_bo_list_handle_t * list)
 {
 	union drm_amdgpu_bo_list args;
 	int r;
@@ -634,7 +634,7 @@ int amdgpu_bo_list_destroy(amdgpu_bo_list_handle list)
 	return r;
 }
 
-int amdgpu_bo_list_update(amdgpu_bo_list_handle handle,
+int amdgpu_bo_list_update(amdgpu_bo_list_handle_t * handle,
 			  uint32_t number_of_resources,
 			  amdgpu_bo_handle *resources,
 			  uint8_t *resource_prios)
diff --git a/tests/amdgpu/amdgpu_test.h b/tests/amdgpu/amdgpu_test.h
index acf3359..d4f1873 100644
--- a/tests/amdgpu/amdgpu_test.h
+++ b/tests/amdgpu/amdgpu_test.h
@@ -226,7 +226,7 @@ amdgpu_bo_unmap_and_free(amdgpu_bo_handle bo, amdgpu_va_handle_t * va_handle,
 
 static inline int
 amdgpu_get_bo_list(amdgpu_device_handle dev, amdgpu_bo_handle bo1,
-		   amdgpu_bo_handle bo2, amdgpu_bo_list_handle *list)
+		   amdgpu_bo_handle bo2, amdgpu_bo_list_handle_t ** list)
 {
 	amdgpu_bo_handle resources[] = {bo1, bo2};
 
diff --git a/tests/amdgpu/basic_tests.c b/tests/amdgpu/basic_tests.c
index 7838249..509154c 100644
--- a/tests/amdgpu/basic_tests.c
+++ b/tests/amdgpu/basic_tests.c
@@ -292,7 +292,7 @@ static void amdgpu_command_submission_gfx_separate_ibs(void)
 	struct amdgpu_cs_fence fence_status = {0};
 	uint32_t *ptr;
 	uint32_t expired;
-	amdgpu_bo_list_handle bo_list;
+	amdgpu_bo_list_handle_t * bo_list;
 	amdgpu_va_handle_t * va_handle, va_handle_ce;
 	int r;
 
@@ -381,7 +381,7 @@ static void amdgpu_command_submission_gfx_shared_ib(void)
 	struct amdgpu_cs_fence fence_status = {0};
 	uint32_t *ptr;
 	uint32_t expired;
-	amdgpu_bo_list_handle bo_list;
+	amdgpu_bo_list_handle_t * bo_list;
 	amdgpu_va_handle_t * va_handle;
 	int r;
 
@@ -488,7 +488,7 @@ static void amdgpu_semaphore_test(void)
 	struct amdgpu_cs_fence fence_status = {0};
 	uint32_t *ptr;
 	uint32_t expired;
-	amdgpu_bo_list_handle bo_list[2];
+	amdgpu_bo_list_handle_t * bo_list[2];
 	amdgpu_va_handle_t * va_handle[2];
 	int r, i;
 
@@ -618,7 +618,7 @@ static void amdgpu_command_submission_compute_nop(void)
 	uint32_t *ptr;
 	uint32_t expired;
 	int i, r, instance;
-	amdgpu_bo_list_handle bo_list;
+	amdgpu_bo_list_handle_t * bo_list;
 	amdgpu_va_handle_t * va_handle;
 
 	r = amdgpu_cs_ctx_create(device_handle, &context_handle);
-- 
2.7.4

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: libdrm/amdgpu - Fixup typedef not to hide pointer type
       [not found] ` <1474015570-30928-1-git-send-email-funfunctor-dczkZgxz+BNUPWh3PAxdjQ@public.gmane.org>
                     ` (2 preceding siblings ...)
  2016-09-16  8:46   ` [PATCH 3/3] amdgpu: Fix amdgpu_bo_list_handle " Edward O'Callaghan
@ 2016-09-16  8:49   ` Christian König
       [not found]     ` <98564703-e915-2729-b5c9-43afddc881a5-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
  3 siblings, 1 reply; 8+ messages in thread
From: Christian König @ 2016-09-16  8:49 UTC (permalink / raw)
  To: Edward O'Callaghan, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

NAK, that is clearly an API breakage.

BTW: Why would we want to stop hiding the type?

Christian.

Am 16.09.2016 um 10:46 schrieb Edward O'Callaghan:
> Oops, turns out I mailed to dri-devel by mistake so resending here.
>
> The following series fixes up libdrm/amdgpu such that to not hide
> a pointer type behind a typedef.
>
> Please Review,
>
> Edward O'Callaghan (3):
>   [PATCH 1/3] amdgpu: Fix amdgpu_va_handle typedef not to hide pointer
>   [PATCH 2/3] amdgpu: Fix amdgpu_semaphore_handle typedef not to hide
>   [PATCH 3/3] amdgpu: Fix amdgpu_bo_list_handle typedef not to hide
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx


_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: libdrm/amdgpu - Fixup typedef not to hide pointer type
       [not found]     ` <98564703-e915-2729-b5c9-43afddc881a5-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
@ 2016-09-16  9:02       ` Edward O'Callaghan
       [not found]         ` <bc823f27-6163-1688-9cf0-0c8b5934111d-dczkZgxz+BNUPWh3PAxdjQ@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Edward O'Callaghan @ 2016-09-16  9:02 UTC (permalink / raw)
  To: Christian König, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW


[-- Attachment #1.1.1: Type: text/plain, Size: 1674 bytes --]

Hi Christian,

On 09/16/2016 06:49 PM, Christian König wrote:
> NAK, that is clearly an API breakage.

It should have never been typedef'ed in the first place. Does that mean
we would have to bump version for API change? What is the procedure there?

> 
> BTW: Why would we want to stop hiding the type?

Quite a few reasons, I'll start with to justify the change:

https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/CodingStyle?id=refs/tags/v4.8-rc6#n276

Suppose you have 'amdgpu_semaphore_handle' as typedef of a pointer type
and you had some function 'void f(amdgpu_semaphore_handle * h) {}'.
Suppose now, within 'f()' we deference 'h' and use the result in some
way. The issue is that it is not directly obvious that we have a double
pointer type and so while it maybe the case that '(*h != NULL)' it could
well be the case that '(h == NULL)'.

Kind Regards,
Edward.

> 
> Christian.
> 
> Am 16.09.2016 um 10:46 schrieb Edward O'Callaghan:
>> Oops, turns out I mailed to dri-devel by mistake so resending here.
>>
>> The following series fixes up libdrm/amdgpu such that to not hide
>> a pointer type behind a typedef.
>>
>> Please Review,
>>
>> Edward O'Callaghan (3):
>>   [PATCH 1/3] amdgpu: Fix amdgpu_va_handle typedef not to hide pointer
>>   [PATCH 2/3] amdgpu: Fix amdgpu_semaphore_handle typedef not to hide
>>   [PATCH 3/3] amdgpu: Fix amdgpu_bo_list_handle typedef not to hide
>> _______________________________________________
>> amd-gfx mailing list
>> amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
>> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
> 
> 


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

[-- Attachment #2: Type: text/plain, Size: 154 bytes --]

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: libdrm/amdgpu - Fixup typedef not to hide pointer type
       [not found]         ` <bc823f27-6163-1688-9cf0-0c8b5934111d-dczkZgxz+BNUPWh3PAxdjQ@public.gmane.org>
@ 2016-09-16  9:12           ` Christian König
       [not found]             ` <223e0fa5-bb37-c9d8-9d04-b9ef29d0d9f7-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Christian König @ 2016-09-16  9:12 UTC (permalink / raw)
  To: Edward O'Callaghan, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

Am 16.09.2016 um 11:02 schrieb Edward O'Callaghan:
> Hi Christian,
>
> On 09/16/2016 06:49 PM, Christian König wrote:
>> NAK, that is clearly an API breakage.
> It should have never been typedef'ed in the first place. Does that mean
> we would have to bump version for API change? What is the procedure there?

Keep it as it is, you can't change it even if we bump the version number 
you would break existing userspace.

>
>> BTW: Why would we want to stop hiding the type?
> Quite a few reasons, I'll start with to justify the change:
>
> https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/CodingStyle?id=refs/tags/v4.8-rc6#n276

This doesn't apply here, this is a user space library interface and not 
the kernel.

The structure types are not defined outside of the library and so you 
can't dereference or NULL check them.

Regards,
Christian.

>
> Suppose you have 'amdgpu_semaphore_handle' as typedef of a pointer type
> and you had some function 'void f(amdgpu_semaphore_handle * h) {}'.
> Suppose now, within 'f()' we deference 'h' and use the result in some
> way. The issue is that it is not directly obvious that we have a double
> pointer type and so while it maybe the case that '(*h != NULL)' it could
> well be the case that '(h == NULL)'.
>
> Kind Regards,
> Edward.
>
>> Christian.
>>
>> Am 16.09.2016 um 10:46 schrieb Edward O'Callaghan:
>>> Oops, turns out I mailed to dri-devel by mistake so resending here.
>>>
>>> The following series fixes up libdrm/amdgpu such that to not hide
>>> a pointer type behind a typedef.
>>>
>>> Please Review,
>>>
>>> Edward O'Callaghan (3):
>>>    [PATCH 1/3] amdgpu: Fix amdgpu_va_handle typedef not to hide pointer
>>>    [PATCH 2/3] amdgpu: Fix amdgpu_semaphore_handle typedef not to hide
>>>    [PATCH 3/3] amdgpu: Fix amdgpu_bo_list_handle typedef not to hide
>>> _______________________________________________
>>> amd-gfx mailing list
>>> amd-gfx@lists.freedesktop.org
>>> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
>>

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: libdrm/amdgpu - Fixup typedef not to hide pointer type
       [not found]             ` <223e0fa5-bb37-c9d8-9d04-b9ef29d0d9f7-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
@ 2016-09-16 10:49               ` Christian König
  0 siblings, 0 replies; 8+ messages in thread
From: Christian König @ 2016-09-16 10:49 UTC (permalink / raw)
  To: Edward O'Callaghan, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

Well thinking more about that what you probably could do is changing the 
typedefs to put the pointer into a single element structure.

That should break only when somebody really abused the API and shouldn't 
change the ABI.

Regards,
Christian.

Am 16.09.2016 um 11:12 schrieb Christian König:
> Am 16.09.2016 um 11:02 schrieb Edward O'Callaghan:
>> Hi Christian,
>>
>> On 09/16/2016 06:49 PM, Christian König wrote:
>>> NAK, that is clearly an API breakage.
>> It should have never been typedef'ed in the first place. Does that mean
>> we would have to bump version for API change? What is the procedure 
>> there?
>
> Keep it as it is, you can't change it even if we bump the version 
> number you would break existing userspace.
>
>>
>>> BTW: Why would we want to stop hiding the type?
>> Quite a few reasons, I'll start with to justify the change:
>>
>> https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/CodingStyle?id=refs/tags/v4.8-rc6#n276 
>>
>
> This doesn't apply here, this is a user space library interface and 
> not the kernel.
>
> The structure types are not defined outside of the library and so you 
> can't dereference or NULL check them.
>
> Regards,
> Christian.
>
>>
>> Suppose you have 'amdgpu_semaphore_handle' as typedef of a pointer type
>> and you had some function 'void f(amdgpu_semaphore_handle * h) {}'.
>> Suppose now, within 'f()' we deference 'h' and use the result in some
>> way. The issue is that it is not directly obvious that we have a double
>> pointer type and so while it maybe the case that '(*h != NULL)' it could
>> well be the case that '(h == NULL)'.
>>
>> Kind Regards,
>> Edward.
>>
>>> Christian.
>>>
>>> Am 16.09.2016 um 10:46 schrieb Edward O'Callaghan:
>>>> Oops, turns out I mailed to dri-devel by mistake so resending here.
>>>>
>>>> The following series fixes up libdrm/amdgpu such that to not hide
>>>> a pointer type behind a typedef.
>>>>
>>>> Please Review,
>>>>
>>>> Edward O'Callaghan (3):
>>>>    [PATCH 1/3] amdgpu: Fix amdgpu_va_handle typedef not to hide 
>>>> pointer
>>>>    [PATCH 2/3] amdgpu: Fix amdgpu_semaphore_handle typedef not to hide
>>>>    [PATCH 3/3] amdgpu: Fix amdgpu_bo_list_handle typedef not to hide
>>>> _______________________________________________
>>>> amd-gfx mailing list
>>>> amd-gfx@lists.freedesktop.org
>>>> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
>>>
>

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-09-16 10:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-16  8:46 libdrm/amdgpu - Fixup typedef not to hide pointer type Edward O'Callaghan
     [not found] ` <1474015570-30928-1-git-send-email-funfunctor-dczkZgxz+BNUPWh3PAxdjQ@public.gmane.org>
2016-09-16  8:46   ` [PATCH 1/3] amdgpu: Fix amdgpu_va_handle " Edward O'Callaghan
2016-09-16  8:46   ` [PATCH 2/3] amdgpu: Fix amdgpu_semaphore_handle " Edward O'Callaghan
2016-09-16  8:46   ` [PATCH 3/3] amdgpu: Fix amdgpu_bo_list_handle " Edward O'Callaghan
2016-09-16  8:49   ` libdrm/amdgpu - Fixup " Christian König
     [not found]     ` <98564703-e915-2729-b5c9-43afddc881a5-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2016-09-16  9:02       ` Edward O'Callaghan
     [not found]         ` <bc823f27-6163-1688-9cf0-0c8b5934111d-dczkZgxz+BNUPWh3PAxdjQ@public.gmane.org>
2016-09-16  9:12           ` Christian König
     [not found]             ` <223e0fa5-bb37-c9d8-9d04-b9ef29d0d9f7-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2016-09-16 10:49               ` Christian König

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.