Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4434374ybl; Mon, 3 Feb 2020 18:58:21 -0800 (PST) X-Google-Smtp-Source: APXvYqzG6wRX4zsBJ5C4BrnzySbzzlpZG/tt+oFAgc3Ro47JIg9CfzPH9Eng7XRKCTMYX8suHo+I X-Received: by 2002:a9d:6647:: with SMTP id q7mr21166527otm.35.1580785101494; Mon, 03 Feb 2020 18:58:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580785101; cv=none; d=google.com; s=arc-20160816; b=Oq2Xo/xlbJhuL1t6b7KdZhQqKcLwr8BNkiMLrxMoeDBCSCKzOlyI85zVt/NPAcE1A8 LWb8Te0k7VUs1F1pX1RYORc1oawfwlJBaEH0c+IYEmfOK0L+aYSzFO56uiIVUTcJqDvD K5UKojoJUsykhbLIYl94b9+RYkQQrxgrqPHNSUwPeuw57pyYC2TEN/a/LDeg9ui9DiTG 5C7048S4llWZFs5zc7CvAJvUrZAUih3YGmFosYv8Memw4+tzg2rDOFs5b6AT+2vnHpMY Lr2cHznyVX4LvOJtXp/mT3sxvoDiAsGj5SMgdR1hqE8eSAlz+ySmWXfnx1wE8GuZYpi2 MB1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Icxfnp9HKjOCxxd8LHDLtBzlH++tvRBMGK02TWhaPYI=; b=rb4m6Vvjy7edU8NQ6wEmlIZJ1BQZ5/IWszH8FY19ZzqRSHSRc9CgscwribxqK67LzW zTEPa3qrfuwDgn7rsjf4Aj0dnAmhpqTgTbJ1Lzhtz9BpukN11McdW/iedddAk+apYuem VmMY93x9A9BLnyeFAy5g15vPU1iJgoFhaZchrNVcdGShUM+rdPVwD8sr6drVRGp5ThSA OKomFwsyvCKWpudWDl3NNm3kvogbuvz23H4eo+getcEwUy2ki+4w1/hji3TCScjFJjTR gGexFynY21rHxUKKHmUZfLJ9s8e84J5tEL8mxfgAwtfDVdUaQEdwWysVXi+6tKSGCnjn wxbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=hAKlVKM+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k19si10002329otr.52.2020.02.03.18.58.09; Mon, 03 Feb 2020 18:58:21 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=hAKlVKM+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727225AbgBDC5C (ORCPT + 99 others); Mon, 3 Feb 2020 21:57:02 -0500 Received: from mail-pj1-f65.google.com ([209.85.216.65]:36819 "EHLO mail-pj1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727159AbgBDC5A (ORCPT ); Mon, 3 Feb 2020 21:57:00 -0500 Received: by mail-pj1-f65.google.com with SMTP id gv17so700027pjb.1 for ; Mon, 03 Feb 2020 18:57:00 -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=Icxfnp9HKjOCxxd8LHDLtBzlH++tvRBMGK02TWhaPYI=; b=hAKlVKM+cc2osv8Wzq1OdoAIc0gwS/b7aByJyCTRrUEWILDvQchLX65IYYHuMNs4E8 CDdgtxQC2e//gNJXvwuLkaf1Jc6tsm0AM6UNh8PI1AR7GVWNABSDRdQOvy4qpiV35OHK TF/pS1ub1obJ8GAdEHFN4DuUFdUjCgTQrZDuQ= 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=Icxfnp9HKjOCxxd8LHDLtBzlH++tvRBMGK02TWhaPYI=; b=L30QoG2g7bee9oeSOxA6P4cGodK00y9C7KaZy0ncswDJoVGIe4i6K4f5zIuaDj30Q/ G0+/NREypAH4JEEKK6c0V8zObcE+iwhrmD0/kgSCIkRQkuTNW5le6K6A1quxCxAuxhtt +9SyHm0bSqsfeeqUDRzD2eLRIGSHAdNMigepLedRa65d8svCSFS9+9nKaKY2yx90iIRQ Z37iHYdYx+mEvU92YE8KCHnQ5lD4PJEstLFllI09tfpPbXAEv0xfydhqkNWzLNKgL3xV BK0HkSD1ud3/moKxk3ADNw6zZs3aB+++XAwFZ9/6WLJnleDExDpCNTxdOqA4jzL1+V7v /phA== X-Gm-Message-State: APjAAAVvLTuyXrR1LQKPwdS38q769AQlTjkrtHGN6aGH9qWFLA57BLIy w4nFmD1wylauF8j+6SQcWvX7fQ== X-Received: by 2002:a17:902:8f8a:: with SMTP id z10mr27668871plo.169.1580785019903; Mon, 03 Feb 2020 18:56:59 -0800 (PST) Received: from tigerii.tok.corp.google.com ([2401:fa00:8f:203:5bbb:c872:f2b1:f53b]) by smtp.gmail.com with ESMTPSA id e1sm22491971pfl.98.2020.02.03.18.56.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2020 18:56:59 -0800 (PST) From: Sergey Senozhatsky To: Hans Verkuil , Tomasz Figa , Mauro Carvalho Chehab , Kyungmin Park , Marek Szyprowski Cc: Sakari Ailus , Laurent Pinchart , Pawel Osciak , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Sergey Senozhatsky Subject: [RFC][PATCHv2 03/12] videobuf2: add V4L2_FLAG_MEMORY_NON_CONSISTENT flag Date: Tue, 4 Feb 2020 11:56:32 +0900 Message-Id: <20200204025641.218376-4-senozhatsky@chromium.org> X-Mailer: git-send-email 2.25.0.341.g760bfbb309-goog In-Reply-To: <20200204025641.218376-1-senozhatsky@chromium.org> References: <20200204025641.218376-1-senozhatsky@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org By setting or clearing V4L2_FLAG_MEMORY_NON_CONSISTENT flag user-space should be able to set or clear queue's NON_CONSISTENT ->dma_attrs. Queue's ->dma_attrs are passed to the underlying allocator in __vb2_buf_mem_alloc(), so thus user-space is able to request vb2 buffer's memory to be either consistent (coherent) or non-consistent. Change-Id: Ib333081c482e23c9a89386078293e19c3fd59076 Signed-off-by: Sergey Senozhatsky --- Documentation/media/uapi/v4l/buffer.rst | 27 +++++++++++++++++++++++++ include/uapi/linux/videodev2.h | 2 ++ 2 files changed, 29 insertions(+) diff --git a/Documentation/media/uapi/v4l/buffer.rst b/Documentation/media/uapi/v4l/buffer.rst index 9149b57728e5..af007daf0591 100644 --- a/Documentation/media/uapi/v4l/buffer.rst +++ b/Documentation/media/uapi/v4l/buffer.rst @@ -705,6 +705,33 @@ Buffer Flags .. c:type:: v4l2_memory +Memory Consistency Flags +======================== + +.. tabularcolumns:: |p{7.0cm}|p{2.2cm}|p{8.3cm}| + +.. cssclass:: longtable + +.. flat-table:: + :header-rows: 0 + :stub-columns: 0 + :widths: 3 1 4 + + * .. _`V4L2_FLAG_MEMORY_NON_CONSISTENT`: + + - ``V4L2_FLAG_MEMORY_NON_CONSISTENT`` + - 0x00000001 + - vb2 buffer is allocated either in consistent (it will be automatically + coherent between CPU and bus) or non-consistent memory. The latter + can provide performance gains, for instance CPU cache sync/flush + operations can be avoided if the buffer is accesed by the corresponding + device only and CPU does not read/write to/from that buffer. However, + this requires extra care from the driver -- it must guarantee memory + consistency by issuing cache flush/sync when consistency is needed. + If this flag is set V4L2 will attempt to allocate vb2 buffer in + non-consistent memory. This flag is ignored if queue does not report + :ret:`V4L2_BUF_CAP_SUPPORTS_CACHE_HINTS` capability. + enum v4l2_memory ================ diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h index 5f9357dcb060..72efc1c544cd 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -189,6 +189,8 @@ enum v4l2_memory { V4L2_MEMORY_DMABUF = 4, }; +#define V4L2_FLAG_MEMORY_NON_CONSISTENT (1 << 0) + /* see also http://vektor.theorem.ca/graphics/ycbcr/ */ enum v4l2_colorspace { /* -- 2.25.0.341.g760bfbb309-goog