[PATCH] drm/amdgpu: validate shadow before restoring from it
zhoucm1
david1.zhou at amd.com
Tue Apr 25 03:16:57 UTC 2017
On 2017年04月25日 11:14, Roger.He wrote:
> Change-Id: Id925f4e241c4192127880d2017fbf2979aa09fc7
> Signed-off-by: Roger.He <Hongbo.He at amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 33 ++++++++++++++++++++++++++++++
> 1 file changed, 33 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> index f74149c..cebd546 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> @@ -2468,6 +2468,27 @@ bool amdgpu_need_backup(struct amdgpu_device *adev)
> return amdgpu_lockup_timeout > 0 ? true : false;
> }
>
> +static int amdgpu_bo_validate(struct amdgpu_bo *bo)
> +{
> + uint32_t domain;
> + int r;
> +
> + if (bo->pin_count)
> + return 0;
> +
> + domain = bo->prefered_domains;
> +
> +retry:
> + amdgpu_ttm_placement_from_domain(bo, domain);
> + r = ttm_bo_validate(&bo->tbo, &bo->placement, false, false);
> + if (unlikely(r == -ENOMEM) && domain != bo->allowed_domains) {
> + domain = bo->allowed_domains;
> + goto retry;
> + }
> +
> + return r;
> +}
you can move this function to amdgpu_object.c, with that fix, it looks
ok to me, Reviewed-by: Chunming Zhou <david1.zhou at amd.com>
> +
> static int amdgpu_recover_vram_from_shadow(struct amdgpu_device *adev,
> struct amdgpu_ring *ring,
> struct amdgpu_bo *bo,
> @@ -2485,6 +2506,18 @@ static int amdgpu_recover_vram_from_shadow(struct amdgpu_device *adev,
> domain = amdgpu_mem_type_to_domain(bo->tbo.mem.mem_type);
> /* if bo has been evicted, then no need to recover */
> if (domain == AMDGPU_GEM_DOMAIN_VRAM) {
> + r = amdgpu_bo_validate(bo->shadow);
> + if (r) {
> + DRM_ERROR("bo validate failed!\n");
> + goto err;
> + }
> +
> + r = amdgpu_ttm_bind(&bo->shadow->tbo, &bo->shadow->tbo.mem);
> + if (r) {
> + DRM_ERROR("%p bind failed\n", bo->shadow);
> + goto err;
> + }
> +
> r = amdgpu_bo_restore_from_shadow(adev, ring, bo,
> NULL, fence, true);
> if (r) {
More information about the amd-gfx
mailing list