diff mbox

[03/11] drm/msm: Remove call to reservation_object_test_signaled_rcu before wait

Message ID 20160829070834.22296-3-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show

Commit Message

Chris Wilson Aug. 29, 2016, 7:08 a.m. UTC
Since fence_wait_timeout_reservation_object_wait_timeout_rcu() with a
timeout of 0 becomes reservation_object_test_signaled_rcu(), we do not
need to handle such conversion in the caller. The only challenge are
those callers that wish to differentiate the error code between the
nonblocking busy check and potentially blocking wait.

v2: 9 is only 0 in German.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Rob Clark <robdclark@gmail.com>
---
 drivers/gpu/drm/msm/msm_gem.c | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

Comments

Daniel Vetter Sept. 23, 2016, 12:55 p.m. UTC | #1
On Mon, Aug 29, 2016 at 08:08:26AM +0100, Chris Wilson wrote:
> Since fence_wait_timeout_reservation_object_wait_timeout_rcu() with a
> timeout of 0 becomes reservation_object_test_signaled_rcu(), we do not
> need to handle such conversion in the caller. The only challenge are
> those callers that wish to differentiate the error code between the
> nonblocking busy check and potentially blocking wait.
> 
> v2: 9 is only 0 in German.
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Rob Clark <robdclark@gmail.com>

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> ---
>  drivers/gpu/drm/msm/msm_gem.c | 22 ++++++++++------------
>  1 file changed, 10 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
> index 6cd4af443139..45796a88d353 100644
> --- a/drivers/gpu/drm/msm/msm_gem.c
> +++ b/drivers/gpu/drm/msm/msm_gem.c
> @@ -584,18 +584,16 @@ int msm_gem_cpu_prep(struct drm_gem_object *obj, uint32_t op, ktime_t *timeout)
>  {
>  	struct msm_gem_object *msm_obj = to_msm_bo(obj);
>  	bool write = !!(op & MSM_PREP_WRITE);
> -
> -	if (op & MSM_PREP_NOSYNC) {
> -		if (!reservation_object_test_signaled_rcu(msm_obj->resv, write))
> -			return -EBUSY;
> -	} else {
> -		int ret;
> -
> -		ret = reservation_object_wait_timeout_rcu(msm_obj->resv, write,
> -				true, timeout_to_jiffies(timeout));
> -		if (ret <= 0)
> -			return ret == 0 ? -ETIMEDOUT : ret;
> -	}
> +	unsigned long remain =
> +		op & MSG_PREP_NOSYNC ? 0 : timeout_to_jiffies(timeout);
> +	long ret;
> +
> +	ret = reservation_object_wait_timeout_rcu(msm_obj->resv, write,
> +						  true,  remain);
> +	if (ret == 0)
> +		return remain == 0 ? -EBUSY : -ETIMEDOUT;
> +	else if (ret < 0)
> +		return ret;
>  
>  	/* TODO cache maintenance */
>  
> -- 
> 2.9.3
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
Rob Clark Sept. 23, 2016, 1:07 p.m. UTC | #2
On Fri, Sep 23, 2016 at 8:55 AM, Daniel Vetter <daniel@ffwll.ch> wrote:
> On Mon, Aug 29, 2016 at 08:08:26AM +0100, Chris Wilson wrote:
>> Since fence_wait_timeout_reservation_object_wait_timeout_rcu() with a
>> timeout of 0 becomes reservation_object_test_signaled_rcu(), we do not
>> need to handle such conversion in the caller. The only challenge are
>> those callers that wish to differentiate the error code between the
>> nonblocking busy check and potentially blocking wait.
>>
>> v2: 9 is only 0 in German.
>>
>> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
>> Cc: Rob Clark <robdclark@gmail.com>
>
> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

fyi, this is in my msm-next pull-req sent last week..  (with one small
s/MSG_PREP_NOSYNC/MSM_PREP_NOSYNC/ fixup ;-))

BR,
-R


>> ---
>>  drivers/gpu/drm/msm/msm_gem.c | 22 ++++++++++------------
>>  1 file changed, 10 insertions(+), 12 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
>> index 6cd4af443139..45796a88d353 100644
>> --- a/drivers/gpu/drm/msm/msm_gem.c
>> +++ b/drivers/gpu/drm/msm/msm_gem.c
>> @@ -584,18 +584,16 @@ int msm_gem_cpu_prep(struct drm_gem_object *obj, uint32_t op, ktime_t *timeout)
>>  {
>>       struct msm_gem_object *msm_obj = to_msm_bo(obj);
>>       bool write = !!(op & MSM_PREP_WRITE);
>> -
>> -     if (op & MSM_PREP_NOSYNC) {
>> -             if (!reservation_object_test_signaled_rcu(msm_obj->resv, write))
>> -                     return -EBUSY;
>> -     } else {
>> -             int ret;
>> -
>> -             ret = reservation_object_wait_timeout_rcu(msm_obj->resv, write,
>> -                             true, timeout_to_jiffies(timeout));
>> -             if (ret <= 0)
>> -                     return ret == 0 ? -ETIMEDOUT : ret;
>> -     }
>> +     unsigned long remain =
>> +             op & MSG_PREP_NOSYNC ? 0 : timeout_to_jiffies(timeout);
>> +     long ret;
>> +
>> +     ret = reservation_object_wait_timeout_rcu(msm_obj->resv, write,
>> +                                               true,  remain);
>> +     if (ret == 0)
>> +             return remain == 0 ? -EBUSY : -ETIMEDOUT;
>> +     else if (ret < 0)
>> +             return ret;
>>
>>       /* TODO cache maintenance */
>>
>> --
>> 2.9.3
>>
>> _______________________________________________
>> dri-devel mailing list
>> dri-devel@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/dri-devel
>
> --
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
diff mbox

Patch

diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
index 6cd4af443139..45796a88d353 100644
--- a/drivers/gpu/drm/msm/msm_gem.c
+++ b/drivers/gpu/drm/msm/msm_gem.c
@@ -584,18 +584,16 @@  int msm_gem_cpu_prep(struct drm_gem_object *obj, uint32_t op, ktime_t *timeout)
 {
 	struct msm_gem_object *msm_obj = to_msm_bo(obj);
 	bool write = !!(op & MSM_PREP_WRITE);
-
-	if (op & MSM_PREP_NOSYNC) {
-		if (!reservation_object_test_signaled_rcu(msm_obj->resv, write))
-			return -EBUSY;
-	} else {
-		int ret;
-
-		ret = reservation_object_wait_timeout_rcu(msm_obj->resv, write,
-				true, timeout_to_jiffies(timeout));
-		if (ret <= 0)
-			return ret == 0 ? -ETIMEDOUT : ret;
-	}
+	unsigned long remain =
+		op & MSG_PREP_NOSYNC ? 0 : timeout_to_jiffies(timeout);
+	long ret;
+
+	ret = reservation_object_wait_timeout_rcu(msm_obj->resv, write,
+						  true,  remain);
+	if (ret == 0)
+		return remain == 0 ? -EBUSY : -ETIMEDOUT;
+	else if (ret < 0)
+		return ret;
 
 	/* TODO cache maintenance */