* [PATCH] drm/amdgpu/ttm: Fix memory leak userptr pages
@ 2021-03-17 16:08 Daniel Gomez
2021-03-18 7:49 ` Christian König
2021-03-19 2:56 ` Alex Deucher
0 siblings, 2 replies; 4+ messages in thread
From: Daniel Gomez @ 2021-03-17 16:08 UTC (permalink / raw)
Cc: dagmcr, Daniel Gomez, Alex Deucher, Christian König,
David Airlie, Daniel Vetter, Dave Airlie, Felix Kuehling,
Likun Gao, amd-gfx, dri-devel, linux-kernel
If userptr pages have been pinned but not bounded,
they remain uncleared.
Signed-off-by: Daniel Gomez <daniel@qtec.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 9fd2157b133a..50c2b4827c13 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -1162,13 +1162,13 @@ static void amdgpu_ttm_backend_unbind(struct ttm_bo_device *bdev,
struct amdgpu_ttm_tt *gtt = (void *)ttm;
int r;
- if (!gtt->bound)
- return;
-
/* if the pages have userptr pinning then clear that first */
if (gtt->userptr)
amdgpu_ttm_tt_unpin_userptr(bdev, ttm);
+ if (!gtt->bound)
+ return;
+
if (gtt->offset == AMDGPU_BO_INVALID_OFFSET)
return;
--
2.30.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] drm/amdgpu/ttm: Fix memory leak userptr pages
2021-03-17 16:08 [PATCH] drm/amdgpu/ttm: Fix memory leak userptr pages Daniel Gomez
@ 2021-03-18 7:49 ` Christian König
2021-03-18 8:18 ` Daniel Gomez
2021-03-19 2:56 ` Alex Deucher
1 sibling, 1 reply; 4+ messages in thread
From: Christian König @ 2021-03-18 7:49 UTC (permalink / raw)
To: Daniel Gomez
Cc: dagmcr, Alex Deucher, David Airlie, Daniel Vetter, Dave Airlie,
Felix Kuehling, Likun Gao, amd-gfx, dri-devel, linux-kernel
Am 17.03.21 um 17:08 schrieb Daniel Gomez:
> If userptr pages have been pinned but not bounded,
> they remain uncleared.
>
> Signed-off-by: Daniel Gomez <daniel@qtec.com>
Good catch, not sure if that can ever happen in practice but better save
than sorry.
Reviewed-by: Christian König <christian.koenig@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> index 9fd2157b133a..50c2b4827c13 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> @@ -1162,13 +1162,13 @@ static void amdgpu_ttm_backend_unbind(struct ttm_bo_device *bdev,
> struct amdgpu_ttm_tt *gtt = (void *)ttm;
> int r;
>
> - if (!gtt->bound)
> - return;
> -
> /* if the pages have userptr pinning then clear that first */
> if (gtt->userptr)
> amdgpu_ttm_tt_unpin_userptr(bdev, ttm);
>
> + if (!gtt->bound)
> + return;
> +
> if (gtt->offset == AMDGPU_BO_INVALID_OFFSET)
> return;
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] drm/amdgpu/ttm: Fix memory leak userptr pages
2021-03-18 7:49 ` Christian König
@ 2021-03-18 8:18 ` Daniel Gomez
0 siblings, 0 replies; 4+ messages in thread
From: Daniel Gomez @ 2021-03-18 8:18 UTC (permalink / raw)
To: Christian König
Cc: Daniel Gomez, Alex Deucher, David Airlie, Daniel Vetter,
Dave Airlie, Felix Kuehling, Likun Gao, amd-gfx list, dri-devel,
Linux Kernel Mailing List
On Thu, 18 Mar 2021 at 08:49, Christian König <christian.koenig@amd.com> wrote:
>
> Am 17.03.21 um 17:08 schrieb Daniel Gomez:
> > If userptr pages have been pinned but not bounded,
> > they remain uncleared.
> >
> > Signed-off-by: Daniel Gomez <daniel@qtec.com>
>
> Good catch, not sure if that can ever happen in practice but better save
> than sorry.
Thanks! We actually had a case with clEnqueueWriteBuffer where the
driver was leaking.
I can see the problem also affects to the radeon driver so, I'll send
a patch for that one as
well.
>
> Reviewed-by: Christian König <christian.koenig@amd.com>
>
> > ---
> > drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 6 +++---
> > 1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> > index 9fd2157b133a..50c2b4827c13 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> > @@ -1162,13 +1162,13 @@ static void amdgpu_ttm_backend_unbind(struct ttm_bo_device *bdev,
> > struct amdgpu_ttm_tt *gtt = (void *)ttm;
> > int r;
> >
> > - if (!gtt->bound)
> > - return;
> > -
> > /* if the pages have userptr pinning then clear that first */
> > if (gtt->userptr)
> > amdgpu_ttm_tt_unpin_userptr(bdev, ttm);
> >
> > + if (!gtt->bound)
> > + return;
> > +
> > if (gtt->offset == AMDGPU_BO_INVALID_OFFSET)
> > return;
> >
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] drm/amdgpu/ttm: Fix memory leak userptr pages
2021-03-17 16:08 [PATCH] drm/amdgpu/ttm: Fix memory leak userptr pages Daniel Gomez
2021-03-18 7:49 ` Christian König
@ 2021-03-19 2:56 ` Alex Deucher
1 sibling, 0 replies; 4+ messages in thread
From: Alex Deucher @ 2021-03-19 2:56 UTC (permalink / raw)
To: Daniel Gomez
Cc: Maling list - DRI developers, David Airlie, Felix Kuehling, LKML,
amd-gfx list, Likun Gao, dagmcr, Alex Deucher, Dave Airlie,
Christian König
Applied. Thanks!
Alex
On Wed, Mar 17, 2021 at 12:09 PM Daniel Gomez <daniel@qtec.com> wrote:
>
> If userptr pages have been pinned but not bounded,
> they remain uncleared.
>
> Signed-off-by: Daniel Gomez <daniel@qtec.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> index 9fd2157b133a..50c2b4827c13 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> @@ -1162,13 +1162,13 @@ static void amdgpu_ttm_backend_unbind(struct ttm_bo_device *bdev,
> struct amdgpu_ttm_tt *gtt = (void *)ttm;
> int r;
>
> - if (!gtt->bound)
> - return;
> -
> /* if the pages have userptr pinning then clear that first */
> if (gtt->userptr)
> amdgpu_ttm_tt_unpin_userptr(bdev, ttm);
>
> + if (!gtt->bound)
> + return;
> +
> if (gtt->offset == AMDGPU_BO_INVALID_OFFSET)
> return;
>
> --
> 2.30.2
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-03-19 2:57 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-17 16:08 [PATCH] drm/amdgpu/ttm: Fix memory leak userptr pages Daniel Gomez
2021-03-18 7:49 ` Christian König
2021-03-18 8:18 ` Daniel Gomez
2021-03-19 2:56 ` Alex Deucher
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).