All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/radeon: fix userptr BO unpin bug v2
@ 2015-05-05  7:24 Christian König
  2015-05-05 13:48 ` Alex Deucher
  0 siblings, 1 reply; 2+ messages in thread
From: Christian König @ 2015-05-05  7:24 UTC (permalink / raw)
  To: alexdeucher, imirkin; +Cc: dri-devel

From: "monk.liu" <monk.liu@amd.com>

Fixing a memory leak with userptrs.

v2: clean up the loop, use an iterator instead

Signed-off-by: monk.liu <monk.liu@amd.com>
Signed-off-by: Christian König <christian.koenig@amd.com>
CC: stable@vger.kernel.org
---
 drivers/gpu/drm/radeon/radeon_ttm.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
index b292aca..921dd0f 100644
--- a/drivers/gpu/drm/radeon/radeon_ttm.c
+++ b/drivers/gpu/drm/radeon/radeon_ttm.c
@@ -591,7 +591,7 @@ static void radeon_ttm_tt_unpin_userptr(struct ttm_tt *ttm)
 {
 	struct radeon_device *rdev = radeon_get_rdev(ttm->bdev);
 	struct radeon_ttm_tt *gtt = (void *)ttm;
-	struct scatterlist *sg;
+	struct sg_page_iter sg_iter;
 	int i;
 
 	int write = !(gtt->userflags & RADEON_GEM_USERPTR_READONLY);
@@ -605,9 +605,8 @@ static void radeon_ttm_tt_unpin_userptr(struct ttm_tt *ttm)
 	/* free the sg table and pages again */
 	dma_unmap_sg(rdev->dev, ttm->sg->sgl, ttm->sg->nents, direction);
 
-	for_each_sg(ttm->sg->sgl, sg, ttm->sg->nents, i) {
-		struct page *page = sg_page(sg);
-
+	for_each_sg_page(ttm->sg->sgl, &sg_iter, ttm->sg->nents, 0) {
+		struct page *page = sg_page_iter_page(&sg_iter);
 		if (!(gtt->userflags & RADEON_GEM_USERPTR_READONLY))
 			set_page_dirty(page);
 
-- 
1.9.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] drm/radeon: fix userptr BO unpin bug v2
  2015-05-05  7:24 [PATCH] drm/radeon: fix userptr BO unpin bug v2 Christian König
@ 2015-05-05 13:48 ` Alex Deucher
  0 siblings, 0 replies; 2+ messages in thread
From: Alex Deucher @ 2015-05-05 13:48 UTC (permalink / raw)
  To: Christian König; +Cc: Maling list - DRI developers

On Tue, May 5, 2015 at 3:24 AM, Christian König <deathsimple@vodafone.de> wrote:
> From: "monk.liu" <monk.liu@amd.com>
>
> Fixing a memory leak with userptrs.
>
> v2: clean up the loop, use an iterator instead
>
> Signed-off-by: monk.liu <monk.liu@amd.com>
> Signed-off-by: Christian König <christian.koenig@amd.com>
> CC: stable@vger.kernel.org

Applied to my -fixes tree.

Alex


> ---
>  drivers/gpu/drm/radeon/radeon_ttm.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
> index b292aca..921dd0f 100644
> --- a/drivers/gpu/drm/radeon/radeon_ttm.c
> +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
> @@ -591,7 +591,7 @@ static void radeon_ttm_tt_unpin_userptr(struct ttm_tt *ttm)
>  {
>         struct radeon_device *rdev = radeon_get_rdev(ttm->bdev);
>         struct radeon_ttm_tt *gtt = (void *)ttm;
> -       struct scatterlist *sg;
> +       struct sg_page_iter sg_iter;
>         int i;
>
>         int write = !(gtt->userflags & RADEON_GEM_USERPTR_READONLY);
> @@ -605,9 +605,8 @@ static void radeon_ttm_tt_unpin_userptr(struct ttm_tt *ttm)
>         /* free the sg table and pages again */
>         dma_unmap_sg(rdev->dev, ttm->sg->sgl, ttm->sg->nents, direction);
>
> -       for_each_sg(ttm->sg->sgl, sg, ttm->sg->nents, i) {
> -               struct page *page = sg_page(sg);
> -
> +       for_each_sg_page(ttm->sg->sgl, &sg_iter, ttm->sg->nents, 0) {
> +               struct page *page = sg_page_iter_page(&sg_iter);
>                 if (!(gtt->userflags & RADEON_GEM_USERPTR_READONLY))
>                         set_page_dirty(page);
>
> --
> 1.9.1
>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-05-05 13:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-05  7:24 [PATCH] drm/radeon: fix userptr BO unpin bug v2 Christian König
2015-05-05 13:48 ` Alex Deucher

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.