[amd-gfx] [PATCH] drm/amdgpu: split sync to VM fence into separate function

Alex Deucher alexdeucher at gmail.com
Thu Jun 16 16:13:56 UTC 2016


On Thu, Jun 16, 2016 at 8:59 AM, Christian König
<deathsimple at vodafone.de> wrote:
> From: Christian König <christian.koenig at amd.com>
>
> We know which fences are the VM fences, so no need to test them all the time.
>
> Signed-off-by: Christian König <christian.koenig at amd.com>

Nice clean up.

Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu.h      |  2 ++
>  drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c   |  5 ++---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c | 22 ++++++++++++++++++----
>  3 files changed, 22 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> index 8c8d4fe..51b6d0a1 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> @@ -593,6 +593,8 @@ struct amdgpu_sync {
>  void amdgpu_sync_create(struct amdgpu_sync *sync);
>  int amdgpu_sync_fence(struct amdgpu_device *adev, struct amdgpu_sync *sync,
>                       struct fence *f);
> +int amdgpu_sync_vm_fence(struct amdgpu_device *adev, struct amdgpu_sync *sync,
> +                        struct fence *f);
>  int amdgpu_sync_resv(struct amdgpu_device *adev,
>                      struct amdgpu_sync *sync,
>                      struct reservation_object *resv,
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> index 523da20..a67fb2b 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> @@ -593,7 +593,7 @@ static int amdgpu_bo_vm_update_pte(struct amdgpu_cs_parser *p,
>         if (r)
>                 return r;
>
> -       r = amdgpu_sync_fence(adev, &p->job->sync, vm->page_directory_fence);
> +       r = amdgpu_sync_vm_fence(adev, &p->job->sync, vm->page_directory_fence);
>         if (r)
>                 return r;
>
> @@ -619,11 +619,10 @@ static int amdgpu_bo_vm_update_pte(struct amdgpu_cs_parser *p,
>                                 return r;
>
>                         f = bo_va->last_pt_update;
> -                       r = amdgpu_sync_fence(adev, &p->job->sync, f);
> +                       r = amdgpu_sync_vm_fence(adev, &p->job->sync, f);
>                         if (r)
>                                 return r;
>                 }
> -
>         }
>
>         r = amdgpu_vm_clear_invalids(adev, vm, &p->job->sync);
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c
> index 5c8d302..d8a8acb 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_sync.c
> @@ -146,10 +146,6 @@ int amdgpu_sync_fence(struct amdgpu_device *adev, struct amdgpu_sync *sync,
>         if (!f)
>                 return 0;
>
> -       if (amdgpu_sync_same_dev(adev, f) &&
> -           amdgpu_sync_get_owner(f) == AMDGPU_FENCE_OWNER_VM)
> -               amdgpu_sync_keep_later(&sync->last_vm_update, f);
> -
>         if (amdgpu_sync_add_later(sync, f))
>                 return 0;
>
> @@ -163,6 +159,24 @@ int amdgpu_sync_fence(struct amdgpu_device *adev, struct amdgpu_sync *sync,
>  }
>
>  /**
> + * amdgpu_sync_vm_fence - remember to sync to this VM fence
> + *
> + * @sync: sync object to add fence to
> + * @fence: fence to sync to
> + *
> + * Sync to fence and remember it as VM update.
> + */
> +int amdgpu_sync_vm_fence(struct amdgpu_device *adev, struct amdgpu_sync *sync,
> +                        struct fence *f)
> +{
> +       if (!f)
> +               return 0;
> +
> +       amdgpu_sync_keep_later(&sync->last_vm_update, f);
> +       return amdgpu_sync_fence(adev, sync, f);
> +}
> +
> +/**
>   * amdgpu_sync_resv - sync to a reservation object
>   *
>   * @sync: sync object to add fences from reservation object to
> --
> 2.5.0
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx


More information about the amd-gfx mailing list