Skip to contentSkip to conversation

drm/nouveau: fix ttm move notify callback

PATCH In review [email protected] 3 participants 13 messages Jan 5, 2012 – Jan 24, 2012 1 message not in the archive

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

PATCH 1/1 drm/nouveau: fix ttm move notify callback

From: Jerome Glisse <[email protected]>

ttm might call the move notify with null new mem placement, properly handle this case inside nouveau move notify callback.

---
 drivers/gpu/drm/nouveau/nouveau_bo.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/nouveau/nouveau_bo.c +3 -3
index f12dd0f..65f5b0b 100644
@@ -808,9 +808,8 @@ out:
 }
 
 static void
-nouveau_bo_move_ntfy(struct ttm_buffer_object *bo, struct ttm_mem_reg *new_mem)
+nouveau_bo_move_notify(struct ttm_buffer_object *bo, struct ttm_mem_reg *new_mem)
 {
-	struct nouveau_mem *node = new_mem->mm_node;
 	struct nouveau_bo *nvbo = nouveau_bo(bo);
 	struct nouveau_vma *vma;
 
@@ -820,6 +819,7 @@ nouveau_bo_move_ntfy(struct ttm_buffer_object *bo, struct ttm_mem_reg *new_mem)
 		} else
 		if (new_mem && new_mem->mem_type == TTM_PL_TT &&
 		    nvbo->page_shift == vma->vm->spg_shift) {
+			struct nouveau_mem *node = new_mem->mm_node;
 			nouveau_vm_map_sg(vma, 0, new_mem->
 					  num_pages << PAGE_SHIFT,
 					  node, node->pages);
@@ -1131,7 +1131,7 @@ struct ttm_bo_driver nouveau_bo_driver = {
 	.invalidate_caches = nouveau_bo_invalidate_caches,
 	.init_mem_type = nouveau_bo_init_mem_type,
 	.evict_flags = nouveau_bo_evict_flags,
-	.move_notify = nouveau_bo_move_ntfy,
+	.move_notify = nouveau_bo_move_notify,
 	.move = nouveau_bo_move,
 	.verify_access = nouveau_bo_verify_access,
 	.sync_obj_signaled = __nouveau_fence_signalled,
Signature · 1 line
1.7.7.1
#1 lore raw
Quoted 4 lines · On Thu, 2012-01-05 at 13:31 -0500, [email protected] wrote:

From: Jerome Glisse <[email protected]>

ttm might call the move notify with null new mem placement, properly handle this case inside nouveau move notify callback.

This has been fixed already in a -next tree I sent to Dave.

Ben.

Quoted 38 lines
---
 drivers/gpu/drm/nouveau/nouveau_bo.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/nouveau/nouveau_bo.c +3 -3
index f12dd0f..65f5b0b 100644
@@ -808,9 +808,8 @@ out:
 }
 
 static void
-nouveau_bo_move_ntfy(struct ttm_buffer_object *bo, struct ttm_mem_reg *new_mem)
+nouveau_bo_move_notify(struct ttm_buffer_object *bo, struct ttm_mem_reg *new_mem)
 {
-	struct nouveau_mem *node = new_mem->mm_node;
 	struct nouveau_bo *nvbo = nouveau_bo(bo);
 	struct nouveau_vma *vma;
 
@@ -820,6 +819,7 @@ nouveau_bo_move_ntfy(struct ttm_buffer_object *bo, struct ttm_mem_reg *new_mem)
 		} else
 		if (new_mem && new_mem->mem_type == TTM_PL_TT &&
 		    nvbo->page_shift == vma->vm->spg_shift) {
+			struct nouveau_mem *node = new_mem->mm_node;
 			nouveau_vm_map_sg(vma, 0, new_mem->
 					  num_pages << PAGE_SHIFT,
 					  node, node->pages);
@@ -1131,7 +1131,7 @@ struct ttm_bo_driver nouveau_bo_driver = {
 	.invalidate_caches = nouveau_bo_invalidate_caches,
 	.init_mem_type = nouveau_bo_init_mem_type,
 	.evict_flags = nouveau_bo_evict_flags,
-	.move_notify = nouveau_bo_move_ntfy,
+	.move_notify = nouveau_bo_move_notify,
 	.move = nouveau_bo_move,
 	.verify_access = nouveau_bo_verify_access,
 	.sync_obj_signaled = __nouveau_fence_signalled,

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw
Quoted 10 lines · Konrad Rzeszutek Wilk
Quoted 6 lines · Ben Skeggs
Quoted 4 lines · On Thu, 2012-01-05 at 13:31 -0500, [email protected] wrote:

From: Jerome Glisse <[email protected]>

ttm might call the move notify with null new mem placement, properly handle this case inside nouveau move notify callback.

This has been fixed already in a -next tree I sent to Dave.

I just tried -next with your patch (and two other fixes that I had sent):

Quoted 8 lines

drm/ttm/dma: Only call set_pages_array_wb when the page is not in WB pool
drm/ttm/dma: Fix accounting error when calling ttm_mem_global_free_page and don't try to free freed pages

and Jerome's AGP fix:
ttm: fix agp since ttm tt rework

and got the crash (but only with NVidia cards) after swapping between Xorg and the VCs. Look in drm-next.jpg

http://darnok.org/vga/drm-next.jpg

Quoted 3 lines

With your patch removed ("drm/nouveau/ttm: fix crash as a result of a recent ttm change") and the patch below by Jerome I still get it to crash (see drm-next-with-Jerome-fix-revert-Ben.jpg)..

http://darnok.org/vga/drm-next-with-Jerome-fix-revert-Ben.jpg

Quoted 47 lines
Quoted 47 lines

Ben.

Quoted 30 lines
---
 drivers/gpu/drm/nouveau/nouveau_bo.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/nouveau/nouveau_bo.c +2 -2
index f12dd0f..65f5b0b 100644
@@ -808,9 +808,8 @@ out:
 }
 
 static void
-nouveau_bo_move_ntfy(struct ttm_buffer_object *bo, struct ttm_mem_reg *new_mem)
+nouveau_bo_move_notify(struct ttm_buffer_object *bo, struct ttm_mem_reg *new_mem)
 {
-	struct nouveau_mem *node = new_mem->mm_node;
 	struct nouveau_bo *nvbo = nouveau_bo(bo);
 	struct nouveau_vma *vma;
 
@@ -820,6 +819,7 @@ nouveau_bo_move_ntfy(struct ttm_buffer_object *bo, struct ttm_mem_reg *new_mem)
 		} else
 		if (new_mem && new_mem->mem_type == TTM_PL_TT &&
 		    nvbo->page_shift == vma->vm->spg_shift) {
+			struct nouveau_mem *node = new_mem->mm_node;
 			nouveau_vm_map_sg(vma, 0, new_mem->
 					  num_pages << PAGE_SHIFT,
 					  node, node->pages);

drivers/gpu/drm/nouveau/nouveau_bo.c struct ttm_bo_driver nouveau_bo_driver = { · line 1137

Quoted 8 lines
drivers/gpu/drm/nouveau/nouveau_bo.c +1 -1
@@ -1131,7 +1131,7 @@ struct ttm_bo_driver nouveau_bo_driver = {
 	.invalidate_caches = nouveau_bo_invalidate_caches,
 	.init_mem_type = nouveau_bo_init_mem_type,
 	.evict_flags = nouveau_bo_evict_flags,
-	.move_notify = nouveau_bo_move_ntfy,
+	.move_notify = nouveau_bo_move_notify,
 	.move = nouveau_bo_move,
 	.verify_access = nouveau_bo_verify_access,
 	.sync_obj_signaled = __nouveau_fence_signalled,

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

#4 lore raw
Quoted 20 lines · Konrad Rzeszutek Wilk
Quoted 10 lines · Konrad Rzeszutek Wilk
Quoted 6 lines · Ben Skeggs
Quoted 4 lines · On Thu, 2012-01-05 at 13:31 -0500, [email protected] wrote:

From: Jerome Glisse <[email protected]>

ttm might call the move notify with null new mem placement, properly handle this case inside nouveau move notify callback.

This has been fixed already in a -next tree I sent to Dave.

I just tried -next with your patch (and two other fixes that I had sent):

Quoted 8 lines

drm/ttm/dma: Only call set_pages_array_wb when the page is not in WB pool
drm/ttm/dma: Fix accounting error when calling ttm_mem_global_free_page and don't try to free freed pages

and Jerome's AGP fix:
ttm: fix agp since ttm tt rework

and got the crash (but only with NVidia cards) after swapping between Xorg and the VCs. Look in drm-next.jpg

Quoted 8 lines

http://darnok.org/vga/drm-next.jpg

Quoted 3 lines

With your patch removed ("drm/nouveau/ttm: fix crash as a result of a recent ttm change") and the patch below by Jerome I still get it to crash (see drm-next-with-Jerome-fix-revert-Ben.jpg)..

http://darnok.org/vga/drm-next-with-Jerome-fix-revert-Ben.jpg

Anything special to trigger it ? I can't trigger it with simple gnome3 session (firefox evince ...)

Cheers,
Jerome

#5 lore raw
Quoted 25 lines · Jerome Glisse
Quoted 23 lines · Konrad Rzeszutek Wilk
Quoted 10 lines · Konrad Rzeszutek Wilk
Quoted 6 lines · Ben Skeggs
Quoted 4 lines · On Thu, 2012-01-05 at 13:31 -0500, [email protected] wrote:

From: Jerome Glisse <[email protected]>

ttm might call the move notify with null new mem placement, properly handle this case inside nouveau move notify callback.

This has been fixed already in a -next tree I sent to Dave.

I just tried -next with your patch (and two other fixes that I had sent):

Quoted 8 lines

drm/ttm/dma: Only call set_pages_array_wb when the page is not in WB pool
drm/ttm/dma: Fix accounting error when calling ttm_mem_global_free_page and don't try to free freed pages

and Jerome's AGP fix:
ttm: fix agp since ttm tt rework

and got the crash (but only with NVidia cards) after swapping between Xorg and the VCs. Look in drm-next.jpg

http://darnok.org/vga/drm-next.jpg

Quoted 1 line
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

With your patch removed ("drm/nouveau/ttm: fix crash as a result of a recent ttm change") and the patch below by Jerome I still get it to crash (see drm-next-with-Jerome-fix-revert-Ben.jpg)..

http://darnok.org/vga/drm-next-with-Jerome-fix-revert-Ben.jpg

Anything special to trigger it ? I can't trigger it with simple gnome3 session (firefox evince ...)

I ran etracer, then switched over to a framebuffer console (Alt-F2), logged in. Then ran perf record and switched back to etracer. Ran a couple of laps and when finished quit the perf top. On the PCI-e it took a while (so I had to run a couple of laps).

On the AGP one it happended immediately, which is no surprise since the code looks to be activated when we do garbage collection and the machine only had 2GB. The PCIe on has 8GB. Perhaps a better way would be to force the workqueue by setting the pool limits to smaller values.

Quoted 3 lines

Cheers,
Jerome

#6 lore raw
Quoted 35 lines · Konrad Rzeszutek Wilk
Quoted 25 lines · Jerome Glisse
Quoted 23 lines · Konrad Rzeszutek Wilk
Quoted 10 lines · Konrad Rzeszutek Wilk
Quoted 6 lines · Ben Skeggs
Quoted 4 lines · On Thu, 2012-01-05 at 13:31 -0500, [email protected] wrote:

From: Jerome Glisse <[email protected]>

ttm might call the move notify with null new mem placement, properly handle this case inside nouveau move notify callback.

This has been fixed already in a -next tree I sent to Dave.

I just tried -next with your patch (and two other fixes that I had sent):

Quoted 8 lines

drm/ttm/dma: Only call set_pages_array_wb when the page is not in WB pool
drm/ttm/dma: Fix accounting error when calling ttm_mem_global_free_page and don't try to free freed pages

and Jerome's AGP fix:
ttm: fix agp since ttm tt rework

and got the crash (but only with NVidia cards) after swapping between Xorg and the VCs. Look in drm-next.jpg

http://darnok.org/vga/drm-next.jpg

Quoted 1 line
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

With your patch removed ("drm/nouveau/ttm: fix crash as a result of a recent ttm change") and the patch below by Jerome I still get it to crash (see drm-next-with-Jerome-fix-revert-Ben.jpg)..

http://darnok.org/vga/drm-next-with-Jerome-fix-revert-Ben.jpg

Anything special to trigger it ? I can't trigger it with simple gnome3 session (firefox evince ...)

Quoted 9 lines

I ran etracer, then switched over to a framebuffer console (Alt-F2), logged in. Then ran perf record and switched back to etracer. Ran a couple of laps and when finished quit the perf top. On the PCI-e it took a while (so I had to run a couple of laps).

On the AGP one it happended immediately, which is no surprise since the code looks to be activated when we do garbage collection and the machine only had 2GB. The PCIe on has 8GB. Perhaps a better way would be to force the workqueue by setting the pool limits to smaller values.

Still having difficulty to reproduce can you reproduce with the attached printk debuging patch and provide the log (only few printk preceding the oops or segfault are interesting).

Cheers,
Jerome

Quoted 1 line

From 862e2cc6d35d85404ed24d24c5a5c49c5ef45fc7 Mon Sep 17 00:00:00 2001

From: Jerome Glisse <[email protected]>
Date: Fri, 6 Jan 2012 13:20:08 -0500
Subject: [PATCH] TTM-DEBUG-PRINTK

---
 drivers/gpu/drm/nouveau/nouveau_bo.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/gpu/drm/nouveau/nouveau_bo.c +2 -0
index 724b41a..326b64a 100644
@@ -812,12 +812,14 @@ nouveau_bo_move_ntfy(struct ttm_buffer_object *bo, struct ttm_mem_reg *new_mem)
 	struct nouveau_bo *nvbo = nouveau_bo(bo);
 	struct nouveau_vma *vma;
 
+DRM_INFO("%s list (%p %p)\n", __func__, nvbo->vma_list.prev, nvbo->vma_list.next);
 	list_for_each_entry(vma, &nvbo->vma_list, head) {
 		if (new_mem && new_mem->mem_type == TTM_PL_VRAM) {
 			nouveau_vm_map(vma, new_mem->mm_node);
 		} else
 		if (new_mem && new_mem->mem_type == TTM_PL_TT &&
 		    nvbo->page_shift == vma->vm->spg_shift) {
+DRM_INFO("%s vma %p new mem %p %d pages\n", __func__, vma, new_mem, new_mem->num_pages);
 			nouveau_vm_map_sg(vma, 0, new_mem->
 					  num_pages << PAGE_SHIFT,
 					  new_mem->mm_node);
Signature · 1 line
1.7.5.4

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

#7 lore raw
Quoted 3 lines

Still having difficulty to reproduce can you reproduce with the attached printk debuging patch and provide the log (only few printk preceding the oops or segfault are interesting).

http://darnok.org/vga/move_notify-v212.log

Quoted 35 lines

Cheers,
Jerome

Quoted 1 line

From 862e2cc6d35d85404ed24d24c5a5c49c5ef45fc7 Mon Sep 17 00:00:00 2001

From: Jerome Glisse <[email protected]>
Date: Fri, 6 Jan 2012 13:20:08 -0500
Subject: [PATCH] TTM-DEBUG-PRINTK

---
 drivers/gpu/drm/nouveau/nouveau_bo.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/gpu/drm/nouveau/nouveau_bo.c +2 -0
index 724b41a..326b64a 100644
@@ -812,12 +812,14 @@ nouveau_bo_move_ntfy(struct ttm_buffer_object *bo, struct ttm_mem_reg *new_mem)
 	struct nouveau_bo *nvbo = nouveau_bo(bo);
 	struct nouveau_vma *vma;
 
+DRM_INFO("%s list (%p %p)\n", __func__, nvbo->vma_list.prev, nvbo->vma_list.next);
 	list_for_each_entry(vma, &nvbo->vma_list, head) {
 		if (new_mem && new_mem->mem_type == TTM_PL_VRAM) {
 			nouveau_vm_map(vma, new_mem->mm_node);
 		} else
 		if (new_mem && new_mem->mem_type == TTM_PL_TT &&
 		    nvbo->page_shift == vma->vm->spg_shift) {
+DRM_INFO("%s vma %p new mem %p %d pages\n", __func__, vma, new_mem, new_mem->num_pages);
 			nouveau_vm_map_sg(vma, 0, new_mem->
 					  num_pages << PAGE_SHIFT,
 					  new_mem->mm_node);
Signature · 1 line
1.7.5.4
#8 lore raw
Quoted 6 lines · Konrad Rzeszutek Wilk
Quoted 3 lines

Still having difficulty to reproduce can you reproduce with the attached printk debuging patch and provide the log (only few printk preceding the oops or segfault are interesting).

http://darnok.org/vga/move_notify-v212.log

Looks like nouveau doesn't like move notify being call on driver shutdown or when somethings om nv50 is down. Ben i think you will be better at finding a fix for that than me.

Cheers,
Jerome

#9 lore raw
Quoted 11 lines · Jerome Glisse
Quoted 6 lines · Konrad Rzeszutek Wilk
Quoted 3 lines

Still having difficulty to reproduce can you reproduce with the attached printk debuging patch and provide the log (only few printk preceding the oops or segfault are interesting).

http://darnok.org/vga/move_notify-v212.log

Looks like nouveau doesn't like move notify being call on driver shutdown or when somethings om nv50 is down. Ben i think you will be better at finding a fix for that than me.

I'm also not able to reproduce this issue on a NV98 (so, i'd expect every nv50+ chipset to behave the same) chipset with the current code in Dave's drm-core-next tree..

Am I missing something?

Ben.

Quoted 3 lines

Cheers,
Jerome

#10 lore raw
Quoted 9 lines · Ben Skeggs
Quoted 8 lines · Jerome Glisse
Quoted 6 lines · Konrad Rzeszutek Wilk
Quoted 3 lines

Still having difficulty to reproduce can you reproduce with the attached printk debuging patch and provide the log (only few printk preceding the oops or segfault are interesting).

http://darnok.org/vga/move_notify-v212.log

Quoted 6 lines
Quoted 3 lines

Looks like nouveau doesn't like move notify being call on driver shutdown or when somethings om nv50 is down. Ben i think you will be better at finding a fix for that than me.

I'm also not able to reproduce this issue on a NV98 (so, i'd expect every nv50+ chipset to behave the same) chipset with the current code in Dave's drm-core-next tree..

I was using 3.2 and then merged drm-core-next tree on top of that.

Quoted 2 lines

Am I missing something?

I am using a stock Fedora 16 with X Server 1.11.2. Machine has 8GB, and one DVI monitor and is an AMD box. The kernel was compiled using the default Fedora Core .config and for any new options I just hit enter.

Don't have the experimental libGL code, so using:
OpenGL version string: 2.1 Mesa 7.11.2

for the rendering. And the test setup is fairly easy - launch etracer, switch to a FB VC (Ctrl-Alt-F2), login, find the etracer pid and run perf --record --pid X and then switch back. Finish playing the game, exit it and then switch to the FB VC to turn it off, and it happens.

Sometimes it happens when I just finished the game.

I also can reproduce this with an AGP card (GeForce 4 Ti4200?) on an Intel Prescott box (2GB of memory) - also with stock Fedora 16. Thought the crash is different:

http://darnok.org/vga/agp_nouveau_crash.jpg

Hmm, I can hook up a serial console to that box to get a better output - but perhaps before I do that should is there a debug patch I should compile in?

#11 lore raw
In reply to Ben Skeggs
Quoted 9 lines · Ben Skeggs
Quoted 8 lines · Jerome Glisse
Quoted 6 lines · Konrad Rzeszutek Wilk
Quoted 3 lines

Still having difficulty to reproduce can you reproduce with the attached printk debuging patch and provide the log (only few printk preceding the oops or segfault are interesting).

http://darnok.org/vga/move_notify-v212.log

Quoted 6 lines
Quoted 3 lines

Looks like nouveau doesn't like move notify being call on driver shutdown or when somethings om nv50 is down. Ben i think you will be better at finding a fix for that than me.

I'm also not able to reproduce this issue on a NV98 (so, i'd expect every nv50+ chipset to behave the same) chipset with the current code in Dave's drm-core-next tree..

There looks to be a bug about this openned when folks where using firefox and seeing large pictures or scrolling through a large web-page.

Any thoughts or things I could try out to narrow this down?

#12 lore raw
In reply to [email protected]
Quoted 4 lines · On Thu, Jan 05, 2012 at 01:31:55PM -0500, [email protected] wrote:

From: Jerome Glisse <[email protected]>

ttm might call the move notify with null new mem placement, properly handle this case inside nouveau move notify callback.

Let me give this a spin tonight on both PCIe and AGP hardware.

Um, were you thinking to repost your TTM AGP patch? I remember you sent it as a "hey, try this please", but can't recall whether you were looking to post another one?

Quoted 45 lines
---
 drivers/gpu/drm/nouveau/nouveau_bo.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/nouveau/nouveau_bo.c +3 -3
index f12dd0f..65f5b0b 100644
@@ -808,9 +808,8 @@ out:
 }
 
 static void
-nouveau_bo_move_ntfy(struct ttm_buffer_object *bo, struct ttm_mem_reg *new_mem)
+nouveau_bo_move_notify(struct ttm_buffer_object *bo, struct ttm_mem_reg *new_mem)
 {
-	struct nouveau_mem *node = new_mem->mm_node;
 	struct nouveau_bo *nvbo = nouveau_bo(bo);
 	struct nouveau_vma *vma;
 
@@ -820,6 +819,7 @@ nouveau_bo_move_ntfy(struct ttm_buffer_object *bo, struct ttm_mem_reg *new_mem)
 		} else
 		if (new_mem && new_mem->mem_type == TTM_PL_TT &&
 		    nvbo->page_shift == vma->vm->spg_shift) {
+			struct nouveau_mem *node = new_mem->mm_node;
 			nouveau_vm_map_sg(vma, 0, new_mem->
 					  num_pages << PAGE_SHIFT,
 					  node, node->pages);
@@ -1131,7 +1131,7 @@ struct ttm_bo_driver nouveau_bo_driver = {
 	.invalidate_caches = nouveau_bo_invalidate_caches,
 	.init_mem_type = nouveau_bo_init_mem_type,
 	.evict_flags = nouveau_bo_evict_flags,
-	.move_notify = nouveau_bo_move_ntfy,
+	.move_notify = nouveau_bo_move_notify,
 	.move = nouveau_bo_move,
 	.verify_access = nouveau_bo_verify_access,
 	.sync_obj_signaled = __nouveau_fence_signalled,
Signature · 6 lines
1.7.7.1

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#13 lore raw
Quoted 12 lines · Konrad Rzeszutek Wilk
Quoted 4 lines · On Thu, Jan 05, 2012 at 01:31:55PM -0500, [email protected] wrote:

From: Jerome Glisse <[email protected]>

ttm might call the move notify with null new mem placement, properly handle this case inside nouveau move notify callback.

Let me give this a spin tonight on both PCIe and AGP hardware.

Um, were you thinking to repost your TTM AGP patch? I remember you sent it as a "hey, try this please", but can't recall whether you were looking to post another one?

AGP patch i sent is good to go. I tested it enough to be confident now.

Cheers,
Jerome