- save the omni version
sync: optimize fence merges

If the two fences being merged contain sync_pts from the same timeline,
those two pts will be collapsed into a single pt representing the latter
of the two.

Signed-off-by: Erik Gilling <konkers@android.com>
Change-Id: Iced7ebb7e5a17a0c8b1a2969ba3388a4edb9ecaf
sync: add internal refcounting to fences

If a fence is released while a timeline that one of it's pts is on is being
signaled, it is possible for that fence to be deleted before it is signaled.
This patch adds a refcount for internal references such as signaled pt
processing.

Signed-off-by: Erik Gilling <konkers@android.com>
Change-Id: Ie8605e6fd2ac026c207220a03d84e1c1078ec719
sync: add reference counting to timelines

If a timeline is destroyed while fences still hold pts on it, the reworked
fence release handler can cause the timeline to be freed before all it's points
are freed.

Signed-off-by: Erik Gilling <konkers@android.com>
Change-Id: I1cd8ddb638eded7db9db446ff6b37f3dd165d6c4
sync: Fix error paths

Check the return value of get_unused_fd to make sure a valid
file descriptor is returned.

Make sure to call put_unused_fd even if an error occurs before
the fd can be used.

Signed-off-by: Rebecca Schultz Zavin <rebecca@android.com>
Change-Id: I0fe8f78d9e30ecfc4d271c5d875424543dae2d0f
sync: change wait timeout to mirror poll semantics

Signed-off-by: Erik Gilling <konkers@android.com>
Change-Id: Ib38e6d339d41885a33027752690d65a52b6897f6
sync: fix erase-o in sync_fence_wait

Signed-off-by: Erik Gilling <konkers@android.com>
Change-Id: I189707cf658a9f1f2943515c891b43961994e774
sync: clean up compiler warnings

Signed-off-by: Erik Gilling <konkers@android.com>
Change-Id: I8a2ec5db652c61fd04571402067b37273b91e78f
sync: dump sync state to console on timeout

Signed-off-by: Erik Gilling <konkers@android.com>
Change-Id: I74bca6b4a2afa7ed5b1f5233c5165d2edddf269a
sync: use correct signed type when handling SYNC_IOC_WAIT

Signed-off-by: Erik Gilling <konkers@android.com>
Change-Id: Ic7d5adf9b145765e52b23186b8c3c793ccf29be7
sync: improve timeout dumps

Signed-off-by: Erik Gilling <konkers@android.com>
Change-Id: I3b378d63c324c7b5862dd214f380b5e91131cc2a
sync: dump sync state of fence errors

Signed-off-by: Erik Gilling <konkers@android.com>
Change-Id: I297a43aadf83504993040ea875c7f22d988628f1
sync: protect unlocked access to fence status

Fence status is checked outside of locks in both sync_fence_wait and
sync_fence_poll.  This patch adds propper barrier protection in these
cases to avoid seeing stale status.

Signed-off-by: Erik Gilling <konkers@android.com>
Change-Id: I9d8b6ce6accb415e797df58068a1ccd54e6be445
sync: update new fence status with sync_fence_signal_pt

If a fence's pt is signaled before sync_fence_create is called, the fence
will never transition into the signaled state.  This also address a tiny
race if a merged fence's pt after sync_fence_get_status checks it's status
and before fence->status is updated.

Signed-off-by: Erik Gilling <konkers@android.com>
Change-Id: Ic8e292a323db26c6f04cb4757d920278b3125ff6
sync: use proper barriers when waiting indefinitely

The previous fix only addressed waiting with a timeout.

Signed-off-by: Erik Gilling <konkers@android.com>
Change-Id: I8ad735d2d0dfdd53592904e8a54f5689cb5eaa5e
sync: refactor sync debug printing

Move driver callbacks to fill strings instead of using seq_files.  This
will allow those values to be used in a future tracepoint patch.

Signed-off-by: Erik Gilling <konkers@android.com>
Change-Id: I9b706343e35b11124141fe520e520514a32003d2
sync: add tracepoint support

Change-Id: I181326db4247009161557e45444c9b3548b83d25
Signed-off-by: Erik Gilling <konkers@android.com>
sync: Fix race condition between merge and signal

The copied sync_pt was activated immediately. If the sync_pt was
signaled before the entire merge was completed, the new fence's pt_list
could be iterated over while it is still in the process of being
created.

Moving the the sync_pt_activate call for all new sync_pts to after both
the sync_fence_copy_pts and the sync_fence_merge_pts calls ensure that
the pt_list is complete and immutable before it can be reached from the
timeline's active list.

Change-Id: I3bed16b76c427da1d9f6a59b0b2f084de0b6927b
Signed-off-by: Ørjan Eide <orjan.eide@arm.com>
Signed-off-by: Erik Gilling <konkers@android.com>
sync: don't log wait timeouts when timeout = 0

Change-Id: I776605233218b93376a8fd6bf81e70df435e2ceb
Signed-off-by: Erik Gilling <konkers@android.com>
sync: fix timeout = 0 wait behavior

Change-Id: I8b9254e92c26d9f44abbc0c77fb44624de947013
Signed-off-by: Jamie Gennis <jgennis@google.com>