Re: DMA API issues

From: Takashi Iwai (tiwai_at_suse.de)
Date: 06/21/04

  • Next message: Jake Moilanen: "[PATCH 1/2] Spinlock timeouts"
    Date:	Mon, 21 Jun 2004 15:35:42 +0200
    To: Russell King <rmk+lkml@arm.linux.org.uk>
    
    

    At Fri, 18 Jun 2004 20:43:22 +0100,
    Russell King wrote:
    >
    > On Fri, Jun 18, 2004 at 12:21:12PM -0700, Matt Porter wrote:
    > > > page_to_dma so that device specific dma addresses can be constructed.
    > >
    > > A struct device argument to page_to_dma seems like a no brainer to be
    > > included.
    >
    > Tony Lindgren recently submitted a patch for this:
    >
    > http://www.arm.linux.org.uk/developer/patches/viewpatch.php?id=1931/1
    >
    > which now pending for Linus. ARM platforms now have three macros to
    > define if they want to override the default struct page to DMA address
    > translation.

    Wouldn't it be nicer to define a more generic style like

    struct page *dma_to_page(struct device *, void *, dma_addr_t)

    ??

    >
    > > I see that's somewhat like what David Brownell suggested before...a single
    > > pointer to a set of dma ops from struct device. hppa_dma_ops translated
    > > into a generic dma_ops entity with fields corresponding to existing
    > > DMA API calls would be a good starting point. We can get rid of some
    > > address translation hacks in a lot of custom embedded PPC drivers
    > > with something like this.
    >
    > I really don't think we need to go this far.
    >
    > As I understand it, the issue seems to surround DMA coherent memory
    > for USB descriptors, and what happens when we call the streaming DMA
    > API.
    >
    > We have the latter solved with Deepak's DMA bounce code (already merged)
    > provided it's given the right information to determine when bounce
    > buffers are needed.
    >
    > The bounce code only needs a way to get at the "safe" DMA memory, and
    > it uses DMA pools for that. DMA pools in turn take their memory from
    > dma_alloc_coherent.
    >
    > So, we just need a way to make dma_alloc_coherent do the right thing.
    > One suggestion from James yesterday was to have a way to register
    > device-private "coherent DMA" backing memory with dma_alloc_coherent,
    > which it would use in preference to calling alloc_pages(). However,
    > this memory would have no struct page pointer associated with it, and
    > our dma_alloc_coherent implementation currently relies completely on
    > that condition existing - so it would mean a complete rewrite of that.
    >
    > Note also that some drivers (notably ALSA) assume that memory returned
    > from dma_alloc_coherent() does have struct page pointers, so this would
    > also break ALSA (which in turn provides much more of a justification
    > for the DMA MMAP API I was trying (and failed) to propose a few months
    > back.)

    Yes, the struct page pointer is needed for vma_ops.nopage in mmap on
    ALSA. So far, this is broken on some architectures like ARM. We need
    a proper conversion from virtual/bus pointer to a page struct.

    Of course, mmap is not mandatory, and we have a fallback via
    ioctl/read/write. But it's important to _know_ whether remapping is
    available...

    --
    Takashi Iwai <tiwai@suse.de>		ALSA Developer - www.alsa-project.org
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at  http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at  http://www.tux.org/lkml/
    

  • Next message: Jake Moilanen: "[PATCH 1/2] Spinlock timeouts"

    Relevant Pages

    • Re: Request for feedback on common data backstore in the kernel
      ... struct mbuf ... a 2k cluster (which comes from a different pool than the core mbuf) to ... The current backstores are loaded into DMA by using the BUS-DMA ... gigs of memory, but only a 2GB window for mapping main memory... ...
      (freebsd-arch)
    • Re: Request for feedback on common data backstore in the kernel
      ... struct mbuf ... a 2k cluster (which comes from a different pool than the core mbuf) to ... The current backstores are loaded into DMA by using the BUS-DMA framework. ... gigs of memory, but only a 2GB window for mapping main memory... ...
      (freebsd-arch)
    • Re: Request for feedback on common data backstore in the kernel
      ... struct mbuf ... a 2k cluster (which comes from a different pool than the core mbuf) to ... The current backstores are loaded into DMA by using the BUS-DMA framework. ... gigs of memory, but only a 2GB window for mapping main memory... ...
      (freebsd-net)
    • [PATCH] spelling fixes: arch/arm/
      ... copy data to/from buffers located outside the DMA region. ... the remainder of memory is at the top and the DMA memory ... Peers on the PCI bus running ... - * devices are controlles by different NPUs on the same bus, ...
      (Linux-Kernel)
    • [PATCH] [0/13] General DMA zone rework
      ... Traditionally it was designed only for ISA dma which is limited to ... On 32bit i386 with its limited virtual memory space the next zone is ... cannot actually be used for ISA or any other device with <32bit DMA mask. ... I chose to implement a new "maskable memory" allocator to solve these ...
      (Linux-Kernel)