Skip to contentSkip to conversation

amdgpu/TTM oopses since merging swiotlb_dma_ops into the dma_direct code

DISCUSSION Michel Dänzer 6 participants 13 messages Jan 10, 2019 – Jan 14, 2019 7 messages not in the archive DMA mapping helpers

lore
Share & tools
lore
#0 lore raw

Hi Christoph,

https://bugs.freedesktop.org/109234 (please ignore comments #6-#9) was bisected to your commit 55897af63091 "dma-direct: merge swiotlb_dma_ops into the dma_direct code". Any ideas?

Signature · 6 lines
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#1 lore raw
Quoted 7 lines · Michel Dänzer

Hi Christoph,

https://bugs.freedesktop.org/109234 (please ignore comments #6-#9) was bisected to your commit 55897af63091 "dma-direct: merge swiotlb_dma_ops into the dma_direct code". Any ideas?

From the trace it looks like we git the case where swiotlb tries to copy back data from a bounce buffer, but hits a dangling or NULL pointer. So a couple questions for the submitter:

- does the system have more than 4GB memory and thus use swiotlb? (check /proc/meminfo, and if something SWIOTLB appears in dmesg)
- does the device this happens on have a DMA mask smaller than the available memory, that is should swiotlb be used here to start with?
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#2 lore raw

Am 10.01.19 um 14:57 schrieb Christoph Hellwig:

Quoted 11 lines · Michel Dänzer
Quoted 6 lines

Hi Christoph,

https://bugs.freedesktop.org/109234 (please ignore comments #6-#9) was bisected to your commit 55897af63091 "dma-direct: merge swiotlb_dma_ops into the dma_direct code". Any ideas?

From the trace it looks like we git the case where swiotlb tries
to copy back data from a bounce buffer, but hits a dangling or NULL pointer. So a couple questions for the submitter:

Quoted 5 lines

- does the system have more than 4GB memory and thus use swiotlb? (check /proc/meminfo, and if something SWIOTLB appears in dmesg)
- does the device this happens on have a DMA mask smaller than the available memory, that is should swiotlb be used here to start with?

Rather unlikely. The device is an AMD GPU, so we can address memory up to 1TB.

Christian.

Quoted 4 lines

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

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

A message that is not in the archive (sent off-list or not yet received): a3f0fd49-2286-ee2a-f0e8-dfe82aac73fb-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#4 lore raw
Quoted 4 lines · Christian König
Quoted 4 lines

From the trace it looks like we git the case where swiotlb tries
to copy back data from a bounce buffer, but hits a dangling or NULL pointer. So a couple questions for the submitter:

Quoted 8 lines
Quoted 5 lines

- does the system have more than 4GB memory and thus use swiotlb? (check /proc/meminfo, and if something SWIOTLB appears in dmesg)
- does the device this happens on have a DMA mask smaller than the available memory, that is should swiotlb be used here to start with?

Rather unlikely. The device is an AMD GPU, so we can address memory up to 1TB.

So we probably somehow got a false positive.

For now I'like the reported to confirm that the dma_direct_unmap_page+0x92 backtrace really is in the swiotlb code (I can't think of anything else, but I'd rather be sure).

Second it would be great to print what the contents of io_tlb_start and io_tlb_end are, e.g. by doing a printk_once in is_swiotlb_buffer, maybe that gives a clue why we are hitting the swiotlb code here.

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

#6 lore raw
Quoted 12 lines · Christoph Hellwig
Quoted 10 lines · Christian König
Quoted 9 lines

From the trace it looks like we git the case where swiotlb tries
to copy back data from a bounce buffer, but hits a dangling or NULL pointer. So a couple questions for the submitter:

- does the system have more than 4GB memory and thus use swiotlb? (check /proc/meminfo, and if something SWIOTLB appears in dmesg)
- does the device this happens on have a DMA mask smaller than the available memory, that is should swiotlb be used here to start with?

Quoted 8 lines
Quoted 2 lines

Rather unlikely. The device is an AMD GPU, so we can address memory up to 1TB.

So we probably somehow got a false positive.

For now I'like the reported to confirm that the dma_direct_unmap_page+0x92 backtrace really is in the swiotlb code (I can't think of anything else, but I'd rather be sure).

I'm not sure what you want me to confirm. Could you elaborate?

Quoted 4 lines

Second it would be great to print what the contents of io_tlb_start and io_tlb_end are, e.g. by doing a printk_once in is_swiotlb_buffer, maybe that gives a clue why we are hitting the swiotlb code here.

include/linux/swiotlb.h +1 -0
index 7c007ed7505f..042246dbae00 100644
@@ -69,6 +69,7 @@ extern phys_addr_t io_tlb_start, io_tlb_end;
 
 static inline bool is_swiotlb_buffer(phys_addr_t paddr)
 {
+    printk_once(KERN_INFO "io_tlb_start: %llu, io_tlb_end: %llu",
io_tlb_start, io_tlb_end);
     return paddr >= io_tlb_start && paddr < io_tlb_end;

}

Result on boot:

[   11.405558] io_tlb_start: 3782983680, io_tlb_end: 3850092544

Regards,

Sibren
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu

#7 lore raw
Quoted 16 lines · Sibren Vasse
Quoted 15 lines · Christoph Hellwig
Quoted 12 lines · Christian König
Quoted 9 lines

From the trace it looks like we git the case where swiotlb tries
to copy back data from a bounce buffer, but hits a dangling or NULL pointer. So a couple questions for the submitter:

- does the system have more than 4GB memory and thus use swiotlb? (check /proc/meminfo, and if something SWIOTLB appears in dmesg)
- does the device this happens on have a DMA mask smaller than the available memory, that is should swiotlb be used here to start with?

Rather unlikely. The device is an AMD GPU, so we can address memory up to 1TB.

Quoted 6 lines
Quoted 5 lines

So we probably somehow got a false positive.

For now I'like the reported to confirm that the dma_direct_unmap_page+0x92 backtrace really is in the swiotlb code (I can't think of anything else, but I'd rather be sure).

I'm not sure what you want me to confirm. Could you elaborate?

Please open the vmlinux file for which this happend in gdb, then send the output from this command

	l *(dma_direct_unmap_page+0x92)

to this thread.

Quoted 17 lines
Quoted 3 lines

Second it would be great to print what the contents of io_tlb_start and io_tlb_end are, e.g. by doing a printk_once in is_swiotlb_buffer, maybe that gives a clue why we are hitting the swiotlb code here.

include/linux/swiotlb.h +1 -0
index 7c007ed7505f..042246dbae00 100644
@@ -69,6 +69,7 @@ extern phys_addr_t io_tlb_start, io_tlb_end;
 
 static inline bool is_swiotlb_buffer(phys_addr_t paddr)
 {
+    printk_once(KERN_INFO "io_tlb_start: %llu, io_tlb_end: %llu",
 io_tlb_start, io_tlb_end);
     return paddr >= io_tlb_start && paddr < io_tlb_end;
 }
Quoted 2 lines

Result on boot:

[   11.405558] io_tlb_start: 3782983680, io_tlb_end: 3850092544

So this is a normal swiotlb location, and it does defintively exist.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

#9 lore raw
Quoted 23 lines · Christoph Hellwig
Quoted 21 lines · Sibren Vasse
Quoted 20 lines · Christoph Hellwig
Quoted 4 lines · Christian König
Quoted 4 lines

From the trace it looks like we git the case where swiotlb tries
to copy back data from a bounce buffer, but hits a dangling or NULL pointer. So a couple questions for the submitter:

Quoted 8 lines
Quoted 5 lines

- does the system have more than 4GB memory and thus use swiotlb? (check /proc/meminfo, and if something SWIOTLB appears in dmesg)
- does the device this happens on have a DMA mask smaller than the available memory, that is should swiotlb be used here to start with?

Rather unlikely. The device is an AMD GPU, so we can address memory up to 1TB.

So we probably somehow got a false positive.

For now I'like the reported to confirm that the dma_direct_unmap_page+0x92 backtrace really is in the swiotlb code (I can't think of anything else, but I'd rather be sure).

Quoted 8 lines
Quoted 1 line

I'm not sure what you want me to confirm. Could you elaborate?

Please open the vmlinux file for which this happend in gdb, then send the output from this command

        l *(dma_direct_unmap_page+0x92)

to this thread.

My call trace contained:

Jan 10 16:34:51 <hostname> kernel:  dma_direct_unmap_page+0x7a/0x80

(gdb) list *(dma_direct_unmap_page+0x7a)
0xffffffff810fa28a is in dma_direct_unmap_page (kernel/dma/direct.c:291).
286 size_t size, enum dma_data_direction dir,
unsigned long attrs)
287 {
288 phys_addr_t phys = dma_to_phys(dev, addr);
289
290 if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
291 dma_direct_sync_single_for_cpu(dev, addr, size, dir);
292
293 if (unlikely(is_swiotlb_buffer(phys)))
294 swiotlb_tbl_unmap_single(dev, phys, size, dir, attrs);
295 }
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#10 lore raw
In reply to a message not in the archive
Quoted 16 lines · Christoph Hellwig
Quoted 4 lines · Christian König
Quoted 4 lines

From the trace it looks like we git the case where swiotlb tries
to copy back data from a bounce buffer, but hits a dangling or NULL pointer. So a couple questions for the submitter:

Quoted 8 lines
Quoted 5 lines

- does the system have more than 4GB memory and thus use swiotlb? (check /proc/meminfo, and if something SWIOTLB appears in dmesg)
- does the device this happens on have a DMA mask smaller than the available memory, that is should swiotlb be used here to start with?

Rather unlikely. The device is an AMD GPU, so we can address memory up to 1TB.

So we probably somehow got a false positive.

Quoted 7 lines

For now I'like the reported to confirm that the dma_direct_unmap_page+0x92 backtrace really is in the swiotlb code (I can't think of anything else, but I'd rather be sure).

Second it would be great to print what the contents of io_tlb_start and io_tlb_end are, e.g. by doing a printk_once in is_swiotlb_buffer, maybe that gives a clue why we are hitting the swiotlb code here.

Any progress? https://bugzilla.kernel.org/show_bug.cgi?id=202261 was also filed about this.

I hope everyone's clear that this needs to be resolved one way or another by 5.0 final (though the sooner, the better :).

Signature · 6 lines
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

#12 lore raw
Quoted 6 lines · Christoph Hellwig
Quoted 4 lines · Michel Dänzer

Hi Christoph,

Quoted 7 lines
Quoted 3 lines

https://bugs.freedesktop.org/109234 (please ignore comments #6-#9) was bisected to your commit 55897af63091 "dma-direct: merge swiotlb_dma_ops into the dma_direct code". Any ideas?

From the trace it looks like we git the case where swiotlb tries to copy back data from a bounce buffer, but hits a dangling or NULL pointer. So a couple questions for the submitter:

My apologies if I misunderstand something, this subject matter is new to me.

Quoted 2 lines

- does the system have more than 4GB memory and thus use swiotlb?

My system has 8GB memory. The other report on the bug tracker had 16GB.

Quoted 1 line

(check /proc/meminfo, and if something SWIOTLB appears in dmesg)

/proc/meminfo: https://ptpb.pw/4rxI
Can I grep dmesg for a string?

Quoted 3 lines

- does the device this happens on have a DMA mask smaller than the available memory, that is should swiotlb be used here to start with?

It's a MSI Radeon RX 570 Gaming X 4GB. The other report was a RX 580. lshw output: https://ptpb.pw/6s0H

Regards,

Sibren
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu

A message that is not in the archive (sent off-list or not yet received): CAF=iVctGGs1OzHBg6MgpxrFbT_19T4YvH8muBZtsLJBDwGhrvQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#14 lore raw
Quoted 17 lines · Sibren Vasse
Quoted 6 lines · Christoph Hellwig
Quoted 4 lines · Michel Dänzer

Hi Christoph,

Quoted 7 lines
Quoted 3 lines

https://bugs.freedesktop.org/109234 (please ignore comments #6-#9) was bisected to your commit 55897af63091 "dma-direct: merge swiotlb_dma_ops into the dma_direct code". Any ideas?

From the trace it looks like we git the case where swiotlb tries to copy back data from a bounce buffer, but hits a dangling or NULL pointer. So a couple questions for the submitter:

My apologies if I misunderstand something, this subject matter is new to me.

Quoted 1 line
Quoted 6 lines
Quoted 1 line

- does the system have more than 4GB memory and thus use swiotlb?

My system has 8GB memory. The other report on the bug tracker had 16GB.

Quoted 1 line

(check /proc/meminfo, and if something SWIOTLB appears in dmesg)

/proc/meminfo: https://ptpb.pw/4rxI
Can I grep dmesg for a string?

Can you attach the 'dmesg'?

Quoted 11 lines
Quoted 4 lines

- does the device this happens on have a DMA mask smaller than the available memory, that is should swiotlb be used here to start with?

It's a MSI Radeon RX 570 Gaming X 4GB. The other report was a RX 580. lshw output: https://ptpb.pw/6s0H

Regards,

Sibren

A message that is not in the archive (sent off-list or not yet received): 20190110170557.GD27546-he5eyhs8q0BAdwtm4QZOy9BPR1lH4CV8@public.gmane.org

#16 lore raw
Quoted 19 lines · Konrad Rzeszutek Wilk
Quoted 17 lines · Sibren Vasse
Quoted 6 lines · Christoph Hellwig
Quoted 4 lines · Michel Dänzer

Hi Christoph,

Quoted 7 lines
Quoted 3 lines

https://bugs.freedesktop.org/109234 (please ignore comments #6-#9) was bisected to your commit 55897af63091 "dma-direct: merge swiotlb_dma_ops into the dma_direct code". Any ideas?

From the trace it looks like we git the case where swiotlb tries to copy back data from a bounce buffer, but hits a dangling or NULL pointer. So a couple questions for the submitter:

My apologies if I misunderstand something, this subject matter is new to me.

Quoted 1 line
Quoted 8 lines
Quoted 6 lines
Quoted 1 line

- does the system have more than 4GB memory and thus use swiotlb?

My system has 8GB memory. The other report on the bug tracker had 16GB.

Quoted 1 line

(check /proc/meminfo, and if something SWIOTLB appears in dmesg)

/proc/meminfo: https://ptpb.pw/4rxI
Can I grep dmesg for a string?

Can you attach the 'dmesg'?

Dmesg attached.

#17 lore raw
In reply to Sibren Vasse

Hmm, I wonder if we are not actually using swiotlb in the end, can you check if your dmesg contains this line or not?

PCI-DMA: Using software bounce buffering for IO (SWIOTLB)

If not I guess we found a bug in swiotlb exit vs is_swiotlb_buffer, and you can try this patch:

kernel/dma/swiotlb.c +2 -0
index d6361776dc5c..1fb6fd68b9c7 100644
@@ -378,6 +378,8 @@ void __init swiotlb_exit(void)
 		memblock_free_late(io_tlb_start,
 				   PAGE_ALIGN(io_tlb_nslabs << IO_TLB_SHIFT));
 	}
+	io_tlb_start = 0;
+	io_tlb_end = 0;
 	io_tlb_nslabs = 0;
 	max_segment = 0;
 }

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

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

#19 lore raw
Quoted 5 lines · Christoph Hellwig

Hmm, I wonder if we are not actually using swiotlb in the end, can you check if your dmesg contains this line or not?

PCI-DMA: Using software bounce buffering for IO (SWIOTLB)

This line does not appear in my dmesg.

Quoted 9 lines

If not I guess we found a bug in swiotlb exit vs is_swiotlb_buffer, and you can try this patch:

kernel/dma/swiotlb.c +0 -0
index d6361776dc5c..1fb6fd68b9c7 100644

kernel/dma/swiotlb.c void __init swiotlb_exit(void) · line 385

Quoted 8 lines
kernel/dma/swiotlb.c +2 -0
@@ -378,6 +378,8 @@ void __init swiotlb_exit(void)
                memblock_free_late(io_tlb_start,
                                   PAGE_ALIGN(io_tlb_nslabs << IO_TLB_SHIFT));
        }
+       io_tlb_start = 0;
+       io_tlb_end = 0;
        io_tlb_nslabs = 0;
        max_segment = 0;
 }

With the patch applied to v5.0-rc2 I can no longer reproduce the issue.
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx