On Wednesday 20 April 2011 23:52:56 Rebecca Schultz Zavin wrote:
The android team's graphics folks, the their counterparts at intel, imagination tech, nvidia, qualcomm and arm have all told me that they need a method for mapping buffers uncached to userspace. The common case for this is to write vertexes, textures etc to these buffers once and never touch them again. This may happen several (or even several 10s or more) of times per frame. My experience with cache flushes on ARM architectures matches Marek's.
Ok, thanks for the confirmation on that, both of you.
Is the requirement only to have the uncached mapping in user space then while it does not need to be mapped into the kernel, or is there also a requirement to map the same buffers into the kernel address space?
We already allow very limited amounts of buffers to be mapped uncached into the kernel using dma_alloc_coherent(), but that is typically for stuff like descriptor tables where we have at most a few pages per device.
On coherent systems (arch_is_coherent()), we do return a cacheable mapping for dma_alloc_coherent, and I assume that you wouldn't want that, because it prevents mapping the same buffer into user space as uncached.
I suppose what we want here is a way to get a scatterlist for memory has a linear mapping on a given device and is not mapped into the kernel address space at all. This is something that is not possible with the dma-mapping interface yet. In particular, using the streaming mapping API (dma_map_sg) currently requires that the page is mapped into linear mapping because the kernel wants to do the appropriate cache flushes that we are trying to avoid.
I think the issue of contiguous memory allocation and cache attributes are totally separate, except that in cases where large contiguous regions are necessary -- the problem qualcom's pmem and friends were written to solve -- you pretty much end up needing to put aside a pool of buffers at boot anyway in order to guarantee the availability of large order allocations. Once you've done that, the attributes problem goes away since your memory is not in the direct map.
I don't think we strictly have to completely hide that pool from other users, if we decide to use the highmem approach. All pages in highmem today should be movable, so we can free up contiguous space that is not mapped by paging out the data that is there.
Arnd