Skip to contentSkip to conversation

drm/radeon: fix check order in radeon_bo_move

PATCH In review Christian König 4 participants 8 messages Nov 25, 2020 – Nov 27, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/radeon: fix check order in radeon_bo_move

Reorder the code to fix checking if blitting is available.

---
 drivers/gpu/drm/radeon/radeon_ttm.c | 54 +++++++++++++----------------
 1 file changed, 24 insertions(+), 30 deletions(-)
drivers/gpu/drm/radeon/radeon_ttm.c +24 -30
index 0ca381b95d3d..2b598141225f 100644
@@ -216,27 +216,15 @@ static int radeon_bo_move(struct ttm_buffer_object *bo, bool evict,
 	struct ttm_resource *old_mem = &bo->mem;
 	int r;
 
-	if ((old_mem->mem_type == TTM_PL_SYSTEM &&
-	     new_mem->mem_type == TTM_PL_VRAM) ||
-	    (old_mem->mem_type == TTM_PL_VRAM &&
-	     new_mem->mem_type == TTM_PL_SYSTEM)) {
-		hop->fpfn = 0;
-		hop->lpfn = 0;
-		hop->mem_type = TTM_PL_TT;
-		hop->flags = 0;
-		return -EMULTIHOP;
-	}
-
 	if (new_mem->mem_type == TTM_PL_TT) {
 		r = radeon_ttm_tt_bind(bo->bdev, bo->ttm, new_mem);
 		if (r)
 			return r;
 	}
-	radeon_bo_move_notify(bo, evict, new_mem);
 
 	r = ttm_bo_wait_ctx(bo, ctx);
 	if (r)
-		goto fail;
+		return r;
 
 	/* Can't move a pinned BO */
 	rbo = container_of(bo, struct radeon_bo, tbo);
@@ -246,12 +234,12 @@ static int radeon_bo_move(struct ttm_buffer_object *bo, bool evict,
 	rdev = radeon_get_rdev(bo->bdev);
 	if (old_mem->mem_type == TTM_PL_SYSTEM && bo->ttm == NULL) {
 		ttm_bo_move_null(bo, new_mem);
-		return 0;
+		goto out;
 	}
 	if (old_mem->mem_type == TTM_PL_SYSTEM &&
 	    new_mem->mem_type == TTM_PL_TT) {
 		ttm_bo_move_null(bo, new_mem);
-		return 0;
+		goto out;
 	}
 
 	if (old_mem->mem_type == TTM_PL_TT &&
@@ -259,31 +247,37 @@ static int radeon_bo_move(struct ttm_buffer_object *bo, bool evict,
 		radeon_ttm_tt_unbind(bo->bdev, bo->ttm);
 		ttm_resource_free(bo, &bo->mem);
 		ttm_bo_assign_mem(bo, new_mem);
-		return 0;
+		goto out;
 	}
-	if (!rdev->ring[radeon_copy_ring_index(rdev)].ready ||
-	    rdev->asic->copy.copy == NULL) {
-		/* use memcpy */
-		goto memcpy;
+	if (rdev->ring[radeon_copy_ring_index(rdev)].ready &&
+	    rdev->asic->copy.copy != NULL) {
+		if ((old_mem->mem_type == TTM_PL_SYSTEM &&
+		     new_mem->mem_type == TTM_PL_VRAM) ||
+		    (old_mem->mem_type == TTM_PL_VRAM &&
+		     new_mem->mem_type == TTM_PL_SYSTEM)) {
+			hop->fpfn = 0;
+			hop->lpfn = 0;
+			hop->mem_type = TTM_PL_TT;
+			hop->flags = 0;
+			return -EMULTIHOP;
+		}
+
+		r = radeon_move_blit(bo, evict, new_mem, old_mem);
+	} else {
+		r = -ENODEV;
 	}
 
-	r = radeon_move_blit(bo, evict, new_mem, old_mem);
 	if (r) {
-memcpy:
 		r = ttm_bo_move_memcpy(bo, ctx, new_mem);
-		if (r) {
-			goto fail;
-		}
+		if (r)
+			return r;
 	}
 
+out:
 	/* update statistics */
 	atomic64_add((u64)bo->num_pages << PAGE_SHIFT, &rdev->num_bytes_moved);
+	radeon_bo_move_notify(bo, evict, new_mem);
 	return 0;
-fail:
-	swap(*new_mem, bo->mem);
-	radeon_bo_move_notify(bo, false, new_mem);
-	swap(*new_mem, bo->mem);
-	return r;
 }
 
 static int radeon_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_resource *mem)
Signature · 6 lines
2.25.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#1 lore raw

Ping, Dave this is another fix for the Multihop patch set.

Without it radeon is completely broken on drm-misc-next.

Thanks,
Christian.

Am 25.11.20 um 15:34 schrieb Christian König:

Quoted 98 lines

Reorder the code to fix checking if blitting is available.

---
  drivers/gpu/drm/radeon/radeon_ttm.c | 54 +++++++++++++----------------
  1 file changed, 24 insertions(+), 30 deletions(-)
drivers/gpu/drm/radeon/radeon_ttm.c +23 -25
index 0ca381b95d3d..2b598141225f 100644
@@ -216,27 +216,15 @@ static int radeon_bo_move(struct ttm_buffer_object *bo, bool evict,
  	struct ttm_resource *old_mem = &bo->mem;
  	int r;
 
-	if ((old_mem->mem_type == TTM_PL_SYSTEM &&
-	     new_mem->mem_type == TTM_PL_VRAM) ||
-	    (old_mem->mem_type == TTM_PL_VRAM &&
-	     new_mem->mem_type == TTM_PL_SYSTEM)) {
-		hop->fpfn = 0;
-		hop->lpfn = 0;
-		hop->mem_type = TTM_PL_TT;
-		hop->flags = 0;
-		return -EMULTIHOP;
-	}
-
  	if (new_mem->mem_type == TTM_PL_TT) {
  		r = radeon_ttm_tt_bind(bo->bdev, bo->ttm, new_mem);
  		if (r)
  			return r;
  	}
-	radeon_bo_move_notify(bo, evict, new_mem);
 
  	r = ttm_bo_wait_ctx(bo, ctx);
  	if (r)
-		goto fail;
+		return r;
 
  	/* Can't move a pinned BO */
  	rbo = container_of(bo, struct radeon_bo, tbo);
@@ -246,12 +234,12 @@ static int radeon_bo_move(struct ttm_buffer_object *bo, bool evict,
  	rdev = radeon_get_rdev(bo->bdev);
  	if (old_mem->mem_type == TTM_PL_SYSTEM && bo->ttm == NULL) {
  		ttm_bo_move_null(bo, new_mem);
-		return 0;
+		goto out;
  	}
  	if (old_mem->mem_type == TTM_PL_SYSTEM &&
  	    new_mem->mem_type == TTM_PL_TT) {
  		ttm_bo_move_null(bo, new_mem);
-		return 0;
+		goto out;
  	}
 
  	if (old_mem->mem_type == TTM_PL_TT &&
@@ -259,31 +247,37 @@ static int radeon_bo_move(struct ttm_buffer_object *bo, bool evict,
  		radeon_ttm_tt_unbind(bo->bdev, bo->ttm);
  		ttm_resource_free(bo, &bo->mem);
  		ttm_bo_assign_mem(bo, new_mem);
-		return 0;
+		goto out;
  	}
-	if (!rdev->ring[radeon_copy_ring_index(rdev)].ready ||
-	    rdev->asic->copy.copy == NULL) {
-		/* use memcpy */
-		goto memcpy;
+	if (rdev->ring[radeon_copy_ring_index(rdev)].ready &&
+	    rdev->asic->copy.copy != NULL) {
+		if ((old_mem->mem_type == TTM_PL_SYSTEM &&
+		     new_mem->mem_type == TTM_PL_VRAM) ||
+		    (old_mem->mem_type == TTM_PL_VRAM &&
+		     new_mem->mem_type == TTM_PL_SYSTEM)) {
+			hop->fpfn = 0;
+			hop->lpfn = 0;
+			hop->mem_type = TTM_PL_TT;
+			hop->flags = 0;
+			return -EMULTIHOP;
+		}
+
+		r = radeon_move_blit(bo, evict, new_mem, old_mem);
+	} else {
+		r = -ENODEV;
  	}
 
-	r = radeon_move_blit(bo, evict, new_mem, old_mem);
  	if (r) {
-memcpy:
  		r = ttm_bo_move_memcpy(bo, ctx, new_mem);
-		if (r) {
-			goto fail;
-		}
+		if (r)
+			return r;
  	}
 
+out:
  	/* update statistics */
  	atomic64_add((u64)bo->num_pages << PAGE_SHIFT, &rdev->num_bytes_moved);

drivers/gpu/drm/radeon/radeon_ttm.c static int radeon_bo_move(struct ttm_buffer_object *bo, bool evict, · line 283

Quoted 10 lines
drivers/gpu/drm/radeon/radeon_ttm.c +1 -5
+	radeon_bo_move_notify(bo, evict, new_mem);
  	return 0;
-fail:
-	swap(*new_mem, bo->mem);
-	radeon_bo_move_notify(bo, false, new_mem);
-	swap(*new_mem, bo->mem);
-	return r;
  }
 
  static int radeon_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_resource *mem)

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Reviewed-by on v1 1/1
#2 lore raw
In reply to Christian König
Quoted 2 lines · Christian König

Reorder the code to fix checking if blitting is available.

Might be good to explain why blitting might not be available, e.g. suspend/resume and or chip death and stuff like that.

Quoted 1 line

Needs Fixes: 28a68f828266 ("drm/radeon/ttm: use multihop")

Btw

$ dim fixes [sha1]

generates that for you plus nice cc list of offenders. With the Fixes line added:

At least I'm hanging onto the illusion that I understand what you did here :-) -Daniel

Quoted 112 lines
---
 drivers/gpu/drm/radeon/radeon_ttm.c | 54 +++++++++++++----------------
 1 file changed, 24 insertions(+), 30 deletions(-)
drivers/gpu/drm/radeon/radeon_ttm.c +24 -31
index 0ca381b95d3d..2b598141225f 100644
@@ -216,27 +216,15 @@ static int radeon_bo_move(struct ttm_buffer_object *bo, bool evict,
        struct ttm_resource *old_mem = &bo->mem;
        int r;
 
-       if ((old_mem->mem_type == TTM_PL_SYSTEM &&
-            new_mem->mem_type == TTM_PL_VRAM) ||
-           (old_mem->mem_type == TTM_PL_VRAM &&
-            new_mem->mem_type == TTM_PL_SYSTEM)) {
-               hop->fpfn = 0;
-               hop->lpfn = 0;
-               hop->mem_type = TTM_PL_TT;
-               hop->flags = 0;
-               return -EMULTIHOP;
-       }
-
        if (new_mem->mem_type == TTM_PL_TT) {
                r = radeon_ttm_tt_bind(bo->bdev, bo->ttm, new_mem);
                if (r)
                        return r;
        }
-       radeon_bo_move_notify(bo, evict, new_mem);
 
        r = ttm_bo_wait_ctx(bo, ctx);
        if (r)
-               goto fail;
+               return r;
 
        /* Can't move a pinned BO */
        rbo = container_of(bo, struct radeon_bo, tbo);
@@ -246,12 +234,12 @@ static int radeon_bo_move(struct ttm_buffer_object *bo, bool evict,
        rdev = radeon_get_rdev(bo->bdev);
        if (old_mem->mem_type == TTM_PL_SYSTEM && bo->ttm == NULL) {
                ttm_bo_move_null(bo, new_mem);
-               return 0;
+               goto out;
        }
        if (old_mem->mem_type == TTM_PL_SYSTEM &&
            new_mem->mem_type == TTM_PL_TT) {
                ttm_bo_move_null(bo, new_mem);
-               return 0;
+               goto out;
        }
 
        if (old_mem->mem_type == TTM_PL_TT &&
@@ -259,31 +247,37 @@ static int radeon_bo_move(struct ttm_buffer_object *bo, bool evict,
                radeon_ttm_tt_unbind(bo->bdev, bo->ttm);
                ttm_resource_free(bo, &bo->mem);
                ttm_bo_assign_mem(bo, new_mem);
-               return 0;
+               goto out;
        }
-       if (!rdev->ring[radeon_copy_ring_index(rdev)].ready ||
-           rdev->asic->copy.copy == NULL) {
-               /* use memcpy */
-               goto memcpy;
+       if (rdev->ring[radeon_copy_ring_index(rdev)].ready &&
+           rdev->asic->copy.copy != NULL) {
+               if ((old_mem->mem_type == TTM_PL_SYSTEM &&
+                    new_mem->mem_type == TTM_PL_VRAM) ||
+                   (old_mem->mem_type == TTM_PL_VRAM &&
+                    new_mem->mem_type == TTM_PL_SYSTEM)) {
+                       hop->fpfn = 0;
+                       hop->lpfn = 0;
+                       hop->mem_type = TTM_PL_TT;
+                       hop->flags = 0;
+                       return -EMULTIHOP;
+               }
+
+               r = radeon_move_blit(bo, evict, new_mem, old_mem);
+       } else {
+               r = -ENODEV;
        }
 
-       r = radeon_move_blit(bo, evict, new_mem, old_mem);
        if (r) {
-memcpy:
                r = ttm_bo_move_memcpy(bo, ctx, new_mem);
-               if (r) {
-                       goto fail;
-               }
+               if (r)
+                       return r;
        }
 
+out:
        /* update statistics */
        atomic64_add((u64)bo->num_pages << PAGE_SHIFT, &rdev->num_bytes_moved);
+       radeon_bo_move_notify(bo, evict, new_mem);
        return 0;
-fail:
-       swap(*new_mem, bo->mem);
-       radeon_bo_move_notify(bo, false, new_mem);
-       swap(*new_mem, bo->mem);
-       return r;
 }
 
 static int radeon_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_resource *mem)
--

2.25.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
maintainer Reviewed-by
#3 lore raw

Oops sorry for delay LGTM

Quoted 132 lines · Daniel Vetter
Quoted 2 lines · Christian König

Reorder the code to fix checking if blitting is available.

Might be good to explain why blitting might not be available, e.g. suspend/resume and or chip death and stuff like that.

Quoted 1 line

Needs Fixes: 28a68f828266 ("drm/radeon/ttm: use multihop")

Btw

$ dim fixes [sha1]

generates that for you plus nice cc list of offenders. With the Fixes line added:

At least I'm hanging onto the illusion that I understand what you did here :-) -Daniel

Quoted 108 lines
---
 drivers/gpu/drm/radeon/radeon_ttm.c | 54 +++++++++++++----------------
 1 file changed, 24 insertions(+), 30 deletions(-)
drivers/gpu/drm/radeon/radeon_ttm.c +24 -31
index 0ca381b95d3d..2b598141225f 100644
@@ -216,27 +216,15 @@ static int radeon_bo_move(struct ttm_buffer_object *bo, bool evict,
        struct ttm_resource *old_mem = &bo->mem;
        int r;
 
-       if ((old_mem->mem_type == TTM_PL_SYSTEM &&
-            new_mem->mem_type == TTM_PL_VRAM) ||
-           (old_mem->mem_type == TTM_PL_VRAM &&
-            new_mem->mem_type == TTM_PL_SYSTEM)) {
-               hop->fpfn = 0;
-               hop->lpfn = 0;
-               hop->mem_type = TTM_PL_TT;
-               hop->flags = 0;
-               return -EMULTIHOP;
-       }
-
        if (new_mem->mem_type == TTM_PL_TT) {
                r = radeon_ttm_tt_bind(bo->bdev, bo->ttm, new_mem);
                if (r)
                        return r;
        }
-       radeon_bo_move_notify(bo, evict, new_mem);
 
        r = ttm_bo_wait_ctx(bo, ctx);
        if (r)
-               goto fail;
+               return r;
 
        /* Can't move a pinned BO */
        rbo = container_of(bo, struct radeon_bo, tbo);
@@ -246,12 +234,12 @@ static int radeon_bo_move(struct ttm_buffer_object *bo, bool evict,
        rdev = radeon_get_rdev(bo->bdev);
        if (old_mem->mem_type == TTM_PL_SYSTEM && bo->ttm == NULL) {
                ttm_bo_move_null(bo, new_mem);
-               return 0;
+               goto out;
        }
        if (old_mem->mem_type == TTM_PL_SYSTEM &&
            new_mem->mem_type == TTM_PL_TT) {
                ttm_bo_move_null(bo, new_mem);
-               return 0;
+               goto out;
        }
 
        if (old_mem->mem_type == TTM_PL_TT &&
@@ -259,31 +247,37 @@ static int radeon_bo_move(struct ttm_buffer_object *bo, bool evict,
                radeon_ttm_tt_unbind(bo->bdev, bo->ttm);
                ttm_resource_free(bo, &bo->mem);
                ttm_bo_assign_mem(bo, new_mem);
-               return 0;
+               goto out;
        }
-       if (!rdev->ring[radeon_copy_ring_index(rdev)].ready ||
-           rdev->asic->copy.copy == NULL) {
-               /* use memcpy */
-               goto memcpy;
+       if (rdev->ring[radeon_copy_ring_index(rdev)].ready &&
+           rdev->asic->copy.copy != NULL) {
+               if ((old_mem->mem_type == TTM_PL_SYSTEM &&
+                    new_mem->mem_type == TTM_PL_VRAM) ||
+                   (old_mem->mem_type == TTM_PL_VRAM &&
+                    new_mem->mem_type == TTM_PL_SYSTEM)) {
+                       hop->fpfn = 0;
+                       hop->lpfn = 0;
+                       hop->mem_type = TTM_PL_TT;
+                       hop->flags = 0;
+                       return -EMULTIHOP;
+               }
+
+               r = radeon_move_blit(bo, evict, new_mem, old_mem);
+       } else {
+               r = -ENODEV;
        }
 
-       r = radeon_move_blit(bo, evict, new_mem, old_mem);
        if (r) {
-memcpy:
                r = ttm_bo_move_memcpy(bo, ctx, new_mem);
-               if (r) {
-                       goto fail;
-               }
+               if (r)
+                       return r;
        }
 
+out:
        /* update statistics */
        atomic64_add((u64)bo->num_pages << PAGE_SHIFT, &rdev->num_bytes_moved);
+       radeon_bo_move_notify(bo, evict, new_mem);
        return 0;
-fail:
-       swap(*new_mem, bo->mem);
-       radeon_bo_move_notify(bo, false, new_mem);
-       swap(*new_mem, bo->mem);
-       return r;
 }
 
 static int radeon_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_resource *mem)
--

2.25.1

Quoted 15 lines
Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#4 lore raw

Am 27.11.20 um 09:31 schrieb Dave Airlie:

Quoted 3 lines

Oops sorry for delay LGTM

Thanks.

Quoted 10 lines · Daniel Vetter
Quoted 8 lines
Quoted 1 line · Christian König

Reorder the code to fix checking if blitting is available.

Might be good to explain why blitting might not be available, e.g. suspend/resume and or chip death and stuff like that.

Quoted 1 line

Needs Fixes: 28a68f828266 ("drm/radeon/ttm: use multihop")

Why does the subject of the patch needs to be in "()" ? I was already wondering why dim sometimes complains about my Fixes tag.

Quoted 9 lines
Quoted 9 lines

Btw

$ dim fixes [sha1]

generates that for you plus nice cc list of offenders. With the Fixes line added:

Thanks,
Christian.

Quoted 111 lines
Quoted 111 lines

At least I'm hanging onto the illusion that I understand what you did here :-) -Daniel

Quoted 108 lines
---
  drivers/gpu/drm/radeon/radeon_ttm.c | 54 +++++++++++++----------------
  1 file changed, 24 insertions(+), 30 deletions(-)
drivers/gpu/drm/radeon/radeon_ttm.c +24 -31
index 0ca381b95d3d..2b598141225f 100644
@@ -216,27 +216,15 @@ static int radeon_bo_move(struct ttm_buffer_object *bo, bool evict,
         struct ttm_resource *old_mem = &bo->mem;
         int r;
 
-       if ((old_mem->mem_type == TTM_PL_SYSTEM &&
-            new_mem->mem_type == TTM_PL_VRAM) ||
-           (old_mem->mem_type == TTM_PL_VRAM &&
-            new_mem->mem_type == TTM_PL_SYSTEM)) {
-               hop->fpfn = 0;
-               hop->lpfn = 0;
-               hop->mem_type = TTM_PL_TT;
-               hop->flags = 0;
-               return -EMULTIHOP;
-       }
-
         if (new_mem->mem_type == TTM_PL_TT) {
                 r = radeon_ttm_tt_bind(bo->bdev, bo->ttm, new_mem);
                 if (r)
                         return r;
         }
-       radeon_bo_move_notify(bo, evict, new_mem);
 
         r = ttm_bo_wait_ctx(bo, ctx);
         if (r)
-               goto fail;
+               return r;
 
         /* Can't move a pinned BO */
         rbo = container_of(bo, struct radeon_bo, tbo);
@@ -246,12 +234,12 @@ static int radeon_bo_move(struct ttm_buffer_object *bo, bool evict,
         rdev = radeon_get_rdev(bo->bdev);
         if (old_mem->mem_type == TTM_PL_SYSTEM && bo->ttm == NULL) {
                 ttm_bo_move_null(bo, new_mem);
-               return 0;
+               goto out;
         }
         if (old_mem->mem_type == TTM_PL_SYSTEM &&
             new_mem->mem_type == TTM_PL_TT) {
                 ttm_bo_move_null(bo, new_mem);
-               return 0;
+               goto out;
         }
 
         if (old_mem->mem_type == TTM_PL_TT &&
@@ -259,31 +247,37 @@ static int radeon_bo_move(struct ttm_buffer_object *bo, bool evict,
                 radeon_ttm_tt_unbind(bo->bdev, bo->ttm);
                 ttm_resource_free(bo, &bo->mem);
                 ttm_bo_assign_mem(bo, new_mem);
-               return 0;
+               goto out;
         }
-       if (!rdev->ring[radeon_copy_ring_index(rdev)].ready ||
-           rdev->asic->copy.copy == NULL) {
-               /* use memcpy */
-               goto memcpy;
+       if (rdev->ring[radeon_copy_ring_index(rdev)].ready &&
+           rdev->asic->copy.copy != NULL) {
+               if ((old_mem->mem_type == TTM_PL_SYSTEM &&
+                    new_mem->mem_type == TTM_PL_VRAM) ||
+                   (old_mem->mem_type == TTM_PL_VRAM &&
+                    new_mem->mem_type == TTM_PL_SYSTEM)) {
+                       hop->fpfn = 0;
+                       hop->lpfn = 0;
+                       hop->mem_type = TTM_PL_TT;
+                       hop->flags = 0;
+                       return -EMULTIHOP;
+               }
+
+               r = radeon_move_blit(bo, evict, new_mem, old_mem);
+       } else {
+               r = -ENODEV;
         }
 
-       r = radeon_move_blit(bo, evict, new_mem, old_mem);
         if (r) {
-memcpy:
                 r = ttm_bo_move_memcpy(bo, ctx, new_mem);
-               if (r) {
-                       goto fail;
-               }
+               if (r)
+                       return r;
         }
 
+out:
         /* update statistics */
         atomic64_add((u64)bo->num_pages << PAGE_SHIFT, &rdev->num_bytes_moved);
+       radeon_bo_move_notify(bo, evict, new_mem);
         return 0;
-fail:
-       swap(*new_mem, bo->mem);
-       radeon_bo_move_notify(bo, false, new_mem);
-       swap(*new_mem, bo->mem);
-       return r;
  }
 
  static int radeon_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_resource *mem)
--

2.25.1

Quoted 14 lines
Quoted 6 lines
Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Quoted 8 lines

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#5 lore raw
Quoted 13 lines · Christian König

Am 27.11.20 um 09:31 schrieb Dave Airlie:

Quoted 3 lines

Oops sorry for delay LGTM

Thanks.

Quoted 5 lines · Daniel Vetter
Quoted 3 lines
Quoted 1 line · Christian König

Reorder the code to fix checking if blitting is available.

Quoted 8 lines
Quoted 5 lines
Quoted 5 lines

Might be good to explain why blitting might not be available, e.g. suspend/resume and or chip death and stuff like that.

Quoted 1 line

Needs Fixes: 28a68f828266 ("drm/radeon/ttm: use multihop")

Why does the subject of the patch needs to be in "()" ? I was already wondering why dim sometimes complains about my Fixes tag.

Hm I thought that's the official style. I kinda hacked around on it until linux-next stopped complaining about our Fixes: tags. Maybe it's not quite accurately reflecting the current bikeshed. Iirc checkpatch even complains when you leave out the commit before the sha1, at least in free-form text in the commit message.
-Daniel

Quoted 139 lines
Quoted 9 lines
Quoted 9 lines

Btw

$ dim fixes [sha1]

generates that for you plus nice cc list of offenders. With the Fixes line added:

Thanks,
Christian.

Quoted 125 lines
Quoted 125 lines

At least I'm hanging onto the illusion that I understand what you did here :-) -Daniel

Quoted 108 lines
---
  drivers/gpu/drm/radeon/radeon_ttm.c | 54 +++++++++++++----------------
  1 file changed, 24 insertions(+), 30 deletions(-)
drivers/gpu/drm/radeon/radeon_ttm.c +24 -31
index 0ca381b95d3d..2b598141225f 100644
@@ -216,27 +216,15 @@ static int radeon_bo_move(struct ttm_buffer_object *bo, bool evict,
         struct ttm_resource *old_mem = &bo->mem;
         int r;
 
-       if ((old_mem->mem_type == TTM_PL_SYSTEM &&
-            new_mem->mem_type == TTM_PL_VRAM) ||
-           (old_mem->mem_type == TTM_PL_VRAM &&
-            new_mem->mem_type == TTM_PL_SYSTEM)) {
-               hop->fpfn = 0;
-               hop->lpfn = 0;
-               hop->mem_type = TTM_PL_TT;
-               hop->flags = 0;
-               return -EMULTIHOP;
-       }
-
         if (new_mem->mem_type == TTM_PL_TT) {
                 r = radeon_ttm_tt_bind(bo->bdev, bo->ttm, new_mem);
                 if (r)
                         return r;
         }
-       radeon_bo_move_notify(bo, evict, new_mem);
 
         r = ttm_bo_wait_ctx(bo, ctx);
         if (r)
-               goto fail;
+               return r;
 
         /* Can't move a pinned BO */
         rbo = container_of(bo, struct radeon_bo, tbo);
@@ -246,12 +234,12 @@ static int radeon_bo_move(struct ttm_buffer_object *bo, bool evict,
         rdev = radeon_get_rdev(bo->bdev);
         if (old_mem->mem_type == TTM_PL_SYSTEM && bo->ttm == NULL) {
                 ttm_bo_move_null(bo, new_mem);
-               return 0;
+               goto out;
         }
         if (old_mem->mem_type == TTM_PL_SYSTEM &&
             new_mem->mem_type == TTM_PL_TT) {
                 ttm_bo_move_null(bo, new_mem);
-               return 0;
+               goto out;
         }
 
         if (old_mem->mem_type == TTM_PL_TT &&
@@ -259,31 +247,37 @@ static int radeon_bo_move(struct ttm_buffer_object *bo, bool evict,
                 radeon_ttm_tt_unbind(bo->bdev, bo->ttm);
                 ttm_resource_free(bo, &bo->mem);
                 ttm_bo_assign_mem(bo, new_mem);
-               return 0;
+               goto out;
         }
-       if (!rdev->ring[radeon_copy_ring_index(rdev)].ready ||
-           rdev->asic->copy.copy == NULL) {
-               /* use memcpy */
-               goto memcpy;
+       if (rdev->ring[radeon_copy_ring_index(rdev)].ready &&
+           rdev->asic->copy.copy != NULL) {
+               if ((old_mem->mem_type == TTM_PL_SYSTEM &&
+                    new_mem->mem_type == TTM_PL_VRAM) ||
+                   (old_mem->mem_type == TTM_PL_VRAM &&
+                    new_mem->mem_type == TTM_PL_SYSTEM)) {
+                       hop->fpfn = 0;
+                       hop->lpfn = 0;
+                       hop->mem_type = TTM_PL_TT;
+                       hop->flags = 0;
+                       return -EMULTIHOP;
+               }
+
+               r = radeon_move_blit(bo, evict, new_mem, old_mem);
+       } else {
+               r = -ENODEV;
         }
 
-       r = radeon_move_blit(bo, evict, new_mem, old_mem);
         if (r) {
-memcpy:
                 r = ttm_bo_move_memcpy(bo, ctx, new_mem);
-               if (r) {
-                       goto fail;
-               }
+               if (r)
+                       return r;
         }
 
+out:
         /* update statistics */
         atomic64_add((u64)bo->num_pages << PAGE_SHIFT, &rdev->num_bytes_moved);
+       radeon_bo_move_notify(bo, evict, new_mem);
         return 0;
-fail:
-       swap(*new_mem, bo->mem);
-       radeon_bo_move_notify(bo, false, new_mem);
-       swap(*new_mem, bo->mem);
-       return r;
  }
 
  static int radeon_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_resource *mem)
--

2.25.1

Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
maintainer
#6 lore raw

Am 27.11.20 um 15:46 schrieb Daniel Vetter:

Quoted 16 lines
Quoted 14 lines · Christian König

Am 27.11.20 um 09:31 schrieb Dave Airlie:

Quoted 3 lines

Oops sorry for delay LGTM

Thanks.

Quoted 8 lines · Daniel Vetter
Quoted 7 lines
Quoted 1 line · Christian König

Reorder the code to fix checking if blitting is available.

Might be good to explain why blitting might not be available, e.g. suspend/resume and or chip death and stuff like that.

Quoted 1 line
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line

Needs Fixes: 28a68f828266 ("drm/radeon/ttm: use multihop")

Why does the subject of the patch needs to be in "()" ? I was already wondering why dim sometimes complains about my Fixes tag.

Hm I thought that's the official style. I kinda hacked around on it until linux-next stopped complaining about our Fixes: tags. Maybe it's not quite accurately reflecting the current bikeshed. Iirc checkpatch even complains when you leave out the commit before the sha1, at least in free-form text in the commit message.

Well "git log -1 --oneline 28a68f828266" gives me:

28a68f828266 drm/radeon/ttm: use multihop

Which is what I would naturally expect here, but no idea what the official format should be.

Christian.

Quoted 13 lines

-Daniel

Quoted 11 lines
Quoted 8 lines
Quoted 8 lines

Btw

$ dim fixes [sha1]

generates that for you plus nice cc list of offenders. With the Fixes line added:

Thanks,
Christian.

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#7 lore raw
Quoted 26 lines · Christian König

Am 27.11.20 um 15:46 schrieb Daniel Vetter:

Quoted 16 lines
Quoted 14 lines · Christian König

Am 27.11.20 um 09:31 schrieb Dave Airlie:

Quoted 3 lines

Oops sorry for delay LGTM

Thanks.

Quoted 8 lines · Daniel Vetter
Quoted 7 lines
Quoted 1 line · Christian König

Reorder the code to fix checking if blitting is available.

Might be good to explain why blitting might not be available, e.g. suspend/resume and or chip death and stuff like that.

Quoted 1 line
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line

Needs Fixes: 28a68f828266 ("drm/radeon/ttm: use multihop")

Why does the subject of the patch needs to be in "()" ? I was already wondering why dim sometimes complains about my Fixes tag.

Hm I thought that's the official style. I kinda hacked around on it until linux-next stopped complaining about our Fixes: tags. Maybe it's not quite accurately reflecting the current bikeshed. Iirc checkpatch even complains when you leave out the commit before the sha1, at least in free-form text in the commit message.

Quoted 6 lines

Well "git log -1 --oneline 28a68f828266" gives me:

28a68f828266 drm/radeon/ttm: use multihop

Which is what I would naturally expect here, but no idea what the official format should be.

dim cite $sha1 is our attempt at modelling it. And yeah it's just bikeshedded differently for no good reason. And I just noticed that dim cite doesn't include the commit before the sha1.
-Daniel

Quoted 17 lines

Christian.

Quoted 13 lines

-Daniel

Quoted 11 lines
Quoted 8 lines
Quoted 8 lines

Btw

$ dim fixes [sha1]

generates that for you plus nice cc list of offenders. With the Fixes line added:

Thanks,
Christian.

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel