From patchwork Wed Jun 29 09:31:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sylwester Nawrocki/Kernel \\(PLT\\) /SRPOL/Staff Engineer/Samsung Electronics" X-Patchwork-Id: 9204623 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 10F0D607D8 for ; Wed, 29 Jun 2016 09:32:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F392D2864C for ; Wed, 29 Jun 2016 09:32:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E81462864E; Wed, 29 Jun 2016 09:32:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5F3012864D for ; Wed, 29 Jun 2016 09:31:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752208AbcF2Jb5 (ORCPT ); Wed, 29 Jun 2016 05:31:57 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:52082 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751846AbcF2Jby (ORCPT ); Wed, 29 Jun 2016 05:31:54 -0400 Received: from epcpsbgm2new.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0O9J00LPS14ZJ750@mailout1.samsung.com>; Wed, 29 Jun 2016 18:31:51 +0900 (KST) X-AuditID: cbfee61b-f798b6d00000114d-db-577395873792 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2new.samsung.com (EPCPMTA) with SMTP id BE.21.04429.78593775; Wed, 29 Jun 2016 02:31:51 -0700 (MST) Received: from AMDC1344.digital.local ([106.116.147.32]) by mmp1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0O9J00IUQ14QF330@mmp1.samsung.com>; Wed, 29 Jun 2016 18:31:51 +0900 (KST) From: Sylwester Nawrocki To: linux-media@vger.kernel.org Cc: linux-samsung-soc@vger.kernel.org, k.debski@samsung.com, b.zolnierkie@samsung.com, m.szyprowski@samsung.com, Sylwester Nawrocki Subject: [PATCH] exynos4-is: Fix buffer release issue on fimc m2m video nodes Date: Wed, 29 Jun 2016 11:31:30 +0200 Message-id: <1467192690-6101-1-git-send-email-s.nawrocki@samsung.com> X-Mailer: git-send-email 1.9.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrNJMWRmVeSWpSXmKPExsVy+t9jAd32qcXhBid/alhsnLGe1eLH6wts Fj0btrJazDi/j8li7ZG77BaH37SzOrB59G1ZxejxeZNcAFMUl01Kak5mWWqRvl0CV0Zr9x32 greKFW/v/WRpYFwq28XIwSEhYCJx4wd/FyMnkCkmceHeerYuRi4OIYGljBI/Lh5hhHB+MUq0 P17LBlLFJmAo0Xu0jxHEFhGQl3jSewOsg1lgAaPE+pdXmEASwgK+EtdvnAKzWQRUJXZM/QjW wCvgKvF34VUmiHVyEiePTWadwMi9gJFhFaNEakFyQXFSeq5RXmq5XnFibnFpXrpecn7uJkZw EDyT3sF4eJf7IUYBDkYlHl6LC0XhQqyJZcWVuYcYJTiYlUR4l/cXhwvxpiRWVqUW5ccXleak Fh9ilOZgURLnffx/XZiQQHpiSWp2ampBahFMlomDU6qBscOu+9+bT5XuX69ZvIoSn/ymMiGU 5dn/7w58S+/dWbFbbv5lqQ957Fvquv7MMtXVM5C81uVm1BV7WujS5tNdgYezr5lHfjhxXo6l kuuWvOj0hs1R5fPXZl8uP2D7/fPbqP2u9g2x/+6mLvv+Tzvq1Xn2bXGxd79LHbrTlNcZeX/5 dkVO0a3JX5RYijMSDbWYi4oTATF0w2b+AQAA Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This fixes dropping ownership of buffers in the driver's stop_streaming callback, so buffers on the memory-to-memory video nodes are properly released, also in case when the driver has a buffer only on one of the queues (OUTPUT, CAPTURE) before the video node close. The issue was being reported by videobuf2 with a following warning while checking q->owned_by_drv_count: [ 2498.310766] WARNING: CPU: 0 PID: 9358 at drivers/media/v4l2-core/videobuf2-core.c:1818 __vb2_queue_cancel+0xe8/0x14c [ 2498.320258] Modules linked in: [ 2498.323212] CPU: 0 PID: 9358 Comm: v4l2_decode Not tainted 4.7.0-rc4-next-20160627 #1210 [ 2498.331284] Hardware name: SAMSUNG EXYNOS (Flattened Device Tree) [ 2498.331327] [] (unwind_backtrace) from [] (show_stack+0x10/0x14) [ 2498.331344] [] (show_stack) from [] (dump_stack+0x74/0x94) [ 2498.331358] [] (dump_stack) from [] (__warn+0xd4/0x100) [ 2498.331369] [] (__warn) from [] (warn_slowpath_null+0x20/0x28) [ 2498.331381] [] (warn_slowpath_null) from [] (__vb2_queue_cancel+0xe8/0x14c) [ 2498.331395] [] (__vb2_queue_cancel) from [] (vb2_core_queue_release+0x18/0x38) [ 2498.331406] [] (vb2_core_queue_release) from [] (v4l2_m2m_ctx_release+0x1c/0x28) [ 2498.331420] [] (v4l2_m2m_ctx_release) from [] (fimc_m2m_release+0x24/0x78) [ 2498.331437] [] (fimc_m2m_release) from [] (v4l2_release+0x34/0x74) [ 2498.331455] [] (v4l2_release) from [] (__fput+0x80/0x1bc) [ 2498.331469] [] (__fput) from [] (task_work_run+0xc0/0xe4) [ 2498.331482] [] (task_work_run) from [] (do_exit+0x304/0xa24) [ 2498.331493] [] (do_exit) from [] (do_group_exit+0x3c/0xbc) [ 2498.331505] [] (do_group_exit) from [] (get_signal+0x200/0x65c) [ 2498.331517] [] (get_signal) from [] (do_signal+0x84/0x3c4) [ 2498.331532] [] (do_signal) from [] (do_work_pending+0xa4/0xb4) [ 2498.331545] [] (do_work_pending) from [] (slow_work_pending+0xc/0x20) Reported-by: Marek Szyprowski Signed-off-by: Sylwester Nawrocki --- drivers/media/platform/exynos4-is/fimc-m2m.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/drivers/media/platform/exynos4-is/fimc-m2m.c b/drivers/media/platform/exynos4-is/fimc-m2m.c index 55ec4c9..ec1c762 100644 --- a/drivers/media/platform/exynos4-is/fimc-m2m.c +++ b/drivers/media/platform/exynos4-is/fimc-m2m.c @@ -50,30 +50,28 @@ void fimc_m2m_job_finish(struct fimc_ctx *ctx, int vb_state) src_vb = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx); dst_vb = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx); - if (src_vb && dst_vb) { + if (src_vb) v4l2_m2m_buf_done(src_vb, vb_state); + if (dst_vb) v4l2_m2m_buf_done(dst_vb, vb_state); + if (src_vb && dst_vb) v4l2_m2m_job_finish(ctx->fimc_dev->m2m.m2m_dev, ctx->fh.m2m_ctx); - } } /* Complete the transaction which has been scheduled for execution. */ -static int fimc_m2m_shutdown(struct fimc_ctx *ctx) +static void fimc_m2m_shutdown(struct fimc_ctx *ctx) { struct fimc_dev *fimc = ctx->fimc_dev; - int ret; if (!fimc_m2m_pending(fimc)) - return 0; + return; fimc_ctx_state_set(FIMC_CTX_SHUT, ctx); - ret = wait_event_timeout(fimc->irq_queue, - !fimc_ctx_state_is_set(FIMC_CTX_SHUT, ctx), - FIMC_SHUTDOWN_TIMEOUT); - - return ret == 0 ? -ETIMEDOUT : ret; + wait_event_timeout(fimc->irq_queue, + !fimc_ctx_state_is_set(FIMC_CTX_SHUT, ctx), + FIMC_SHUTDOWN_TIMEOUT); } static int start_streaming(struct vb2_queue *q, unsigned int count) @@ -88,12 +86,10 @@ static int start_streaming(struct vb2_queue *q, unsigned int count) static void stop_streaming(struct vb2_queue *q) { struct fimc_ctx *ctx = q->drv_priv; - int ret; - ret = fimc_m2m_shutdown(ctx); - if (ret == -ETIMEDOUT) - fimc_m2m_job_finish(ctx, VB2_BUF_STATE_ERROR); + fimc_m2m_shutdown(ctx); + fimc_m2m_job_finish(ctx, VB2_BUF_STATE_ERROR); pm_runtime_put(&ctx->fimc_dev->pdev->dev); }