From patchwork Sat Mar 22 11:03:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 3877391 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E50409F39B for ; Sat, 22 Mar 2014 11:04:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 03F2C2010F for ; Sat, 22 Mar 2014 11:04:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3D854202B4 for ; Sat, 22 Mar 2014 11:04:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751318AbaCVLDk (ORCPT ); Sat, 22 Mar 2014 07:03:40 -0400 Received: from mail-pa0-f54.google.com ([209.85.220.54]:38677 "EHLO mail-pa0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751314AbaCVLDh (ORCPT ); Sat, 22 Mar 2014 07:03:37 -0400 Received: by mail-pa0-f54.google.com with SMTP id lf10so3493850pab.27 for ; Sat, 22 Mar 2014 04:03:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ARS+ho8J4Urh1TpTxasm5LypBvwwmYGVVBWmnw25/FI=; b=HIPm+Vzb+2Mu6IUlUDScmYKf3TC//Ag4m4vWhcRAUfWPRvDrzMDDsUN1vxmVwpPhwc df+zw9pl2Edc884rOd1OYy6hre1SBMu+DIMldGwH1S3XhctyOycS/7Cr5kGa+yh4a2sZ aVAp0t4v5YBvuD2rxBs0OZRxi8NFt/H3p0jZmsYV8wBaiPo/QxMT3X8cIYGMXjxqTkJy WecksJU9nHKej+BV1nmts4twwqfuqYfLLiAHAMqaG40ztfJxY4Ws4uSY6M2GVFHL44ju 5ofEv9x0GpiNIogvYqlk5mJQWNfMSeSyh6FYQV2rYtCDgOgYd4uPS/QVnuz/LpKD68Y6 mQdg== X-Received: by 10.68.159.228 with SMTP id xf4mr59717778pbb.74.1395486216941; Sat, 22 Mar 2014 04:03:36 -0700 (PDT) Received: from tango-charlie.vayavyatech.com ([122.166.13.141]) by mx.google.com with ESMTPSA id vx10sm40576987pac.17.2014.03.22.04.03.33 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 22 Mar 2014 04:03:36 -0700 (PDT) From: "Lad, Prabhakar" To: LMML Cc: LKML , Mauro Carvalho Chehab , Lad Prabhakar , Hans Verkuil , DLOS Subject: [PATCH RESEND for v3.15 1/3] media: davinci: vpif_capture: fix releasing of active buffers Date: Sat, 22 Mar 2014 16:33:07 +0530 Message-Id: <1395486189-16713-2-git-send-email-prabhakar.csengg@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1395486189-16713-1-git-send-email-prabhakar.csengg@gmail.com> References: <1395486189-16713-1-git-send-email-prabhakar.csengg@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, 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 From: "Lad, Prabhakar" from commit-id: b3379c6201bb3555298cdbf0aa004af260f2a6a4 "vb2: only call start_streaming if sufficient buffers are queued" the vb2 framework warns on (WARN_ON()) if all the active buffers are not released when streaming is stopped, initially the vb2 silently released the buffer internally if the buffer was not released by the driver. Also this patch moves the disabling of interrupts from relase() callback to stop_streaming() callback as which needs to be done ideally. This patch fixes following issue: WARNING: CPU: 0 PID: 2049 at drivers/media/v4l2-core/videobuf2-core.c:2011 __vb2_queue_cancel+0x1a0/0x218() Modules linked in: CPU: 0 PID: 2049 Comm: vpif_capture Tainted: G W 3.14.0-rc5-00414-ged97a6f #89 [] (unwind_backtrace) from [] (show_stack+0x10/0x14) [] (show_stack) from [] (warn_slowpath_common+0x68/0x88) [] (warn_slowpath_common) from [] (warn_slowpath_null+0x1c/0x24) [] (warn_slowpath_null) from [] (__vb2_queue_cancel+0x1a0/0x218) [] (__vb2_queue_cancel) from [] (vb2_queue_release+0x14/0x24) [] (vb2_queue_release) from [] (vpif_release+0x60/0x230) [] (vpif_release) from [] (v4l2_release+0x34/0x74) [] (v4l2_release) from [] (__fput+0x80/0x224) [] (__fput) from [] (task_work_run+0xa0/0xd0) [] (task_work_run) from [] (do_exit+0x244/0x918) [] (do_exit) from [] (do_group_exit+0x48/0xdc) [] (do_group_exit) from [] (get_signal_to_deliver+0x2a0/0x5bc) [] (get_signal_to_deliver) from [] (do_signal+0x78/0x3a0) [] (do_signal) from [] (do_work_pending+0xa4/0xb4) [] (do_work_pending) from [] (work_pending+0xc/0x20) ---[ end trace 5faa75e8c2f8a6a1 ]--- ------------[ cut here ]------------ WARNING: CPU: 0 PID: 2049 at drivers/media/v4l2-core/videobuf2-core.c:1095 vb2_buffer_done+0x1e0/0x224() Modules linked in: CPU: 0 PID: 2049 Comm: vpif_capture Tainted: G W 3.14.0-rc5-00414-ged97a6f #89 [] (unwind_backtrace) from [] (show_stack+0x10/0x14) [] (show_stack) from [] (warn_slowpath_common+0x68/0x88) [] (warn_slowpath_common) from [] (warn_slowpath_null+0x1c/0x24) [] (warn_slowpath_null) from [] (vb2_buffer_done+0x1e0/0x224) [] (vb2_buffer_done) from [] (__vb2_queue_cancel+0x1d0/0x218) [] (__vb2_queue_cancel) from [] (vb2_queue_release+0x14/0x24) [] (vb2_queue_release) from [] (vpif_release+0x60/0x230) [] (vpif_release) from [] (v4l2_release+0x34/0x74) [] (v4l2_release) from [] (__fput+0x80/0x224) [] (__fput) from [] (task_work_run+0xa0/0xd0) [] (task_work_run) from [] (do_exit+0x244/0x918) [] (do_exit) from [] (do_group_exit+0x48/0xdc) [] (do_group_exit) from [] (get_signal_to_deliver+0x2a0/0x5bc) [] (get_signal_to_deliver) from [] (do_signal+0x78/0x3a0) [] (do_signal) from [] (do_work_pending+0xa4/0xb4) [] (do_work_pending) from [] (work_pending+0xc/0x20) ---[ end trace 5faa75e8c2f8a6a2 ]--- Signed-off-by: Lad, Prabhakar --- drivers/media/platform/davinci/vpif_capture.c | 34 +++++++++++++++++-------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c index 756da78..8dea0b8 100644 --- a/drivers/media/platform/davinci/vpif_capture.c +++ b/drivers/media/platform/davinci/vpif_capture.c @@ -358,8 +358,31 @@ static int vpif_stop_streaming(struct vb2_queue *vq) common = &ch->common[VPIF_VIDEO_INDEX]; + /* Disable channel as per its device type and channel id */ + if (VPIF_CHANNEL0_VIDEO == ch->channel_id) { + enable_channel0(0); + channel0_intr_enable(0); + } + if ((VPIF_CHANNEL1_VIDEO == ch->channel_id) || + (2 == common->started)) { + enable_channel1(0); + channel1_intr_enable(0); + } + common->started = 0; + /* release all active buffers */ spin_lock_irqsave(&common->irqlock, flags); + if (common->cur_frm == common->next_frm) { + vb2_buffer_done(&common->cur_frm->vb, VB2_BUF_STATE_ERROR); + } else { + if (common->cur_frm != NULL) + vb2_buffer_done(&common->cur_frm->vb, + VB2_BUF_STATE_ERROR); + if (common->next_frm != NULL) + vb2_buffer_done(&common->next_frm->vb, + VB2_BUF_STATE_ERROR); + } + while (!list_empty(&common->dma_queue)) { common->next_frm = list_entry(common->dma_queue.next, struct vpif_cap_buffer, list); @@ -933,17 +956,6 @@ static int vpif_release(struct file *filep) if (fh->io_allowed[VPIF_VIDEO_INDEX]) { /* Reset io_usrs member of channel object */ common->io_usrs = 0; - /* Disable channel as per its device type and channel id */ - if (VPIF_CHANNEL0_VIDEO == ch->channel_id) { - enable_channel0(0); - channel0_intr_enable(0); - } - if ((VPIF_CHANNEL1_VIDEO == ch->channel_id) || - (2 == common->started)) { - enable_channel1(0); - channel1_intr_enable(0); - } - common->started = 0; /* Free buffers allocated */ vb2_queue_release(&common->buffer_queue); vb2_dma_contig_cleanup_ctx(common->alloc_ctx);