Re: [PATCH] Sam440ep support
flat view
From: Takashi Iwai <hidden>
Date: 2008-05-06 11:31:41
At Tue, 06 May 2008 21:25:53 +1000, Benjamin Herrenschmidt wrote:
On Tue, 2008-05-06 at 13:14 +0200, Takashi Iwai wrote:quoted
quoted
sg allocations are usually lists of page, so virt_to_page shouldn'tbe aquoted
problem in the first place, though we still need some way to get the right prot attributes.The problem is that ALSA SG buffer is composed from pages allocated via dma_alloc_coherent(), and the pages are retrieved via virt_to_page for DMA pages, as found in sound/core/sgbuf.c. I didn't care about SG-buffer cases in my initial patch, and it's a bit messy. The current code requires page lists becasue it calls vmap() to get a virtually linear buffer.Hrm... the problem is that you aren't supposed to make up sglists with the result of dma_alloc_coherent... It might be a limitation of our core DMA API, but that's we have to deal with today.. If you're going to make up sglists and call vmap, you should allocate pages with normal GFP. If that is a problem vs. DMA'bility of those pages, then ... we have a problem :-) I don't think we can easily update the DMA API at this stage. What we could do is provide a way to retrieve the struct page array from the result of dma_alloc_coherent...
In most cases, it can be obtained via pfn_to_page(), I suppose. But, it's definitely arch-specific thingy, and a generic solution would be really appreciated. Alternatively, we can change the ALSA PCM core code that accesses the virtual linear buffer and handles SG-buffers as they are. Maybe it'll give a bit more useful clean-up in the whole memory-management codes in ALSA in the end. Takashi