01 May, 2013

1 commit

  • For debugging purposes, it is useful to have a name-string added
    while exporting buffers. Hence, dma_buf_export() is replaced with
    dma_buf_export_named(), which additionally takes 'exp_name' as a
    parameter.

    For backward compatibility, and for lazy exporters who don't wish to
    name themselves, a #define dma_buf_export() is also made available,
    which adds a __FILE__ instead of 'exp_name'.

    Cc: Daniel Vetter
    [Thanks for the idea!]
    Reviewed-by: Daniel Vetter
    Signed-off-by: Sumit Semwal

    Sumit Semwal
     

27 Feb, 2013

1 commit

  • All drivers which implement this need to have some sort of refcount to
    allow concurrent vmap usage. Hence implement this in the dma-buf core.

    To protect against concurrent calls we need a lock, which potentially
    causes new funny locking inversions. But this shouldn't be a problem
    for exporters with statically allocated backing storage, and more
    dynamic drivers have decent issues already anyway.

    Inspired by some refactoring patches from Aaron Plattner, who
    implemented the same idea, but only for drm/prime drivers.

    v2: Check in dma_buf_release that no dangling vmaps are left.
    Suggested by Aaron Plattner. We might want to do similar checks for
    attachments, but that's for another patch. Also fix up ERR_PTR return
    for vmap.

    v3: Check whether the passed-in vmap address matches with the cached
    one for vunmap. Eventually we might want to remove that parameter -
    compared to the kmap functions there's no need for the vaddr for
    unmapping. Suggested by Chris Wilson.

    v4: Fix a brown-paper-bag bug spotted by Aaron Plattner.

    Cc: Aaron Plattner
    Reviewed-by: Aaron Plattner
    Tested-by: Aaron Plattner
    Reviewed-by: Rob Clark
    Signed-off-by: Daniel Vetter
    Signed-off-by: Sumit Semwal

    Daniel Vetter
     

19 Nov, 2012

1 commit


25 May, 2012

2 commits

  • Signed-off-by: Dave Airlie
    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
     

26 Mar, 2012

2 commits


13 Jan, 2012

1 commit


06 Jan, 2012

1 commit