[PATCH 2/2] drm/ttm: use RCU to pipeline evictions

Alex Deucher alexdeucher at gmail.com
Tue Jul 5 21:14:40 UTC 2016


On Tue, Jul 5, 2016 at 8:30 AM, Christian König <deathsimple at vodafone.de> wrote:
> From: Christian König <christian.koenig at amd.com>
>
> Could be faster on the read path.
>
> Signed-off-by: Christian König <christian.koenig at amd.com>

Just one style nit pick below.  Beyond that, the series is:
Reviewed-by: Alex Deucher <alexander.deucher at amd.com>


> ---
>  drivers/gpu/drm/ttm/ttm_bo.c      | 16 ++++++++++------
>  drivers/gpu/drm/ttm/ttm_bo_util.c |  8 +++++---
>  2 files changed, 15 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index 66c50ad..7e30f3b 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -797,9 +797,11 @@ static int ttm_bo_add_move_fence(struct ttm_buffer_object *bo,
>         struct fence *fence;
>         int ret;
>
> -       spin_lock(&man->move_lock);
> -       fence = fence_get(man->move);
> -       spin_unlock(&man->move_lock);
> +       rcu_read_lock();
> +       do
> +               fence = rcu_dereference(man->move);
> +       while (unlikely(fence && !fence_get_rcu(fence)));

I generally like to see parens with do/while loops.

> +       rcu_read_unlock();
>
>         if (fence) {
>                 reservation_object_add_shared_fence(bo->resv, fence);
> @@ -1304,9 +1306,11 @@ static int ttm_bo_force_list_clean(struct ttm_bo_device *bdev,
>         }
>         spin_unlock(&glob->lru_lock);
>
> -       spin_lock(&man->move_lock);
> -       fence = fence_get(man->move);
> -       spin_unlock(&man->move_lock);
> +       rcu_read_lock();
> +       do
> +               fence = rcu_dereference(man->move);
> +       while (unlikely(fence && !fence_get_rcu(fence)));

Same here.

> +       rcu_read_unlock();
>
>         if (fence) {
>                 ret = fence_wait(fence, false);
> diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c
> index 4da0e78..fcd2431 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo_util.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
> @@ -746,6 +746,7 @@ int ttm_bo_pipeline_move(struct ttm_buffer_object *bo,
>                 ttm_bo_unref(&ghost_obj);
>
>         } else if (from->flags & TTM_MEMTYPE_FLAG_FIXED) {
> +               struct fence *old;
>
>                 /**
>                  * BO doesn't have a TTM we need to bind/unbind. Just remember
> @@ -753,9 +754,10 @@ int ttm_bo_pipeline_move(struct ttm_buffer_object *bo,
>                  */
>
>                 spin_lock(&from->move_lock);
> -               if (!from->move || fence_is_later(fence, from->move)) {
> -                       fence_put(from->move);
> -                       from->move = fence_get(fence);
> +               old = rcu_dereference_protected(from->move, 1);
> +               if (!old || fence_is_later(fence, old)) {
> +                       rcu_assign_pointer(from->move, fence_get(fence));
> +                       fence_put(old);
>                 }
>                 spin_unlock(&from->move_lock);
>
> --
> 2.5.0
>
> _______________________________________________
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel


More information about the dri-devel mailing list