From: zhoucm1 <david1.zhou-5C7GfCeVMHo@public.gmane.org>
To: "Roger.He" <Hongbo.He-5C7GfCeVMHo@public.gmane.org>,
amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: Re: [PATCH 2/3] drm/amdgpu: validate bo before restoring from shadow
Date: Fri, 21 Apr 2017 15:13:48 +0800 [thread overview]
Message-ID: <58F9B12C.1020704@amd.com> (raw)
In-Reply-To: <1492758472-12585-1-git-send-email-Hongbo.He-5C7GfCeVMHo@public.gmane.org>
On 2017年04月21日 15:07, Roger.He wrote:
> Change-Id: Id925f4e241c4192127880d2017fbf2979aa09fc7
> Signed-off-by: Roger.He <Hongbo.He@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 46 ++++++++++++++++++++++++++++++
> 1 file changed, 46 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> index 3d8f227..f882496 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> @@ -2468,6 +2468,40 @@ bool amdgpu_need_backup(struct amdgpu_device *adev)
> return amdgpu_lockup_timeout > 0 ? true : false;
> }
>
> +static int amdgpu_bo_validate_helper(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;
> +}
> +
> +static int amdgpu_bo_validate(struct amdgpu_bo *bo)
> +{
> + int r = amdgpu_bo_validate_helper(bo);
> +
> + if (r)
> + return r;
> +
> + if (bo->shadow)
> + r = amdgpu_bo_validate_helper(bo->shadow);
> +
> + return r;
> +}
> +
> static int amdgpu_recover_vram_from_shadow(struct amdgpu_device *adev,
> struct amdgpu_ring *ring,
> struct amdgpu_bo *bo,
> @@ -2485,6 +2519,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);
you only need to validate shadow, parent already is checked.
Regards,
David Zhou
> + 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) {
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
prev parent reply other threads:[~2017-04-21 7:13 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-21 7:07 [PATCH 2/3] drm/amdgpu: validate bo before restoring from shadow Roger.He
[not found] ` <1492758472-12585-1-git-send-email-Hongbo.He-5C7GfCeVMHo@public.gmane.org>
2017-04-21 7:13 ` zhoucm1 [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=58F9B12C.1020704@amd.com \
--to=david1.zhou-5c7gfcevmho@public.gmane.org \
--cc=Hongbo.He-5C7GfCeVMHo@public.gmane.org \
--cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox