Re: [RFC v2 2/5] dmaengine: Add slave DMA interface



On Tue, 29 Jan 2008 23:30:05 -0800
David Brownell <david-b@xxxxxxxxxxx> wrote:

On Tuesday 29 January 2008, Haavard Skinnemoen wrote:
@@ -297,6 +356,13 @@ struct dma_device {
        struct dma_async_tx_descriptor *(*device_prep_dma_interrupt)(
                struct dma_chan *chan);
 
+       struct dma_slave_descriptor *(*device_prep_slave)(
+               struct dma_chan *chan, dma_addr_t mem_addr,
+               enum dma_slave_direction direction,
+               enum dma_slave_width reg_width,
+               size_t len, unsigned long flags);

That isn't enough options! Check out arch/arm/plat-omap/dma.c (and
maybe OMAP5912 DMA docs [1] for not-very-recent specs) as one example.
You'll see more options that drivers need to use, including:

- DMA priority and arbitration
- Burst size, packing/unpacking support (for optimized memory access)
- Multiple DMA quanta (not just reg_width, but also frames and blocks)
- Multiple synch modes (per element/"width", frame, or block)
- Multiple addressing modes: pre-index, post-index, double-index, ...
- Both descriptor-based and register based transfers
- ... lots more ...

Ok, I didn't bother to check the specs, as I think your main argument
is that these options vary from controller to controller, so we need to
make this extensible.

Not all options are specific to DMA slave transfers either, although
most of them are probably more important in this context.

Descriptor-based vs. register-based transfers sounds like something the
DMA engine driver is free to decide on its own.

Example: USB tends to use one packet per "frame" and have the DMA
request signal mean "give me the next frame". It's sometimes been
very important to use use the tuning options to avoid some on-chip
race conditions for transfers that cross lots of internal busses and
clock domains, and to have special handling for aborting transfers
and handling "short RX" packets.

Is it enough to set these options on a per-channel basis, or do they
have to be per-transfer?

I wonder whether a unified programming interface is the right way
to approach peripheral DMA support, given such variability. The DMAC
from Synopsys that you're working with has some of those options, but
not all of them... and other DMA controllers have their own oddities.

Yes, but I still think it's worthwhile to have a common interface to
common functionality. Drivers for hardware that does proper flow
control won't need to mess with priority and arbitration settings
anyway, although they could do it in order to tweak performance. So a
plain "write this memory block to the TX register of this slave"
interface will be useful in many cases.

For memcpy() acceleration, sure -- there shouldn't be much scope for
differences. Source, destination, bytecount ... go! (Not that it's
anywhere *near* that quick in the current interface.)

Well, I can imagine copying scatterlists may be useful too. Also, some
controllers support "stride" (or "scatter-gather", as Synopsys calls
it), which can be useful for framebuffer bitblt acceleration, for
example.

For peripheral DMA, maybe it should be a "core plus subclasses"
approach so that platform drivers can make use hardware-specific
knowledge (SOC-specific peripheral drivers using SOC-specific DMA),
sharing core code for dma-memcpy() and DMA channel housekeeping.

I mostly agree, but I think providing basic DMA slave transfers only
through extensions will cause maintenance nightmares for the drivers
using it. But I suppose we could have something along the lines of
"core plus standard subclasses plus SOC-specific subclasses"...

We already have something along those lines through the capabilities
mask, taking care of the "standard subclasses" part. How about we add
some kind of type ID to struct dma_device so that a driver can use
container_of() to get at the extended bits if it recognizes the type?

Haavard
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



Relevant Pages

  • Re: [RFC v2 2/5] dmaengine: Add slave DMA interface
    ... is that these options vary from controller to controller, ... Not all options are specific to DMA slave transfers either, ... DMA engine driver is free to decide on its own. ...
    (Linux-Kernel)
  • Re: Uninstall VIA IDE Controller and use Windows Default Drivers?
    ... If not you could uninstall all of the VIA drivers under Control ... Then upon a reboot....reinstall using the options in their install routine ... insisting that DMA is not enabled on any drive. ... Highpoint HPT3xx ATA RAID CONTROLLER ...
    (microsoft.public.windowsxp.help_and_support)
  • DMA mapping API on 32-bit X86 with CONFIG_HIGHMEM64G
    ... Essentially what it was doing was taking some memory that the userspace app was transferring to/from the device, doing get_user_pages on it, and then using the old-style page_to_phys, etc. functions to DMA on that memory instead of the modern DMA API. ... The strategy that Linux Device Drivers, 3rd Edition suggests is doing get_user_pages, creating an SG list from the returned pages and then using dma_map_sg on that list. ... I believe the block and networking layers have their own ways of ensuring that they don't feed such buffers to their drivers if they can't handle it, but a basic character device driver is kind of left out in the cold here and the DMA API doesn't appear to work as documented in this case. ...
    (Linux-Kernel)
  • Re: [PATCH/RFC 0/2] simple SPI framework, refresh + ads7864 driver
    ... > have to split the large transfers into SG lists. ... I've seen plenty other drivers that just segment large buffers ... into multiple DMA transfers ... ... You are conflating memory allocation with DMA mapping. ...
    (Linux-Kernel)
  • Re: IOMMU and graphics cards
    ... Its not only the bitmap. ... memory if the aperture in the AMD IOMMU driver is enlarged to, say, 4GB. ... Most devices don't need such a large amount of DMA address space. ... The proprietary drivers make problems so far. ...
    (Linux-Kernel)