[PATCH 1/2] dma-buf: return index of the first signaled fence (v2)

2016-11-09 Thread Sumit Semwal
Hi Alex, Christian,

On 8 November 2016 at 04:12, Sumit Semwal  wrote:
> Hi Alex,
>
> On 07-Nov-2016 11:14 PM, "Alex Deucher"  wrote:
>>
>> On Fri, Nov 4, 2016 at 6:03 PM, Sumit Semwal 
>> wrote:
>> > Hi Alex,
>> >
>> > Thanks for the patches.
>> >
>> > On 4 November 2016 at 14:16, Alex Deucher  wrote:
>> >> From: "monk.liu" 
>> >>
>> >> Return the index of the first signaled fence.  This information
>> >> is useful in some APIs like Vulkan.
>> >>
>> >> v2: rebase on drm-next (fence -> dma_fence)
>> >>
>> >> Signed-off-by: monk.liu 
>> >> Signed-off-by: Alex Deucher 
>> >> Cc: Sumit Semwal 
>> >> ---
>> >>
>> >> This is the same patch set I send out yesterday, I just
>> >> squashed the amdgpu patches together and rebased everything on
>> >> the fence -> dma_fence renaming.  This is used by our VK driver
>> >> and we are planning to use it in mesa as well.
>> >>
>> >
>> > Would you be ok if I apply this and the amdgpu patch both together via
>> > drm-misc, or would you like me to notify you once I merge this for you
>> > to take the amdgpu patch via your tree? I'm fine either ways, but
>> > perhaps drm-misc would be a bit neater.
>> >
>>
>> Either way works for me.  Whatever is easier for you.
>>
> Thanks, will take these and Christian's patches through the  drm-misc tree,
> hopefully today. (returning from LPC and just landed at my home city, 4am
> here, but will hope to push these today! )
>> Alex
>

Applied to drm-misc; Thanks!

> Best,
> Sumit.


[PATCH 1/2] dma-buf: return index of the first signaled fence (v2)

2016-11-08 Thread Sumit Semwal
Hi Alex,

On 07-Nov-2016 11:14 PM, "Alex Deucher"  wrote:
>
> On Fri, Nov 4, 2016 at 6:03 PM, Sumit Semwal 
wrote:
> > Hi Alex,
> >
> > Thanks for the patches.
> >
> > On 4 November 2016 at 14:16, Alex Deucher  wrote:
> >> From: "monk.liu" 
> >>
> >> Return the index of the first signaled fence.  This information
> >> is useful in some APIs like Vulkan.
> >>
> >> v2: rebase on drm-next (fence -> dma_fence)
> >>
> >> Signed-off-by: monk.liu 
> >> Signed-off-by: Alex Deucher 
> >> Cc: Sumit Semwal 
> >> ---
> >>
> >> This is the same patch set I send out yesterday, I just
> >> squashed the amdgpu patches together and rebased everything on
> >> the fence -> dma_fence renaming.  This is used by our VK driver
> >> and we are planning to use it in mesa as well.
> >>
> >
> > Would you be ok if I apply this and the amdgpu patch both together via
> > drm-misc, or would you like me to notify you once I merge this for you
> > to take the amdgpu patch via your tree? I'm fine either ways, but
> > perhaps drm-misc would be a bit neater.
> >
>
> Either way works for me.  Whatever is easier for you.
>
Thanks, will take these and Christian's patches through the  drm-misc tree,
hopefully today. (returning from LPC and just landed at my home city, 4am
here, but will hope to push these today! )
> Alex

Best,
Sumit.
-- next part --
An HTML attachment was scrubbed...
URL: 



[PATCH 1/2] dma-buf: return index of the first signaled fence (v2)

2016-11-07 Thread Alex Deucher
On Fri, Nov 4, 2016 at 6:03 PM, Sumit Semwal  wrote:
> Hi Alex,
>
> Thanks for the patches.
>
> On 4 November 2016 at 14:16, Alex Deucher  wrote:
>> From: "monk.liu" 
>>
>> Return the index of the first signaled fence.  This information
>> is useful in some APIs like Vulkan.
>>
>> v2: rebase on drm-next (fence -> dma_fence)
>>
>> Signed-off-by: monk.liu 
>> Signed-off-by: Alex Deucher 
>> Cc: Sumit Semwal 
>> ---
>>
>> This is the same patch set I send out yesterday, I just
>> squashed the amdgpu patches together and rebased everything on
>> the fence -> dma_fence renaming.  This is used by our VK driver
>> and we are planning to use it in mesa as well.
>>
>
> Would you be ok if I apply this and the amdgpu patch both together via
> drm-misc, or would you like me to notify you once I merge this for you
> to take the amdgpu patch via your tree? I'm fine either ways, but
> perhaps drm-misc would be a bit neater.
>

Either way works for me.  Whatever is easier for you.

Alex


[PATCH 1/2] dma-buf: return index of the first signaled fence (v2)

2016-11-05 Thread Christian König
Am 04.11.2016 um 21:16 schrieb Alex Deucher:
> From: "monk.liu" 
>
> Return the index of the first signaled fence.  This information
> is useful in some APIs like Vulkan.
>
> v2: rebase on drm-next (fence -> dma_fence)
>
> Signed-off-by: monk.liu 
> Signed-off-by: Alex Deucher 
> Cc: Sumit Semwal 

Both patches are Reviewed-by: Christian König .

> ---
>
> This is the same patch set I send out yesterday, I just
> squashed the amdgpu patches together and rebased everything on
> the fence -> dma_fence renaming.  This is used by our VK driver
> and we are planning to use it in mesa as well.
>
> drivers/dma-buf/dma-fence.c | 20 +++-
>   include/linux/dma-fence.h   |  2 +-
>   2 files changed, 16 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/dma-buf/dma-fence.c b/drivers/dma-buf/dma-fence.c
> index 9ef3c2f..dd00990 100644
> --- a/drivers/dma-buf/dma-fence.c
> +++ b/drivers/dma-buf/dma-fence.c
> @@ -402,14 +402,18 @@ dma_fence_default_wait(struct dma_fence *fence, bool 
> intr, signed long timeout)
>   EXPORT_SYMBOL(dma_fence_default_wait);
>   
>   static bool
> -dma_fence_test_signaled_any(struct dma_fence **fences, uint32_t count)
> +dma_fence_test_signaled_any(struct dma_fence **fences, uint32_t count,
> + uint32_t *idx)
>   {
>   int i;
>   
>   for (i = 0; i < count; ++i) {
>   struct dma_fence *fence = fences[i];
> - if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, >flags))
> + if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, >flags)) {
> + if (idx)
> + *idx = i;
>   return true;
> + }
>   }
>   return false;
>   }
> @@ -421,6 +425,7 @@ dma_fence_test_signaled_any(struct dma_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
> @@ -432,7 +437,7 @@ dma_fence_test_signaled_any(struct dma_fence **fences, 
> uint32_t count)
>*/
>   signed long
>   dma_fence_wait_any_timeout(struct dma_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;
> @@ -443,8 +448,11 @@ dma_fence_wait_any_timeout(struct dma_fence **fences, 
> uint32_t count,
>   
>   if (timeout == 0) {
>   for (i = 0; i < count; ++i)
> - if (dma_fence_is_signaled(fences[i]))
> + if (dma_fence_is_signaled(fences[i])) {
> + if (idx)
> + *idx = i;
>   return 1;
> + }
>   
>   return 0;
>   }
> @@ -467,6 +475,8 @@ dma_fence_wait_any_timeout(struct dma_fence **fences, 
> uint32_t count,
>   if (dma_fence_add_callback(fence, [i].base,
>  dma_fence_default_wait_cb)) {
>   /* This fence is already signaled */
> + if (idx)
> + *idx = i;
>   goto fence_rm_cb;
>   }
>   }
> @@ -477,7 +487,7 @@ dma_fence_wait_any_timeout(struct dma_fence **fences, 
> uint32_t count,
>   else
>   set_current_state(TASK_UNINTERRUPTIBLE);
>   
> - if (dma_fence_test_signaled_any(fences, count))
> + if (dma_fence_test_signaled_any(fences, count, idx))
>   break;
>   
>   ret = schedule_timeout(ret);
> diff --git a/include/linux/dma-fence.h b/include/linux/dma-fence.h
> index ba60c04..e578fe7 100644
> --- a/include/linux/dma-fence.h
> +++ b/include/linux/dma-fence.h
> @@ -382,7 +382,7 @@ signed long dma_fence_wait_timeout(struct dma_fence *,
>  bool intr, signed long timeout);
>   signed long dma_fence_wait_any_timeout(struct dma_fence **fences,
>  uint32_t count,
> -bool intr, signed long timeout);
> +bool intr, signed long timeout, uint32_t 
> *idx);
>   
>   /**
>* dma_fence_wait - sleep until the fence gets signaled




[PATCH 1/2] dma-buf: return index of the first signaled fence (v2)

2016-11-04 Thread Alex Deucher
From: "monk.liu" 

Return the index of the first signaled fence.  This information
is useful in some APIs like Vulkan.

v2: rebase on drm-next (fence -> dma_fence)

Signed-off-by: monk.liu 
Signed-off-by: Alex Deucher 
Cc: Sumit Semwal 
---

This is the same patch set I send out yesterday, I just
squashed the amdgpu patches together and rebased everything on
the fence -> dma_fence renaming.  This is used by our VK driver
and we are planning to use it in mesa as well.

drivers/dma-buf/dma-fence.c | 20 +++-
 include/linux/dma-fence.h   |  2 +-
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/drivers/dma-buf/dma-fence.c b/drivers/dma-buf/dma-fence.c
index 9ef3c2f..dd00990 100644
--- a/drivers/dma-buf/dma-fence.c
+++ b/drivers/dma-buf/dma-fence.c
@@ -402,14 +402,18 @@ dma_fence_default_wait(struct dma_fence *fence, bool 
intr, signed long timeout)
 EXPORT_SYMBOL(dma_fence_default_wait);

 static bool
-dma_fence_test_signaled_any(struct dma_fence **fences, uint32_t count)
+dma_fence_test_signaled_any(struct dma_fence **fences, uint32_t count,
+   uint32_t *idx)
 {
int i;

for (i = 0; i < count; ++i) {
struct dma_fence *fence = fences[i];
-   if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, >flags))
+   if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, >flags)) {
+   if (idx)
+   *idx = i;
return true;
+   }
}
return false;
 }
@@ -421,6 +425,7 @@ dma_fence_test_signaled_any(struct dma_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
@@ -432,7 +437,7 @@ dma_fence_test_signaled_any(struct dma_fence **fences, 
uint32_t count)
  */
 signed long
 dma_fence_wait_any_timeout(struct dma_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;
@@ -443,8 +448,11 @@ dma_fence_wait_any_timeout(struct dma_fence **fences, 
uint32_t count,

if (timeout == 0) {
for (i = 0; i < count; ++i)
-   if (dma_fence_is_signaled(fences[i]))
+   if (dma_fence_is_signaled(fences[i])) {
+   if (idx)
+   *idx = i;
return 1;
+   }

return 0;
}
@@ -467,6 +475,8 @@ dma_fence_wait_any_timeout(struct dma_fence **fences, 
uint32_t count,
if (dma_fence_add_callback(fence, [i].base,
   dma_fence_default_wait_cb)) {
/* This fence is already signaled */
+   if (idx)
+   *idx = i;
goto fence_rm_cb;
}
}
@@ -477,7 +487,7 @@ dma_fence_wait_any_timeout(struct dma_fence **fences, 
uint32_t count,
else
set_current_state(TASK_UNINTERRUPTIBLE);

-   if (dma_fence_test_signaled_any(fences, count))
+   if (dma_fence_test_signaled_any(fences, count, idx))
break;

ret = schedule_timeout(ret);
diff --git a/include/linux/dma-fence.h b/include/linux/dma-fence.h
index ba60c04..e578fe7 100644
--- a/include/linux/dma-fence.h
+++ b/include/linux/dma-fence.h
@@ -382,7 +382,7 @@ signed long dma_fence_wait_timeout(struct dma_fence *,
   bool intr, signed long timeout);
 signed long dma_fence_wait_any_timeout(struct dma_fence **fences,
   uint32_t count,
-  bool intr, signed long timeout);
+  bool intr, signed long timeout, uint32_t 
*idx);

 /**
  * dma_fence_wait - sleep until the fence gets signaled
-- 
2.5.5



[PATCH 1/2] dma-buf: return index of the first signaled fence (v2)

2016-11-04 Thread Sumit Semwal
Hi Alex,

Thanks for the patches.

On 4 November 2016 at 14:16, Alex Deucher  wrote:
> From: "monk.liu" 
>
> Return the index of the first signaled fence.  This information
> is useful in some APIs like Vulkan.
>
> v2: rebase on drm-next (fence -> dma_fence)
>
> Signed-off-by: monk.liu 
> Signed-off-by: Alex Deucher 
> Cc: Sumit Semwal 
> ---
>
> This is the same patch set I send out yesterday, I just
> squashed the amdgpu patches together and rebased everything on
> the fence -> dma_fence renaming.  This is used by our VK driver
> and we are planning to use it in mesa as well.
>

Would you be ok if I apply this and the amdgpu patch both together via
drm-misc, or would you like me to notify you once I merge this for you
to take the amdgpu patch via your tree? I'm fine either ways, but
perhaps drm-misc would be a bit neater.

> drivers/dma-buf/dma-fence.c | 20 +++-
>  include/linux/dma-fence.h   |  2 +-
>  2 files changed, 16 insertions(+), 6 deletions(-)
>

Best regards,
Sumit.


[PATCH 1/2] dma-buf: return index of the first signaled fence

2016-09-12 Thread Alex Deucher
From: "monk.liu" 

Return the index of the first signaled fence.  This information
is useful in some APIs like Vulkan.

Signed-off-by: monk.liu 
Signed-off-by: Alex Deucher 
---
 drivers/dma-buf/fence.c | 19 ++-
 include/linux/fence.h   |  2 +-
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/drivers/dma-buf/fence.c b/drivers/dma-buf/fence.c
index 4d51f9e..90b7d27 100644
--- a/drivers/dma-buf/fence.c
+++ b/drivers/dma-buf/fence.c
@@ -398,14 +398,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, >flags))
+   if (test_bit(FENCE_FLAG_SIGNALED_BIT, >flags)) {
+   if (idx)
+   *idx = i;
return true;
+   }
}
return false;
 }
@@ -417,6 +420,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
@@ -428,7 +432,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;
@@ -439,8 +443,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;
}
@@ -463,6 +470,8 @@ fence_wait_any_timeout(struct fence **fences, uint32_t 
count,
if (fence_add_callback(fence, [i].base,
   fence_default_wait_cb)) {
/* This fence is already signaled */
+   if (idx)
+   *idx = i;
goto fence_rm_cb;
}
}
@@ -473,7 +482,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);
diff --git a/include/linux/fence.h b/include/linux/fence.h
index 8cc719a..2d21113 100644
--- a/include/linux/fence.h
+++ b/include/linux/fence.h
@@ -325,7 +325,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
-- 
2.5.5