On Tue, May 27, 2003 at 11:53:22AM +0100, Christoph Hellwig wrote:
> > ralf> Use the value returned by pci_alloc_consistent in *dma_handle
> > ralf> instead of trying to do any conversions with of
> > ralf> pci_alloc_consistent's return value.
> > How about virt_to_page()?
> > Currently, many sound drivers (including ALSA) pass a
> > pci_alloc_consistent's return value to virt_to_page.
> You are not allow to do so. Any driver doing this is broken.
That however is exactly what's documented in DMA-mapping.txt:
portably refer to any piece of memory. If you have a cpu pointer
(which may be validly DMA'd too) you may easily obtain the page
and offset using something like this:
struct page *page = virt_to_page(ptr);
unsigned long offset = ((unsigned long)ptr & ~PAGE_MASK);
While it's officially documented I still don't like it. A double
conversion such as page_address(virt_to_page(ptr)) would accidently
turn a pointer of an uncached mapping into one to a cached area for the
same object - that will almost certainly not work as expected on a