From patchwork Thu Sep 7 18:42:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Padovan X-Patchwork-Id: 9942665 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 8EFDE602CC for ; Thu, 7 Sep 2017 18:42:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8885B287FA for ; Thu, 7 Sep 2017 18:42:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7D362287FD; Thu, 7 Sep 2017 18:42:41 +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=ham 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 29B2C287FA for ; Thu, 7 Sep 2017 18:42:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755875AbdIGSmi (ORCPT ); Thu, 7 Sep 2017 14:42:38 -0400 Received: from mail-qk0-f195.google.com ([209.85.220.195]:38252 "EHLO mail-qk0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755868AbdIGSmh (ORCPT ); Thu, 7 Sep 2017 14:42:37 -0400 Received: by mail-qk0-f195.google.com with SMTP id c69so301042qke.5; Thu, 07 Sep 2017 11:42:36 -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=bCqh8vqX8keCaoNpZWg+somu1PTb0rUGoGgvyjlXoV0=; b=TqgT4N2k096VUXbE7CFl0XjAZ3giU0zmUSpigzOXv9IEer5FbCcHgv6OxP5v9JM8KY cUS5YHDjPV5w1snhN3oyMUaVNeFvCxberkLk61k73rAvf4PQX6gCP56CltEujmVzIeuL j1l0nLwaZHabNsgvsT5RAYYqA+6/6WVn6gmvw15uBZFOJVbe2mF2JLvLsV9c+cUNIvXC kdvewBR6LoXc6vazGFTusLwdU8t/4zLN0IRwB2xsRhqLkLJMxs4zNGPbDrQck4m0vCK/ k8pS8ucBtOtnw12jU4amM3IKqWvvyjqEnFbAzw4d3+llNmThgRhmLTmjofj4CR/ksS+G iArg== X-Gm-Message-State: AHPjjUgBVfKTbEdAKLHt14Xfq276+BUYPTME0E1qDAp1b8m2TQIuwd+B 3LXzu31UK0qb/0nsIyc= X-Google-Smtp-Source: AOwi7QA6I5ZrkPk4kH9k/u6FCLOA8fRlS5nRKVRb59qtnV7rSwjHFspRl+y9oqOUcYAPAEW6JDQJtA== X-Received: by 10.55.215.140 with SMTP id t12mr376772qkt.61.1504809756074; Thu, 07 Sep 2017 11:42:36 -0700 (PDT) Received: from localhost.localdomain ([187.10.21.246]) by smtp.gmail.com with ESMTPSA id v30sm213216qtg.70.2017.09.07.11.42.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 07 Sep 2017 11:42:35 -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 01/15] [media] v4l: Document explicit synchronization behaviour Date: Thu, 7 Sep 2017 15:42:12 -0300 Message-Id: <20170907184226.27482-2-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 Add section to VIDIOC_QBUF about it v2: - mention that fences are files (Hans) - rework for the new API Signed-off-by: Gustavo Padovan --- Documentation/media/uapi/v4l/vidioc-qbuf.rst | 31 ++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/Documentation/media/uapi/v4l/vidioc-qbuf.rst b/Documentation/media/uapi/v4l/vidioc-qbuf.rst index 1f3612637200..fae0b1431672 100644 --- a/Documentation/media/uapi/v4l/vidioc-qbuf.rst +++ b/Documentation/media/uapi/v4l/vidioc-qbuf.rst @@ -117,6 +117,37 @@ immediately with an ``EAGAIN`` error code when no buffer is available. The struct :c:type:`v4l2_buffer` structure is specified in :ref:`buffer`. +Explicit Synchronization +------------------------ + +Explicit Synchronization allows us to control the synchronization of +shared buffers from userspace by passing fences to the kernel and/or +receiving them from it. Fences passed to the kernel are named in-fences and +the kernel should wait them to signal before using the buffer, i.e., queueing +it to the driver. On the other side, the kernel can create out-fences for the +buffers it queues to the drivers, out-fences signal when the driver is +finished with buffer, that is the buffer is ready. The fence are represented +by file and passed as file descriptor to userspace. + +The in-fences are communicated to the kernel at the ``VIDIOC_QBUF`` ioctl +using the ``V4L2_BUF_FLAG_IN_FENCE`` buffer +flags and the `fence_fd` field. If an in-fence needs to be passed to the kernel, +`fence_fd` should be set to the fence file descriptor number and the +``V4L2_BUF_FLAG_IN_FENCE`` should be set as well. Failure to set both will +cause ``VIDIOC_QBUF`` to return with error. + +To get a out-fence back from V4L2 the ``V4L2_BUF_FLAG_OUT_FENCE`` flag should +be set to notify it that the next queued buffer should have a fence attached to +it. That means the out-fence may not be associated with the buffer in the +current ``VIDIOC_QBUF`` ioctl call because the ordering in which videobuf2 core +queues the buffers to the drivers can't be guaranteed. To become aware of the +of the next queued buffer and the out-fence attached to it the +``V4L2_EVENT_BUF_QUEUED`` event should be used. It will trigger an event +for every buffer queued to the V4L2 driver. + +At streamoff the out-fences will either signal normally if the drivers wait +for the operations on the buffers to finish or signal with error if the +driver cancel the pending operations. Return Value ============