diff mbox

[1/3] drm/radeon: use RCU query for GEM_BUSY syscall

Message ID 1435830072-21835-1-git-send-email-greg@chown.ath.cx (mailing list archive)
State New, archived
Headers show

Commit Message

Grigori Goronzy July 2, 2015, 9:41 a.m. UTC
We don't need to call the (expensive) radeon_bo_wait, checking the
fences via RCU is much faster. The reservation done by radeon_bo_wait
does not save us from any race conditions.
---
 drivers/gpu/drm/radeon/radeon_gem.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

Comments

Alex Deucher July 2, 2015, 2:28 p.m. UTC | #1
On Thu, Jul 2, 2015 at 5:41 AM, Grigori Goronzy <greg@chown.ath.cx> wrote:
> We don't need to call the (expensive) radeon_bo_wait, checking the
> fences via RCU is much faster. The reservation done by radeon_bo_wait
> does not save us from any race conditions.

Can you add your signed-off by to these patches?

Alex

> ---
>  drivers/gpu/drm/radeon/radeon_gem.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/radeon_gem.c b/drivers/gpu/drm/radeon/radeon_gem.c
> index ac3c131..7199e19 100644
> --- a/drivers/gpu/drm/radeon/radeon_gem.c
> +++ b/drivers/gpu/drm/radeon/radeon_gem.c
> @@ -428,7 +428,6 @@ int radeon_gem_mmap_ioctl(struct drm_device *dev, void *data,
>  int radeon_gem_busy_ioctl(struct drm_device *dev, void *data,
>                           struct drm_file *filp)
>  {
> -       struct radeon_device *rdev = dev->dev_private;
>         struct drm_radeon_gem_busy *args = data;
>         struct drm_gem_object *gobj;
>         struct radeon_bo *robj;
> @@ -440,10 +439,16 @@ int radeon_gem_busy_ioctl(struct drm_device *dev, void *data,
>                 return -ENOENT;
>         }
>         robj = gem_to_radeon_bo(gobj);
> -       r = radeon_bo_wait(robj, &cur_placement, true);
> +
> +       r = reservation_object_test_signaled_rcu(robj->tbo.resv, true);
> +       if (r == 0)
> +               r = -EBUSY;
> +       else
> +               r = 0;
> +
> +       cur_placement = ACCESS_ONCE(robj->tbo.mem.mem_type);
>         args->domain = radeon_mem_type_to_domain(cur_placement);
>         drm_gem_object_unreference_unlocked(gobj);
> -       r = radeon_gem_handle_lockup(rdev, r);
>         return r;
>  }
>
> --
> 1.9.1
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
diff mbox

Patch

diff --git a/drivers/gpu/drm/radeon/radeon_gem.c b/drivers/gpu/drm/radeon/radeon_gem.c
index ac3c131..7199e19 100644
--- a/drivers/gpu/drm/radeon/radeon_gem.c
+++ b/drivers/gpu/drm/radeon/radeon_gem.c
@@ -428,7 +428,6 @@  int radeon_gem_mmap_ioctl(struct drm_device *dev, void *data,
 int radeon_gem_busy_ioctl(struct drm_device *dev, void *data,
 			  struct drm_file *filp)
 {
-	struct radeon_device *rdev = dev->dev_private;
 	struct drm_radeon_gem_busy *args = data;
 	struct drm_gem_object *gobj;
 	struct radeon_bo *robj;
@@ -440,10 +439,16 @@  int radeon_gem_busy_ioctl(struct drm_device *dev, void *data,
 		return -ENOENT;
 	}
 	robj = gem_to_radeon_bo(gobj);
-	r = radeon_bo_wait(robj, &cur_placement, true);
+
+	r = reservation_object_test_signaled_rcu(robj->tbo.resv, true);
+	if (r == 0)
+		r = -EBUSY;
+	else
+		r = 0;
+
+	cur_placement = ACCESS_ONCE(robj->tbo.mem.mem_type);
 	args->domain = radeon_mem_type_to_domain(cur_placement);
 	drm_gem_object_unreference_unlocked(gobj);
-	r = radeon_gem_handle_lockup(rdev, r);
 	return r;
 }