Re: sparc/staging compile error

From: Benjamin Herrenschmidt
Date: Fri Nov 07 2008 - 18:09:28 EST



> May be the code is not doing what is supposed to do, but here is what the
> driver is trying to achieve:
>
> The driver allocates a set of buffers for DMA. These buffers are mapped
> into user space, when the user does an mmap. In transmit, when the user
> space writes to these buffers, the data has to reach physical memory so
> that the device can access them. For receive, the cache has to be
> invalidated before the user space reads the buffer.
>
> Do let me know if further clarification is required. Any inputs and
> suggestions are welcome.

Well, this is the wrong API to do that. First, some platforms are cache
coherent and thus don't need anything there other than maybe a barrier.

Then, the dma_* API is what you want to ensure cache coherency with DMA
transfers within the kernel.

If userspace can directly trigger DMA from pre-allocated buffers, then
doing an ioctl to sync is a major wastage, since most platforms are
cache coherent (and thus don't need it) and those who are not generally
provide user-space accessible ways of doing the flush to some extent
(not all, for example, BookE PPC cannot invalidate the data cache from
userspace, only flush it).

In any case, we would need to understand better your driver userspace
API and transfer model to find the right solution.

Ben.


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/