23 Oct, 2019

1 commit

  • The .ioctl and .compat_ioctl file operations have the same prototype so
    they can both point to the same function, which works great almost all
    the time when all the commands are compatible.

    One exception is the s390 architecture, where a compat pointer is only
    31 bit wide, and converting it into a 64-bit pointer requires calling
    compat_ptr(). Most drivers here will never run in s390, but since we now
    have a generic helper for it, it's easy enough to use it consistently.

    I double-checked all these drivers to ensure that all ioctl arguments
    are used as pointers or are ignored, but are not interpreted as integer
    values.

    Acked-by: Jason Gunthorpe
    Acked-by: Daniel Vetter
    Acked-by: Mauro Carvalho Chehab
    Acked-by: Greg Kroah-Hartman
    Acked-by: David Sterba
    Acked-by: Darren Hart (VMware)
    Acked-by: Jonathan Cameron
    Acked-by: Bjorn Andersson
    Acked-by: Dan Williams
    Signed-off-by: Arnd Bergmann

    Arnd Bergmann
     

13 Aug, 2019

1 commit

  • During release of the syncpt, we remove it from the list of syncpt and
    the tree, but only if it is not already been removed. However, during
    signaling, we first remove the syncpt from the list. So, if we
    concurrently free and signal the syncpt, the free may decide that it is
    not part of the tree and immediately free itself -- meanwhile the
    signaler goes on to use the now freed datastructure.

    In particular, we get struck by commit 0e2f733addbf ("dma-buf: make
    dma_fence structure a bit smaller v2") as the cb_list is immediately
    clobbered by the kfree_rcu.

    v2: Avoid calling into timeline_fence_release() from under the spinlock

    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=111381
    Fixes: d3862e44daa7 ("dma-buf/sw-sync: Fix locking around sync_timeline lists")
    References: 0e2f733addbf ("dma-buf: make dma_fence structure a bit smaller v2")
    Signed-off-by: Chris Wilson
    Cc: Sumit Semwal
    Cc: Sean Paul
    Cc: Gustavo Padovan
    Cc: Christian König
    Cc: # v4.14+
    Acked-by: Christian König
    Link: https://patchwork.freedesktop.org/patch/msgid/20190812154247.20508-1-chris@chris-wilson.co.uk

    Chris Wilson
     

05 Jun, 2019

1 commit

  • Based on 1 normalized pattern(s):

    this software is licensed under the terms of the gnu general public
    license version 2 as published by the free software foundation and
    may be copied distributed and modified under those terms this
    program is distributed in the hope that it will be useful but
    without any warranty without even the implied warranty of
    merchantability or fitness for a particular purpose see the gnu
    general public license for more details

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-only

    has been chosen to replace the boilerplate/reference in 285 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Alexios Zavras
    Reviewed-by: Allison Randal
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190529141900.642774971@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

16 Apr, 2019

1 commit


07 Dec, 2018

1 commit

  • For a lot of use cases we need 64bit sequence numbers. Currently drivers
    overload the dma_fence structure to store the additional bits.

    Stop doing that and make the sequence number in the dma_fence always
    64bit.

    For compatibility with hardware which can do only 32bit sequences the
    comparisons in __dma_fence_is_later only takes the lower 32bits as significant
    when the upper 32bits are all zero.

    v2: change the logic in __dma_fence_is_later

    Signed-off-by: Christian König
    Reviewed-by: Chunming Zhou
    Link: https://patchwork.freedesktop.org/patch/266927/

    Christian König
     

03 Jul, 2018

1 commit

  • Almost everyone uses dma_fence_default_wait.

    v2: Also remove the BUG_ON(!ops->wait) (Chris).

    Reviewed-by: Christian König (v1)
    Signed-off-by: Daniel Vetter
    Cc: Chris Wilson
    Cc: Sumit Semwal
    Cc: Gustavo Padovan
    Cc: linux-media@vger.kernel.org
    Cc: linaro-mm-sig@lists.linaro.org
    Link: https://patchwork.freedesktop.org/patch/msgid/20180503142603.28513-5-daniel.vetter@ffwll.ch

    Daniel Vetter
     

19 Feb, 2018

1 commit

  • drivers/dma-buf/sw_sync.c:248: warning: No description found for parameter 'obj'
    drivers/dma-buf/sw_sync.c:248: warning: No description found for parameter 'value'
    drivers/dma-buf/sw_sync.c:248: warning: Excess function parameter 'parent' description in 'sync_pt_create'
    drivers/dma-buf/sw_sync.c:248: warning: Excess function parameter 'inc' description in 'sync_pt_create'

    Signed-off-by: Chris Wilson
    Signed-off-by: Daniel Vetter
    Link: https://patchwork.freedesktop.org/patch/msgid/20180208113816.8288-1-chris@chris-wilson.co.uk

    Chris Wilson
     

31 Jan, 2018

1 commit


09 Sep, 2017

1 commit

  • To avoid hanging userspace components that might have been waiting on the
    active fences of the destroyed timeline we need to signal with error all
    remaining fences on such timeline.

    This restore the default behaviour of the Android sw_sync framework, which
    Android still relies on. It was broken on the dma fence conversion a few
    years ago and never fixed.

    v2: Do not bother with cleanup do the list (Chris Wilson)

    Reviewed-by: Chris Wilson
    Signed-off-by: Dominik Behr
    Signed-off-by: Gustavo Padovan
    Link: https://patchwork.freedesktop.org/patch/msgid/20170907190246.16425-2-gustavo@padovan.org

    Dominik Behr
     

01 Aug, 2017

2 commits

  • If userspace already dropped its own reference by closing the sw_sync
    fence fd we might end up in a deadlock where
    dma_fence_is_signaled_locked() will trigger the release of the fence and
    thus try to hold the lock to remove the fence from the list.

    dma_fence_is_signaled_locked() tries to release/free the fence and hold
    the lock in the process.

    We fix that by changing the order operation and clean up the list and
    rb-tree first.

    v2: Drop fence get/put dance and manipulate the list first (Chris Wilson)

    Cc: Chris Wilson
    Signed-off-by: Gustavo Padovan
    Reviewed-by: Chris Wilson
    Link: https://patchwork.freedesktop.org/patch/msgid/20170729152217.8362-2-gustavo@padovan.org

    Gustavo Padovan
     
  • We are going to use timeline_fence_signaled() in a internal function in
    the next commit.

    Cc: Chris Wilson
    Signed-off-by: Gustavo Padovan
    Reviewed-by: Chris Wilson
    Link: https://patchwork.freedesktop.org/patch/msgid/20170729152217.8362-1-gustavo@padovan.org

    Gustavo Padovan
     

30 Jun, 2017

6 commits

  • Reduce the list iteration when incrementing the timeline by storing the
    fences in increasing order.

    v2: Prevent spinlock recursion on free during create
    v3: Fixup rebase conflict inside comments that escaped the compiler.

    Signed-off-by: Chris Wilson
    Cc: Sumit Semwal
    Cc: Sean Paul
    Cc: Gustavo Padovan
    Reviewed-by: Sean Paul
    Signed-off-by: Gustavo Padovan
    Link: http://patchwork.freedesktop.org/patch/msgid/20170629211253.22766-1-chris@chris-wilson.co.uk

    Chris Wilson
     
  • The sync_pt were not adding themselves atomically to the timeline lists,
    corruption imminent. Only a single list is required to track the
    unsignaled sync_pt, so reduce it and rename the lock more appropriately
    along with using idiomatic names to distinguish a list from links along
    it.

    v2: Prevent spinlock recursion on free during create (next patch) and
    fixup crossref in kerneldoc

    Signed-off-by: Chris Wilson
    Cc: Sumit Semwal
    Cc: Sean Paul
    Cc: Gustavo Padovan
    Reviewed-by: Sean Paul
    Signed-off-by: Gustavo Padovan
    Link: http://patchwork.freedesktop.org/patch/msgid/20170629210532.5617-1-chris@chris-wilson.co.uk

    Chris Wilson
     
  • Since sync_pt is only allocated from a single location and is no longer
    the base class for fences (that is struct dma_fence) it no longer needs
    a generic unsized allocator.

    Signed-off-by: Chris Wilson
    Cc: Sumit Semwal
    Cc: Sean Paul
    Cc: Gustavo Padovan
    Reviewed-by: Sean Paul
    Signed-off-by: Gustavo Padovan
    Link: http://patchwork.freedesktop.org/patch/msgid/20170629125930.821-5-chris@chris-wilson.co.uk

    Chris Wilson
     
  • If we know the context under which we are called, then we can use the
    simpler form of spin_lock_irq (saving the save/restore).

    Signed-off-by: Chris Wilson
    Cc: Sumit Semwal
    Cc: Sean Paul
    Cc: Gustavo Padovan
    Reviewed-by: Sean Paul
    Signed-off-by: Gustavo Padovan
    Link: http://patchwork.freedesktop.org/patch/msgid/20170629125930.821-4-chris@chris-wilson.co.uk

    Chris Wilson
     
  • The timeline is u32, which limits any single advance to INT_MAX so that
    we can detect all fences that need signaling.

    Signed-off-by: Chris Wilson
    Cc: Sumit Semwal
    Cc: Sean Paul
    Cc: Gustavo Padovan
    Reviewed-by: Sean Paul
    Signed-off-by: Gustavo Padovan
    Link: http://patchwork.freedesktop.org/patch/msgid/20170629125930.821-3-chris@chris-wilson.co.uk

    Chris Wilson
     
  • Use the canonical __dma_fence_is_later() to compare the fence seqno
    against the timeline seqno to check if the fence is signaled.

    Signed-off-by: Chris Wilson
    Cc: Sumit Semwal
    Cc: Sean Paul
    Cc: Gustavo Padovan
    Reviewed-by: Sean Paul
    Signed-off-by: Gustavo Padovan
    Link: http://patchwork.freedesktop.org/patch/msgid/20170629125930.821-2-chris@chris-wilson.co.uk

    Chris Wilson
     

09 Nov, 2016

2 commits

  • Once sw_sync_ioctl_create_fence() returns we no longer have the
    *pt pointer to the fence base object thus we need to put the reference
    we have from the fence creation to keep a correct reference accounting.

    Signed-off-by: Gustavo Padovan
    Reviewed-by: Chris Wilson
    Signed-off-by: Sumit Semwal
    Link: http://patchwork.freedesktop.org/patch/msgid/1477515599-7685-1-git-send-email-gustavo@padovan.org

    Gustavo Padovan
     
  • We get 1 warning when building kernel with W=1:
    drivers/dma-buf/sw_sync.c:87:23: warning: no previous prototype for 'sync_timeline_create' [-Wmissing-prototypes]

    In fact, this function is only used in the file in which it is
    declared and don't need a declaration, but can be made static.
    So this patch marks it 'static'.

    Signed-off-by: Baoyou Xie
    Reviewed-by: Gustavo Padovan
    Signed-off-by: Sumit Semwal
    Link: http://patchwork.freedesktop.org/patch/msgid/1474202961-10099-1-git-send-email-baoyou.xie@linaro.org

    Baoyou Xie
     

25 Oct, 2016

1 commit

  • I plan to usurp the short name of struct fence for a core kernel struct,
    and so I need to rename the specialised fence/timeline for DMA
    operations to make room.

    A consensus was reached in
    https://lists.freedesktop.org/archives/dri-devel/2016-July/113083.html
    that making clear this fence applies to DMA operations was a good thing.
    Since then the patch has grown a bit as usage increases, so hopefully it
    remains a good thing!

    (v2...: rebase, rerun spatch)
    v3: Compile on msm, spotted a manual fixup that I broke.
    v4: Try again for msm, sorry Daniel

    coccinelle script:
    @@

    @@
    - struct fence
    + struct dma_fence
    @@

    @@
    - struct fence_ops
    + struct dma_fence_ops
    @@

    @@
    - struct fence_cb
    + struct dma_fence_cb
    @@

    @@
    - struct fence_array
    + struct dma_fence_array
    @@

    @@
    - enum fence_flag_bits
    + enum dma_fence_flag_bits
    @@

    @@
    (
    - fence_init
    + dma_fence_init
    |
    - fence_release
    + dma_fence_release
    |
    - fence_free
    + dma_fence_free
    |
    - fence_get
    + dma_fence_get
    |
    - fence_get_rcu
    + dma_fence_get_rcu
    |
    - fence_put
    + dma_fence_put
    |
    - fence_signal
    + dma_fence_signal
    |
    - fence_signal_locked
    + dma_fence_signal_locked
    |
    - fence_default_wait
    + dma_fence_default_wait
    |
    - fence_add_callback
    + dma_fence_add_callback
    |
    - fence_remove_callback
    + dma_fence_remove_callback
    |
    - fence_enable_sw_signaling
    + dma_fence_enable_sw_signaling
    |
    - fence_is_signaled_locked
    + dma_fence_is_signaled_locked
    |
    - fence_is_signaled
    + dma_fence_is_signaled
    |
    - fence_is_later
    + dma_fence_is_later
    |
    - fence_later
    + dma_fence_later
    |
    - fence_wait_timeout
    + dma_fence_wait_timeout
    |
    - fence_wait_any_timeout
    + dma_fence_wait_any_timeout
    |
    - fence_wait
    + dma_fence_wait
    |
    - fence_context_alloc
    + dma_fence_context_alloc
    |
    - fence_array_create
    + dma_fence_array_create
    |
    - to_fence_array
    + to_dma_fence_array
    |
    - fence_is_array
    + dma_fence_is_array
    |
    - trace_fence_emit
    + trace_dma_fence_emit
    |
    - FENCE_TRACE
    + DMA_FENCE_TRACE
    |
    - FENCE_WARN
    + DMA_FENCE_WARN
    |
    - FENCE_ERR
    + DMA_FENCE_ERR
    )
    (
    ...
    )

    Signed-off-by: Chris Wilson
    Reviewed-by: Gustavo Padovan
    Acked-by: Sumit Semwal
    Acked-by: Christian König
    Signed-off-by: Daniel Vetter
    Link: http://patchwork.freedesktop.org/patch/msgid/20161025120045.28839-1-chris@chris-wilson.co.uk

    Chris Wilson
     

15 Aug, 2016

1 commit

  • SW_SYNC allows to run tests on the sync_file framework via debugfs on

    /sync/sw_sync

    Opening and closing the file triggers creation and release of a sync
    timeline. To create fences on this timeline the SW_SYNC_IOC_CREATE_FENCE
    ioctl should be used. To increment the timeline value use SW_SYNC_IOC_INC.

    Also it exports Sync information on

    /sync/info

    Signed-off-by: Gustavo Padovan
    Reviewed-by: Eric Engestrom
    Signed-off-by: Greg Kroah-Hartman

    Gustavo Padovan