diff mbox

[06/16] drm/mgag200: Fix logic in mgag200_bo_pin()

Message ID 1374066449-21714-7-git-send-email-eich@suse.com (mailing list archive)
State New, archived
Headers show

Commit Message

Egbert Eich July 17, 2013, 1:07 p.m. UTC
Signed-off-by: Egbert Eich <eich@suse.de>
---
 drivers/gpu/drm/mgag200/mgag200_ttm.c | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)

Comments

Dave Airlie July 23, 2013, 5:38 a.m. UTC | #1
On Wed, Jul 17, 2013 at 11:07 PM, Egbert Eich <eich@suse.com> wrote:
> Signed-off-by: Egbert Eich <eich@suse.de>

Is this just missing a return 0; ? in the bo->pin_count > 0 case?
seems like a simpler patch.

Dave.

> ---
>  drivers/gpu/drm/mgag200/mgag200_ttm.c | 22 +++++++++-------------
>  1 file changed, 9 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/gpu/drm/mgag200/mgag200_ttm.c b/drivers/gpu/drm/mgag200/mgag200_ttm.c
> index 6461fd2..2606031 100644
> --- a/drivers/gpu/drm/mgag200/mgag200_ttm.c
> +++ b/drivers/gpu/drm/mgag200/mgag200_ttm.c
> @@ -350,20 +350,16 @@ int mgag200_bo_pin(struct mgag200_bo *bo, u32 pl_flag, u64 *gpu_addr)
>  {
>         int i, ret;
>
> -       if (bo->pin_count) {
> -               bo->pin_count++;
> -               if (gpu_addr)
> -                       *gpu_addr = mgag200_bo_gpu_offset(bo);
> -       }
> -
> -       mgag200_ttm_placement(bo, pl_flag);
> -       for (i = 0; i < bo->placement.num_placement; i++)
> -               bo->placements[i] |= TTM_PL_FLAG_NO_EVICT;
> -       ret = ttm_bo_validate(&bo->bo, &bo->placement, false, false);
> -       if (ret)
> -               return ret;
>
> -       bo->pin_count = 1;
> +       if (!bo->pin_count) {
> +               mgag200_ttm_placement(bo, pl_flag);
> +               for (i = 0; i < bo->placement.num_placement; i++)
> +                       bo->placements[i] |= TTM_PL_FLAG_NO_EVICT;
> +               ret = ttm_bo_validate(&bo->bo, &bo->placement, false, false);
> +               if (ret)
> +                       return ret;
> +       }
> +       bo->pin_count++;
>         if (gpu_addr)
>                 *gpu_addr = mgag200_bo_gpu_offset(bo);
>         return 0;
> --
> 1.8.1.4
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
diff mbox

Patch

diff --git a/drivers/gpu/drm/mgag200/mgag200_ttm.c b/drivers/gpu/drm/mgag200/mgag200_ttm.c
index 6461fd2..2606031 100644
--- a/drivers/gpu/drm/mgag200/mgag200_ttm.c
+++ b/drivers/gpu/drm/mgag200/mgag200_ttm.c
@@ -350,20 +350,16 @@  int mgag200_bo_pin(struct mgag200_bo *bo, u32 pl_flag, u64 *gpu_addr)
 {
 	int i, ret;
 
-	if (bo->pin_count) {
-		bo->pin_count++;
-		if (gpu_addr)
-			*gpu_addr = mgag200_bo_gpu_offset(bo);
-	}
-
-	mgag200_ttm_placement(bo, pl_flag);
-	for (i = 0; i < bo->placement.num_placement; i++)
-		bo->placements[i] |= TTM_PL_FLAG_NO_EVICT;
-	ret = ttm_bo_validate(&bo->bo, &bo->placement, false, false);
-	if (ret)
-		return ret;
 
-	bo->pin_count = 1;
+	if (!bo->pin_count) {
+		mgag200_ttm_placement(bo, pl_flag);
+		for (i = 0; i < bo->placement.num_placement; i++)
+			bo->placements[i] |= TTM_PL_FLAG_NO_EVICT;
+		ret = ttm_bo_validate(&bo->bo, &bo->placement, false, false);
+		if (ret)
+			return ret;
+	}
+	bo->pin_count++;
 	if (gpu_addr)
 		*gpu_addr = mgag200_bo_gpu_offset(bo);
 	return 0;