On Wed, Sep 28, 2011 at 13:12, Hans Verkuil hverkuil@xs4all.nl wrote:
On Wednesday, September 28, 2011 12:52:58 Daniel Vetter wrote:
On get_scatterlist walk the attachment list and grab the dma requirements of all devices (via some platform/dma specific stuff attached to struct device). Then walk through a list of dma allocators your platform provides (page_alloc, cma, ...) until you have one that satisfies the requirements and alloc the backing storage.
Then create an sg_list out of hit and map_sg it, like above.
Hmm. Here is where I run into problems. Right now the get_scatterlist op is set by the driver that exports the buffer. So each driver supporting dma_buf would have it's own get_scatterlist implementation, each able to walk the attachment list. This feels wrong to me. get_scatterlist is doing too much and this functionality should probably be split up somehow.
I think we'll end up with a default implementation that just creates a dma_buf objects and hides all the magic from drivers. But for special cases (like when using objects mapped into auto-tiling iommus) and drivers with special infrastructure (drm drivers) I think we should be able to override this.
Maybe we should add such a thing as an official function to the api. The x86 implementation should be fairly simple (array of struct page* for backing storage), on arm it would deal with all the insanity there is.
There is also the problem of how to determine whether all requirements are satisfied: that's currently left undefined.
I think that should be a platform/architecture problem. And I'm happy not to be forced to deal with arm ;-) In general, if anything of that arm-craziness leaks into the interface, that's bad, so I regard your question here as a good sign ...
For arm we probably need some helper functions to make this easier.
- Sharing of a special buffer object, like a tiled buffer remapping into
omap's TILER. attach would check whether the device can actually access that special io area (iirc on omap only certain devices can access the tiler). get_scatterlist would just create a 1-entry sg_list that points directly to the pyhsical address (in device space) of the remapped buffer. This is way I want get_scatterlist to return a mapped buffer (and for api cleanliness).
OK.
I think I would like to see a demo implementation and proper documentation. Both help a lot to bring the API into focus and identify what works and what doesn't. If it's hard to explain or to implement, then we probably should improve that part :-)
Yeah, definitely. I think it'll take a while for the arm-insanity-induced infrastructure to shape up unfortunately, but maybe I can hack something together on x86 with i915 as a proof of concept.
Cheers, Daniel