From patchwork Tue Aug 5 17:00:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philipp Zabel X-Patchwork-Id: 4680611 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 51F6DC0338 for ; Tue, 5 Aug 2014 17:00:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7642A2018A for ; Tue, 5 Aug 2014 17:00:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 53915201BA for ; Tue, 5 Aug 2014 17:00:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755932AbaHERAh (ORCPT ); Tue, 5 Aug 2014 13:00:37 -0400 Received: from metis.ext.pengutronix.de ([92.198.50.35]:52211 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755635AbaHERAe (ORCPT ); Tue, 5 Aug 2014 13:00:34 -0400 Received: from dude.hi.pengutronix.de ([10.1.0.7] helo=dude.pengutronix.de) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1XEi64-0007Bm-26; Tue, 05 Aug 2014 19:00:24 +0200 From: Philipp Zabel To: linux-media@vger.kernel.org Cc: Mauro Carvalho Chehab , Kamil Debski , kernel@pengutronix.de, Philipp Zabel Subject: [PATCH 05/15] [media] coda: dequeue buffers if start_streaming fails Date: Tue, 5 Aug 2014 19:00:10 +0200 Message-Id: <1407258020-12078-6-git-send-email-p.zabel@pengutronix.de> X-Mailer: git-send-email 2.0.1 In-Reply-To: <1407258020-12078-1-git-send-email-p.zabel@pengutronix.de> References: <1407258020-12078-1-git-send-email-p.zabel@pengutronix.de> X-SA-Exim-Connect-IP: 10.1.0.7 X-SA-Exim-Mail-From: p.zabel@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-media@vger.kernel.org Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 Signed-off-by: Philipp Zabel --- drivers/media/platform/coda/coda-common.c | 34 +++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/drivers/media/platform/coda/coda-common.c b/drivers/media/platform/coda/coda-common.c index 86fc527..1e93889 100644 --- a/drivers/media/platform/coda/coda-common.c +++ b/drivers/media/platform/coda/coda-common.c @@ -1005,6 +1005,7 @@ static int coda_start_streaming(struct vb2_queue *q, unsigned int count) struct coda_ctx *ctx = vb2_get_drv_priv(q); struct v4l2_device *v4l2_dev = &ctx->dev->v4l2_dev; struct coda_q_data *q_data_src, *q_data_dst; + struct vb2_buffer *buf; u32 dst_fourcc; int ret = 0; @@ -1016,17 +1017,23 @@ static int coda_start_streaming(struct vb2_queue *q, unsigned int count) coda_fill_bitstream(ctx); mutex_unlock(&ctx->bitstream_mutex); - if (coda_get_bitstream_payload(ctx) < 512) - return -EINVAL; + if (coda_get_bitstream_payload(ctx) < 512) { + ret = -EINVAL; + goto err; + } } else { - if (count < 1) - return -EINVAL; + if (count < 1) { + ret = -EINVAL; + goto err; + } } ctx->streamon_out = 1; } else { - if (count < 1) - return -EINVAL; + if (count < 1) { + ret = -EINVAL; + goto err; + } ctx->streamon_cap = 1; } @@ -1047,7 +1054,8 @@ static int coda_start_streaming(struct vb2_queue *q, unsigned int count) q_data_dst->fourcc); if (!ctx->codec) { v4l2_err(v4l2_dev, "couldn't tell instance type.\n"); - return -EINVAL; + ret = -EINVAL; + goto err; } ret = ctx->ops->start_streaming(ctx); @@ -1055,11 +1063,21 @@ static int coda_start_streaming(struct vb2_queue *q, unsigned int count) if (ret == -EAGAIN) return 0; else if (ret < 0) - return ret; + goto err; } ctx->initialized = 1; return ret; + +err: + if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) { + while ((buf = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx))) + v4l2_m2m_buf_done(buf, VB2_BUF_STATE_DEQUEUED); + } else { + while ((buf = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx))) + v4l2_m2m_buf_done(buf, VB2_BUF_STATE_DEQUEUED); + } + return ret; } static void coda_stop_streaming(struct vb2_queue *q)