Skip to contentSkip to conversation

drm/ttm: fix incorrect TT->SYSTEM move handling

PATCH In review Christian König 2 participants 4 messages Sep 16, 2020 – Sep 17, 2020

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

PATCH 1/1 drm/ttm: fix incorrect TT->SYSTEM move handling

When we move from the SYSTEM domain to the TT domain we still need to potentially change the caching state.

This is most likely the source of a bunch of problems with AGP and USWC together with hibernation and swap.

---
 drivers/gpu/drm/ttm/ttm_bo.c | 8 --------
 1 file changed, 8 deletions(-)
drivers/gpu/drm/ttm/ttm_bo.c +0 -8
index ffbdc20d8e8d..5f7efc90970e 100644
@@ -264,13 +264,6 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
 			if (ret)
 				goto out_err;
 		}
-
-		if (bo->mem.mem_type == TTM_PL_SYSTEM) {
-			if (bdev->driver->move_notify)
-				bdev->driver->move_notify(bo, evict, mem);
-			bo->mem = *mem;
-			goto moved;
-		}
 	}
 
 	if (bdev->driver->move_notify)
@@ -293,7 +286,6 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
 		goto out_err;
 	}
 
-moved:
 	bo->evicted = false;
 
 	ctx->bytes_moved += bo->num_pages << PAGE_SHIFT;
Signature · 6 lines
2.17.1

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

Am 16.09.20 um 16:24 schrieb Christian König:

Quoted 1 line

When we move from the SYSTEM domain to the TT domain

Typo in the subject, the order in the sentence here is the correct one.

This is an important bug fix I'm hunting for years. Please review.

Thanks,
Christian.

Quoted 30 lines

we still need to potentially change the caching state.

This is most likely the source of a bunch of problems with AGP and USWC together with hibernation and swap.

---
  drivers/gpu/drm/ttm/ttm_bo.c | 8 --------
  1 file changed, 8 deletions(-)
drivers/gpu/drm/ttm/ttm_bo.c +0 -7
index ffbdc20d8e8d..5f7efc90970e 100644
@@ -264,13 +264,6 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
  			if (ret)
  				goto out_err;
  		}
-
-		if (bo->mem.mem_type == TTM_PL_SYSTEM) {
-			if (bdev->driver->move_notify)
-				bdev->driver->move_notify(bo, evict, mem);
-			bo->mem = *mem;
-			goto moved;
-		}
  	}
 
  	if (bdev->driver->move_notify)

drivers/gpu/drm/ttm/ttm_bo.c static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo, · line 291

Quoted 7 lines
drivers/gpu/drm/ttm/ttm_bo.c +0 -1
@@ -293,7 +286,6 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
  		goto out_err;
  	}
 
-moved:
  	bo->evicted = false;
 
  	ctx->bytes_moved += bo->num_pages << PAGE_SHIFT;

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

maintainer
#2 lore raw
In reply to Christian König
Quoted 6 lines · Christian König

When we move from the SYSTEM domain to the TT domain we still need to potentially change the caching state.

This is most likely the source of a bunch of problems with AGP and USWC together with hibernation and swap.

I'm going to need more commentary, because I've been staring at this code a lot in the past few days and I'm although I dislike this path, I'm not sure what this brings.

The current code flow to me is for SYSTEM->TT domain

ttm_tt_create
ttm_tt_set_placement_caching (new placement)
ttm_tt_bind (can cause populate)
move_notify
replace pointers
evicted = false
return

The new flow looks like
ttm_tt_create
ttm_tt_set_placement_caching (new placement)
ttm_tt_bind (can cause populate)
move_notify
(via ttm_bo_move_ttm)
ttm_tt_set_placement_caching (new placement)
ttm_tt_bind
replace pointers
(back to main code)
evicted = false
return

Is the second set placement caching doing something different here? or is there something that happens in move notify that we need to set things afterwards?

Dave.

Quoted 34 lines
---
 drivers/gpu/drm/ttm/ttm_bo.c | 8 --------
 1 file changed, 8 deletions(-)
drivers/gpu/drm/ttm/ttm_bo.c +0 -9
index ffbdc20d8e8d..5f7efc90970e 100644
@@ -264,13 +264,6 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
                        if (ret)
                                goto out_err;
                }
-
-               if (bo->mem.mem_type == TTM_PL_SYSTEM) {
-                       if (bdev->driver->move_notify)
-                               bdev->driver->move_notify(bo, evict, mem);
-                       bo->mem = *mem;
-                       goto moved;
-               }
        }
 
        if (bdev->driver->move_notify)
@@ -293,7 +286,6 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
                goto out_err;
        }
 
-moved:
        bo->evicted = false;
 
        ctx->bytes_moved += bo->num_pages << PAGE_SHIFT;
--
Quoted 2 lines

2.17.1

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

#3 lore raw

Am 16.09.20 um 21:27 schrieb Dave Airlie:

Quoted 34 lines
Quoted 5 lines · Christian König

When we move from the SYSTEM domain to the TT domain we still need to potentially change the caching state.

This is most likely the source of a bunch of problems with AGP and USWC together with hibernation and swap.

I'm going to need more commentary, because I've been staring at this code a lot in the past few days and I'm although I dislike this path, I'm not sure what this brings.

The current code flow to me is for SYSTEM->TT domain

ttm_tt_create
ttm_tt_set_placement_caching (new placement)
ttm_tt_bind (can cause populate)
move_notify
replace pointers
evicted = false
return

The new flow looks like
ttm_tt_create
ttm_tt_set_placement_caching (new placement)
ttm_tt_bind (can cause populate)
move_notify
(via ttm_bo_move_ttm)
ttm_tt_set_placement_caching (new placement)
ttm_tt_bind
replace pointers
(back to main code)
evicted = false
return

Quoted 3 lines

Is the second set placement caching doing something different here? or is there something that happens in move notify that we need to set things afterwards?

Oh, I was blind. Haven't seen the call to ttm_tt_set_placement_caching() directly before this one.

So forget this one, need to keep searching why hibernation doesn't work :(

Christian.

Quoted 31 lines

Dave.

Quoted 28 lines
---
  drivers/gpu/drm/ttm/ttm_bo.c | 8 --------
  1 file changed, 8 deletions(-)
drivers/gpu/drm/ttm/ttm_bo.c +0 -7
index ffbdc20d8e8d..5f7efc90970e 100644
@@ -264,13 +264,6 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
                         if (ret)
                                 goto out_err;
                 }
-
-               if (bo->mem.mem_type == TTM_PL_SYSTEM) {
-                       if (bdev->driver->move_notify)
-                               bdev->driver->move_notify(bo, evict, mem);
-                       bo->mem = *mem;
-                       goto moved;
-               }
         }
 
         if (bdev->driver->move_notify)
@@ -293,7 +286,6 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
                 goto out_err;
         }
 
Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/ttm/ttm_bo.c +0 -2
-moved:
         bo->evicted = false;
 
         ctx->bytes_moved += bo->num_pages << PAGE_SHIFT;
--

2.17.1

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