summaryrefslogtreecommitdiff
path: root/amdgpu
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2021-10-03 19:38:48 +0200
committerSimon Ser <contact@emersion.fr>2021-10-06 09:03:21 +0200
commitef77e5e1eb6f17a653911342c5c1f7392a13d873 (patch)
tree4e6a8152f067c80df8840746f8f06b88ebc70e7b /amdgpu
parentbd26b61cff33517840b3f1900bbe1849b8672f65 (diff)
downloadlibdrm-ef77e5e1eb6f17a653911342c5c1f7392a13d873.tar.gz
libdrm-ef77e5e1eb6f17a653911342c5c1f7392a13d873.tar.bz2
libdrm-ef77e5e1eb6f17a653911342c5c1f7392a13d873.zip
amdgpu: use drmCloseBufferHandle
Instead of using a hand-rolled amdgpu_close_kms_handle function, use the function from libdrm core, which does exactly the same thing. Signed-off-by: Simon Ser <contact@emersion.fr> Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Diffstat (limited to 'amdgpu')
-rw-r--r--amdgpu/amdgpu_bo.c24
1 files changed, 8 insertions, 16 deletions
diff --git a/amdgpu/amdgpu_bo.c b/amdgpu/amdgpu_bo.c
index 5bdb8fe8..54b1fb90 100644
--- a/amdgpu/amdgpu_bo.c
+++ b/amdgpu/amdgpu_bo.c
@@ -39,14 +39,6 @@
#include "amdgpu_internal.h"
#include "util_math.h"
-static int amdgpu_close_kms_handle(int fd, uint32_t handle)
-{
- struct drm_gem_close args = {};
-
- args.handle = handle;
- return drmIoctl(fd, DRM_IOCTL_GEM_CLOSE, &args);
-}
-
static int amdgpu_bo_create(amdgpu_device_handle dev,
uint64_t size,
uint32_t handle,
@@ -101,7 +93,7 @@ drm_public int amdgpu_bo_alloc(amdgpu_device_handle dev,
buf_handle);
pthread_mutex_unlock(&dev->bo_table_mutex);
if (r) {
- amdgpu_close_kms_handle(dev->fd, args.out.handle);
+ drmCloseBufferHandle(dev->fd, args.out.handle);
}
out:
@@ -216,7 +208,7 @@ static int amdgpu_bo_export_flink(amdgpu_bo_handle bo)
bo->flink_name = flink.name;
if (bo->dev->flink_fd != bo->dev->fd)
- amdgpu_close_kms_handle(bo->dev->flink_fd, handle);
+ drmCloseBufferHandle(bo->dev->flink_fd, handle);
pthread_mutex_lock(&bo->dev->bo_table_mutex);
r = handle_table_insert(&bo->dev->bo_flink_names, bo->flink_name, bo);
@@ -342,8 +334,8 @@ drm_public int amdgpu_bo_import(amdgpu_device_handle dev,
close(dma_fd);
if (r)
goto free_bo_handle;
- r = amdgpu_close_kms_handle(dev->flink_fd,
- open_arg.handle);
+ r = drmCloseBufferHandle(dev->flink_fd,
+ open_arg.handle);
if (r)
goto free_bo_handle;
}
@@ -381,12 +373,12 @@ drm_public int amdgpu_bo_import(amdgpu_device_handle dev,
free_bo_handle:
if (flink_name && open_arg.handle)
- amdgpu_close_kms_handle(dev->flink_fd, open_arg.handle);
+ drmCloseBufferHandle(dev->flink_fd, open_arg.handle);
if (bo)
amdgpu_bo_free(bo);
else
- amdgpu_close_kms_handle(dev->fd, handle);
+ drmCloseBufferHandle(dev->fd, handle);
unlock:
pthread_mutex_unlock(&dev->bo_table_mutex);
return r;
@@ -415,7 +407,7 @@ drm_public int amdgpu_bo_free(amdgpu_bo_handle buf_handle)
amdgpu_bo_cpu_unmap(bo);
}
- amdgpu_close_kms_handle(dev->fd, bo->handle);
+ drmCloseBufferHandle(dev->fd, bo->handle);
pthread_mutex_destroy(&bo->cpu_access_mutex);
free(bo);
}
@@ -598,7 +590,7 @@ drm_public int amdgpu_create_bo_from_user_mem(amdgpu_device_handle dev,
r = amdgpu_bo_create(dev, size, args.handle, buf_handle);
pthread_mutex_unlock(&dev->bo_table_mutex);
if (r) {
- amdgpu_close_kms_handle(dev->fd, args.handle);
+ drmCloseBufferHandle(dev->fd, args.handle);
}
out: