From patchwork Fri Sep 1 01:50:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gustavo F. Padovan" X-Patchwork-Id: 43670 X-Patchwork-Delegate: hverkuil@xs4all.nl Received: from vger.kernel.org ([209.132.180.67]) by www.linuxtv.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dnb6n-0002eG-7Y; Fri, 01 Sep 2017 01:50:57 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751388AbdIABuz (ORCPT + 1 other); Thu, 31 Aug 2017 21:50:55 -0400 Received: from mail-qt0-f196.google.com ([209.85.216.196]:35258 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751351AbdIABuy (ORCPT ); Thu, 31 Aug 2017 21:50:54 -0400 Received: by mail-qt0-f196.google.com with SMTP id u11so1008659qtu.2 for ; Thu, 31 Aug 2017 18:50:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Ec2MBdGZzH5NteE9jUmk/OX7AJiZn/UwYWcAKtgnN7w=; b=midnZbMIyKWta2yvk3OLHll58ShY+HOf4PlnsirSSYqkBS71axq3n5Na2DhSJCp0Jr C/g4Um6K//TbaBjjc7hIgL26sWyzSe+ISsaai7uFAsAdB38Uz+DnbqiDlGdfXbaN7zjk Ma9TILYaPVfUS+81o17wIc3/zENuSPWpdrTYwVq9asthNe8EdNu30qwGnsgfNbmutNhZ dggKLkNMHcNr+eXaWDvv8vRtoqSvlljfWAqTsIsbUwWqDKahOnwp8c7Fq001zejwAvNv 8UvvA00Xnz07rG6G6oDM6AgmuuCWsASWu34s/Vupe2AEwndWx1sV1CedCIjh/OfDDtqS h2ng== X-Gm-Message-State: AHPjjUjWC6o/gvwiqrPPMzxSOc4/W2TyUwLRkAo2m85RNKJIzC4S+m4E wZPvun0bp7z4mvlcPzU= X-Google-Smtp-Source: ADKCNb6mwa37Oh3peh2WSyFSV5RKzdwMU5ebUl3sbmiDnQ6u6LDuZ5NyiWOBkW/n7DVIgCZUKzCUww== X-Received: by 10.200.15.145 with SMTP id b17mr533049qtk.287.1504230653541; Thu, 31 Aug 2017 18:50:53 -0700 (PDT) Received: from localhost.localdomain ([187.10.21.246]) by smtp.gmail.com with ESMTPSA id o17sm6366232qkl.52.2017.08.31.18.50.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Aug 2017 18:50:52 -0700 (PDT) From: Gustavo Padovan To: linux-media@vger.kernel.org Cc: Hans Verkuil , Mauro Carvalho Chehab , Shuah Khan , Gustavo Padovan Subject: [PATCH v2 02/14] [media] vb2: check earlier if stream can be started Date: Thu, 31 Aug 2017 22:50:29 -0300 Message-Id: <20170901015041.7757-3-gustavo@padovan.org> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170901015041.7757-1-gustavo@padovan.org> References: <20170901015041.7757-1-gustavo@padovan.org> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Gustavo Padovan To support explicit synchronization we need to run all operations that can fail before we queue the buffer to the driver. With fences the queueing will be delayed if the fence is not signaled yet and it will be better if such callback do not fail. For that we move the vb2_start_streaming() before the queuing for the buffer may happen. Signed-off-by: Gustavo Padovan --- drivers/media/v4l2-core/videobuf2-core.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c index cb115ba6a1d2..60f8b582396a 100644 --- a/drivers/media/v4l2-core/videobuf2-core.c +++ b/drivers/media/v4l2-core/videobuf2-core.c @@ -1399,29 +1399,27 @@ int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb) trace_vb2_qbuf(q, vb); /* - * If already streaming, give the buffer to driver for processing. - * If not, the buffer will be given to driver on next streamon. - */ - if (q->start_streaming_called) - __enqueue_in_driver(vb); - - /* Fill buffer information for the userspace */ - if (pb) - call_void_bufop(q, fill_user_buffer, vb, pb); - - /* * If streamon has been called, and we haven't yet called * start_streaming() since not enough buffers were queued, and * we now have reached the minimum number of queued buffers, * then we can finally call start_streaming(). + * + * If already streaming, give the buffer to driver for processing. + * If not, the buffer will be given to driver on next streamon. */ if (q->streaming && !q->start_streaming_called && q->queued_count >= q->min_buffers_needed) { ret = vb2_start_streaming(q); if (ret) return ret; + } else if (q->start_streaming_called) { + __enqueue_in_driver(vb); } + /* Fill buffer information for the userspace */ + if (pb) + call_void_bufop(q, fill_user_buffer, vb, pb); + dprintk(2, "qbuf of buffer %d succeeded\n", vb->index); return 0; }