Skip to content

Commit 41576bb

Browse files
dtorjohnstultz-work
authored andcommitted
CHROMIUM: android: fix warning when releasing active sync point
Userspace can close the sync device while there are still active fence points, in which case kernel produces the following warning: [ 43.853176] ------------[ cut here ]------------ [ 43.857834] WARNING: CPU: 0 PID: 892 at /mnt/host/source/src/third_party/kernel/v3.18/drivers/staging/android/sync.c:439 android_fence_release+0x88/0x104() [ 43.871741] CPU: 0 PID: 892 Comm: Binder_5 Tainted: G U 3.18.0-07661-g0550ce9 #1 [ 43.880176] Hardware name: Google Tegra210 Smaug Rev 1+ (DT) [ 43.885834] Call trace: [ 43.888294] [<ffffffc000207464>] dump_backtrace+0x0/0x10c [ 43.893697] [<ffffffc000207580>] show_stack+0x10/0x1c [ 43.898756] [<ffffffc000ab1258>] dump_stack+0x74/0xb8 [ 43.903814] [<ffffffc00021d414>] warn_slowpath_common+0x84/0xb0 [ 43.909736] [<ffffffc00021d530>] warn_slowpath_null+0x14/0x20 [ 43.915482] [<ffffffc00088aefc>] android_fence_release+0x84/0x104 [ 43.921582] [<ffffffc000671cc4>] fence_release+0x104/0x134 [ 43.927066] [<ffffffc00088b0cc>] sync_fence_free+0x74/0x9c [ 43.932552] [<ffffffc00088b128>] sync_fence_release+0x34/0x48 [ 43.938304] [<ffffffc000317bbc>] __fput+0x100/0x1b8 [ 43.943185] [<ffffffc000317cc8>] ____fput+0x8/0x14 [ 43.947982] [<ffffffc000237f38>] task_work_run+0xb0/0xe4 [ 43.953297] [<ffffffc000207074>] do_notify_resume+0x44/0x5c [ 43.958867] ---[ end trace 5a2aa4027cc5d171 ]--- Let's fix it by introducing a new optional callback (disable_signaling) to fence operations so that drivers can do proper clean ups when we remove last callback for given fence. BUG=chrome-os-partner:40303 TEST=Boot Smaug and observe that warning is gone. Change-Id: I05c34dcf74438c28405438c7ead0706b1f810fff Signed-off-by: Dmitry Torokhov <[email protected]> Reviewed-on: https://chromium-review.googlesource.com/303409 Reviewed-by: Andrew Bresticker <[email protected]>
1 parent efa5c49 commit 41576bb

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

drivers/dma-buf/fence.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,12 @@ fence_remove_callback(struct fence *fence, struct fence_cb *cb)
304304
spin_lock_irqsave(fence->lock, flags);
305305

306306
ret = !list_empty(&cb->node);
307-
if (ret)
307+
if (ret) {
308308
list_del_init(&cb->node);
309+
if (list_empty(&fence->cb_list))
310+
if (fence->ops->disable_signaling)
311+
fence->ops->disable_signaling(fence);
312+
}
309313

310314
spin_unlock_irqrestore(fence->lock, flags);
311315

drivers/staging/android/sync.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,13 @@ static bool android_fence_enable_signaling(struct fence *fence)
465465
return true;
466466
}
467467

468+
static void android_fence_disable_signaling(struct fence *fence)
469+
{
470+
struct sync_pt *pt = container_of(fence, struct sync_pt, base);
471+
472+
list_del_init(&pt->active_list);
473+
}
474+
468475
static int android_fence_fill_driver_data(struct fence *fence,
469476
void *data, int size)
470477
{
@@ -508,6 +515,7 @@ static const struct fence_ops android_fence_ops = {
508515
.get_driver_name = android_fence_get_driver_name,
509516
.get_timeline_name = android_fence_get_timeline_name,
510517
.enable_signaling = android_fence_enable_signaling,
518+
.disable_signaling = android_fence_disable_signaling,
511519
.signaled = android_fence_signaled,
512520
.wait = fence_default_wait,
513521
.release = android_fence_release,

include/linux/fence.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ struct fence_cb {
107107
* @get_driver_name: returns the driver name.
108108
* @get_timeline_name: return the name of the context this fence belongs to.
109109
* @enable_signaling: enable software signaling of fence.
110+
* @disable_signaling: disable software signaling of fence (optional).
110111
* @signaled: [optional] peek whether the fence is signaled, can be null.
111112
* @wait: custom wait implementation, or fence_default_wait.
112113
* @release: [optional] called on destruction of fence, can be null
@@ -166,6 +167,7 @@ struct fence_ops {
166167
const char * (*get_driver_name)(struct fence *fence);
167168
const char * (*get_timeline_name)(struct fence *fence);
168169
bool (*enable_signaling)(struct fence *fence);
170+
void (*disable_signaling)(struct fence *fence);
169171
bool (*signaled)(struct fence *fence);
170172
signed long (*wait)(struct fence *fence, bool intr, signed long timeout);
171173
void (*release)(struct fence *fence);

0 commit comments

Comments
 (0)