[linux-dvb] [v4l-dvb-maintainer] [patch]dma on stack in dib0700
xyzzy at speakeasy.org
Wed Aug 27 03:31:35 CEST 2008
On Tue, 26 Aug 2008, Alan Stern wrote:
> > > That isn't good enough. If the buffer is part of a larger data
> > > structure (such as the main device descriptor), then the mutex has to
> > > protect the entire data structure -- not just the buffer.
> > >
> > Erm, why? The mutex makes sure the buffer gets used only by one usb control
> > transaction at a time, and the structure of which it is part does not get freed
> > until all usb transactions using the buffer are done.
> That's not entirely accurate. The mutex makes sure the buffer gets
> used only by one USB control transfer _on the host_. But it also gets
> used simultaneously by the USB host controller, through DMA accesses.
> On some architectures these DMA accesses do not respect the CPU cache.
> Access by the CPU to different parts of the same cache line while the
> transfer is in progress can overwrite data that was stored by the host
Isn't there a dma API for this?
It seems like you would need to allocate the cacheline size times two
(minus "1") and then use the middle of that. Any less and the memory used
could overlap a cacheline boundary.
More information about the linux-dvb