public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
* Bug in add_dma_entry()'s debugging code
@ 2023-11-27 16:02 Alan Stern
  2023-11-27 16:07 ` Christoph Hellwig
  0 siblings, 1 reply; 16+ messages in thread
From: Alan Stern @ 2023-11-27 16:02 UTC (permalink / raw)
  To: Hamza Mahfooz, Dan Williams, Christoph Hellwig
  Cc: Marek Szyprowski, Andrew, Ferry Toth, Andy Shevchenko,
	Thorsten Leemhuis, iommu, Kernel development list,
	USB mailing list

Among other things, add_dma_entry() in kernel/dma/debug.c prints an 
error message when it sees two overlapping FROM_DEVICE DMA mappings.  
The actual overlap detection is performed by a separate routine, 
active_cacheline_insert().  But the criterion this routine uses is 
wrong.

All it looks for is mappings that start on the same cache line.  However 
on architectures that have cache-coherent DMA (such as x86), touching 
the same cache line does not mean that two DMA mappings will interfere 
with each other.  To truly overlap, they would have to touch the same 
_bytes_.

The routine does not check for this, and consequently we get error 
messages about overlapping mappings when in fact there is no overlap.  
This bug has been reported in

	https://bugzilla.kernel.org/show_bug.cgi?id=215740

How should this be fixed?  Since the check done in add_dma_entry() is 
completely invalid for x86 and similar architectures, should it simply 
be removed for them?  Or should the check be enhanced to look for 
byte-granularity overlap?

Alan Stern

PS: As a separate issue, active_cacheline_insert() fails to detect 
overlap in situations where a mapping occupies more than one cache line.  
For example, if mapping A uses lines N and N+1 and mapping B uses line 
N+1, no overlap will be detected because the radix-tree keys for A and B 
will be different (N vs. N+1).

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2023-12-06 16:21 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-27 16:02 Bug in add_dma_entry()'s debugging code Alan Stern
2023-11-27 16:07 ` Christoph Hellwig
2023-11-27 16:51   ` Alan Stern
2023-11-28 13:37     ` Christoph Hellwig
2023-11-28 15:18       ` Alan Stern
2023-11-28 16:31         ` Robin Murphy
2023-11-28 16:34           ` Andy Shevchenko
2023-11-28 16:54             ` Robin Murphy
2023-11-28 17:44         ` Catalin Marinas
2023-11-30 20:08           ` Ferry Toth
2023-12-01 11:08             ` Catalin Marinas
2023-12-01 12:17               ` Ferry Toth
2023-12-01 16:21                 ` Alan Stern
2023-12-01 17:42                   ` Catalin Marinas
2023-12-05 18:28                     ` Alan Stern
     [not found]                       ` <1e4df825-08fa-40cf-a565-9c0d285c9b73@gmail.com>
2023-12-06 16:21                         ` Alan Stern

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox