All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/syncobj: extend syncobj query ability
@ 2019-07-23  5:22 Chunming Zhou
  2019-07-23 13:58 ` Koenig, Christian
  2019-07-23 14:06 ` Lionel Landwerlin
  0 siblings, 2 replies; 6+ messages in thread
From: Chunming Zhou @ 2019-07-23  5:22 UTC (permalink / raw)
  To: dri-devel; +Cc: Christian König

user space needs a flexiable query ability.
So that umd can get last signaled or submitted point.

Change-Id: I6512b430524ebabe715e602a2bf5abb0a7e780ea
Signed-off-by: Chunming Zhou <david1.zhou@amd.com>
Cc: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Cc: Christian König <Christian.Koenig@amd.com>
---
 drivers/gpu/drm/drm_syncobj.c | 36 +++++++++++++++++------------------
 include/uapi/drm/drm.h        |  3 ++-
 2 files changed, 20 insertions(+), 19 deletions(-)

diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c
index 3d400905100b..f70dedf3ef4f 100644
--- a/drivers/gpu/drm/drm_syncobj.c
+++ b/drivers/gpu/drm/drm_syncobj.c
@@ -1197,9 +1197,6 @@ drm_syncobj_timeline_signal_ioctl(struct drm_device *dev, void *data,
 	if (!drm_core_check_feature(dev, DRIVER_SYNCOBJ_TIMELINE))
 		return -EOPNOTSUPP;
 
-	if (args->pad != 0)
-		return -EINVAL;
-
 	if (args->count_handles == 0)
 		return -EINVAL;
 
@@ -1268,9 +1265,6 @@ int drm_syncobj_query_ioctl(struct drm_device *dev, void *data,
 	if (!drm_core_check_feature(dev, DRIVER_SYNCOBJ_TIMELINE))
 		return -EOPNOTSUPP;
 
-	if (args->pad != 0)
-		return -EINVAL;
-
 	if (args->count_handles == 0)
 		return -EINVAL;
 
@@ -1291,23 +1285,29 @@ int drm_syncobj_query_ioctl(struct drm_device *dev, void *data,
 		if (chain) {
 			struct dma_fence *iter, *last_signaled = NULL;
 
-			dma_fence_chain_for_each(iter, fence) {
-				if (!iter)
-					break;
-				dma_fence_put(last_signaled);
-				last_signaled = dma_fence_get(iter);
-				if (!to_dma_fence_chain(last_signaled)->prev_seqno)
-					/* It is most likely that timeline has
-					 * unorder points. */
-					break;
+			if (args->flags &
+			    DRM_SYNCOBJ_QUERY_FLAGS_LAST_SUBMITTED) {
+				point = fence->seqno;
+			} else {
+				dma_fence_chain_for_each(iter, fence) {
+					if (!iter)
+						break;
+					dma_fence_put(last_signaled);
+					last_signaled = dma_fence_get(iter);
+					if (!to_dma_fence_chain(last_signaled)->prev_seqno)
+						/* It is most likely that timeline has
+						* unorder points. */
+						break;
+				}
+				point = dma_fence_is_signaled(last_signaled) ?
+					last_signaled->seqno :
+					to_dma_fence_chain(last_signaled)->prev_seqno;
 			}
-			point = dma_fence_is_signaled(last_signaled) ?
-				last_signaled->seqno :
-				to_dma_fence_chain(last_signaled)->prev_seqno;
 			dma_fence_put(last_signaled);
 		} else {
 			point = 0;
 		}
+		dma_fence_put(fence);
 		ret = copy_to_user(&points[i], &point, sizeof(uint64_t));
 		ret = ret ? -EFAULT : 0;
 		if (ret)
diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h
index 661d73f9a919..fd987ce24d9f 100644
--- a/include/uapi/drm/drm.h
+++ b/include/uapi/drm/drm.h
@@ -777,11 +777,12 @@ struct drm_syncobj_array {
 	__u32 pad;
 };
 
+#define DRM_SYNCOBJ_QUERY_FLAGS_LAST_SUBMITTED (1 << 0) /* last available point on timeline syncobj */
 struct drm_syncobj_timeline_array {
 	__u64 handles;
 	__u64 points;
 	__u32 count_handles;
-	__u32 pad;
+	__u32 flags;
 };
 
 
-- 
2.17.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] drm/syncobj: extend syncobj query ability
  2019-07-23  5:22 [PATCH] drm/syncobj: extend syncobj query ability Chunming Zhou
@ 2019-07-23 13:58 ` Koenig, Christian
  2019-07-23 14:07   ` Chunming Zhou
  2019-07-23 14:06 ` Lionel Landwerlin
  1 sibling, 1 reply; 6+ messages in thread
From: Koenig, Christian @ 2019-07-23 13:58 UTC (permalink / raw)
  To: Zhou, David(ChunMing), dri-devel

Am 23.07.19 um 07:22 schrieb Chunming Zhou:
> user space needs a flexiable query ability.
> So that umd can get last signaled or submitted point.
>
> Change-Id: I6512b430524ebabe715e602a2bf5abb0a7e780ea
> Signed-off-by: Chunming Zhou <david1.zhou@amd.com>
> Cc: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
> Cc: Christian König <Christian.Koenig@amd.com>

I've recently found a bug in drm_syncobj_query_ioctl() which I'm going 
to commit tomorrow.

Apart from that it looks good to me, but I think we should cleanup a bit 
and move the dma_fence_chain_for_each()... into a helper function in 
dma-fence-chain.c

Christian.

> ---
>   drivers/gpu/drm/drm_syncobj.c | 36 +++++++++++++++++------------------
>   include/uapi/drm/drm.h        |  3 ++-
>   2 files changed, 20 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c
> index 3d400905100b..f70dedf3ef4f 100644
> --- a/drivers/gpu/drm/drm_syncobj.c
> +++ b/drivers/gpu/drm/drm_syncobj.c
> @@ -1197,9 +1197,6 @@ drm_syncobj_timeline_signal_ioctl(struct drm_device *dev, void *data,
>   	if (!drm_core_check_feature(dev, DRIVER_SYNCOBJ_TIMELINE))
>   		return -EOPNOTSUPP;
>   
> -	if (args->pad != 0)
> -		return -EINVAL;
> -
>   	if (args->count_handles == 0)
>   		return -EINVAL;
>   
> @@ -1268,9 +1265,6 @@ int drm_syncobj_query_ioctl(struct drm_device *dev, void *data,
>   	if (!drm_core_check_feature(dev, DRIVER_SYNCOBJ_TIMELINE))
>   		return -EOPNOTSUPP;
>   
> -	if (args->pad != 0)
> -		return -EINVAL;
> -
>   	if (args->count_handles == 0)
>   		return -EINVAL;
>   
> @@ -1291,23 +1285,29 @@ int drm_syncobj_query_ioctl(struct drm_device *dev, void *data,
>   		if (chain) {
>   			struct dma_fence *iter, *last_signaled = NULL;
>   
> -			dma_fence_chain_for_each(iter, fence) {
> -				if (!iter)
> -					break;
> -				dma_fence_put(last_signaled);
> -				last_signaled = dma_fence_get(iter);
> -				if (!to_dma_fence_chain(last_signaled)->prev_seqno)
> -					/* It is most likely that timeline has
> -					 * unorder points. */
> -					break;
> +			if (args->flags &
> +			    DRM_SYNCOBJ_QUERY_FLAGS_LAST_SUBMITTED) {
> +				point = fence->seqno;
> +			} else {
> +				dma_fence_chain_for_each(iter, fence) {
> +					if (!iter)
> +						break;
> +					dma_fence_put(last_signaled);
> +					last_signaled = dma_fence_get(iter);
> +					if (!to_dma_fence_chain(last_signaled)->prev_seqno)
> +						/* It is most likely that timeline has
> +						* unorder points. */
> +						break;
> +				}
> +				point = dma_fence_is_signaled(last_signaled) ?
> +					last_signaled->seqno :
> +					to_dma_fence_chain(last_signaled)->prev_seqno;
>   			}
> -			point = dma_fence_is_signaled(last_signaled) ?
> -				last_signaled->seqno :
> -				to_dma_fence_chain(last_signaled)->prev_seqno;
>   			dma_fence_put(last_signaled);
>   		} else {
>   			point = 0;
>   		}
> +		dma_fence_put(fence);
>   		ret = copy_to_user(&points[i], &point, sizeof(uint64_t));
>   		ret = ret ? -EFAULT : 0;
>   		if (ret)
> diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h
> index 661d73f9a919..fd987ce24d9f 100644
> --- a/include/uapi/drm/drm.h
> +++ b/include/uapi/drm/drm.h
> @@ -777,11 +777,12 @@ struct drm_syncobj_array {
>   	__u32 pad;
>   };
>   
> +#define DRM_SYNCOBJ_QUERY_FLAGS_LAST_SUBMITTED (1 << 0) /* last available point on timeline syncobj */
>   struct drm_syncobj_timeline_array {
>   	__u64 handles;
>   	__u64 points;
>   	__u32 count_handles;
> -	__u32 pad;
> +	__u32 flags;
>   };
>   
>   

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] drm/syncobj: extend syncobj query ability
  2019-07-23  5:22 [PATCH] drm/syncobj: extend syncobj query ability Chunming Zhou
  2019-07-23 13:58 ` Koenig, Christian
@ 2019-07-23 14:06 ` Lionel Landwerlin
  1 sibling, 0 replies; 6+ messages in thread
From: Lionel Landwerlin @ 2019-07-23 14:06 UTC (permalink / raw)
  To: Chunming Zhou, dri-devel; +Cc: Christian König

On 23/07/2019 08:22, Chunming Zhou wrote:
> user space needs a flexiable query ability.
> So that umd can get last signaled or submitted point.
>
> Change-Id: I6512b430524ebabe715e602a2bf5abb0a7e780ea
> Signed-off-by: Chunming Zhou <david1.zhou@amd.com>
> Cc: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
> Cc: Christian König <Christian.Koenig@amd.com>
> ---
>   drivers/gpu/drm/drm_syncobj.c | 36 +++++++++++++++++------------------
>   include/uapi/drm/drm.h        |  3 ++-
>   2 files changed, 20 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c
> index 3d400905100b..f70dedf3ef4f 100644
> --- a/drivers/gpu/drm/drm_syncobj.c
> +++ b/drivers/gpu/drm/drm_syncobj.c
> @@ -1197,9 +1197,6 @@ drm_syncobj_timeline_signal_ioctl(struct drm_device *dev, void *data,
>   	if (!drm_core_check_feature(dev, DRIVER_SYNCOBJ_TIMELINE))
>   		return -EOPNOTSUPP;
>   
> -	if (args->pad != 0)
> -		return -EINVAL;


I think args->flags should still be 0 for this ioctl.


> -
>   	if (args->count_handles == 0)
>   		return -EINVAL;
>   
> @@ -1268,9 +1265,6 @@ int drm_syncobj_query_ioctl(struct drm_device *dev, void *data,
>   	if (!drm_core_check_feature(dev, DRIVER_SYNCOBJ_TIMELINE))
>   		return -EOPNOTSUPP;
>   
> -	if (args->pad != 0)
> -		return -EINVAL;


You probably want to verify that (args->flags & 
~DRM_SYNCOBJ_QUERY_FLAGS_LAST_SUBMITTED) == 0.


> -
>   	if (args->count_handles == 0)
>   		return -EINVAL;
>   
> @@ -1291,23 +1285,29 @@ int drm_syncobj_query_ioctl(struct drm_device *dev, void *data,
>   		if (chain) {
>   			struct dma_fence *iter, *last_signaled = NULL;
>   
> -			dma_fence_chain_for_each(iter, fence) {
> -				if (!iter)
> -					break;
> -				dma_fence_put(last_signaled);
> -				last_signaled = dma_fence_get(iter);
> -				if (!to_dma_fence_chain(last_signaled)->prev_seqno)
> -					/* It is most likely that timeline has
> -					 * unorder points. */
> -					break;
> +			if (args->flags &
> +			    DRM_SYNCOBJ_QUERY_FLAGS_LAST_SUBMITTED) {
> +				point = fence->seqno;
> +			} else {
> +				dma_fence_chain_for_each(iter, fence) {
> +					if (!iter)
> +						break;
> +					dma_fence_put(last_signaled);
> +					last_signaled = dma_fence_get(iter);
> +					if (!to_dma_fence_chain(last_signaled)->prev_seqno)
> +						/* It is most likely that timeline has
> +						* unorder points. */
> +						break;
> +				}
> +				point = dma_fence_is_signaled(last_signaled) ?
> +					last_signaled->seqno :
> +					to_dma_fence_chain(last_signaled)->prev_seqno;
>   			}
> -			point = dma_fence_is_signaled(last_signaled) ?
> -				last_signaled->seqno :
> -				to_dma_fence_chain(last_signaled)->prev_seqno;
>   			dma_fence_put(last_signaled);
>   		} else {
>   			point = 0;
>   		}
> +		dma_fence_put(fence);
>   		ret = copy_to_user(&points[i], &point, sizeof(uint64_t));
>   		ret = ret ? -EFAULT : 0;
>   		if (ret)
> diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h
> index 661d73f9a919..fd987ce24d9f 100644
> --- a/include/uapi/drm/drm.h
> +++ b/include/uapi/drm/drm.h
> @@ -777,11 +777,12 @@ struct drm_syncobj_array {
>   	__u32 pad;
>   };
>   
> +#define DRM_SYNCOBJ_QUERY_FLAGS_LAST_SUBMITTED (1 << 0) /* last available point on timeline syncobj */
>   struct drm_syncobj_timeline_array {
>   	__u64 handles;
>   	__u64 points;
>   	__u32 count_handles;
> -	__u32 pad;
> +	__u32 flags;
>   };
>   
>   


_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] drm/syncobj: extend syncobj query ability
  2019-07-23 13:58 ` Koenig, Christian
@ 2019-07-23 14:07   ` Chunming Zhou
  2019-07-23 14:08     ` Koenig, Christian
  0 siblings, 1 reply; 6+ messages in thread
From: Chunming Zhou @ 2019-07-23 14:07 UTC (permalink / raw)
  To: Koenig, Christian, Zhou, David(ChunMing), dri-devel


在 2019/7/23 21:58, Koenig, Christian 写道:
> Am 23.07.19 um 07:22 schrieb Chunming Zhou:
>> user space needs a flexiable query ability.
>> So that umd can get last signaled or submitted point.
>>
>> Change-Id: I6512b430524ebabe715e602a2bf5abb0a7e780ea
>> Signed-off-by: Chunming Zhou <david1.zhou@amd.com>
>> Cc: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
>> Cc: Christian König <Christian.Koenig@amd.com>
> I've recently found a bug in drm_syncobj_query_ioctl() which I'm going
> to commit tomorrow.

Yes, I've realized. Loinel has put RB on it.


>
> Apart from that it looks good to me,

Thanks,


>   but I think we should cleanup a bit
> and move the dma_fence_chain_for_each()... into a helper function in
> dma-fence-chain.c

Do you mind a saperate cleanup patch for that? I don't want to touch 
kernel directory in this patch, so that we can cherry-pick it easily.


-David

>
> Christian.
>
>> ---
>>    drivers/gpu/drm/drm_syncobj.c | 36 +++++++++++++++++------------------
>>    include/uapi/drm/drm.h        |  3 ++-
>>    2 files changed, 20 insertions(+), 19 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c
>> index 3d400905100b..f70dedf3ef4f 100644
>> --- a/drivers/gpu/drm/drm_syncobj.c
>> +++ b/drivers/gpu/drm/drm_syncobj.c
>> @@ -1197,9 +1197,6 @@ drm_syncobj_timeline_signal_ioctl(struct drm_device *dev, void *data,
>>    	if (!drm_core_check_feature(dev, DRIVER_SYNCOBJ_TIMELINE))
>>    		return -EOPNOTSUPP;
>>    
>> -	if (args->pad != 0)
>> -		return -EINVAL;
>> -
>>    	if (args->count_handles == 0)
>>    		return -EINVAL;
>>    
>> @@ -1268,9 +1265,6 @@ int drm_syncobj_query_ioctl(struct drm_device *dev, void *data,
>>    	if (!drm_core_check_feature(dev, DRIVER_SYNCOBJ_TIMELINE))
>>    		return -EOPNOTSUPP;
>>    
>> -	if (args->pad != 0)
>> -		return -EINVAL;
>> -
>>    	if (args->count_handles == 0)
>>    		return -EINVAL;
>>    
>> @@ -1291,23 +1285,29 @@ int drm_syncobj_query_ioctl(struct drm_device *dev, void *data,
>>    		if (chain) {
>>    			struct dma_fence *iter, *last_signaled = NULL;
>>    
>> -			dma_fence_chain_for_each(iter, fence) {
>> -				if (!iter)
>> -					break;
>> -				dma_fence_put(last_signaled);
>> -				last_signaled = dma_fence_get(iter);
>> -				if (!to_dma_fence_chain(last_signaled)->prev_seqno)
>> -					/* It is most likely that timeline has
>> -					 * unorder points. */
>> -					break;
>> +			if (args->flags &
>> +			    DRM_SYNCOBJ_QUERY_FLAGS_LAST_SUBMITTED) {
>> +				point = fence->seqno;
>> +			} else {
>> +				dma_fence_chain_for_each(iter, fence) {
>> +					if (!iter)
>> +						break;
>> +					dma_fence_put(last_signaled);
>> +					last_signaled = dma_fence_get(iter);
>> +					if (!to_dma_fence_chain(last_signaled)->prev_seqno)
>> +						/* It is most likely that timeline has
>> +						* unorder points. */
>> +						break;
>> +				}
>> +				point = dma_fence_is_signaled(last_signaled) ?
>> +					last_signaled->seqno :
>> +					to_dma_fence_chain(last_signaled)->prev_seqno;
>>    			}
>> -			point = dma_fence_is_signaled(last_signaled) ?
>> -				last_signaled->seqno :
>> -				to_dma_fence_chain(last_signaled)->prev_seqno;
>>    			dma_fence_put(last_signaled);
>>    		} else {
>>    			point = 0;
>>    		}
>> +		dma_fence_put(fence);
>>    		ret = copy_to_user(&points[i], &point, sizeof(uint64_t));
>>    		ret = ret ? -EFAULT : 0;
>>    		if (ret)
>> diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h
>> index 661d73f9a919..fd987ce24d9f 100644
>> --- a/include/uapi/drm/drm.h
>> +++ b/include/uapi/drm/drm.h
>> @@ -777,11 +777,12 @@ struct drm_syncobj_array {
>>    	__u32 pad;
>>    };
>>    
>> +#define DRM_SYNCOBJ_QUERY_FLAGS_LAST_SUBMITTED (1 << 0) /* last available point on timeline syncobj */
>>    struct drm_syncobj_timeline_array {
>>    	__u64 handles;
>>    	__u64 points;
>>    	__u32 count_handles;
>> -	__u32 pad;
>> +	__u32 flags;
>>    };
>>    
>>    
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] drm/syncobj: extend syncobj query ability
  2019-07-23 14:07   ` Chunming Zhou
@ 2019-07-23 14:08     ` Koenig, Christian
  2019-07-30 12:00       ` Koenig, Christian
  0 siblings, 1 reply; 6+ messages in thread
From: Koenig, Christian @ 2019-07-23 14:08 UTC (permalink / raw)
  To: Zhou, David(ChunMing), dri-devel

Am 23.07.19 um 16:07 schrieb Zhou, David(ChunMing):
> 在 2019/7/23 21:58, Koenig, Christian 写道:
>> Am 23.07.19 um 07:22 schrieb Chunming Zhou:
>>> user space needs a flexiable query ability.
>>> So that umd can get last signaled or submitted point.
>>>
>>> Change-Id: I6512b430524ebabe715e602a2bf5abb0a7e780ea
>>> Signed-off-by: Chunming Zhou <david1.zhou@amd.com>
>>> Cc: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
>>> Cc: Christian König <Christian.Koenig@amd.com>
>> I've recently found a bug in drm_syncobj_query_ioctl() which I'm going
>> to commit tomorrow.
> Yes, I've realized. Loinel has put RB on it.
>
>
>> Apart from that it looks good to me,
> Thanks,
>
>
>>    but I think we should cleanup a bit
>> and move the dma_fence_chain_for_each()... into a helper function in
>> dma-fence-chain.c
> Do you mind a saperate cleanup patch for that? I don't want to touch
> kernel directory in this patch, so that we can cherry-pick it easily.

Yeah, works for me as well.

Christian.

>
>
> -David
>
>> Christian.
>>
>>> ---
>>>     drivers/gpu/drm/drm_syncobj.c | 36 +++++++++++++++++------------------
>>>     include/uapi/drm/drm.h        |  3 ++-
>>>     2 files changed, 20 insertions(+), 19 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c
>>> index 3d400905100b..f70dedf3ef4f 100644
>>> --- a/drivers/gpu/drm/drm_syncobj.c
>>> +++ b/drivers/gpu/drm/drm_syncobj.c
>>> @@ -1197,9 +1197,6 @@ drm_syncobj_timeline_signal_ioctl(struct drm_device *dev, void *data,
>>>     	if (!drm_core_check_feature(dev, DRIVER_SYNCOBJ_TIMELINE))
>>>     		return -EOPNOTSUPP;
>>>     
>>> -	if (args->pad != 0)
>>> -		return -EINVAL;
>>> -
>>>     	if (args->count_handles == 0)
>>>     		return -EINVAL;
>>>     
>>> @@ -1268,9 +1265,6 @@ int drm_syncobj_query_ioctl(struct drm_device *dev, void *data,
>>>     	if (!drm_core_check_feature(dev, DRIVER_SYNCOBJ_TIMELINE))
>>>     		return -EOPNOTSUPP;
>>>     
>>> -	if (args->pad != 0)
>>> -		return -EINVAL;
>>> -
>>>     	if (args->count_handles == 0)
>>>     		return -EINVAL;
>>>     
>>> @@ -1291,23 +1285,29 @@ int drm_syncobj_query_ioctl(struct drm_device *dev, void *data,
>>>     		if (chain) {
>>>     			struct dma_fence *iter, *last_signaled = NULL;
>>>     
>>> -			dma_fence_chain_for_each(iter, fence) {
>>> -				if (!iter)
>>> -					break;
>>> -				dma_fence_put(last_signaled);
>>> -				last_signaled = dma_fence_get(iter);
>>> -				if (!to_dma_fence_chain(last_signaled)->prev_seqno)
>>> -					/* It is most likely that timeline has
>>> -					 * unorder points. */
>>> -					break;
>>> +			if (args->flags &
>>> +			    DRM_SYNCOBJ_QUERY_FLAGS_LAST_SUBMITTED) {
>>> +				point = fence->seqno;
>>> +			} else {
>>> +				dma_fence_chain_for_each(iter, fence) {
>>> +					if (!iter)
>>> +						break;
>>> +					dma_fence_put(last_signaled);
>>> +					last_signaled = dma_fence_get(iter);
>>> +					if (!to_dma_fence_chain(last_signaled)->prev_seqno)
>>> +						/* It is most likely that timeline has
>>> +						* unorder points. */
>>> +						break;
>>> +				}
>>> +				point = dma_fence_is_signaled(last_signaled) ?
>>> +					last_signaled->seqno :
>>> +					to_dma_fence_chain(last_signaled)->prev_seqno;
>>>     			}
>>> -			point = dma_fence_is_signaled(last_signaled) ?
>>> -				last_signaled->seqno :
>>> -				to_dma_fence_chain(last_signaled)->prev_seqno;
>>>     			dma_fence_put(last_signaled);
>>>     		} else {
>>>     			point = 0;
>>>     		}
>>> +		dma_fence_put(fence);
>>>     		ret = copy_to_user(&points[i], &point, sizeof(uint64_t));
>>>     		ret = ret ? -EFAULT : 0;
>>>     		if (ret)
>>> diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h
>>> index 661d73f9a919..fd987ce24d9f 100644
>>> --- a/include/uapi/drm/drm.h
>>> +++ b/include/uapi/drm/drm.h
>>> @@ -777,11 +777,12 @@ struct drm_syncobj_array {
>>>     	__u32 pad;
>>>     };
>>>     
>>> +#define DRM_SYNCOBJ_QUERY_FLAGS_LAST_SUBMITTED (1 << 0) /* last available point on timeline syncobj */
>>>     struct drm_syncobj_timeline_array {
>>>     	__u64 handles;
>>>     	__u64 points;
>>>     	__u32 count_handles;
>>> -	__u32 pad;
>>> +	__u32 flags;
>>>     };
>>>     
>>>     

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] drm/syncobj: extend syncobj query ability
  2019-07-23 14:08     ` Koenig, Christian
@ 2019-07-30 12:00       ` Koenig, Christian
  0 siblings, 0 replies; 6+ messages in thread
From: Koenig, Christian @ 2019-07-30 12:00 UTC (permalink / raw)
  To: Zhou, David(ChunMing), dri-devel

Am 23.07.19 um 16:08 schrieb Christian König:
> Am 23.07.19 um 16:07 schrieb Zhou, David(ChunMing):
>> 在 2019/7/23 21:58, Koenig, Christian 写道:
>>> Am 23.07.19 um 07:22 schrieb Chunming Zhou:
>>>> user space needs a flexiable query ability.
>>>> So that umd can get last signaled or submitted point.
>>>>
>>>> Change-Id: I6512b430524ebabe715e602a2bf5abb0a7e780ea
>>>> Signed-off-by: Chunming Zhou <david1.zhou@amd.com>
>>>> Cc: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
>>>> Cc: Christian König <Christian.Koenig@amd.com>
>>> I've recently found a bug in drm_syncobj_query_ioctl() which I'm going
>>> to commit tomorrow.
>> Yes, I've realized. Loinel has put RB on it.
>>
>>
>>> Apart from that it looks good to me,
>> Thanks,
>>
>>
>>>    but I think we should cleanup a bit
>>> and move the dma_fence_chain_for_each()... into a helper function in
>>> dma-fence-chain.c
>> Do you mind a saperate cleanup patch for that? I don't want to touch
>> kernel directory in this patch, so that we can cherry-pick it easily.
>
> Yeah, works for me as well.

Sorry this got delayed a bit. I've just pushed my fix to drm-misc-next 
and amd-staging-drm-next.

Can you rebase and send this one out again? Going to push it to 
drm-misc-next then.

Christian.

>
> Christian.
>
>>
>>
>> -David
>>
>>> Christian.
>>>
>>>> ---
>>>>     drivers/gpu/drm/drm_syncobj.c | 36 
>>>> +++++++++++++++++------------------
>>>>     include/uapi/drm/drm.h        |  3 ++-
>>>>     2 files changed, 20 insertions(+), 19 deletions(-)
>>>>
>>>> diff --git a/drivers/gpu/drm/drm_syncobj.c 
>>>> b/drivers/gpu/drm/drm_syncobj.c
>>>> index 3d400905100b..f70dedf3ef4f 100644
>>>> --- a/drivers/gpu/drm/drm_syncobj.c
>>>> +++ b/drivers/gpu/drm/drm_syncobj.c
>>>> @@ -1197,9 +1197,6 @@ drm_syncobj_timeline_signal_ioctl(struct 
>>>> drm_device *dev, void *data,
>>>>         if (!drm_core_check_feature(dev, DRIVER_SYNCOBJ_TIMELINE))
>>>>             return -EOPNOTSUPP;
>>>>     -    if (args->pad != 0)
>>>> -        return -EINVAL;
>>>> -
>>>>         if (args->count_handles == 0)
>>>>             return -EINVAL;
>>>>     @@ -1268,9 +1265,6 @@ int drm_syncobj_query_ioctl(struct 
>>>> drm_device *dev, void *data,
>>>>         if (!drm_core_check_feature(dev, DRIVER_SYNCOBJ_TIMELINE))
>>>>             return -EOPNOTSUPP;
>>>>     -    if (args->pad != 0)
>>>> -        return -EINVAL;
>>>> -
>>>>         if (args->count_handles == 0)
>>>>             return -EINVAL;
>>>>     @@ -1291,23 +1285,29 @@ int drm_syncobj_query_ioctl(struct 
>>>> drm_device *dev, void *data,
>>>>             if (chain) {
>>>>                 struct dma_fence *iter, *last_signaled = NULL;
>>>>     -            dma_fence_chain_for_each(iter, fence) {
>>>> -                if (!iter)
>>>> -                    break;
>>>> -                dma_fence_put(last_signaled);
>>>> -                last_signaled = dma_fence_get(iter);
>>>> -                if (!to_dma_fence_chain(last_signaled)->prev_seqno)
>>>> -                    /* It is most likely that timeline has
>>>> -                     * unorder points. */
>>>> -                    break;
>>>> +            if (args->flags &
>>>> +                DRM_SYNCOBJ_QUERY_FLAGS_LAST_SUBMITTED) {
>>>> +                point = fence->seqno;
>>>> +            } else {
>>>> +                dma_fence_chain_for_each(iter, fence) {
>>>> +                    if (!iter)
>>>> +                        break;
>>>> +                    dma_fence_put(last_signaled);
>>>> +                    last_signaled = dma_fence_get(iter);
>>>> +                    if 
>>>> (!to_dma_fence_chain(last_signaled)->prev_seqno)
>>>> +                        /* It is most likely that timeline has
>>>> +                        * unorder points. */
>>>> +                        break;
>>>> +                }
>>>> +                point = dma_fence_is_signaled(last_signaled) ?
>>>> +                    last_signaled->seqno :
>>>> + to_dma_fence_chain(last_signaled)->prev_seqno;
>>>>                 }
>>>> -            point = dma_fence_is_signaled(last_signaled) ?
>>>> -                last_signaled->seqno :
>>>> - to_dma_fence_chain(last_signaled)->prev_seqno;
>>>>                 dma_fence_put(last_signaled);
>>>>             } else {
>>>>                 point = 0;
>>>>             }
>>>> +        dma_fence_put(fence);
>>>>             ret = copy_to_user(&points[i], &point, sizeof(uint64_t));
>>>>             ret = ret ? -EFAULT : 0;
>>>>             if (ret)
>>>> diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h
>>>> index 661d73f9a919..fd987ce24d9f 100644
>>>> --- a/include/uapi/drm/drm.h
>>>> +++ b/include/uapi/drm/drm.h
>>>> @@ -777,11 +777,12 @@ struct drm_syncobj_array {
>>>>         __u32 pad;
>>>>     };
>>>>     +#define DRM_SYNCOBJ_QUERY_FLAGS_LAST_SUBMITTED (1 << 0) /* 
>>>> last available point on timeline syncobj */
>>>>     struct drm_syncobj_timeline_array {
>>>>         __u64 handles;
>>>>         __u64 points;
>>>>         __u32 count_handles;
>>>> -    __u32 pad;
>>>> +    __u32 flags;
>>>>     };
>

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-07-30 12:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-23  5:22 [PATCH] drm/syncobj: extend syncobj query ability Chunming Zhou
2019-07-23 13:58 ` Koenig, Christian
2019-07-23 14:07   ` Chunming Zhou
2019-07-23 14:08     ` Koenig, Christian
2019-07-30 12:00       ` Koenig, Christian
2019-07-23 14:06 ` Lionel Landwerlin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.