From patchwork Tue Sep 8 10:33:48 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 7139871 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 F20D09F402 for ; Tue, 8 Sep 2015 10:36:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0859D205D6 for ; Tue, 8 Sep 2015 10:36:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 08CE62072E for ; Tue, 8 Sep 2015 10:36:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754401AbbIHKgF (ORCPT ); Tue, 8 Sep 2015 06:36:05 -0400 Received: from mga14.intel.com ([192.55.52.115]:24329 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754246AbbIHKf5 (ORCPT ); Tue, 8 Sep 2015 06:35:57 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP; 08 Sep 2015 03:35:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,489,1437462000"; d="scan'208";a="784920522" Received: from paasikivi.fi.intel.com ([10.237.72.42]) by fmsmga001.fm.intel.com with ESMTP; 08 Sep 2015 03:35:54 -0700 Received: from nauris.fi.intel.com (nauris.localdomain [192.168.240.2]) by paasikivi.fi.intel.com (Postfix) with ESMTP id 54DA120754; Tue, 8 Sep 2015 13:35:51 +0300 (EEST) Received: by nauris.fi.intel.com (Postfix, from userid 1000) id 9BDF7201EF; Tue, 8 Sep 2015 13:34:16 +0300 (EEST) From: Sakari Ailus To: linux-media@vger.kernel.org Cc: pawel@osciak.com, m.szyprowski@samsung.com, kyungmin.park@samsung.com, hverkuil@xs4all.nl Subject: [RFC 04/11] v4l: Unify cache management hint buffer flags Date: Tue, 8 Sep 2015 13:33:48 +0300 Message-Id: <1441708435-12736-5-git-send-email-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.1.0.231.g7484e3b In-Reply-To: <1441708435-12736-1-git-send-email-sakari.ailus@linux.intel.com> References: <1441708435-12736-1-git-send-email-sakari.ailus@linux.intel.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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 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 --- Documentation/DocBook/media/v4l/io.xml | 25 +++++++++++-------------- include/trace/events/v4l2.h | 3 +-- include/uapi/linux/videodev2.h | 7 +++++-- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/Documentation/DocBook/media/v4l/io.xml b/Documentation/DocBook/media/v4l/io.xml index 7bbc2a4..4facd63 100644 --- a/Documentation/DocBook/media/v4l/io.xml +++ b/Documentation/DocBook/media/v4l/io.xml @@ -1112,21 +1112,18 @@ application. Drivers set or clear this flag when the linkend="vidioc-qbuf">VIDIOC_DQBUF ioctl is called. - 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 - 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 VIDIOC_DQBUF + and VIDIOC_QBUF IOCTLs. + The flag has no effect on some devices / architectures. + V4L2_BUF_FLAG_LAST diff --git a/include/trace/events/v4l2.h b/include/trace/events/v4l2.h index dbf017b..4cee91d 100644 --- a/include/trace/events/v4l2.h +++ b/include/trace/events/v4l2.h @@ -78,8 +78,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 3228fbe..8d85aac 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -875,8 +875,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