dma-buf: return index of the first signaled fence
PATCH 1/3 dma-buf: return index of the first signaled fence
From: "monk.liu" <[email protected]>
Return the index of the first signaled fence. This information is useful in some APIs like Vulkan.
--- drivers/dma-buf/fence.c | 19 ++++++++++++++----- include/linux/fence.h | 2 +- 2 files changed, 15 insertions(+), 6 deletions(-)
drivers/dma-buf/fence.c +14 -5
@@ -397,14 +397,17 @@ out:EXPORT_SYMBOL (fence_default_wait);static bool -fence_test_signaled_any (struct fence **fences,uint32_t count) +fence_test_signaled_any (struct fence **fences,uint32_t count,uint32_t *idx) {int i;for (i =0 ; i < count; ++i) {struct fence *fence = fences[i]; -if (test_bit (FENCE_FLAG_SIGNALED_BIT , &fence->flags)) +if (test_bit (FENCE_FLAG_SIGNALED_BIT , &fence->flags)) { +if (idx) + *idx = i;return true; + } }return false; }
@@ -416,6 +419,7 @@ fence_test_signaled_any(struct fence **fences, uint32_t count)* @count: [in] number of fences to wait on * @intr: [in] if true, do an interruptible wait * @timeout: [in] timeout value in jiffies, or MAX_SCHEDULE_TIMEOUT +* @idx: [out] the first signaled fence index, meaninful only on Returns positive * * Returns -EINVAL on custom fence wait implementation, -ERESTARTSYS if * interrupted, 0 if the wait timed out, or the remaining timeout in jiffies
@@ -427,7 +431,7 @@ fence_test_signaled_any(struct fence **fences, uint32_t count)*/ signed long fence_wait_any_timeout (struct fence **fences,uint32_t count, -bool intr,signed long timeout) +bool intr,signed long timeout,uint32_t *idx) {struct default_wait_cb *cb;signed long ret = timeout;
@@ -438,8 +442,11 @@ fence_wait_any_timeout(struct fence **fences, uint32_t count,if (timeout ==0 ) {for (i =0 ; i < count; ++i) -if (fence_is_signaled (fences[i])) +if (fence_is_signaled (fences[i])) { +if (idx) + *idx = i;return 1 ; + }return 0 ; }
@@ -462,6 +469,8 @@ fence_wait_any_timeout(struct fence **fences, uint32_t count,if (fence_add_callback (fence, &cb[i].base, fence_default_wait_cb)) {/* This fence is already signaled */ +if (idx) + *idx = i; goto fence_rm_cb; } }
@@ -472,7 +481,7 @@ fence_wait_any_timeout(struct fence **fences, uint32_t count,else set_current_state (TASK_UNINTERRUPTIBLE ); -if (fence_test_signaled_any (fences, count)) +if (fence_test_signaled_any (fences, count, idx))break ; ret =schedule_timeout (ret);
include/linux/fence.h +1 -1
@@ -327,7 +327,7 @@ static inline struct fence *fence_later(struct fence *f1, struct fence *f2)signed long fence_wait_timeout (struct fence *,bool intr,signed long timeout);signed long fence_wait_any_timeout (struct fence **fences,uint32_t count, -bool intr,signed long timeout); +bool intr,signed long timeout,uint32_t *idx);/** * fence_wait - sleep until the fence gets signaled
Signature · 6 lines
2.5.5 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
A message that is not in the archive (sent off-list or not yet received): 1478194871-29766-1-git-send-email-alexander.deucher-5C7GfCeVMHo@public.gmane.org
PATCH 2/3 drm/amdgpu: add the interface of waiting multiple fences (v3)
From: Junwei Zhang <[email protected]>
v2: agd: rebase and squash in all the previous optimizations and changes so everything compiles.
v3: squash in Slava's 32bit build fix
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 + drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 171 ++++++++++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 1 + include/uapi/drm/amdgpu_drm.h | 27 +++++ 4 files changed, 201 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -0
@@ -1214,6 +1214,8 @@ int amdgpu_gem_op_ioctl(struct drm_device *dev, void *data, struct drm_file *filp);int amdgpu_cs_ioctl (struct drm_device *dev,void *data,struct drm_file *filp);int amdgpu_cs_wait_ioctl (struct drm_device *dev,void *data,struct drm_file *filp); +int amdgpu_cs_wait_fences_ioctl (struct drm_device *dev,void *data, +struct drm_file *filp);int amdgpu_gem_metadata_ioctl (struct drm_device *dev,void *data,struct drm_file *filp);
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +171 -0
177 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +1 -0
@@ -825,6 +825,7 @@ const struct drm_ioctl_desc amdgpu_ioctls_kms[] = {DRM_IOCTL_DEF_DRV (AMDGPU_CS , amdgpu_cs_ioctl,DRM_AUTH |DRM_RENDER_ALLOW ),DRM_IOCTL_DEF_DRV (AMDGPU_INFO , amdgpu_info_ioctl,DRM_AUTH |DRM_RENDER_ALLOW ),DRM_IOCTL_DEF_DRV (AMDGPU_WAIT_CS , amdgpu_cs_wait_ioctl,DRM_AUTH |DRM_RENDER_ALLOW ), +DRM_IOCTL_DEF_DRV (AMDGPU_WAIT_FENCES , amdgpu_cs_wait_fences_ioctl,DRM_AUTH |DRM_RENDER_ALLOW ),DRM_IOCTL_DEF_DRV (AMDGPU_GEM_METADATA , amdgpu_gem_metadata_ioctl,DRM_AUTH |DRM_RENDER_ALLOW ),DRM_IOCTL_DEF_DRV (AMDGPU_GEM_VA , amdgpu_gem_va_ioctl,DRM_AUTH |DRM_RENDER_ALLOW ), DRM_IOCTL_DEF_DRV(AMDGPU_GEM_OP, amdgpu_gem_op_ioctl, DRM_AUTH|DRM_RENDER_ALLOW),
include/uapi/drm/amdgpu_drm.h +27 -0
@@ -50,6 +50,7 @@ extern "C" {#define DRM_AMDGPU_WAIT_CS 0x09#define DRM_AMDGPU_GEM_OP 0x10#define DRM_AMDGPU_GEM_USERPTR 0x11 +#define DRM_AMDGPU_WAIT_FENCES 0x12#define DRM_AMDGPU_FREESYNC 0x14#define DRM_IOCTL_AMDGPU_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_CREATE, union drm_amdgpu_gem_create)
@@ -64,6 +65,7 @@ extern "C" {#define DRM_IOCTL_AMDGPU_WAIT_CS DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_WAIT_CS, union drm_amdgpu_wait_cs)#define DRM_IOCTL_AMDGPU_GEM_OP DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_OP, struct drm_amdgpu_gem_op)#define DRM_IOCTL_AMDGPU_GEM_USERPTR DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_USERPTR, struct drm_amdgpu_gem_userptr) +#define DRM_IOCTL_AMDGPU_WAIT_FENCES DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_WAIT_FENCES, union drm_amdgpu_wait_fences)#define DRM_IOCTL_AMDGPU_FREESYNC DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_FREESYNC, struct drm_amdgpu_freesync)#define AMDGPU_GEM_DOMAIN_CPU 0x1
@@ -309,6 +311,31 @@ union drm_amdgpu_wait_cs {struct drm_amdgpu_wait_cs_out out; }; +struct drm_amdgpu_fence { +__u32 ctx_id; +__u32 ip_type; +__u32 ip_instance; +__u32 ring; +__u64 seq_no; +}; + +struct drm_amdgpu_wait_fences_in { +/** This points to uint64_t * which points to fences */ +__u64 fences; +__u32 fence_count; +__u32 wait_all; +__u64 timeout_ns; +}; + +struct drm_amdgpu_wait_fences_out { +__u64 status; +}; + +union drm_amdgpu_wait_fences { +struct drm_amdgpu_wait_fences_in in; +struct drm_amdgpu_wait_fences_out out; +}; +#define AMDGPU_GEM_OP_GET_GEM_CREATE_INFO 0#define AMDGPU_GEM_OP_SET_PLACEMENT 1
Signature · 6 lines
2.5.5 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Sumit Semwal
maintainerRe: [PATCH 2/3] drm/amdgpu: add the interface of waiting multiple fences (v3)
Hi Alex,
Thanks for the patch!
Quoted 21 lines · Alex Deucher
From: Junwei Zhang <[email protected]>
v2: agd: rebase and squash in all the previous optimizations and changes so everything compiles.
v3: squash in Slava's 32bit build fixSigned-off-by Junwei Zhang <[email protected]>Reviewed-by Monk Liu <[email protected]>Reviewed-by Jammy Zhou <[email protected]>Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 + drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 171 ++++++++++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 1 + include/uapi/drm/amdgpu_drm.h | 27 +++++ 4 files changed, 201 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu.h +0
-0
<snip>
drivers/gpu/drm/amd/amdgpu/amdgpu.h
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2
-0+ + r =fence_wait_any_timeout (array, fence_count, true, timeout);
With the change proposed about returning index of signalled fence in patch 1/3, I don't think this would build?
Best regards,
Sumit.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sumit Semwal
maintainerRe: [PATCH 2/3] drm/amdgpu: add the interface of waiting multiple fences (v3)
Quoted 11 lines · Sumit Semwal
Hi Alex,
Thanks for the patch!
Quoted 6 lines · Alex Deucher
From: Junwei Zhang <[email protected]>
v2: agd: rebase and squash in all the previous optimizations and changes so everything compiles.
v3: squash in Slava's 32bit build fix
Quoted 9 lines
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0
-0<snip>
drivers/gpu/drm/amd/amdgpu/amdgpu.h
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2
-0+ + r =fence_wait_any_timeout (array, fence_count, true, timeout);With the change proposed about returning index of signalled fence in patch 1/3, I don't think this would build?
O, just noticed - perhaps just a reordering of patches so that this is 1/3 (or even a separate patch?) and dma-buf change for index + amdgpu change for the index are 2/3 and 3/3, should solve it.
Quoted 2 lines
Best regards,
Sumit.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
A message that is not in the archive (sent off-list or not yet received): CAO_48GGkL2Jiwby6Wx3n1_vRNSpCBa9PSaAJxKGore9Rb7=6pg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
RE: [PATCH 2/3] drm/amdgpu: add the interface of waiting multiple fences (v3)
Quoted 39 lines
-----Original Message-----
From: Sumit Semwal [mailto:[email protected]]
Sent: Friday, November 04, 2016 1:15 PM
To: Alex Deucher
Cc: [email protected]; DRI mailing list; Zhang, Jerry; Deucher, Alexander
Subject: Re: [PATCH 2/3] drm/amdgpu: add the interface of waiting multiple fences (v3)Hi Alex,
Thanks for the patch!
Quoted 6 lines · Alex Deucher
From: Junwei Zhang <[email protected]>
v2: agd: rebase and squash in all the previous optimizations and changes so everything compiles.
v3: squash in Slava's 32bit build fixQuoted 7 lines
Signed-off-by Junwei Zhang <[email protected]>Reviewed-by Monk Liu <[email protected]>Reviewed-by Jammy Zhou <[email protected]>Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 + drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 171++++++++++++++++++++++++++++++++
Review
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 1 + include/uapi/drm/amdgpu_drm.h | 27 +++++ 4 files changed, 201 insertions(+)(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/amdgpu.hQuoted 3 lines
index 8d0c689..c2050c0 100644
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0
-0<snip>
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2
-0+ + r =fence_wait_any_timeout (array, fence_count, true, timeout);With the change proposed about returning index of signalled fence in patch 1/3, I don't think this would build?
Yes, Sorry, I messed up the order when I rebased the patches. It should be 2 1 3.
Alex
Quoted 3 lines
Best regards,
Sumit.
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 3/3 drm/amdgpu: return first signaled fence index in status parameter
In reply to a message not in the archiveFrom: "monk.liu" <[email protected]>
Return the index of the first signaled fence in the fences ioctl. This information is useful in some APIs like Vulkan.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 4 +++- drivers/gpu/drm/amd/amdgpu/amdgpu_sa.c | 2 +- include/uapi/drm/amdgpu_drm.h | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +3 -1
@@ -1216,6 +1216,7 @@ static int amdgpu_cs_wait_any_fence(struct amdgpu_device *adev, {unsigned long timeout =amdgpu_gem_timeout (wait->in.timeout_ns);uint32_t fence_count = wait->in.fence_count; +uint32_t first = ~0 ;struct fence **array;unsigned i;long r;
@@ -1241,13 +1242,14 @@ static int amdgpu_cs_wait_any_fence(struct amdgpu_device *adev, } } - r =fence_wait_any_timeout (array, fence_count, true, timeout); + r =fence_wait_any_timeout (array, fence_count, true, timeout, &first);if (r <0 ) goto err_free_fence_array; out:memset (wait,0 ,sizeof (*wait)); wait->out.status = (r >0 ); + wait->out.first_signaled = first;/* set return value 0 to indicate success */ r =0 ;
drivers/gpu/drm/amd/amdgpu/amdgpu_sa.c +1 -1
@@ -361,7 +361,7 @@ int amdgpu_sa_bo_new(struct amdgpu_sa_manager *sa_manager,if (count) {spin_unlock (&sa_manager->wq.lock); t =fence_wait_any_timeout (fences, count, false, -MAX_SCHEDULE_TIMEOUT ); +MAX_SCHEDULE_TIMEOUT ,NULL );for (i =0 ; i < count; ++i)fence_put (fences[i]);
include/uapi/drm/amdgpu_drm.h +2 -1
@@ -328,7 +328,8 @@ struct drm_amdgpu_wait_fences_in { };struct drm_amdgpu_wait_fences_out { -__u64 status; +__u32 status; +__u32 first_signaled; };union drm_amdgpu_wait_fences {
Signature · 6 lines
2.5.5 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Sumit Semwal
maintainerHi Alex,
Thanks for this patch. Adding Gustavo as well.
Quoted 18 lines · Alex Deucher
From: "monk.liu" <[email protected]>
Return the index of the first signaled fence. This information is useful in some APIs like Vulkan.
Signed-off-by monk.liu <[email protected]>Signed-off-by Alex Deucher <[email protected]>Cc Sumit Semwal <[email protected]>--- drivers/dma-buf/fence.c | 19 ++++++++++++++----- include/linux/fence.h | 2 +- 2 files changed, 15 insertions(+), 6 deletions(-)drivers/dma-buf/fence.c +0
-0
drivers/dma-buf/fence.c out: · line 401
Quoted 6 lines
drivers/dma-buf/fence.c +1
-1@@ -397,14 +397,17 @@ out:EXPORT_SYMBOL (fence_default_wait);static bool -fence_test_signaled_any (struct fence **fences,uint32_t count) +fence_test_signaled_any (struct fence **fences,uint32_t count,uint32_t *idx) {
Looks sane to me; Gustavo, comments?
Best regards,
Sumit.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel