> 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 cachecoherent 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 DMAtransfers within the kernel.

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

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