From patchwork Wed Jul 29 15:29:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antti Palosaari X-Patchwork-Id: 6894961 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B03CD9F358 for ; Wed, 29 Jul 2015 15:29:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C3E3320646 for ; Wed, 29 Jul 2015 15:29:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E7FF420607 for ; Wed, 29 Jul 2015 15:29:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752025AbbG2P32 (ORCPT ); Wed, 29 Jul 2015 11:29:28 -0400 Received: from mail.kapsi.fi ([217.30.184.167]:40528 "EHLO mail.kapsi.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750892AbbG2P31 (ORCPT ); Wed, 29 Jul 2015 11:29:27 -0400 Received: from 85-23-164-218.bb.dnainternet.fi ([85.23.164.218] helo=localhost.localdomain.localdomain) by mail.kapsi.fi with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1ZKTIL-0004Vj-DD; Wed, 29 Jul 2015 18:29:25 +0300 From: Antti Palosaari To: linux-media@vger.kernel.org Cc: Antti Palosaari , Hans Verkuil Subject: [PATCH] vb2: revert: vb2: allow requeuing buffers while streaming Date: Wed, 29 Jul 2015 18:29:05 +0300 Message-Id: <1438183745-2652-1-git-send-email-crope@iki.fi> X-Mailer: git-send-email 2.4.3 X-SA-Exim-Connect-IP: 85.23.164.218 X-SA-Exim-Mail-From: crope@iki.fi X-SA-Exim-Scanned: No (on mail.kapsi.fi); SAEximRunCond expanded to false Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 commit ce0eff016f7272faa6dc6eec722b1ca1970ff9aa [media] vb2: allow requeuing buffers while streaming That commit causes buf_queue() called on infinity loop when start_streaming() returns error. On that case resources are eaten quickly and machine crashes. Cc: Hans Verkuil Signed-off-by: Antti Palosaari --- drivers/media/v4l2-core/videobuf2-core.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c index 93b3154..e7b4f6a 100644 --- a/drivers/media/v4l2-core/videobuf2-core.c +++ b/drivers/media/v4l2-core/videobuf2-core.c @@ -182,7 +182,6 @@ module_param(debug, int, 0644); V4L2_BUF_FLAG_KEYFRAME | V4L2_BUF_FLAG_TIMECODE) static void __vb2_queue_cancel(struct vb2_queue *q); -static void __enqueue_in_driver(struct vb2_buffer *vb); /** * __vb2_buf_mem_alloc() - allocate video memory for the given buffer @@ -1154,9 +1153,8 @@ EXPORT_SYMBOL_GPL(vb2_plane_cookie); /** * vb2_buffer_done() - inform videobuf that an operation on a buffer is finished * @vb: vb2_buffer returned from the driver - * @state: either VB2_BUF_STATE_DONE if the operation finished successfully, - * VB2_BUF_STATE_ERROR if the operation finished with an error or - * VB2_BUF_STATE_QUEUED if the driver wants to requeue buffers. + * @state: either VB2_BUF_STATE_DONE if the operation finished successfully + * or VB2_BUF_STATE_ERROR if the operation finished with an error. * If start_streaming fails then it should return buffers with state * VB2_BUF_STATE_QUEUED to put them back into the queue. * @@ -1207,11 +1205,8 @@ void vb2_buffer_done(struct vb2_buffer *vb, enum vb2_buffer_state state) atomic_dec(&q->owned_by_drv_count); spin_unlock_irqrestore(&q->done_lock, flags); - if (state == VB2_BUF_STATE_QUEUED) { - if (q->start_streaming_called) - __enqueue_in_driver(vb); + if (state == VB2_BUF_STATE_QUEUED) return; - } /* Inform any processes that may be waiting for buffers */ wake_up(&q->done_wq);