From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8C4B9C433E9 for ; Tue, 2 Mar 2021 07:46:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 48BAA64DE5 for ; Tue, 2 Mar 2021 07:46:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1576114AbhCBEYK (ORCPT ); Mon, 1 Mar 2021 23:24:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377618AbhCBAsC (ORCPT ); Mon, 1 Mar 2021 19:48:02 -0500 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 716A1C0617AA for ; Mon, 1 Mar 2021 16:46:55 -0800 (PST) Received: by mail-pl1-x62d.google.com with SMTP id s16so10985669plr.9 for ; Mon, 01 Mar 2021 16:46:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+FAmCKsCOBJdKXgPGLujQKDpr0G3L68FXBdpk0I3uZU=; b=DCzZ3ns0osFNMB4XWRWtCNENHbfmbNB0cDqNm2JpKGyDCpXTs8Q8/9AnPtDbFcgkBW Qvux+qblZvARxGQQpCsncrV3q3uZzq7AD8C41HWCdh6d6HnCdr0o9/9kIvf5qs559mwK J26WTakqPT0qmb+NqSkxMz11jmQFJ5YF2Bpng= 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:mime-version:content-transfer-encoding; bh=+FAmCKsCOBJdKXgPGLujQKDpr0G3L68FXBdpk0I3uZU=; b=pt7WHHP8bKGAuFtFQ0G2lYVTTDvnKcVtMK9gjq73K4kQMuvJe7nIsi2gM8RSyl9aMb 9dpHE4nnN00EOk11Hd3Cdl40qSfTgR1zWv+bWzzcOdgtRtjm/N26zaVg0+8nJmTELJUX eDk4P/sZ9azzz2FTvyjKdiBD09mcZMJTA8P+IOwqoSmLRN1WGR/5bXYwhvF0rWx+xnok xjVDNYZUEyPh0VoHw9m1Z/N33ZZArjbSbMxt/n/eW9avootrkHrUdCfvI4+9pifELDfd EPr1rGH1gBLLbXbNBDRw/3Iab9LRZIpaHtu78Ve2s+Wls43rUCq0M9DYK2jiEQHzjKwb HnFw== X-Gm-Message-State: AOAM530TDhZdHB2MiMDRVbTBz2a2PfXOmkeo0GADxiRR9j2gxw71AvLQ Vq1WZVZvuC42QlHpHe6tPq0rKg== X-Google-Smtp-Source: ABdhPJx53LLc4qror9FCkbzXZdiKhQAAtR43uG+4pFc5T6Xw5uiDOYCFwUQtnS0/cowEDcmjPH91AQ== X-Received: by 2002:a17:90a:5b11:: with SMTP id o17mr1675744pji.32.1614646015054; Mon, 01 Mar 2021 16:46:55 -0800 (PST) Received: from senozhatsky.flets-east.jp ([2409:10:2e40:5100:d5d7:1a61:2cdf:273c]) by smtp.gmail.com with ESMTPSA id b14sm678881pji.14.2021.03.01.16.46.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Mar 2021 16:46:54 -0800 (PST) From: Sergey Senozhatsky To: Tomasz Figa , Hans Verkuil Cc: Christoph Hellwig , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Sergey Senozhatsky Subject: [PATCH 5/8] videobuf2: add V4L2_FLAG_MEMORY_NON_COHERENT flag Date: Tue, 2 Mar 2021 09:46:21 +0900 Message-Id: <20210302004624.31294-6-senozhatsky@chromium.org> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog In-Reply-To: <20210302004624.31294-1-senozhatsky@chromium.org> References: <20210302004624.31294-1-senozhatsky@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org By setting or clearing V4L2_FLAG_MEMORY_NON_COHERENT flag user-space should be able to hint vb2 that either a non-coherent (if supported) or coherent memory should be used for the buffer allocation. The patch set also adds a corresponding capability flag: fill_buf_caps() reports V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS when queue supports user-space cache management hints. Signed-off-by: Sergey Senozhatsky --- .../userspace-api/media/v4l/buffer.rst | 40 ++++++++++++++++++- .../media/v4l/vidioc-reqbufs.rst | 5 ++- include/uapi/linux/videodev2.h | 2 + 3 files changed, 43 insertions(+), 4 deletions(-) diff --git a/Documentation/userspace-api/media/v4l/buffer.rst b/Documentation/userspace-api/media/v4l/buffer.rst index 1b0fdc160533..a39852d6174f 100644 --- a/Documentation/userspace-api/media/v4l/buffer.rst +++ b/Documentation/userspace-api/media/v4l/buffer.rst @@ -676,8 +676,6 @@ Buffer Flags \normalsize -.. _memory-flags: - enum v4l2_memory ================ @@ -701,6 +699,44 @@ enum v4l2_memory - 4 - The buffer is used for :ref:`DMA shared buffer ` I/O. +.. _memory-flags: + +Memory Consistency Flags +------------------------ + +.. raw:: latex + + \small + +.. tabularcolumns:: |p{7.0cm}|p{2.1cm}|p{8.4cm}| + +.. cssclass:: longtable + +.. flat-table:: + :header-rows: 0 + :stub-columns: 0 + :widths: 3 1 4 + + * .. _`V4L2-FLAG-MEMORY-NON-COHERENT`: + + - ``V4L2_FLAG_MEMORY_NON_COHERENT`` + - 0x00000001 + - A buffer is allocated either in coherent (it will be automatically + coherent between the CPU and the bus) or non-coherent memory. The + latter can provide performance gains, for instance the CPU cache + sync/flush operations can be avoided if the buffer is accessed by the + corresponding device only and the CPU does not read/write to/from that + buffer. However, this requires extra care from the driver -- it must + guarantee memory consistency by issuing a cache flush/sync when + consistency is needed. If this flag is set V4L2 will attempt to + allocate the buffer in non-coherent memory. The flag takes effect + only if the buffer is used for :ref:`memory mapping ` I/O and the + queue reports the :ref:`V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS + ` capability. + +.. raw:: latex + + \normalsize Timecodes ========= diff --git a/Documentation/userspace-api/media/v4l/vidioc-reqbufs.rst b/Documentation/userspace-api/media/v4l/vidioc-reqbufs.rst index c1c88e00b106..950e7ec1aac5 100644 --- a/Documentation/userspace-api/media/v4l/vidioc-reqbufs.rst +++ b/Documentation/userspace-api/media/v4l/vidioc-reqbufs.rst @@ -154,8 +154,9 @@ aborting or finishing any DMA in progress, an implicit - This capability is set by the driver to indicate that the queue supports cache and memory management hints. However, it's only valid when the queue is used for :ref:`memory mapping ` streaming I/O. See - :ref:`V4L2_BUF_FLAG_NO_CACHE_INVALIDATE ` and - :ref:`V4L2_BUF_FLAG_NO_CACHE_CLEAN `. + :ref:`V4L2_BUF_FLAG_NO_CACHE_INVALIDATE `, + :ref:`V4L2_BUF_FLAG_NO_CACHE_CLEAN ` and + :ref:`V4L2_FLAG_MEMORY_NON_COHERENT `. Return Value ============ diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h index 79dbde3bcf8d..b1d4171fe50b 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -954,6 +954,8 @@ struct v4l2_requestbuffers { __u32 reserved[1]; }; +#define V4L2_FLAG_MEMORY_NON_COHERENT (1 << 0) + /* capabilities for struct v4l2_requestbuffers and v4l2_create_buffers */ #define V4L2_BUF_CAP_SUPPORTS_MMAP (1 << 0) #define V4L2_BUF_CAP_SUPPORTS_USERPTR (1 << 1) -- 2.30.1.766.gb4fecdf3b7-goog