From patchwork Tue Dec 15 01:29:55 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 7851791 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 126CFBEEE1 for ; Tue, 15 Dec 2015 07:18:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E38E420416 for ; Tue, 15 Dec 2015 07:17:59 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id DD29620414 for ; Tue, 15 Dec 2015 07:17:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 25DFE6E6AA; Mon, 14 Dec 2015 23:17:57 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pa0-f53.google.com (mail-pa0-f53.google.com [209.85.220.53]) by gabe.freedesktop.org (Postfix) with ESMTPS id C91B96E25C for ; Mon, 14 Dec 2015 17:29:58 -0800 (PST) Received: by pacwq6 with SMTP id wq6so112993751pac.1 for ; Mon, 14 Dec 2015 17:29:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-type:content-disposition:user-agent; bh=omr46PqL0/NzXvHBUgQDNc1VX14uZY7uI3HbyM+Ej4I=; b=UHjmqPSPFYMjSroUN9Fw0X6hTJsupE7TSpbcAWCyCphjvv4AVIN80fuVzx8euwI/ZR NHnS7yv+Mcm/CBMnaZ04yfFWq4ezkzsuPctPkVvTlRG8zV8bZRY/NFAKvyG3MWwe3LR+ 0NJ421Y1MjJT5M+iS92qCiKOjinKcz7DdyWIsyrU7Zs5eFUv9QAC6B4WXxUtwbAerGmM rfMvRjNOSoZK3/9oNwvZJJoY7YBxzvJIK3wkfBSo3LE3X9yD6TVgc1XVKI/NpZX7EIkg C6KFnAUinuT17VD2lKNjpTVhRi5X2Ex/phpjN1eDj3pVDkGRMt1EfpjbCePVjFtwxAC8 maUg== X-Gm-Message-State: ALoCoQnl1Tv0R3o9wLMZoZ0pcMUTzKfKBJ924++FLMSKpNDF21ky8inEcYd1n3zfXX7zq9TcoiKrTbvk6jmYaNncKUeoJ2yPjg== X-Received: by 10.66.90.166 with SMTP id bx6mr42240933pab.75.1450142998060; Mon, 14 Dec 2015 17:29:58 -0800 (PST) Received: from dtor-ws ([2620:0:1000:1301:1dc6:d5f5:521b:1126]) by smtp.gmail.com with ESMTPSA id w20sm44871247pfi.55.2015.12.14.17.29.56 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Mon, 14 Dec 2015 17:29:57 -0800 (PST) Date: Mon, 14 Dec 2015 17:29:55 -0800 From: Dmitry Torokhov To: Greg Kroah-Hartman Subject: [PATCH] android: fix warning when releasing active sync point Message-ID: <20151215012955.GA28277@dtor-ws> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Mailman-Approved-At: Mon, 14 Dec 2015 23:17:56 -0800 Cc: devel@driverdev.osuosl.org, Andrew Bresticker , Arve =?iso-8859-1?B?SGr4bm5lduVn?= , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Riley Andrews , linux-media@vger.kernel.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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] [] dump_backtrace+0x0/0x10c [ 43.893697] [] show_stack+0x10/0x1c [ 43.898756] [] dump_stack+0x74/0xb8 [ 43.903814] [] warn_slowpath_common+0x84/0xb0 [ 43.909736] [] warn_slowpath_null+0x14/0x20 [ 43.915482] [] android_fence_release+0x84/0x104 [ 43.921582] [] fence_release+0x104/0x134 [ 43.927066] [] sync_fence_free+0x74/0x9c [ 43.932552] [] sync_fence_release+0x34/0x48 [ 43.938304] [] __fput+0x100/0x1b8 [ 43.943185] [] ____fput+0x8/0x14 [ 43.947982] [] task_work_run+0xb0/0xe4 [ 43.953297] [] 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. Reviewed-by: Andrew Bresticker Signed-off-by: Dmitry Torokhov --- drivers/dma-buf/fence.c | 6 +++++- drivers/staging/android/sync.c | 8 ++++++++ include/linux/fence.h | 2 ++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/dma-buf/fence.c b/drivers/dma-buf/fence.c index 7b05dbe..0ed73ad 100644 --- a/drivers/dma-buf/fence.c +++ b/drivers/dma-buf/fence.c @@ -304,8 +304,12 @@ fence_remove_callback(struct fence *fence, struct fence_cb *cb) spin_lock_irqsave(fence->lock, flags); ret = !list_empty(&cb->node); - if (ret) + if (ret) { list_del_init(&cb->node); + if (list_empty(&fence->cb_list)) + if (fence->ops->disable_signaling) + fence->ops->disable_signaling(fence); + } spin_unlock_irqrestore(fence->lock, flags); diff --git a/drivers/staging/android/sync.c b/drivers/staging/android/sync.c index e0c1acb..f8566c1 100644 --- a/drivers/staging/android/sync.c +++ b/drivers/staging/android/sync.c @@ -465,6 +465,13 @@ static bool android_fence_enable_signaling(struct fence *fence) return true; } +static void android_fence_disable_signaling(struct fence *fence) +{ + struct sync_pt *pt = container_of(fence, struct sync_pt, base); + + list_del_init(&pt->active_list); +} + static int android_fence_fill_driver_data(struct fence *fence, void *data, int size) { @@ -508,6 +515,7 @@ static const struct fence_ops android_fence_ops = { .get_driver_name = android_fence_get_driver_name, .get_timeline_name = android_fence_get_timeline_name, .enable_signaling = android_fence_enable_signaling, + .disable_signaling = android_fence_disable_signaling, .signaled = android_fence_signaled, .wait = fence_default_wait, .release = android_fence_release, diff --git a/include/linux/fence.h b/include/linux/fence.h index bb52201..ce44348 100644 --- a/include/linux/fence.h +++ b/include/linux/fence.h @@ -107,6 +107,7 @@ struct fence_cb { * @get_driver_name: returns the driver name. * @get_timeline_name: return the name of the context this fence belongs to. * @enable_signaling: enable software signaling of fence. + * @disable_signaling: disable software signaling of fence (optional). * @signaled: [optional] peek whether the fence is signaled, can be null. * @wait: custom wait implementation, or fence_default_wait. * @release: [optional] called on destruction of fence, can be null @@ -166,6 +167,7 @@ struct fence_ops { const char * (*get_driver_name)(struct fence *fence); const char * (*get_timeline_name)(struct fence *fence); bool (*enable_signaling)(struct fence *fence); + void (*disable_signaling)(struct fence *fence); bool (*signaled)(struct fence *fence); signed long (*wait)(struct fence *fence, bool intr, signed long timeout); void (*release)(struct fence *fence);