amdgpu: hide the final internal functions from global namespace
Thus the only symbols that we export are the ones officially provided by the API. Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com> Reviewed-by: Jammy Zhou <Jammy.Zhou@amd.com>main
parent
b471818977
commit
bddf4df4a1
|
@ -53,7 +53,7 @@ static void amdgpu_close_kms_handle(amdgpu_device_handle dev,
|
||||||
drmIoctl(dev->fd, DRM_IOCTL_GEM_CLOSE, &args);
|
drmIoctl(dev->fd, DRM_IOCTL_GEM_CLOSE, &args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void amdgpu_bo_free_internal(amdgpu_bo_handle bo)
|
drm_private void amdgpu_bo_free_internal(amdgpu_bo_handle bo)
|
||||||
{
|
{
|
||||||
/* Remove the buffer from the hash tables. */
|
/* Remove the buffer from the hash tables. */
|
||||||
pthread_mutex_lock(&bo->dev->bo_table_mutex);
|
pthread_mutex_lock(&bo->dev->bo_table_mutex);
|
||||||
|
|
|
@ -290,7 +290,7 @@ int amdgpu_cs_submit(amdgpu_context_handle context,
|
||||||
*
|
*
|
||||||
* \return absolute timeout in nanoseconds
|
* \return absolute timeout in nanoseconds
|
||||||
*/
|
*/
|
||||||
uint64_t amdgpu_cs_calculate_timeout(uint64_t timeout)
|
drm_private uint64_t amdgpu_cs_calculate_timeout(uint64_t timeout)
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@
|
||||||
#define PTR_TO_UINT(x) ((unsigned)((intptr_t)(x)))
|
#define PTR_TO_UINT(x) ((unsigned)((intptr_t)(x)))
|
||||||
#define UINT_TO_PTR(x) ((void *)((intptr_t)(x)))
|
#define UINT_TO_PTR(x) ((void *)((intptr_t)(x)))
|
||||||
|
|
||||||
pthread_mutex_t fd_mutex = PTHREAD_MUTEX_INITIALIZER;
|
static pthread_mutex_t fd_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||||
static struct util_hash_table *fd_tab;
|
static struct util_hash_table *fd_tab;
|
||||||
|
|
||||||
static unsigned handle_hash(void *key)
|
static unsigned handle_hash(void *key)
|
||||||
|
@ -127,6 +127,41 @@ static int amdgpu_get_auth(int fd, int *auth)
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void amdgpu_device_free_internal(amdgpu_device_handle dev)
|
||||||
|
{
|
||||||
|
amdgpu_vamgr_reference(&dev->vamgr, NULL);
|
||||||
|
util_hash_table_destroy(dev->bo_flink_names);
|
||||||
|
util_hash_table_destroy(dev->bo_handles);
|
||||||
|
pthread_mutex_destroy(&dev->bo_table_mutex);
|
||||||
|
util_hash_table_remove(fd_tab, UINT_TO_PTR(dev->fd));
|
||||||
|
close(dev->fd);
|
||||||
|
if ((dev->flink_fd >= 0) && (dev->fd != dev->flink_fd))
|
||||||
|
close(dev->flink_fd);
|
||||||
|
free(dev);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assignment between two amdgpu_device pointers with reference counting.
|
||||||
|
*
|
||||||
|
* Usage:
|
||||||
|
* struct amdgpu_device *dst = ... , *src = ...;
|
||||||
|
*
|
||||||
|
* dst = src;
|
||||||
|
* // No reference counting. Only use this when you need to move
|
||||||
|
* // a reference from one pointer to another.
|
||||||
|
*
|
||||||
|
* amdgpu_device_reference(&dst, src);
|
||||||
|
* // Reference counters are updated. dst is decremented and src is
|
||||||
|
* // incremented. dst is freed if its reference counter is 0.
|
||||||
|
*/
|
||||||
|
static void amdgpu_device_reference(struct amdgpu_device **dst,
|
||||||
|
struct amdgpu_device *src)
|
||||||
|
{
|
||||||
|
if (update_references(&(*dst)->refcount, &src->refcount))
|
||||||
|
amdgpu_device_free_internal(*dst);
|
||||||
|
*dst = src;
|
||||||
|
}
|
||||||
|
|
||||||
int amdgpu_device_initialize(int fd,
|
int amdgpu_device_initialize(int fd,
|
||||||
uint32_t *major_version,
|
uint32_t *major_version,
|
||||||
uint32_t *minor_version,
|
uint32_t *minor_version,
|
||||||
|
@ -232,29 +267,8 @@ cleanup:
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
void amdgpu_device_free_internal(amdgpu_device_handle dev)
|
|
||||||
{
|
|
||||||
amdgpu_vamgr_reference(&dev->vamgr, NULL);
|
|
||||||
util_hash_table_destroy(dev->bo_flink_names);
|
|
||||||
util_hash_table_destroy(dev->bo_handles);
|
|
||||||
pthread_mutex_destroy(&dev->bo_table_mutex);
|
|
||||||
util_hash_table_remove(fd_tab, UINT_TO_PTR(dev->fd));
|
|
||||||
close(dev->fd);
|
|
||||||
if ((dev->flink_fd >= 0) && (dev->fd != dev->flink_fd))
|
|
||||||
close(dev->flink_fd);
|
|
||||||
free(dev);
|
|
||||||
}
|
|
||||||
|
|
||||||
int amdgpu_device_deinitialize(amdgpu_device_handle dev)
|
int amdgpu_device_deinitialize(amdgpu_device_handle dev)
|
||||||
{
|
{
|
||||||
amdgpu_device_reference(&dev, NULL);
|
amdgpu_device_reference(&dev, NULL);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void amdgpu_device_reference(struct amdgpu_device **dst,
|
|
||||||
struct amdgpu_device *src)
|
|
||||||
{
|
|
||||||
if (update_references(&(*dst)->refcount, &src->refcount))
|
|
||||||
amdgpu_device_free_internal(*dst);
|
|
||||||
*dst = src;
|
|
||||||
}
|
|
||||||
|
|
|
@ -140,7 +140,7 @@ int amdgpu_query_firmware_version(amdgpu_device_handle dev, unsigned fw_type,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int amdgpu_query_gpu_info_init(amdgpu_device_handle dev)
|
drm_private int amdgpu_query_gpu_info_init(amdgpu_device_handle dev)
|
||||||
{
|
{
|
||||||
int r, i;
|
int r, i;
|
||||||
|
|
||||||
|
|
|
@ -119,9 +119,7 @@ struct amdgpu_context {
|
||||||
* Functions.
|
* Functions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void amdgpu_device_free_internal(amdgpu_device_handle dev);
|
drm_private void amdgpu_bo_free_internal(amdgpu_bo_handle bo);
|
||||||
|
|
||||||
void amdgpu_bo_free_internal(amdgpu_bo_handle bo);
|
|
||||||
|
|
||||||
drm_private struct amdgpu_bo_va_mgr*
|
drm_private struct amdgpu_bo_va_mgr*
|
||||||
amdgpu_vamgr_get_global(struct amdgpu_device *dev);
|
amdgpu_vamgr_get_global(struct amdgpu_device *dev);
|
||||||
|
@ -137,9 +135,9 @@ amdgpu_vamgr_find_va(struct amdgpu_bo_va_mgr *mgr, uint64_t size,
|
||||||
drm_private void
|
drm_private void
|
||||||
amdgpu_vamgr_free_va(struct amdgpu_bo_va_mgr *mgr, uint64_t va, uint64_t size);
|
amdgpu_vamgr_free_va(struct amdgpu_bo_va_mgr *mgr, uint64_t va, uint64_t size);
|
||||||
|
|
||||||
int amdgpu_query_gpu_info_init(amdgpu_device_handle dev);
|
drm_private int amdgpu_query_gpu_info_init(amdgpu_device_handle dev);
|
||||||
|
|
||||||
uint64_t amdgpu_cs_calculate_timeout(uint64_t timeout);
|
drm_private uint64_t amdgpu_cs_calculate_timeout(uint64_t timeout);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inline functions.
|
* Inline functions.
|
||||||
|
@ -189,20 +187,4 @@ static inline void amdgpu_bo_reference(struct amdgpu_bo **dst,
|
||||||
*dst = src;
|
*dst = src;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Assignment between two amdgpu_device pointers with reference counting.
|
|
||||||
*
|
|
||||||
* Usage:
|
|
||||||
* struct amdgpu_device *dst = ... , *src = ...;
|
|
||||||
*
|
|
||||||
* dst = src;
|
|
||||||
* // No reference counting. Only use this when you need to move
|
|
||||||
* // a reference from one pointer to another.
|
|
||||||
*
|
|
||||||
* amdgpu_device_reference(&dst, src);
|
|
||||||
* // Reference counters are updated. dst is decremented and src is
|
|
||||||
* // incremented. dst is freed if its reference counter is 0.
|
|
||||||
*/
|
|
||||||
void amdgpu_device_reference(struct amdgpu_device **dst,
|
|
||||||
struct amdgpu_device *src);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue