amdgpu: only add DRM_RDWR when kernel accept it
PATCH 1/1 amdgpu: only add DRM_RDWR when kernel accept it
For kernel < 4.6 drm_prime_handle_to_fd_ioctl won't accept DRM_RDWR.
--- amdgpu/amdgpu_bo.c | 8 ++++++-- amdgpu/amdgpu_internal.h | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-)
amdgpu/amdgpu_bo.c +6 -2
@@ -229,6 +229,7 @@ int amdgpu_bo_export(amdgpu_bo_handle bo, uint32_t *shared_handle) {int r; +uint32_t flags;switch (type) {case amdgpu_bo_handle_type_gem_flink_name:
@@ -246,8 +247,11 @@ int amdgpu_bo_export(amdgpu_bo_handle bo,case amdgpu_bo_handle_type_dma_buf_fd:amdgpu_add_handle_to_table (bo); -return drmPrimeHandleToFD (bo->dev->fd, bo->handle, -DRM_CLOEXEC |DRM_RDWR , + flags =DRM_CLOEXEC ; +if (AMDGPU_VERSION (bo->dev->major_version, bo->dev->minor_version) >= +AMDGPU_VERSION (3 ,1 )) + flags |=DRM_RDWR ; +return drmPrimeHandleToFD (bo->dev->fd, bo->handle, flags, (int *)shared_handle); }return -EINVAL ;
amdgpu/amdgpu_internal.h +2 -0
@@ -39,6 +39,8 @@#define ROUND_UP (x, y) ((((x)-1) | __round_mask(x, y))+1)#define ROUND_DOWN (x, y) ((x) & ~__round_mask(x, y)) +#define AMDGPU_VERSION (major, minor) ((major << 16) | minor) +#define AMDGPU_INVALID_VA_ADDRESS 0xffffffffffffffff#define AMDGPU_NULL_SUBMIT_SEQ 0
Signature · 6 lines
1.9.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 1523954887-5458-1-git-send-email-Qiang.Yu-5C7GfCeVMHo@public.gmane.org
Hi guys,
CCing: dri-devel.
question to the usual suspects here: Does somebody of hand knows when DRM_RDWR was added and how we can check reliable if it's available or not?
Using the version number of amdgpu for this sounds a bit questionable, cause that reflects amdgpu functionality level and not DRM prime functionality level.
Thanks,
Christian.
Am 17.04.2018 um 10:48 schrieb Qiang Yu:
Quoted 40 lines
For kernel < 4.6
drm_prime_handle_to_fd_ioctlwon't acceptDRM_RDWR.Sigend-off-by Qiang Yu <[email protected]>--- amdgpu/amdgpu_bo.c | 8 ++++++-- amdgpu/amdgpu_internal.h | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-)amdgpu/amdgpu_bo.c +6
-2@@ -229,6 +229,7 @@ int amdgpu_bo_export(amdgpu_bo_handle bo, uint32_t *shared_handle) {int r; +uint32_t flags;switch (type) {case amdgpu_bo_handle_type_gem_flink_name:@@ -246,8 +247,11 @@ int amdgpu_bo_export(amdgpu_bo_handle bo,case amdgpu_bo_handle_type_dma_buf_fd:amdgpu_add_handle_to_table (bo); -return drmPrimeHandleToFD (bo->dev->fd, bo->handle, -DRM_CLOEXEC |DRM_RDWR , + flags =DRM_CLOEXEC ; +if (AMDGPU_VERSION (bo->dev->major_version, bo->dev->minor_version) >= +AMDGPU_VERSION (3 ,1 )) + flags |=DRM_RDWR ; +return drmPrimeHandleToFD (bo->dev->fd, bo->handle, flags, (int *)shared_handle); }return -EINVAL ;amdgpu/amdgpu_internal.h +0
-0
amdgpu/amdgpu_internal.h line 46
Quoted 8 lines
amdgpu/amdgpu_internal.h +2
-0@@ -39,6 +39,8 @@#define ROUND_UP (x, y) ((((x)-1) | __round_mask(x, y))+1)#define ROUND_DOWN (x, y) ((x) & ~__round_mask(x, y)) +#define AMDGPU_VERSION (major, minor) ((major << 16) | minor) +#define AMDGPU_INVALID_VA_ADDRESS 0xffffffffffffffff#define AMDGPU_NULL_SUBMIT_SEQ 0
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx