27 Sep, 2012

1 commit


15 Jun, 2012

1 commit


26 May, 2012

1 commit

  • Pull dma-buf updates from Sumit Semwal:
    "Here's the first signed-tag pull request for dma-buf framework. It
    includes the following key items:
    - mmap support
    - vmap support
    - related documentation updates

    These are needed by various drivers to allow mmap/vmap of dma-buf
    shared buffers. Dave Airlie has some prime patches dependent on the
    vmap pull as well."

    * tag 'tag-for-linus-3.5' of git://git.linaro.org/people/sumitsemwal/linux-dma-buf:
    dma-buf: add initial vmap documentation
    dma-buf: minor documentation fixes.
    dma-buf: add vmap interface
    dma-buf: mmap support

    Linus Torvalds
     

25 May, 2012

3 commits

  • Some minor inline documentation fixes for gaps resulting from new patches.

    Signed-off-by: Sumit Semwal
    Signed-off-by: Sumit Semwal

    Sumit Semwal
     
  • The main requirement I have for this interface is for scanning out
    using the USB gpu devices. Since these devices have to read the
    framebuffer on updates and linearly compress it, using kmaps
    is a major overhead for every update.

    v2: fix warn issues pointed out by Sylwester Nawrocki.

    v3: fix compile !CONFIG_DMA_SHARED_BUFFER and add _GPL for now

    Signed-off-by: Dave Airlie
    Reviewed-by: Rob Clark
    Signed-off-by: Sumit Semwal

    Dave Airlie
     
  • Compared to Rob Clark's RFC I've ditched the prepare/finish hooks
    and corresponding ioctls on the dma_buf file. The major reason for
    that is that many people seem to be under the impression that this is
    also for synchronization with outstanding asynchronous processsing.
    I'm pretty massively opposed to this because:

    - It boils down reinventing a new rather general-purpose userspace
    synchronization interface. If we look at things like futexes, this
    is hard to get right.
    - Furthermore a lot of kernel code has to interact with this
    synchronization primitive. This smells a look like the dri1 hw_lock,
    a horror show I prefer not to reinvent.
    - Even more fun is that multiple different subsystems would interact
    here, so we have plenty of opportunities to create funny deadlock
    scenarios.

    I think synchronization is a wholesale different problem from data
    sharing and should be tackled as an orthogonal problem.

    Now we could demand that prepare/finish may only ensure cache
    coherency (as Rob intended), but that runs up into the next problem:
    We not only need mmap support to facilitate sw-only processing nodes
    in a pipeline (without jumping through hoops by importing the dma_buf
    into some sw-access only importer), which allows for a nicer
    ION->dma-buf upgrade path for existing Android userspace. We also need
    mmap support for existing importing subsystems to support existing
    userspace libraries. And a loot of these subsystems are expected to
    export coherent userspace mappings.

    So prepare/finish can only ever be optional and the exporter /needs/
    to support coherent mappings. Given that mmap access is always
    somewhat fallback-y in nature I've decided to drop this optimization,
    instead of just making it optional. If we demonstrate a clear need for
    this, supported by benchmark results, we can always add it in again
    later as an optional extension.

    Other differences compared to Rob's RFC is the above mentioned support
    for mapping a dma-buf through facilities provided by the importer.
    Which results in mmap support no longer being optional.

    Note that this dma-buf mmap patch does _not_ support every possible
    insanity an existing subsystem could pull of with mmap: Because it
    does not allow to intercept pagefaults and shoot down ptes importing
    subsystems can't add some magic of their own at these points (e.g. to
    automatically synchronize with outstanding rendering or set up some
    special resources). I've done a cursory read through a few mmap
    implementions of various subsytems and I'm hopeful that we can avoid
    this (and the complexity it'd bring with it).

    Additonally I've extended the documentation a bit to explain the hows
    and whys of this mmap extension.

    In case we ever want to add support for explicitly cache maneged
    userspace mmap with a prepare/finish ioctl pair, we could specify that
    userspace needs to mmap a different part of the dma_buf, e.g. the
    range starting at dma_buf->size up to dma_buf->size*2. This works
    because the size of a dma_buf is invariant over it's lifetime. The
    exporter would obviously need to fall back to coherent mappings for
    both ranges if a legacy clients maps the coherent range and the
    architecture cannot suppor conflicting caching policies. Also, this
    would obviously be optional and userspace needs to be able to fall
    back to coherent mappings.

    v2:
    - Spelling fixes from Rob Clark.
    - Compile fix for !DMA_BUF from Rob Clark.
    - Extend commit message to explain how explicitly cache managed mmap
    support could be added later.
    - Extend the documentation with implementations notes for exporters
    that need to manually fake coherency.

    v3:
    - dma_buf pointer initialization goof-up noticed by Rebecca Schultz
    Zavin.

    Cc: Rob Clark
    Cc: Rebecca Schultz Zavin
    Acked-by: Rob Clark
    Signed-Off-by: Daniel Vetter
    Signed-off-by: Sumit Semwal

    Daniel Vetter
     

19 Apr, 2012

1 commit

  • Fix kernel-doc warnings in dma-buf.c:

    Warning(drivers/base/dma-buf.c:305): No description found for parameter 'dmabuf'
    Warning(drivers/base/dma-buf.c:305): Excess function parameter 'dma_buf' description in 'dma_buf_begin_cpu_access'
    Warning(drivers/base/dma-buf.c:332): No description found for parameter 'dmabuf'
    Warning(drivers/base/dma-buf.c:332): Excess function parameter 'dma_buf' description in 'dma_buf_end_cpu_access'
    Warning(drivers/base/dma-buf.c:350): No description found for parameter 'dmabuf'
    Warning(drivers/base/dma-buf.c:350): Excess function parameter 'dma_buf' description in 'dma_buf_kmap_atomic'
    Warning(drivers/base/dma-buf.c:367): No description found for parameter 'dmabuf'
    Warning(drivers/base/dma-buf.c:367): Excess function parameter 'dma_buf' description in 'dma_buf_kunmap_atomic'
    Warning(drivers/base/dma-buf.c:385): No description found for parameter 'dmabuf'
    Warning(drivers/base/dma-buf.c:385): Excess function parameter 'dma_buf' description in 'dma_buf_kmap'
    Warning(drivers/base/dma-buf.c:402): No description found for parameter 'dmabuf'
    Warning(drivers/base/dma-buf.c:402): Excess function parameter 'dma_buf' description in 'dma_buf_kunmap'

    Signed-off-by: Randy Dunlap
    Signed-off-by: Greg Kroah-Hartman

    Randy Dunlap
     

26 Mar, 2012

4 commits

  • Big differences to other contenders in the field (like ion) is
    that this also supports highmem, so we have to split up the cpu
    access from the kernel side into a prepare and a kmap step.

    Prepare is allowed to fail and should do everything required so that
    the kmap calls can succeed (like swapin/backing storage allocation,
    flushing, ...).

    More in-depth explanations will follow in the follow-up documentation
    patch.

    Changes in v2:

    - Clear up begin_cpu_access confusion noticed by Sumit Semwal.
    - Don't automatically fallback from the _atomic variants to the
    non-atomic variants. The _atomic callbacks are not allowed to
    sleep, so we want exporters to make this decision explicit. The
    function signatures are explicit, so simpler exporters can still
    use the same function for both.
    - Make the unmap functions optional. Simpler exporters with permanent
    mappings don't need to do anything at unmap time.

    Changes in v3:

    - Adjust the WARN_ON checks for the new ->ops functions as suggested
    by Rob Clark and Sumit Semwal.
    - Rebased on top of latest dma-buf-next git.

    Changes in v4:

    - Fixup a missing - in a return -EINVAL; statement.

    Signed-Off-by: Daniel Vetter
    Signed-off-by: Rob Clark
    Signed-off-by: Sumit Semwal

    Daniel Vetter
     
  • The mutex protects the attachment list and hence needs to be held
    around the callbakc to the exporters (optional) attach/detach
    functions.

    Holding the mutex around the map/unmap calls doesn't protect any
    dma_buf state. Exporters need to properly protect any of their own
    state anyway (to protect against calls from their own interfaces).
    So this only makes the locking messier (and lockdep easier to anger).

    Therefore let's just drop this.

    v2: Rebased on top of latest dma-buf-next git.

    Signed-off-by: Daniel Vetter
    Reviewed-by: Rob Clark
    Signed-off-by: Sumit Semwal

    Daniel Vetter
     
  • We need to pass the flags into dma_buf_fd at this point,
    so the flags end up doing the right thing for O_CLOEXEC.

    Signed-off-by: Dave Airlie
    Signed-off-by: Rob Clark
    Signed-off-by: Sumit Semwal

    Dave Airlie
     
  • Some exporters may use DMA map/unmap APIs in dma-buf ops, which require
    enum dma_data_direction for both map and unmap operations.

    Thus, the unmap dma_buf_op also needs to have enum dma_data_direction as
    a parameter.

    Reported-by: Tomasz Stanislawski
    Signed-off-by: Sumit Semwal
    Reviewed-by: Daniel Vetter
    Signed-off-by: Sumit Semwal

    Sumit Semwal
     

19 Mar, 2012

4 commits


06 Jan, 2012

1 commit

  • This is the first step in defining a dma buffer sharing mechanism.

    A new buffer object dma_buf is added, with operations and API to allow easy
    sharing of this buffer object across devices.

    The framework allows:
    - creation of a buffer object, its association with a file pointer, and
    associated allocator-defined operations on that buffer. This operation is
    called the 'export' operation.
    - different devices to 'attach' themselves to this exported buffer object, to
    facilitate backing storage negotiation, using dma_buf_attach() API.
    - the exported buffer object to be shared with the other entity by asking for
    its 'file-descriptor (fd)', and sharing the fd across.
    - a received fd to get the buffer object back, where it can be accessed using
    the associated exporter-defined operations.
    - the exporter and user to share the scatterlist associated with this buffer
    object using map_dma_buf and unmap_dma_buf operations.

    Atleast one 'attach()' call is required to be made prior to calling the
    map_dma_buf() operation.

    Couple of building blocks in map_dma_buf() are added to ease introduction
    of sync'ing across exporter and users, and late allocation by the exporter.

    For this first version, this framework will work with certain conditions:
    - *ONLY* exporter will be allowed to mmap to userspace (outside of this
    framework - mmap is not a buffer object operation),
    - currently, *ONLY* users that do not need CPU access to the buffer are
    allowed.

    More details are there in the documentation patch.

    This is based on design suggestions from many people at the mini-summits[1],
    most notably from Arnd Bergmann , Rob Clark and
    Daniel Vetter .

    The implementation is inspired from proof-of-concept patch-set from
    Tomasz Stanislawski , who demonstrated buffer sharing
    between two v4l2 devices. [2]

    [1]: https://wiki.linaro.org/OfficeofCTO/MemoryManagement
    [2]: http://lwn.net/Articles/454389

    Signed-off-by: Sumit Semwal
    Signed-off-by: Sumit Semwal
    Reviewed-by: Daniel Vetter
    Reviewed-by: Dave Airlie
    Reviewed-and-Tested-by: Rob Clark
    Signed-off-by: Dave Airlie

    Sumit Semwal