[Mesa-dev] [PATCH] ac: change ac_query_gpu_info() signatures

Emil Velikov emil.l.velikov at gmail.com
Fri Jun 21 17:11:24 UTC 2019


From: Emil Velikov <emil.velikov at collabora.com>

Currently libdrm_amdgpu provides a typedef of the various handles. While
the goal was to make those opaque, it effectively became part of the API

To the best of my knowledge there are two ways to have opaque handles:
 - "typedef void *foo;" - rather messy IMHO
 - "stuct foo;" and use "struct foo *" through the API

In our case amdgpU_device_handle is used only internally, plus
respective code is not used or applicable for r300 and r600. Hence  we
copied the typedef.

Seemingly this will be a problem since a libdrm_amdgpu wants to change
the API, while not updating the code(?).

Either way, we can safely s/amdgpU_device_handle/void */ and carry on.

Cc: Michel Dänzer <michel at daenzer.net>
Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
---
 src/amd/common/ac_gpu_info.c | 3 ++-
 src/amd/common/ac_gpu_info.h | 4 +---
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/amd/common/ac_gpu_info.c b/src/amd/common/ac_gpu_info.c
index db7f9e47ce1..8bd47cc26b3 100644
--- a/src/amd/common/ac_gpu_info.c
+++ b/src/amd/common/ac_gpu_info.c
@@ -92,7 +92,7 @@ static bool has_syncobj(int fd)
 	return value ? true : false;
 }
 
-bool ac_query_gpu_info(int fd, amdgpu_device_handle dev,
+bool ac_query_gpu_info(int fd, void *dev_p,
 		       struct radeon_info *info,
 		       struct amdgpu_gpu_info *amdinfo)
 {
@@ -104,6 +104,7 @@ bool ac_query_gpu_info(int fd, amdgpu_device_handle dev,
 	struct amdgpu_gds_resource_info gds = {};
 	uint32_t vce_version = 0, vce_feature = 0, uvd_version = 0, uvd_feature = 0;
 	int r, i, j;
+	amdgpu_device_handle dev = dev_p;
 	drmDevicePtr devinfo;
 
 	/* Get PCI info. */
diff --git a/src/amd/common/ac_gpu_info.h b/src/amd/common/ac_gpu_info.h
index 11fb77eee87..ba4940af142 100644
--- a/src/amd/common/ac_gpu_info.h
+++ b/src/amd/common/ac_gpu_info.h
@@ -35,8 +35,6 @@
 extern "C" {
 #endif
 
-/* Prior to C11 the following may trigger a typedef redeclaration warning */
-typedef struct amdgpu_device *amdgpu_device_handle;
 struct amdgpu_gpu_info;
 
 struct radeon_info {
@@ -147,7 +145,7 @@ struct radeon_info {
 	uint32_t                    cik_macrotile_mode_array[16];
 };
 
-bool ac_query_gpu_info(int fd, amdgpu_device_handle dev,
+bool ac_query_gpu_info(int fd, void *dev_p,
 		       struct radeon_info *info,
 		       struct amdgpu_gpu_info *amdinfo);
 
-- 
2.21.0



More information about the mesa-dev mailing list