From patchwork Thu Apr 13 07:57:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 9679197 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 8883760326 for ; Thu, 13 Apr 2017 11:18:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7D2BD2860E for ; Thu, 13 Apr 2017 11:18:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 71E062862E; Thu, 13 Apr 2017 11:18:21 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0DDED2860E for ; Thu, 13 Apr 2017 11:18:21 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3B24C6E882; Thu, 13 Apr 2017 11:17:25 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTPS id 123AA6E7E1 for ; Thu, 13 Apr 2017 07:58:02 +0000 (UTC) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Apr 2017 00:57:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,194,1488873600"; d="scan'208";a="73518666" Received: from paasikivi.fi.intel.com ([10.237.72.42]) by orsmga002.jf.intel.com with ESMTP; 13 Apr 2017 00:57:55 -0700 Received: from nauris.fi.intel.com (nauris.localdomain [192.168.240.2]) by paasikivi.fi.intel.com (Postfix) with ESMTP id 4BDC220E68; Thu, 13 Apr 2017 10:57:54 +0300 (EEST) Received: by nauris.fi.intel.com (Postfix, from userid 1000) id BAB9E201AB; Thu, 13 Apr 2017 10:57:19 +0300 (EEST) From: Sakari Ailus To: linux-media@vger.kernel.org Subject: [RFC v3 04/14] v4l: Unify cache management hint buffer flags Date: Thu, 13 Apr 2017 10:57:09 +0300 Message-Id: <1492070239-21532-5-git-send-email-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1492070239-21532-1-git-send-email-sakari.ailus@linux.intel.com> References: <1492070239-21532-1-git-send-email-sakari.ailus@linux.intel.com> X-Mailman-Approved-At: Thu, 13 Apr 2017 11:17:04 +0000 Cc: daniel.vetter@ffwll.ch, dri-devel@lists.freedesktop.org, hverkuil@xs4all.nl, kyungmin.park@samsung.com, posciak@chromium.org, m.szyprowski@samsung.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP The V4L2_BUF_FLAG_NO_CACHE_INVALIDATE and V4L2_BUF_FLAG_NO_CACHE_CLEAN buffer flags are currently not used by the kernel. Replace the definitions by a single V4L2_BUF_FLAG_NO_CACHE_SYNC flag to be used by further patches. Different cache architectures should not be visible to the user space which can make no meaningful use of the differences anyway. In case a device can make use of non-coherent memory accesses, the necessary cache operations depend on the CPU architecture and the buffer type, not the requests of the user. The cache operation itself may be skipped on the user's request which was the purpose of the two flags. On ARM the invalidate and clean are separate operations whereas on x86(-64) the two are a single operation (flush). Whether the hardware uses the buffer for reading (V4L2_BUF_TYPE_*_OUTPUT*) or writing (V4L2_BUF_TYPE_*CAPTURE*) already defines the required cache operation (clean and invalidate, respectively). No user input is required. Signed-off-by: Sakari Ailus Acked-by: Hans Verkuil --- Documentation/media/uapi/v4l/buffer.rst | 24 ++++++++-------------- .../media/uapi/v4l/vidioc-prepare-buf.rst | 5 ++--- include/trace/events/v4l2.h | 3 +-- include/uapi/linux/videodev2.h | 7 +++++-- 4 files changed, 17 insertions(+), 22 deletions(-) diff --git a/Documentation/media/uapi/v4l/buffer.rst b/Documentation/media/uapi/v4l/buffer.rst index ac58966..601c3e9 100644 --- a/Documentation/media/uapi/v4l/buffer.rst +++ b/Documentation/media/uapi/v4l/buffer.rst @@ -437,23 +437,17 @@ Buffer Flags :ref:`VIDIOC_PREPARE_BUF `, :ref:`VIDIOC_QBUF` or :ref:`VIDIOC_DQBUF ` ioctl is called. - * .. _`V4L2-BUF-FLAG-NO-CACHE-INVALIDATE`: + * .. _`V4L2-BUF-FLAG-NO-CACHE-SYNC`: - - ``V4L2_BUF_FLAG_NO_CACHE_INVALIDATE`` + - ``V4L2_BUF_FLAG_NO_CACHE_SYNC`` - 0x00000800 - - Caches do not have to be invalidated for this buffer. Typically - applications shall use this flag if the data captured in the - buffer is not going to be touched by the CPU, instead the buffer - will, probably, be passed on to a DMA-capable hardware unit for - further processing or output. - * .. _`V4L2-BUF-FLAG-NO-CACHE-CLEAN`: - - - ``V4L2_BUF_FLAG_NO_CACHE_CLEAN`` - - 0x00001000 - - Caches do not have to be cleaned for this buffer. Typically - applications shall use this flag for output buffers if the data in - this buffer has not been created by the CPU but by some - DMA-capable unit, in which case caches have not been used. + - Do not perform CPU cache synchronisation operations when the buffer is + queued or dequeued. The user is responsible for the correct use of + this flag. It should be only used when the buffer is not accessed + using the CPU, e.g. the buffer is written to by a hardware block and + then read by another one, in which case the flag should be set in both + :ref:`VIDIOC_QBUF` and :ref:`VIDIOC_DQBUF` ioctls. The flag has no + effect on some devices / architectures. * .. _`V4L2-BUF-FLAG-LAST`: - ``V4L2_BUF_FLAG_LAST`` diff --git a/Documentation/media/uapi/v4l/vidioc-prepare-buf.rst b/Documentation/media/uapi/v4l/vidioc-prepare-buf.rst index bdcfd9f..80aeb7e 100644 --- a/Documentation/media/uapi/v4l/vidioc-prepare-buf.rst +++ b/Documentation/media/uapi/v4l/vidioc-prepare-buf.rst @@ -36,9 +36,8 @@ pass ownership of the buffer to the driver before actually enqueuing it, using the :ref:`VIDIOC_QBUF` ioctl, and to prepare it for future I/O. Such preparations may include cache invalidation or cleaning. Performing them in advance saves time during the actual I/O. In case such cache -operations are not required, the application can use one of -``V4L2_BUF_FLAG_NO_CACHE_INVALIDATE`` and -``V4L2_BUF_FLAG_NO_CACHE_CLEAN`` flags to skip the respective step. +operations are not required, the application can use the +``V4L2_BUF_FLAG_NO_CACHE_SYNC`` flag to skip the cache synchronization step. The struct :c:type:`v4l2_buffer` structure is specified in :ref:`buffer`. diff --git a/include/trace/events/v4l2.h b/include/trace/events/v4l2.h index ee7754c..fb9ad7b 100644 --- a/include/trace/events/v4l2.h +++ b/include/trace/events/v4l2.h @@ -80,8 +80,7 @@ SHOW_FIELD { V4L2_BUF_FLAG_ERROR, "ERROR" }, \ { V4L2_BUF_FLAG_TIMECODE, "TIMECODE" }, \ { V4L2_BUF_FLAG_PREPARED, "PREPARED" }, \ - { V4L2_BUF_FLAG_NO_CACHE_INVALIDATE, "NO_CACHE_INVALIDATE" }, \ - { V4L2_BUF_FLAG_NO_CACHE_CLEAN, "NO_CACHE_CLEAN" }, \ + { V4L2_BUF_FLAG_NO_CACHE_SYNC, "NO_CACHE_SYNC" }, \ { V4L2_BUF_FLAG_TIMESTAMP_MASK, "TIMESTAMP_MASK" }, \ { V4L2_BUF_FLAG_TIMESTAMP_UNKNOWN, "TIMESTAMP_UNKNOWN" }, \ { V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC, "TIMESTAMP_MONOTONIC" }, \ diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h index 16edbd9..cfe145f 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -934,8 +934,11 @@ struct v4l2_buffer { #define V4L2_BUF_FLAG_TIMECODE 0x00000100 /* Buffer is prepared for queuing */ #define V4L2_BUF_FLAG_PREPARED 0x00000400 -/* Cache handling flags */ -#define V4L2_BUF_FLAG_NO_CACHE_INVALIDATE 0x00000800 +/* Cache sync hint */ +#define V4L2_BUF_FLAG_NO_CACHE_SYNC 0x00000800 +/* DEPRECATED. THIS WILL BE REMOVED IN THE FUTURE! */ +#define V4L2_BUF_FLAG_NO_CACHE_INVALIDATE V4L2_BUF_FLAG_NO_CACHE_SYNC +/* DEPRECATED. THIS WILL BE REMOVED IN THE FUTURE! */ #define V4L2_BUF_FLAG_NO_CACHE_CLEAN 0x00001000 /* Timestamp type */ #define V4L2_BUF_FLAG_TIMESTAMP_MASK 0x0000e000