New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 738131 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Last visit > 30 days ago
Closed: Nov 2017
Cc:
EstimatedDays: ----
NextAction: ----
OS: Chrome
Pri: 3
Type: Bug



Sign in to add a comment

Fix sw_sync fence wraparound in 4.4

Project Member Reported by dbehr@chromium.org, Jun 29 2017

Issue description

sw_sync fences now break when the timeline value reaches 2^32-1
There are few fixes floating on the mailing list upstream. 
 

Comment 2 by dbehr@chromium.org, Aug 31 2017

Status: Started (was: Assigned)
Project Member

Comment 3 by bugdroid1@chromium.org, Sep 19 2017

Labels: merge-merged-chromeos-4.4
The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/third_party/kernel/+/ac302a2e787284fe8b6adee26a075cb4a88abd6c

commit ac302a2e787284fe8b6adee26a075cb4a88abd6c
Author: Gustavo Padovan <gustavo.padovan@collabora.com>
Date: Tue Sep 19 20:26:43 2017

UPSTREAM: dma-buf/dma-fence: improve doc for dma_fence_add_callback()

Document return values for this function.

BUG= chromium:738131 
TEST=run Angry Birds on kevin

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>
Link: http://patchwork.freedesktop.org/patch/msgid/20170215175725.6692-1-gustavo@padovan.org
(cherry picked from commit f642de16c86e9f31d084aa98a50d3a2c923450c2)
Signed-off-by: Dominik Behr <dbehr@chromium.org>

Change-Id: I551129a8679921c6cf9184824f09d3bec885a9c8
Reviewed-on: https://chromium-review.googlesource.com/647006
Commit-Ready: Dominik Behr <dbehr@chromium.org>
Tested-by: Dominik Behr <dbehr@chromium.org>
Reviewed-by: Chad Versace <chadversary@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>

[modify] https://crrev.com/ac302a2e787284fe8b6adee26a075cb4a88abd6c/drivers/dma-buf/dma-fence.c

Project Member

Comment 4 by bugdroid1@chromium.org, Sep 19 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/third_party/kernel/+/df6fdea11d0adfdbfd1fad943def21bd82ccfd78

commit df6fdea11d0adfdbfd1fad943def21bd82ccfd78
Author: Philipp Zabel <p.zabel@pengutronix.de>
Date: Tue Sep 19 20:26:45 2017

UPSTREAM: dma-fence: add dma_fence_match_context helper

Add a helper to check if all fences in a fence array are from a given
context. For convenience, the function can also handle being given a
non-array fence.

BUG= chromium:738131 
TEST=run Angry Birds on kevin

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Reviewed-by: Gustavo Padovan <gustavo.padovan@collabora.com>
Acked-by: Sumit Semwal <sumit.semwal@linaro.org>
Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>
Link: http://patchwork.freedesktop.org/patch/msgid/1489768492-25190-1-git-send-email-p.zabel@pengutronix.de
(cherry picked from commit d5b72a2123dfaf9416b1a1177b4be041f8a8b6d4)
Signed-off-by: Dominik Behr <dbehr@chromium.org>

Change-Id: Ia8cdecc07695b20756e7c93b32a9a28acbf743ac
Reviewed-on: https://chromium-review.googlesource.com/647007
Commit-Ready: Dominik Behr <dbehr@chromium.org>
Tested-by: Dominik Behr <dbehr@chromium.org>
Reviewed-by: Chad Versace <chadversary@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>

[modify] https://crrev.com/df6fdea11d0adfdbfd1fad943def21bd82ccfd78/drivers/dma-buf/dma-fence-array.c
[modify] https://crrev.com/df6fdea11d0adfdbfd1fad943def21bd82ccfd78/include/linux/dma-fence-array.h

Project Member

Comment 5 by bugdroid1@chromium.org, Sep 19 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/third_party/kernel/+/f215ceb1395bd9e0403da61dfa72dc8163d6cfb4

commit f215ceb1395bd9e0403da61dfa72dc8163d6cfb4
Author: Russell King <rmk+kernel@arm.linux.org.uk>
Date: Tue Sep 19 20:26:46 2017

UPSTREAM: dma-buf: fence debugging

Add debugfs output to report shared and exclusive fences on a dma_buf
object.  This produces output such as:

Dma-buf Objects:
size    flags   mode    count   exp_name
08294400        00000000        00000005        00000005        drm
        Exclusive fence: etnaviv 134000.gpu signalled
        Attached Devices:
        gpu-subsystem
Total 1 devices attached

Total 1 objects, 8294400 bytes

BUG= chromium:738131 
TEST=run Angry Birds on kevin

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Reviewed-by: Christian Knig <christian.koenig@amd.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.com>
Link: http://patchwork.freedesktop.org/patch/msgid/E1cttMI-00068z-3X@rmk-PC.armlinux.org.uk
(cherry picked from commit 5eb2c72c8acc3f84c85f9d504b87f25f78ef0eb0)
Signed-off-by: Dominik Behr <dbehr@chromium.org>

Change-Id: I241639a4e764437f6a0c348caecc218cc33145b7
Reviewed-on: https://chromium-review.googlesource.com/647008
Commit-Ready: Dominik Behr <dbehr@chromium.org>
Tested-by: Dominik Behr <dbehr@chromium.org>
Reviewed-by: Chad Versace <chadversary@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>

[modify] https://crrev.com/f215ceb1395bd9e0403da61dfa72dc8163d6cfb4/drivers/dma-buf/dma-buf.c

Project Member

Comment 6 by bugdroid1@chromium.org, Sep 19 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/third_party/kernel/+/5ce90514cb4be0de3e1668deef59c2814e59b704

commit 5ce90514cb4be0de3e1668deef59c2814e59b704
Author: Dave Airlie <airlied@redhat.com>
Date: Tue Sep 19 20:26:47 2017

UPSTREAM: sync_file: get rid of internal reference count.

sync_file uses the reference count of the file, the internal
kref was never getting moved past 1.

We can reintroduce this if we decide we need it later.

[airlied: fix buildbot warnings]

BUG= chromium:738131 
TEST=run Angry Birds on kevin

Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Acked-by: Sumit Semwal <sumit.semwal@linaro.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170413014144.637-2-airlied@gmail.com
(cherry picked from commit d8f2ebaac650dc35db3bf5cf10e8ee1115b455f8)
Signed-off-by: Dominik Behr <dbehr@chromium.org>

Change-Id: I8cce81d29e20ad3c756ab0ea21d06a62f67dc0e6
Reviewed-on: https://chromium-review.googlesource.com/647009
Commit-Ready: Dominik Behr <dbehr@chromium.org>
Tested-by: Dominik Behr <dbehr@chromium.org>
Reviewed-by: Chad Versace <chadversary@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>

[modify] https://crrev.com/5ce90514cb4be0de3e1668deef59c2814e59b704/drivers/dma-buf/sync_file.c
[modify] https://crrev.com/5ce90514cb4be0de3e1668deef59c2814e59b704/include/linux/sync_file.h

Project Member

Comment 7 by bugdroid1@chromium.org, Sep 19 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/third_party/kernel/+/55075444ca3d8cca91ea07eca9983acf1ec351f5

commit 55075444ca3d8cca91ea07eca9983acf1ec351f5
Author: Andres Rodriguez <andresx7@gmail.com>
Date: Tue Sep 19 20:26:48 2017

UPSTREAM: dma-buf: avoid scheduling on fence status query v2

When a timeout of zero is specified, the caller is only interested in
the fence status.

In the current implementation, dma_fence_default_wait will always call
schedule_timeout() at least once for an unsignaled fence. This adds a
significant overhead to a fence status query.

Avoid this overhead by returning early if a zero timeout is specified.

v2: move early return after enable_signaling

BUG= chromium:738131 
TEST=run Angry Birds on kevin

Signed-off-by: Andres Rodriguez <andresx7@gmail.com>
Reviewed-by: Christian Knig <christian.koenig@amd.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170426144620.3560-1-andresx7@gmail.com
(cherry picked from commit 03c0c5f6641533f5fc14bf4e76d2304197402552)
Signed-off-by: Dominik Behr <dbehr@chromium.org>

Change-Id: I01524ef63989dbd56011108f84e4c24122e795d9
Reviewed-on: https://chromium-review.googlesource.com/647010
Commit-Ready: Dominik Behr <dbehr@chromium.org>
Tested-by: Dominik Behr <dbehr@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>

[modify] https://crrev.com/55075444ca3d8cca91ea07eca9983acf1ec351f5/drivers/dma-buf/dma-fence.c

Project Member

Comment 8 by bugdroid1@chromium.org, Sep 19 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/third_party/kernel/+/2aef9d3b9de9d099a14e864ac3e8f43c80a2cd69

commit 2aef9d3b9de9d099a14e864ac3e8f43c80a2cd69
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date: Tue Sep 19 20:26:49 2017

UPSTREAM: dma-buf/sync-file: Defer creation of sync_file->name

Constructing the name takes the majority of the time for allocating a
sync_file to wrap a fence, and the name is very rarely used (only via
the sync_file status user interface). To reduce the impact on the common
path (that of creating sync_file to pass around), defer the construction
of the name until it is first used.

v2: Update kerneldoc (kbuild test robot)
v3: sync_debug.c was peeking at the name
v4: Comment upon the potential race between two users of
sync_file_get_name() and claim that such a race is below the level of
notice. However, to prevent any future nuisance, use a global spinlock
to serialize the assignment of the name.
v5: Completely avoid the read/write race by only storing the name passed
in from the user inside sync_file->user_name and passing in a buffer to
dynamically construct the name otherwise.

BUG= chromium:738131 
TEST=run Angry Birds on kevin

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: Gustavo Padovan <gustavo@padovan.org>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: David Herrmann <dh.herrmann@gmail.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170516111042.24719-1-chris@chris-wilson.co.uk
(cherry picked from commit 71ebc9a3795818eab52e81bbcbdfae130ee35d9e)
Signed-off-by: Dominik Behr <dbehr@chromium.org>

Change-Id: Ib0401c744a1ec3dfbd925352448decf644838f5e
Reviewed-on: https://chromium-review.googlesource.com/647011
Commit-Ready: Dominik Behr <dbehr@chromium.org>
Tested-by: Dominik Behr <dbehr@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>

[modify] https://crrev.com/2aef9d3b9de9d099a14e864ac3e8f43c80a2cd69/drivers/dma-buf/sync_debug.c
[modify] https://crrev.com/2aef9d3b9de9d099a14e864ac3e8f43c80a2cd69/drivers/dma-buf/sync_file.c
[modify] https://crrev.com/2aef9d3b9de9d099a14e864ac3e8f43c80a2cd69/include/linux/sync_file.h

Project Member

Comment 9 by bugdroid1@chromium.org, Sep 19 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/third_party/kernel/+/89783bb906c02b823ac434c667f40eb0cc010fdc

commit 89783bb906c02b823ac434c667f40eb0cc010fdc
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date: Tue Sep 19 20:26:50 2017

UPSTREAM: dma-buf/dma-fence: Extract __dma_fence_is_later()

Often we have the task of comparing two seqno known to be on the same
context, so provide a common __dma_fence_is_later().

BUG= chromium:738131 
TEST=run Angry Birds on kevin

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: Sean Paul <seanpaul@chromium.org>
Cc: Gustavo Padovan <gustavo@padovan.org>
Reviewed-by: Sean Paul <seanpaul@chromium.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170629125930.821-1-chris@chris-wilson.co.uk
(cherry picked from commit 8111477663813caa1a4469cfe6afaae36cd04513)
Signed-off-by: Dominik Behr <dbehr@chromium.org>

Change-Id: Ic47e1f4c71f08aa216210b8e032c2a8d530ab4a4
Reviewed-on: https://chromium-review.googlesource.com/647012
Commit-Ready: Dominik Behr <dbehr@chromium.org>
Tested-by: Dominik Behr <dbehr@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>

[modify] https://crrev.com/89783bb906c02b823ac434c667f40eb0cc010fdc/include/linux/dma-fence.h

Project Member

Comment 10 by bugdroid1@chromium.org, Oct 15 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/third_party/kernel/+/75ada009c07cade6becf9e462efdb8c035254a4b

commit 75ada009c07cade6becf9e462efdb8c035254a4b
Author: Dominik Behr <dbehr@chromium.org>
Date: Fri Oct 13 21:44:43 2017

Revert "REVERTME: dma-buf/sw_sync: fix userspace incrementing timeline by 0x7FFFFFFF"

This reverts commit 8c6ce6c455f8ece1723123a70219f98313bbd2c5.

BUG= chromium:738131 
TEST=run Angry Birds on kevin
CQ-DEPEND=Id0885cf98fb85a3fbe959907072b2f3e95153880

Change-Id: Iecd02304f0a91cafac2620c3ed2b28e640d6fb9c
Reviewed-on: https://chromium-review.googlesource.com/647014
Commit-Ready: Dominik Behr <dbehr@chromium.org>
Tested-by: Dominik Behr <dbehr@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>

[modify] https://crrev.com/75ada009c07cade6becf9e462efdb8c035254a4b/drivers/dma-buf/sw_sync.c

Project Member

Comment 11 by bugdroid1@chromium.org, Oct 15 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/third_party/kernel/+/c1a4ceaab759072dae7df0059939c83368f644bc

commit c1a4ceaab759072dae7df0059939c83368f644bc
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date: Fri Oct 13 21:44:41 2017

UPSTREAM: dma-buf/sw-sync: Fix the is-signaled test to handle u32 wraparound

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

BUG= chromium:738131 
TEST=run Angry Birds on kevin

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: Sean Paul <seanpaul@chromium.org>
Cc: Gustavo Padovan <gustavo@padovan.org>
Reviewed-by: Sean Paul <seanpaul@chromium.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170629125930.821-2-chris@chris-wilson.co.uk
(cherry picked from commit 61894b02716f122dd7662d5d89f5b2245ca551e2)
Signed-off-by: Dominik Behr <dbehr@chromium.org>

Change-Id: I9deced46e9b422ee0feb56acc08a5ba6a6063806
Reviewed-on: https://chromium-review.googlesource.com/669284
Commit-Ready: Dominik Behr <dbehr@chromium.org>
Tested-by: Dominik Behr <dbehr@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>

[modify] https://crrev.com/c1a4ceaab759072dae7df0059939c83368f644bc/drivers/dma-buf/sw_sync.c

Project Member

Comment 12 by bugdroid1@chromium.org, Oct 15 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/third_party/kernel/+/8cb4d2a867bbe1b0ee8c9e4b56009d043148e31b

commit 8cb4d2a867bbe1b0ee8c9e4b56009d043148e31b
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date: Fri Oct 13 21:44:44 2017

UPSTREAM: dma-buf/sw-sync: Prevent user overflow on timeline advance

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

BUG= chromium:738131 
TEST=run Angry Birds on kevin
CQ-DEPEND=Iecd02304f0a91cafac2620c3ed2b28e640d6fb9c

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: Sean Paul <seanpaul@chromium.org>
Cc: Gustavo Padovan <gustavo@padovan.org>
Reviewed-by: Sean Paul <seanpaul@chromium.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170629125930.821-3-chris@chris-wilson.co.uk
(cherry picked from commit 8f66d3aa1735bc95ae58d846a157357e8d41abb8)
Signed-off-by: Dominik Behr <dbehr@chromium.org>

Change-Id: Id0885cf98fb85a3fbe959907072b2f3e95153880
Reviewed-on: https://chromium-review.googlesource.com/669285
Commit-Ready: Dominik Behr <dbehr@chromium.org>
Tested-by: Dominik Behr <dbehr@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>

[modify] https://crrev.com/8cb4d2a867bbe1b0ee8c9e4b56009d043148e31b/drivers/dma-buf/sw_sync.c

Project Member

Comment 13 by bugdroid1@chromium.org, Oct 16 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/third_party/kernel/+/6b8971691948aac37f50d65d48e2751eb0c59bd4

commit 6b8971691948aac37f50d65d48e2751eb0c59bd4
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date: Mon Oct 16 23:11:37 2017

UPSTREAM: dma-buf/sw-sync: Reduce irqsave/irqrestore from known context

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).

BUG= chromium:738131 
TEST=run Angry Birds on kevin

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: Sean Paul <seanpaul@chromium.org>
Cc: Gustavo Padovan <gustavo@padovan.org>
Reviewed-by: Sean Paul <seanpaul@chromium.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170629125930.821-4-chris@chris-wilson.co.uk
(cherry picked from commit a6aa8fca4d792c72947e341d7842d2f700534335)
Signed-off-by: Dominik Behr <dbehr@chromium.org>

Change-Id: I35851945de7d8ab4f3ab7d01c35e6f79d8ee0cfe
Reviewed-on: https://chromium-review.googlesource.com/669286
Commit-Ready: Dominik Behr <dbehr@chromium.org>
Tested-by: Dominik Behr <dbehr@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>

[modify] https://crrev.com/6b8971691948aac37f50d65d48e2751eb0c59bd4/drivers/dma-buf/sync_debug.c
[modify] https://crrev.com/6b8971691948aac37f50d65d48e2751eb0c59bd4/drivers/dma-buf/sw_sync.c

Project Member

Comment 14 by bugdroid1@chromium.org, Oct 16 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/third_party/kernel/+/05837fda0d31c40dde0e2c1a8baa94b7573f7a47

commit 05837fda0d31c40dde0e2c1a8baa94b7573f7a47
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date: Mon Oct 16 23:11:38 2017

UPSTREAM: dma-buf/sw-sync: sync_pt is private and of fixed size

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.

BUG= chromium:738131 
TEST=run Angry Birds on kevin

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: Sean Paul <seanpaul@chromium.org>
Cc: Gustavo Padovan <gustavo@padovan.org>
Reviewed-by: Sean Paul <seanpaul@chromium.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170629125930.821-5-chris@chris-wilson.co.uk
(cherry picked from commit 3b52ce44e720c240afc4c4b03140d7b7811b23bd)
Signed-off-by: Dominik Behr <dbehr@chromium.org>

Change-Id: Ic3217c2aa55b76bf26b9a5f87c4a9d8e16059bcd
Reviewed-on: https://chromium-review.googlesource.com/669287
Commit-Ready: Dominik Behr <dbehr@chromium.org>
Tested-by: Dominik Behr <dbehr@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>

[modify] https://crrev.com/05837fda0d31c40dde0e2c1a8baa94b7573f7a47/drivers/dma-buf/sw_sync.c

Project Member

Comment 15 by bugdroid1@chromium.org, Oct 16 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/third_party/kernel/+/24a1ca36ba73e2bda50c0276c441b53a90ca97fc

commit 24a1ca36ba73e2bda50c0276c441b53a90ca97fc
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date: Mon Oct 16 23:11:39 2017

UPSTREAM: dma-buf/sw-sync: Fix locking around sync_timeline lists

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

Backport: remove disable_signaling from fence ops

BUG= chromium:738131 
TEST=run Angry Birds on kevin

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: Sean Paul <seanpaul@chromium.org>
Cc: Gustavo Padovan <gustavo@padovan.org>
Reviewed-by: Sean Paul <seanpaul@chromium.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170629210532.5617-1-chris@chris-wilson.co.uk
(cherry picked from commit d3862e44daa7a0c94d2f6193502a8c49379acfce)
Signed-off-by: Dominik Behr <dbehr@chromium.org>

Change-Id: Ibc5939907d8c7d4798cdaebb32ece695ee362947
Reviewed-on: https://chromium-review.googlesource.com/669288
Commit-Ready: Dominik Behr <dbehr@chromium.org>
Tested-by: Dominik Behr <dbehr@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>

[modify] https://crrev.com/24a1ca36ba73e2bda50c0276c441b53a90ca97fc/drivers/dma-buf/sync_debug.c
[modify] https://crrev.com/24a1ca36ba73e2bda50c0276c441b53a90ca97fc/drivers/dma-buf/sync_debug.h
[modify] https://crrev.com/24a1ca36ba73e2bda50c0276c441b53a90ca97fc/drivers/dma-buf/sw_sync.c
[modify] https://crrev.com/24a1ca36ba73e2bda50c0276c441b53a90ca97fc/include/linux/dma-fence.h
[modify] https://crrev.com/24a1ca36ba73e2bda50c0276c441b53a90ca97fc/drivers/dma-buf/dma-fence.c

Project Member

Comment 16 by bugdroid1@chromium.org, Oct 18 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/third_party/kernel/+/e29ff93321352ef31a8495879f63e62d0e6a01e2

commit e29ff93321352ef31a8495879f63e62d0e6a01e2
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date: Wed Oct 18 03:49:03 2017

UPSTREAM: dma-buf/sw-sync: Use an rbtree to sort fences in the timeline

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.

BUG= chromium:738131 
TEST=run Angry Birds on kevin

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: Sean Paul <seanpaul@chromium.org>
Cc: Gustavo Padovan <gustavo@padovan.org>
Reviewed-by: Sean Paul <seanpaul@chromium.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170629211253.22766-1-chris@chris-wilson.co.uk
(cherry picked from commit f1e8c67123cf171e2b0357e885e426328b241d7d)
Signed-off-by: Dominik Behr <dbehr@chromium.org>

Change-Id: I0e6f090626fecd575cf4950606e30629f9b7bc93
Reviewed-on: https://chromium-review.googlesource.com/669289
Commit-Ready: Dominik Behr <dbehr@chromium.org>
Tested-by: Dominik Behr <dbehr@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>

[modify] https://crrev.com/e29ff93321352ef31a8495879f63e62d0e6a01e2/drivers/dma-buf/sync_debug.h
[modify] https://crrev.com/e29ff93321352ef31a8495879f63e62d0e6a01e2/drivers/dma-buf/sw_sync.c

Project Member

Comment 17 by bugdroid1@chromium.org, Oct 18 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/third_party/kernel/+/186266c1ce9e9b36ec55a8433b8afaccf7eed421

commit 186266c1ce9e9b36ec55a8433b8afaccf7eed421
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date: Wed Oct 18 03:49:04 2017

BACKPORT: dma-buf/fence: Avoid use of uninitialised timestamp

[  236.821534] WARNING: kmemcheck: Caught 64-bit read from uninitialized memory (ffff8802538683d0)
[  236.828642] 420000001e7f0000000000000000000000080000000000000000000000000000
[  236.839543]  i i i i u u u u i i i i i i i i u u u u u u u u u u u u u u u u
[  236.850420]                                  ^
[  236.854123] RIP: 0010:[<ffffffff81396f07>]  [<ffffffff81396f07>] fence_signal+0x17/0xd0
[  236.861313] RSP: 0018:ffff88024acd7ba0  EFLAGS: 00010282
[  236.865027] RAX: ffffffff812f6a90 RBX: ffff8802527ca800 RCX: ffff880252cb30e0
[  236.868801] RDX: ffff88024ac5d918 RSI: ffff880252f780e0 RDI: ffff880253868380
[  236.872579] RBP: ffff88024acd7bc0 R08: ffff88024acd7be0 R09: 0000000000000000
[  236.876407] R10: 0000000000000000 R11: 0000000000000000 R12: ffff880253868380
[  236.880185] R13: ffff8802538684d0 R14: ffff880253868380 R15: ffff88024cd48e00
[  236.883983] FS:  00007f1646d1a740(0000) GS:ffff88025d000000(0000) knlGS:0000000000000000
[  236.890959] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[  236.894702] CR2: ffff880251360318 CR3: 000000024ad21000 CR4: 00000000001406f0
[  236.898481]  [<ffffffff8130d1ad>] i915_gem_request_retire+0x1cd/0x230
[  236.902439]  [<ffffffff8130e2b3>] i915_gem_request_alloc+0xa3/0x2f0
[  236.906435]  [<ffffffff812fb1bd>] i915_gem_do_execbuffer.isra.41+0xb6d/0x18b0
[  236.910434]  [<ffffffff812fc265>] i915_gem_execbuffer2+0x95/0x1e0
[  236.914390]  [<ffffffff812ad625>] drm_ioctl+0x1e5/0x460
[  236.918275]  [<ffffffff8110d4cf>] do_vfs_ioctl+0x8f/0x5c0
[  236.922168]  [<ffffffff8110da3c>] SyS_ioctl+0x3c/0x70
[  236.926090]  [<ffffffff814b7a5f>] entry_SYSCALL_64_fastpath+0x17/0x93
[  236.930045]  [<ffffffffffffffff>] 0xffffffffffffffff

We only set the timestamp before we mark the fence as signaled. It is
done before to avoid observers having a window in which they may see the
fence as complete but no timestamp. Having it does incur a potential for
the timestamp to be written twice, and even for it to be corrupted if
the u64 write is not atomic. Instead use a new bit to record the
presence of the timestamp, and teach the readers to wait until it is set
if the fence is complete. There still remains a race where the timestamp
for the signaled fence may be shown before the fence is reported as
signaled, but that's a pre-existing error.

Backport: fix conversion from ktime to ns in fence info function.

BUG= chromium:738131 
TEST=run Angry Birds on kevin

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: Gustavo Padovan <gustavo@padovan.org>
Cc: Daniel Vetter <daniel.vetter@intel.com>
Reported-by: Rafael Antognolli <rafael.antognolli@intel.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170214124001.1930-1-chris@chris-wilson.co.uk
(cherry picked from commit 76250f2b743b72cb685cc51ac0cdabb32957180b)
Signed-off-by: Dominik Behr <dbehr@chromium.org>

Change-Id: I7cd2656311d5e9c31d2e18a896ab2d43b0b52af4
Reviewed-on: https://chromium-review.googlesource.com/669290
Commit-Ready: Dominik Behr <dbehr@chromium.org>
Tested-by: Dominik Behr <dbehr@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>

[modify] https://crrev.com/186266c1ce9e9b36ec55a8433b8afaccf7eed421/drivers/dma-buf/sync_debug.c
[modify] https://crrev.com/186266c1ce9e9b36ec55a8433b8afaccf7eed421/drivers/dma-buf/sync_file.c
[modify] https://crrev.com/186266c1ce9e9b36ec55a8433b8afaccf7eed421/include/linux/dma-fence.h
[modify] https://crrev.com/186266c1ce9e9b36ec55a8433b8afaccf7eed421/drivers/dma-buf/dma-fence.c

Project Member

Comment 18 by bugdroid1@chromium.org, Oct 18 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/third_party/kernel/+/f7be9c82aa0f67f051f2948b50d446c06b64d124

commit f7be9c82aa0f67f051f2948b50d446c06b64d124
Author: Daniel Vetter <daniel.vetter@ffwll.ch>
Date: Wed Oct 18 03:49:05 2017

UPSTREAM: dma-fence: Don't BUG_ON when not absolutely needed

It makes debugging a massive pain.

BUG= chromium:738131 
TEST=run Angry Birds on kevin

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: Gustavo Padovan <gustavo@padovan.org>
Cc: linux-media@vger.kernel.org
Cc: linaro-mm-sig@lists.linaro.org
Reviewed-by: Lucas Stach <l.stach@pengutronix.de>
Acked-by: Sumit Semwal <sumit.semwal@linaro.org>
Acked-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20170720125107.26693-1-daniel.vetter@ffwll.ch
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
(cherry picked from commit 6ce31263c9758c85e7d326cdc65c31fc521dc63d)
Signed-off-by: Dominik Behr <dbehr@chromium.org>

Change-Id: Iceb89e0da2c53a4fb1a136b0c14420b96a71589a
Reviewed-on: https://chromium-review.googlesource.com/669291
Commit-Ready: Dominik Behr <dbehr@chromium.org>
Tested-by: Dominik Behr <dbehr@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>

[modify] https://crrev.com/f7be9c82aa0f67f051f2948b50d446c06b64d124/include/linux/dma-fence.h
[modify] https://crrev.com/f7be9c82aa0f67f051f2948b50d446c06b64d124/drivers/dma-buf/dma-fence.c

Project Member

Comment 19 by bugdroid1@chromium.org, Oct 18 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/third_party/kernel/+/963026bb5848c2e1c55eeeeb8b79d50d986b22a9

commit 963026bb5848c2e1c55eeeeb8b79d50d986b22a9
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date: Wed Oct 18 03:49:06 2017

UPSTREAM: dma-buf/sync_file: Allow multiple sync_files to wrap a single dma-fence

Up until recently sync_file were create to export a single dma-fence to
userspace, and so we could canabalise a bit insie dma-fence to mark
whether or not we had enable polling for the sync_file itself. However,
with the advent of syncobj, we do allow userspace to create multiple
sync_files for a single dma-fence. (Similarly, that the sw-sync
validation framework also started returning multiple sync-files wrapping
a single dma-fence for a syncpt also triggering the problem.)

This patch reverts my suggestion in commit e24165537312
("dma-buf/sync_file: only enable fence signalling on poll()") to use a
single bit in the shared dma-fence and restores the sync_file->flags for
tracking the bits individually.

BUG= chromium:738131 
TEST=run Angry Birds on kevin

Reported-by: Gustavo Padovan <gustavo.padovan@collabora.com>
Fixes: f1e8c67123cf ("dma-buf/sw-sync: Use an rbtree to sort fences in the timeline")
Fixes: e9083420bbac ("drm: introduce sync objects (v4)")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: Sean Paul <seanpaul@chromium.org>
Cc: Gustavo Padovan <gustavo@padovan.org>
Cc: dri-devel@lists.freedesktop.org
Cc: <drm-intel-fixes@lists.freedesktop.org> # v4.13-rc1+
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170728212951.7818-1-chris@chris-wilson.co.uk
(cherry picked from commit db1fc97ca0c0d3fdeeadf314d99a26188438940a)
Signed-off-by: Dominik Behr <dbehr@chromium.org>

Change-Id: I83000b862a3d508a50dd7e46c0b1c220f16de30e
Reviewed-on: https://chromium-review.googlesource.com/669292
Commit-Ready: Dominik Behr <dbehr@chromium.org>
Tested-by: Dominik Behr <dbehr@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>

[modify] https://crrev.com/963026bb5848c2e1c55eeeeb8b79d50d986b22a9/drivers/dma-buf/sync_file.c
[modify] https://crrev.com/963026bb5848c2e1c55eeeeb8b79d50d986b22a9/include/linux/sync_file.h

Project Member

Comment 20 by bugdroid1@chromium.org, Oct 18 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/third_party/kernel/+/f80c9070962e7bb51bbf7fcc1b4424037d148fbc

commit f80c9070962e7bb51bbf7fcc1b4424037d148fbc
Author: Gustavo Padovan <gustavo.padovan@collabora.com>
Date: Wed Oct 18 23:15:18 2017

UPSTREAM: dma-buf/sw_sync: move timeline_fence_ops around

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

BUG= chromium:738131 
TEST=run Angry Birds on kevin

Cc: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: https://patchwork.freedesktop.org/patch/msgid/20170729152217.8362-1-gustavo@padovan.org
(cherry picked from commit 150b6a9d7d6fffb95c0a5349960a10569e8218b5)
Signed-off-by: Dominik Behr <dbehr@chromium.org>

Change-Id: I176e5e582fb0b3c71157dda320e986af3ff69e62
Reviewed-on: https://chromium-review.googlesource.com/669293
Commit-Ready: Dominik Behr <dbehr@chromium.org>
Tested-by: Dominik Behr <dbehr@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>

[modify] https://crrev.com/f80c9070962e7bb51bbf7fcc1b4424037d148fbc/drivers/dma-buf/sw_sync.c

Project Member

Comment 21 by bugdroid1@chromium.org, Oct 18 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/third_party/kernel/+/835cb1fe236e5c552d34884b6258bc78f7c95326

commit 835cb1fe236e5c552d34884b6258bc78f7c95326
Author: Gustavo Padovan <gustavo.padovan@collabora.com>
Date: Wed Oct 18 23:15:20 2017

UPSTREAM: dma-buf/sw_sync: clean up list before signaling the fence

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)

BUG= chromium:738131 
TEST=run Angry Birds on kevin

Cc: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: https://patchwork.freedesktop.org/patch/msgid/20170729152217.8362-2-gustavo@padovan.org
(cherry picked from commit 3792b7c1a70815fe4e954221c096f9278638fd21)
Signed-off-by: Dominik Behr <dbehr@chromium.org>

Change-Id: I3344c8babf26fae3e61bc538fc43f6da5c782723
Reviewed-on: https://chromium-review.googlesource.com/669294
Commit-Ready: Dominik Behr <dbehr@chromium.org>
Tested-by: Dominik Behr <dbehr@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>

[modify] https://crrev.com/835cb1fe236e5c552d34884b6258bc78f7c95326/drivers/dma-buf/sw_sync.c

Status: Fixed (was: Started)

Comment 23 by dchan@chromium.org, Jan 22 2018

Status: Archived (was: Fixed)

Comment 24 by dchan@chromium.org, Jan 23 2018

Status: Fixed (was: Archived)

Sign in to add a comment