* [PATCH] drm/amdgpu: validate shadow before restoring from it
@ 2017-04-25 3:14 Roger.He
[not found] ` <1493090078-29023-1-git-send-email-Hongbo.He-5C7GfCeVMHo@public.gmane.org>
0 siblings, 1 reply; 4+ messages in thread
From: Roger.He @ 2017-04-25 3:14 UTC (permalink / raw)
To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
Cc: david1.zhou-5C7GfCeVMHo, Roger.He
Change-Id: Id925f4e241c4192127880d2017fbf2979aa09fc7
Signed-off-by: Roger.He <Hongbo.He@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;
+}
+
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) {
--
2.7.4
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply related [flat|nested] 4+ messages in thread[parent not found: <1493090078-29023-1-git-send-email-Hongbo.He-5C7GfCeVMHo@public.gmane.org>]
* Re: [PATCH] drm/amdgpu: validate shadow before restoring from it [not found] ` <1493090078-29023-1-git-send-email-Hongbo.He-5C7GfCeVMHo@public.gmane.org> @ 2017-04-25 3:16 ` zhoucm1 [not found] ` <58FEBFA9.7050700-5C7GfCeVMHo@public.gmane.org> 0 siblings, 1 reply; 4+ messages in thread From: zhoucm1 @ 2017-04-25 3:16 UTC (permalink / raw) To: Roger.He, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW On 2017年04月25日 11:14, Roger.He wrote: > Change-Id: Id925f4e241c4192127880d2017fbf2979aa09fc7 > Signed-off-by: Roger.He <Hongbo.He@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@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) { _______________________________________________ amd-gfx mailing list amd-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/amd-gfx ^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <58FEBFA9.7050700-5C7GfCeVMHo@public.gmane.org>]
* Re: [PATCH] drm/amdgpu: validate shadow before restoring from it [not found] ` <58FEBFA9.7050700-5C7GfCeVMHo@public.gmane.org> @ 2017-04-25 8:09 ` Christian König [not found] ` <21598379-3859-bf61-50b9-467cbd40ab74-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org> 0 siblings, 1 reply; 4+ messages in thread From: Christian König @ 2017-04-25 8:09 UTC (permalink / raw) To: zhoucm1, Roger.He, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW Am 25.04.2017 um 05:16 schrieb zhoucm1: > > > On 2017年04月25日 11:14, Roger.He wrote: >> Change-Id: Id925f4e241c4192127880d2017fbf2979aa09fc7 >> Signed-off-by: Roger.He <Hongbo.He@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@amd.com> Yeah, agree. Might even be a good idea to use this helper in amdgpu_cs.c as well. IIRC we had something very similar in there as well. But that should be a separate patch, with the function moved to amdgpu_object.c this patch is Reviewed-by: Christian König <christian.koenig@amd.com> as well. Regards, Christian. > >> + >> 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) { > > _______________________________________________ > amd-gfx mailing list > amd-gfx@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/amd-gfx _______________________________________________ amd-gfx mailing list amd-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/amd-gfx ^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <21598379-3859-bf61-50b9-467cbd40ab74-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>]
* RE: [PATCH] drm/amdgpu: validate shadow before restoring from it [not found] ` <21598379-3859-bf61-50b9-467cbd40ab74-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org> @ 2017-04-25 8:49 ` He, Hongbo 0 siblings, 0 replies; 4+ messages in thread From: He, Hongbo @ 2017-04-25 8:49 UTC (permalink / raw) To: Christian König, Zhou, David(ChunMing), amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org -----Original Message----- From: Christian König [mailto:deathsimple@vodafone.de] Sent: Tuesday, April 25, 2017 4:10 PM To: Zhou, David(ChunMing); He, Hongbo; amd-gfx@lists.freedesktop.org Subject: Re: [PATCH] drm/amdgpu: validate shadow before restoring from it Am 25.04.2017 um 05:16 schrieb zhoucm1: > > > On 2017年04月25日 11:14, Roger.He wrote: >> Change-Id: Id925f4e241c4192127880d2017fbf2979aa09fc7 >> Signed-off-by: Roger.He <Hongbo.He@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@amd.com> Yeah, agree. Might even be a good idea to use this helper in amdgpu_cs.c as well. IIRC we had something very similar in there as well. Yes, I have noticed they have some similar logic code. Later if have time, I will try to do that. Thanks for your suggestion! Thanks Roger(Hongbo.He) But that should be a separate patch, with the function moved to amdgpu_object.c this patch is Reviewed-by: Christian König <christian.koenig@amd.com> as well. Regards, Christian. > >> + >> 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) { > > _______________________________________________ > amd-gfx mailing list > amd-gfx@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/amd-gfx _______________________________________________ amd-gfx mailing list amd-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/amd-gfx ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-04-25 8:49 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-25 3:14 [PATCH] drm/amdgpu: validate shadow before restoring from it Roger.He
[not found] ` <1493090078-29023-1-git-send-email-Hongbo.He-5C7GfCeVMHo@public.gmane.org>
2017-04-25 3:16 ` zhoucm1
[not found] ` <58FEBFA9.7050700-5C7GfCeVMHo@public.gmane.org>
2017-04-25 8:09 ` Christian König
[not found] ` <21598379-3859-bf61-50b9-467cbd40ab74-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2017-04-25 8:49 ` He, Hongbo
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.