16 Aug, 2016

1 commit

  • Rendering operations to the dma-buf are tracked implicitly via the
    reservation_object (dmabuf->resv). This is used to allow poll() to
    wait upon outstanding rendering (or just query the current status of
    rendering). The dma-buf sync ioctl allows userspace to prepare the
    dma-buf for CPU access, which should include waiting upon rendering.
    (Some drivers may need to do more work to ensure that the dma-buf mmap
    is coherent as well as complete.)

    v2: Always wait upon the reservation object implicitly. We choose to do
    it after the native handler in case it can do so more efficiently.

    Testcase: igt/prime_vgem
    Testcase: igt/gem_concurrent_blit # *vgem*
    Signed-off-by: Chris Wilson
    Cc: Sumit Semwal
    Cc: Daniel Vetter
    Cc: Eric Anholt
    Cc: linux-media@vger.kernel.org
    Cc: dri-devel@lists.freedesktop.org
    Cc: linaro-mm-sig@lists.linaro.org
    Cc: linux-kernel@vger.kernel.org
    Reviewed-by: Daniel Vetter
    Signed-off-by: Sumit Semwal
    Link: http://patchwork.freedesktop.org/patch/msgid/1471275738-31994-1-git-send-email-chris@chris-wilson.co.uk

    Chris Wilson
     

18 Jul, 2016

1 commit

  • If we fail to create the anon file, we need to remember to release the
    module reference on the owner.

    Signed-off-by: Chris Wilson
    Reviewed-by: Joonas Lahtinen
    Cc: Joonas Lahtinen
    Cc: Sumit Semwal
    Cc: Daniel Vetter
    Cc: linux-media@vger.kernel.org
    Cc: dri-devel@lists.freedesktop.org
    Cc: linaro-mm-sig@lists.linaro.org
    Signed-off-by: Daniel Vetter
    Link: http://patchwork.freedesktop.org/patch/msgid/1468840582-21469-1-git-send-email-chris@chris-wilson.co.uk

    Chris Wilson
     

21 Jun, 2016

3 commits

  • There is only a single user of dma_buf_debugfs_create_file() and that
    one got the function pointer cast wrong. With that one fixed, there is
    no need to have a wrapper for debugfs_create_file(), just call it
    directly.

    With no users left, we can remove dma_buf_debugfs_create_file().

    While at it, simplify the error handling in dma_buf_init_debugfs()
    slightly.

    Signed-off-by: Mathias Krause
    Cc: Sumit Semwal
    Cc: Daniel Vetter
    Reviewed-by: Daniel Vetter
    Signed-off-by: Sumit Semwal
    Link: http://patchwork.freedesktop.org/patch/msgid/1466339491-12639-2-git-send-email-minipli@googlemail.com

    Mathias Krause
     
  • Change the error handling in dma_buf_init_debugfs() to remove the
    "dma_buf" directory if creating the "bufinfo" file fails. No need to
    have an empty debugfs directory around.

    Signed-off-by: Mathias Krause
    Cc: Sumit Semwal
    Cc: Daniel Vetter
    Signed-off-by: Sumit Semwal

    Mathias Krause
     
  • The callback function dma_buf_describe() returns an int not void so the
    function pointer cast in dma_buf_show() is wrong. dma_buf_describe() can
    also fail when acquiring the mutex gets interrupted so always returning
    0 in dma_buf_show() is wrong, too.

    Fix both issues by avoiding the indirection via dma_buf_show() and call
    dma_buf_describe() directly. Rename it to dma_buf_debug_show() to get it
    in line with the other functions.

    This type mismatch was caught by the PaX RAP plugin.

    Signed-off-by: Mathias Krause
    Cc: Sumit Semwal
    Cc: Daniel Vetter
    Cc: Brad Spengler
    Cc: PaX Team
    Signed-off-by: Sumit Semwal

    Mathias Krause
     

01 Jun, 2016

1 commit


21 Mar, 2016

1 commit

  • Just a bit of wording polish plus mentioning that it can fail and must
    be restarted.

    Requested by Sumit.

    v2: Fix them typos (Hans).

    Cc: Chris Wilson
    Cc: Tiago Vignatti
    Cc: Stéphane Marchesin
    Cc: David Herrmann
    Cc: Sumit Semwal
    Cc: Daniel Vetter
    CC: linux-media@vger.kernel.org
    Cc: dri-devel@lists.freedesktop.org
    Cc: linaro-mm-sig@lists.linaro.org
    Cc: intel-gfx@lists.freedesktop.org
    Cc: devel@driverdev.osuosl.org
    Cc: Hans Verkuil
    Acked-by: Sumit Semwal
    Acked-by: Hans Verkuil
    Signed-off-by: Daniel Vetter

    Daniel Vetter
     

19 Mar, 2016

1 commit

  • Drivers, especially i915.ko, can fail during the initial migration of a
    dma-buf for CPU access. However, the error code from the driver was not
    being propagated back to ioctl and so userspace was blissfully ignorant
    of the failure. Rendering corruption ensues.

    Whilst fixing the ioctl to return the error code from
    dma_buf_start_cpu_access(), also do the same for
    dma_buf_end_cpu_access(). For most drivers, dma_buf_end_cpu_access()
    cannot fail. i915.ko however, as most drivers would, wants to avoid being
    uninterruptible (as would be required to guarrantee no failure when
    flushing the buffer to the device). As userspace already has to handle
    errors from the SYNC_IOCTL, take advantage of this to be able to restart
    the syscall across signals.

    This fixes a coherency issue for i915.ko as well as reducing the
    uninterruptible hold upon its BKL, the struct_mutex.

    Fixes commit c11e391da2a8fe973c3c2398452000bed505851e
    Author: Daniel Vetter
    Date: Thu Feb 11 20:04:51 2016 -0200

    dma-buf: Add ioctls to allow userspace to flush

    Testcase: igt/gem_concurrent_blit/*dmabuf*interruptible
    Testcase: igt/prime_mmap_coherency/ioctl-errors
    Signed-off-by: Chris Wilson
    Cc: Tiago Vignatti
    Cc: Stéphane Marchesin
    Cc: David Herrmann
    Cc: Sumit Semwal
    Cc: Daniel Vetter
    CC: linux-media@vger.kernel.org
    Cc: dri-devel@lists.freedesktop.org
    Cc: linaro-mm-sig@lists.linaro.org
    Cc: intel-gfx@lists.freedesktop.org
    Cc: devel@driverdev.osuosl.org
    Signed-off-by: Daniel Vetter
    Link: http://patchwork.freedesktop.org/patch/msgid/1458331359-2634-1-git-send-email-chris@chris-wilson.co.uk

    Chris Wilson
     

12 Feb, 2016

1 commit

  • The userspace might need some sort of cache coherency management e.g. when CPU
    and GPU domains are being accessed through dma-buf at the same time. To
    circumvent this problem there are begin/end coherency markers, that forward
    directly to existing dma-buf device drivers vfunc hooks. Userspace can make use
    of those markers through the DMA_BUF_IOCTL_SYNC ioctl. The sequence would be
    used like following:
    - mmap dma-buf fd
    - for each drawing/upload cycle in CPU 1. SYNC_START ioctl, 2. read/write
    to mmap area 3. SYNC_END ioctl. This can be repeated as often as you
    want (with the new data being consumed by the GPU or say scanout device)
    - munmap once you don't need the buffer any more

    v2 (Tiago): Fix header file type names (u64 -> __u64)
    v3 (Tiago): Add documentation. Use enum dma_buf_sync_flags to the begin/end
    dma-buf functions. Check for overflows in start/length.
    v4 (Tiago): use 2d regions for sync.
    v5 (Tiago): forget about 2d regions (v4); use _IOW in DMA_BUF_IOCTL_SYNC and
    remove range information from struct dma_buf_sync.
    v6 (Tiago): use __u64 structured padded flags instead enum. Adjust
    documentation about the recommendation on using sync ioctls.
    v7 (Tiago): Alex' nit on flags definition and being even more wording in the
    doc about sync usage.
    v9 (Tiago): remove useless is_dma_buf_file check. Fix sync.flags conditionals
    and its mask order check. Add include in dma-buf.h.

    Cc: Ville Syrjälä
    Cc: David Herrmann
    Cc: Sumit Semwal
    Reviewed-by: Stéphane Marchesin
    Signed-off-by: Daniel Vetter
    Signed-off-by: Tiago Vignatti
    Reviewed-by: David Herrmann
    Signed-off-by: Daniel Vetter
    Link: http://patchwork.freedesktop.org/patch/msgid/1455228291-29640-1-git-send-email-tiago.vignatti@intel.com

    Daniel Vetter
     

09 Feb, 2016

1 commit

  • This patch removes range-based information used for optimizations in
    begin_cpu_access and end_cpu_access.

    We don't have any user nor implementation using range-based flush. It seems a
    consensus that if we ever want something like that again (or even more robust
    using 2D, 3D sub-range regions) we can use the upcoming dma-buf sync ioctl for
    such.

    Cc: Sumit Semwal
    Cc: Daniel Vetter
    Signed-off-by: Tiago Vignatti
    Reviewed-by: Stéphane Marchesin
    Signed-off-by: Daniel Vetter
    Link: http://patchwork.freedesktop.org/patch/msgid/1450820214-12509-3-git-send-email-tiago.vignatti@intel.com

    Tiago Vignatti
     

21 May, 2015

1 commit


13 May, 2015

1 commit

  • Add reference counting on a kernel module that exports dma-buf and
    implements its operations. This prevents the module from being unloaded
    while DMABUF file is in use.

    The original patch [1] was submitted by Tomasz Stanislawski, but this
    is a simpler way to do it.

    v3: call module_put() as late as possible, per gregkh's comment.
    v2: move owner to struct dma_buf, and use DEFINE_DMA_BUF_EXPORT_INFO
    macro to simplify the change.

    Acked-by: Greg Kroah-Hartman
    Signed-off-by: Sumit Semwal

    [1]: https://lkml.org/lkml/2012/8/8/163

    Sumit Semwal
     

21 Apr, 2015

1 commit

  • At present, dma_buf_export() takes a series of parameters, which
    makes it difficult to add any new parameters for exporters, if required.

    Make it simpler by moving all these parameters into a struct, and pass
    the struct * as parameter to dma_buf_export().

    While at it, unite dma_buf_export_named() with dma_buf_export(), and
    change all callers accordingly.

    Reviewed-by: Maarten Lankhorst
    Reviewed-by: Daniel Thompson
    Acked-by: Mauro Carvalho Chehab
    Acked-by: Dave Airlie
    Signed-off-by: Sumit Semwal

    Sumit Semwal
     

09 Oct, 2014

1 commit


09 Jul, 2014

5 commits

  • This adds some extra functions to deal with rcu.

    reservation_object_get_fences_rcu() will obtain the list of shared
    and exclusive fences without obtaining the ww_mutex.

    reservation_object_wait_timeout_rcu() will wait on all fences of the
    reservation_object, without obtaining the ww_mutex.

    reservation_object_test_signaled_rcu() will test if all fences of the
    reservation_object are signaled without using the ww_mutex.

    reservation_object_get_excl and reservation_object_get_list require
    the reservation object to be held, updating requires
    write_seqcount_begin/end. If only the exclusive fence is needed,
    rcu_dereference followed by fence_get_rcu can be used, if the shared
    fences are needed it's recommended to use the supplied functions.

    Signed-off-by: Maarten Lankhorst
    Acked-by: Sumit Semwal
    Acked-by: Daniel Vetter
    Reviewed-By: Thomas Hellstrom
    Signed-off-by: Greg Kroah-Hartman

    Maarten Lankhorst
     
  • Move the list of shared fences to a struct, and return it in
    reservation_object_get_list().
    Add reservation_object_get_excl to get the exclusive fence.

    Add reservation_object_reserve_shared(), which reserves space
    in the reservation_object for 1 more shared fence.

    reservation_object_add_shared_fence() and
    reservation_object_add_excl_fence() are used to assign a new
    fence to a reservation_object pointer, to complete a reservation.

    Changes since v1:
    - Add reservation_object_get_excl, reorder code a bit.

    Signed-off-by: Maarten Lankhorst
    Acked-by: Sumit Semwal
    Acked-by: Daniel Vetter
    Signed-off-by: Greg Kroah-Hartman

    Maarten Lankhorst
     
  • Thanks to Fengguang Wu for spotting a missing static cast.

    v2:
    - Kill unused variable need_shared.
    v3:
    - Clarify the BUG() in dma_buf_release some more. (Rob Clark)

    Signed-off-by: Maarten Lankhorst
    Acked-by: Sumit Semwal
    Acked-by: Daniel Vetter
    Signed-off-by: Greg Kroah-Hartman

    Maarten Lankhorst
     
  • This allows reservation objects to be used in dma-buf. it's required
    for implementing polling support on the fences that belong to a dma-buf.

    Signed-off-by: Maarten Lankhorst
    Acked-by: Mauro Carvalho Chehab #drivers/media/v4l2-core/
    Acked-by: Thomas Hellstrom #drivers/gpu/drm/ttm
    Acked-by: Sumit Semwal
    Acked-by: Daniel Vetter
    Signed-off-by: Vincent Stehlé #drivers/gpu/drm/armada/
    Signed-off-by: Greg Kroah-Hartman

    Maarten Lankhorst
     
  • Signed-off-by: Maarten Lankhorst
    Acked-by: Sumit Semwal
    Acked-by: Daniel Vetter
    Signed-off-by: Greg Kroah-Hartman

    Maarten Lankhorst