From patchwork Thu Sep 7 18:42:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Padovan X-Patchwork-Id: 9942727 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CD44B604D7 for ; Thu, 7 Sep 2017 18:47:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CAF4528802 for ; Thu, 7 Sep 2017 18:47:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BFFEF2880F; Thu, 7 Sep 2017 18:47:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 00FEA28802 for ; Thu, 7 Sep 2017 18:47:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756062AbdIGSql (ORCPT ); Thu, 7 Sep 2017 14:46:41 -0400 Received: from mail-qt0-f196.google.com ([209.85.216.196]:33719 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755548AbdIGSmo (ORCPT ); Thu, 7 Sep 2017 14:42:44 -0400 Received: by mail-qt0-f196.google.com with SMTP id h15so336663qta.0; Thu, 07 Sep 2017 11:42:44 -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=dzL6DosM8Hjs9fpbAyUMffzZLzcd8efT81z/f8gcEOUfiNVgZIDSbkXhBJAHS4zPr8 fgeCYOmMpjNftBEKoUq2b5DWWvLS8kojGK27UwDgRfcFR2kRoORpjHDky0KZURsmOZ7R dnNZBC54FMpZrSL/GsbQcIs4qHloRjQfmQp16Bdz3dmPCwBZZ0ADlPaPzhK9zi0D+IkD /5dZ6cJYt5uBHnCfv/ix6E4qzdDmQ4am0LlkiZJ4lV4Lk1lFsEaMQF9iGdNa+FvIILbQ 5yEZKLXVxzAdlnJnKrdP85BKcVGSBrnkCaxxqtcua6MDAVHiqsppBfHv2+n3yeRuNUPx 5KVg== X-Gm-Message-State: AHPjjUj8pYiKRgItpQIL0qhbZDZcB98xWgx1pmZ/EN3IKJ4jVAwaEsJ+ AUKn5Bk/aahoO0DsTSs= X-Google-Smtp-Source: AOwi7QCGyvVEXDOHwNCS0fhX6g20QMXp/n97j4eetljC9u9F3zKmiDz+EbOp5vTiG0MEps2IS7yKZA== X-Received: by 10.200.20.132 with SMTP id l4mr507994qtj.10.1504809763262; Thu, 07 Sep 2017 11:42:43 -0700 (PDT) Received: from localhost.localdomain ([187.10.21.246]) by smtp.gmail.com with ESMTPSA id v30sm213216qtg.70.2017.09.07.11.42.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 07 Sep 2017 11:42:42 -0700 (PDT) From: Gustavo Padovan To: linux-media@vger.kernel.org Cc: Hans Verkuil , Mauro Carvalho Chehab , Shuah Khan , linux-kernel@vger.kernel.org, Gustavo Padovan Subject: [PATCH v3 03/15] [media] vb2: check earlier if stream can be started Date: Thu, 7 Sep 2017 15:42:14 -0300 Message-Id: <20170907184226.27482-4-gustavo@padovan.org> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170907184226.27482-1-gustavo@padovan.org> References: <20170907184226.27482-1-gustavo@padovan.org> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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; }