From patchwork Tue Jul 8 09:41:12 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Molton X-Patchwork-Id: 4503421 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 85369BEEAA for ; Tue, 8 Jul 2014 09:41:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C3FB020158 for ; Tue, 8 Jul 2014 09:41:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id ECA0820173 for ; Tue, 8 Jul 2014 09:41:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753785AbaGHJld (ORCPT ); Tue, 8 Jul 2014 05:41:33 -0400 Received: from ducie-dc1.codethink.co.uk ([185.25.241.215]:37451 "EHLO ducie-dc1.codethink.co.uk" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1753465AbaGHJlb (ORCPT ); Tue, 8 Jul 2014 05:41:31 -0400 Received: from localhost (localhost [127.0.0.1]) by ducie-dc1.codethink.co.uk (Postfix) with ESMTP id 5CCCA46EBB5; Tue, 8 Jul 2014 10:41:30 +0100 (BST) X-Virus-Scanned: Debian amavisd-new at ducie-dc1.codethink.co.uk Received: from ducie-dc1.codethink.co.uk ([127.0.0.1]) by localhost (ducie-dc1.codethink.co.uk [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ly0Cus02FZGu; Tue, 8 Jul 2014 10:41:25 +0100 (BST) Received: from snark.dyn.ducie.codethink.co.uk (snark.dyn.ducie.codethink.co.uk [10.24.1.196]) by ducie-dc1.codethink.co.uk (Postfix) with ESMTPS id 1A6D946DBDD; Tue, 8 Jul 2014 10:41:19 +0100 (BST) Received: from ian by snark.dyn.ducie.codethink.co.uk with local (Exim 4.82) (envelope-from ) id 1X4Rtl-0001zx-3d; Tue, 08 Jul 2014 10:41:17 +0100 From: Ian Molton To: linux-media@vger.kernel.org Cc: linux-kernel@lists.codethink.co.uk, ian.molton@codethink.co.uk, g.liakhovetski@gmx.de, m.chehab@samsung.com, vladimir.barinov@cogentembedded.com, magnus.damm@gmail.com, horms@verge.net.au, linux-sh@vger.kernel.org Subject: [PATCH 2/4] media: rcar_vin: Ensure all in-flight buffers are returned to error state before stopping. Date: Tue, 8 Jul 2014 10:41:12 +0100 Message-Id: <1404812474-7627-3-git-send-email-ian.molton@codethink.co.uk> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1404812474-7627-1-git-send-email-ian.molton@codethink.co.uk> References: <1404812474-7627-1-git-send-email-ian.molton@codethink.co.uk> 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 Videobuf2 complains about buffers that are still marked ACTIVE (in use by the driver) following a call to stop_streaming(). This patch returns all active buffers to state ERROR prior to stopping. Note: this introduces a (non fatal) race condition as the stream is not guaranteed to be stopped at this point. Signed-off-by: Ian Molton Signed-off-by: William Towle --- drivers/media/platform/soc_camera/rcar_vin.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/media/platform/soc_camera/rcar_vin.c b/drivers/media/platform/soc_camera/rcar_vin.c index 7154500..06ce705 100644 --- a/drivers/media/platform/soc_camera/rcar_vin.c +++ b/drivers/media/platform/soc_camera/rcar_vin.c @@ -513,8 +513,14 @@ static void rcar_vin_stop_streaming(struct vb2_queue *vq) struct soc_camera_host *ici = to_soc_camera_host(icd->parent); struct rcar_vin_priv *priv = ici->priv; struct list_head *buf_head, *tmp; + int i; spin_lock_irq(&priv->lock); + + for (i = 0; i < vq->num_buffers; ++i) + if (vq->bufs[i]->state == VB2_BUF_STATE_ACTIVE) + vb2_buffer_done(vq->bufs[i], VB2_BUF_STATE_ERROR); + list_for_each_safe(buf_head, tmp, &priv->capture) list_del_init(buf_head); spin_unlock_irq(&priv->lock);