Re: [RFC v3 4/7] dmaengine: Add slave DMA interface

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Haavard Skinnemoen
Date: Monday, February 18, 2008 - 6:22 am

On Sat, 16 Feb 2008 13:06:54 -0700
"Dan Williams" <dan.j.williams@intel.com> wrote:


But there are currently no operations available for submitting
scatterlists as a single descriptor -- the client iterates over the
scatterlist and submits one descriptor for each entry. So there's no
way you can associated a scatterlist with a single descriptor. You can
perhaps attach it to the last one, but that may get you into trouble if
the transfer is terminated early for some reason.

I don't think the pure source/sink model is very realistic -- clients
can't just submit DMA transfers and then forget about them. They must
at the very least check the status and take appropriate action if there
was an error. They must also notify the driver that the descriptor can
be reused (although I guess if a client doesn't care about the result
it can do this immediately after submission, but I really think clients
_should_ care about the result.)

And since they need to do some sort of cleanup anyway, they might as
well unmap the buffers (or call some dma_memcpy_finish() type of
function that does it for them.)

The clients certainly know the length and direction too, but they don't
necessarily know the physical address since the mapping is done by a
"middle layer". I guess that's the main problem with the model I'm
proposing.

How about we add a kind of "address cookie" struct like this (feel free
to suggest better names):

struct dma_buf_addr {
	void *cpu_addr;
	dma_addr_t dma_addr;
};

The client initializes the cpu_addr part and passes the struct to
dma_async_memcpy_buf_to_buf() or whatever, the middle layer sets the
dma_addr after mapping the buffer (or page), and the client passes the
same struct to dma_finish_memcpy_buf_to_buf(). Which will then be able
to unmap both buffers appropriately.

This will also eliminate the hack in crypto/async_tx/async_xor.c and
make HIGHMEM64G work again.

Scatterlists currently don't have any middle-layer support, so we can
ignore them for now and let the client take the full responsibility of
mapping and unmapping the buffers. If we were to add some middle-layer
functions for dealing with scatterlists, I don't think they would need
any special treatment -- the dma address is kept in the struct
scatterlist array passed by the client, so it would work pretty much
the same way without any special treatment.

Alternatively, we could convert the whole API to use scatterlists. But
that's probably overdoing it.

Btw, this discussion is a bit off-topic for the patch in question, but
it's an issue that needs to be resolved.

Haavard
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[RFC v3 1/7] dmaengine: Couple DMA channels to their physi ..., Haavard Skinnemoen, (Tue Feb 12, 9:43 am)
[RFC v3 2/7] dmaengine: Add dma_client parameter to device ..., Haavard Skinnemoen, (Tue Feb 12, 9:43 am)
[RFC v3 3/7] dmaengine: Add dma_chan_is_in_use() function, Haavard Skinnemoen, (Tue Feb 12, 9:43 am)
[RFC v3 4/7] dmaengine: Add slave DMA interface, Haavard Skinnemoen, (Tue Feb 12, 9:43 am)
[RFC v3 5/7] dmaengine: Make DMA Engine menu visible for A ..., Haavard Skinnemoen, (Tue Feb 12, 9:43 am)
[RFC v3 6/7] dmaengine: Driver for the Synopsys DesignWare ..., Haavard Skinnemoen, (Tue Feb 12, 9:43 am)
Re: [RFC v3 5/7] dmaengine: Make DMA Engine menu visible f ..., Haavard Skinnemoen, (Tue Feb 12, 3:13 pm)
Re: [RFC v3 4/7] dmaengine: Add slave DMA interface, Dan Williams, (Wed Feb 13, 12:21 am)
Re: [RFC v3 4/7] dmaengine: Add slave DMA interface, Haavard Skinnemoen, (Wed Feb 13, 1:03 am)
Re: [RFC v3 5/7] dmaengine: Make DMA Engine menu visible f ..., Haavard Skinnemoen, (Wed Feb 13, 1:44 am)
Re: [RFC v3 4/7] dmaengine: Add slave DMA interface, Dan Williams, (Wed Feb 13, 12:07 pm)
Re: [RFC v3 4/7] dmaengine: Add slave DMA interface, Haavard Skinnemoen, (Wed Feb 13, 12:24 pm)
Re: [RFC v3 4/7] dmaengine: Add slave DMA interface, Haavard Skinnemoen, (Fri Feb 15, 2:53 am)
RE: [RFC v3 4/7] dmaengine: Add slave DMA interface, Nelson, Shannon, (Fri Feb 15, 10:12 am)
Re: [RFC v3 4/7] dmaengine: Add slave DMA interface, Dan Williams, (Sat Feb 16, 1:06 pm)
Re: [RFC v3 4/7] dmaengine: Add slave DMA interface, Haavard Skinnemoen, (Mon Feb 18, 6:22 am)
Re: [RFC v3 4/7] dmaengine: Add slave DMA interface, Haavard Skinnemoen, (Mon Feb 18, 6:29 am)
Re: [RFC v3 4/7] dmaengine: Add slave DMA interface, Dan Williams, (Mon Feb 18, 3:42 pm)
RE: [RFC v3 4/7] dmaengine: Add slave DMA interface, Nelson, Shannon, (Tue Feb 19, 11:46 am)