Re: [PATCH 2/2] drm/radeon: fix userptr BO unpin bug

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, May 1, 2015 at 6:34 AM, Christian König <deathsimple@xxxxxxxxxxx> wrote:
> From: "monk.liu" <monk.liu@xxxxxxx>
>
> Fixing a memory leak with userptrs.
>
> Signed-off-by: monk.liu <monk.liu@xxxxxxx>
> Signed-off-by: Christian König <christian.koenig@xxxxxxx>
> CC: stable@xxxxxxxxxxxxxxx
> ---
>  drivers/gpu/drm/radeon/radeon_ttm.c | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
> index b292aca..e661841 100644
> --- a/drivers/gpu/drm/radeon/radeon_ttm.c
> +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
> @@ -606,13 +606,18 @@ static void radeon_ttm_tt_unpin_userptr(struct ttm_tt *ttm)
>         dma_unmap_sg(rdev->dev, ttm->sg->sgl, ttm->sg->nents, direction);
>
>         for_each_sg(ttm->sg->sgl, sg, ttm->sg->nents, i) {
> +               int len = sg->length >> PAGE_SHIFT;
>                 struct page *page = sg_page(sg);
> +               while (len > 0) {

This is a really awkward loop... IMO it'd be a lot clearer as

for (i = 0; i < sg->length >> PAGE_SHIFT; i++, page++)

[Also I assume that sg->length is never less than a page?]

> +                       if (!(gtt->userflags & RADEON_GEM_USERPTR_READONLY))
> +                               set_page_dirty(page);
>
> -               if (!(gtt->userflags & RADEON_GEM_USERPTR_READONLY))
> -                       set_page_dirty(page);
> +                       mark_page_accessed(page);
> +                       page_cache_release(page);
>
> -               mark_page_accessed(page);
> -               page_cache_release(page);
> +                       page++;
> +                       len--;
> +               }
>         }
>
>         sg_free_table(ttm->sg);
> --
> 1.9.1
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@xxxxxxxxxxxxxxxxxxxxx
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/dri-devel





[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux