Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp1864400ybf; Sun, 1 Mar 2020 20:12:57 -0800 (PST) X-Google-Smtp-Source: APXvYqwfh9mJ1nqa31f1Wa42h5J38bKAYJNJrrzwqrM1xSLviSbel6m3T+zWqDIa3dv5EyCKEejo X-Received: by 2002:aca:bfc6:: with SMTP id p189mr8411587oif.21.1583122376901; Sun, 01 Mar 2020 20:12:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583122376; cv=none; d=google.com; s=arc-20160816; b=x1lhmLZq8fXL07+9kvAIZALkMqgR6pEiXRBVKykD16baztRJ1RHoAHCj+FdQwGofdU zLchY5W4MJpygnY5WJ8yqH36qffe/pvsV3cIAbi/mrzcAIvguLWTbvvdUIUC4IytZ5Pm NYnWIySDsy13jYszVc2oFpXms7Yu/HKQ1ONKlyrrN4Gir6JVmeonwbbfKXRBvPEDomJp SzPSxLk/sX0ECQI4WNP9fFbtM0+JIQrUtqL+Gw7LRJ3DV/p48QGVtoFckA5RByYRJWbA h5xyx+El1x/BzF3WA8QiVjL12h5o/+ffTBAdaDxaKkeRgHHIYsua1WbyjOrIqEA8P1JG 0Pnw== 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=YrB85oXgJhPm+yjrRVrxS1vwiq4+Adj4zLtVRTDt1IY=; b=V+IR9IENgBcwD6aOVZ3kHYiAzBlV/fQFFvPeO2B65FtLQbH/XKmWC2QD9LHUVP2Cp1 Fa9Env5YUXShq5oMd/Sq5J2o7wDZv+1Vbv/R/ews5wMFtQsPf2EaymwgnSUGDSwuqvS+ QE2lPY5awvbPELGLFfMHl8Yqv8SL2USvS7QOXxiRdHmUs22iR+A7RVQ3YM1UA92tlpJH ZREBfHw9hDwjPaAorNBJe7SMxN4zA2XyCuqFhzO7EgQ473BWWTOjvVNfR44FPYKcVVF3 VSDeIYEqYkSmRa+08U79ALZ5/Vzk2OO9NrzbubCkaDafT3QsRg0fqjbylFqXM7970iio EwqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=XqIhMNtb; 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 k194si1165746oib.251.2020.03.01.20.12.45; Sun, 01 Mar 2020 20:12:56 -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=XqIhMNtb; 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 S1726951AbgCBEMb (ORCPT + 99 others); Sun, 1 Mar 2020 23:12:31 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:45680 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726894AbgCBEMb (ORCPT ); Sun, 1 Mar 2020 23:12:31 -0500 Received: by mail-pl1-f196.google.com with SMTP id b22so3648011pls.12 for ; Sun, 01 Mar 2020 20:12:30 -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=YrB85oXgJhPm+yjrRVrxS1vwiq4+Adj4zLtVRTDt1IY=; b=XqIhMNtbLPC20ZwxGlrkZD/qxwtoK++BXMtCphV5QLovF6Grd/E5Zw8z0k1h8LgD9G as4crmLVxevYfc9ajn7rFWoDyg1yswpuvDTToB3lDmBPNNirXwXnml7bt1ZQP4bQgTrY jfpUW698BM97X5gJcCgKv+ixr39NpERrknA38= 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=YrB85oXgJhPm+yjrRVrxS1vwiq4+Adj4zLtVRTDt1IY=; b=d5Hc+T+DBnUgumP+H0JHAbawtcrC3+riFwfYmpwUsw9omrpdtVydNiDtgxzLGybDHs 3VAC589J2Bdi/YL/qtPXmc+9DSoienjiqukTwnnREutSPpSEbWG4kKX6HMLK04JWOT9p 9kCMRfZhXy6voP3ZVS2x2MJbE4sl16JZYo9yEp5Np8VUz/pWjqQx7UvVasnpmK5Hdjrr ny31VKEyViUlEDqihZb1zEsokVVFh470WjnNII82a7EG+LRge05ql1eqZwdBibfYnRZU YS88F3Ds98qwsnjQ/b/jnrmZp9jlXBvijHNyosxguVSqKyK8bu6dic3T7NfkjsFFCCvY 6BAA== X-Gm-Message-State: APjAAAXZI7bUI2bakYFK5+E4ZlSSG2nGVNXWuDSuch4+TUXikHTLPKg7 kyOQQugHFzHVPvg6dgC2z6Ogww== X-Received: by 2002:a17:90a:c301:: with SMTP id g1mr18796339pjt.88.1583122349094; Sun, 01 Mar 2020 20:12:29 -0800 (PST) Received: from tigerii.tok.corp.google.com ([2401:fa00:8f:203:5bbb:c872:f2b1:f53b]) by smtp.gmail.com with ESMTPSA id d82sm1698114pfd.187.2020.03.01.20.12.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Mar 2020 20:12:28 -0800 (PST) From: Sergey Senozhatsky To: Hans Verkuil , Tomasz Figa Cc: Mauro Carvalho Chehab , Kyungmin Park , Marek Szyprowski , Sakari Ailus , Laurent Pinchart , Pawel Osciak , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Sergey Senozhatsky Subject: [PATCHv4 01/11] videobuf2: add cache management members Date: Mon, 2 Mar 2020 13:12:03 +0900 Message-Id: <20200302041213.27662-2-senozhatsky@chromium.org> X-Mailer: git-send-email 2.25.0.265.gbab2e86ba0-goog In-Reply-To: <20200302041213.27662-1-senozhatsky@chromium.org> References: <20200302041213.27662-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 Extend vb2_buffer and vb2_queue structs with cache management members. V4L2 UAPI already contains two buffer flags which user-space, supposedly, can use to control buffer cache sync: - V4L2_BUF_FLAG_NO_CACHE_INVALIDATE - V4L2_BUF_FLAG_NO_CACHE_CLEAN None of these, however, do anything at the moment. This patch set is intended to change it. Since user-space cache management hints are supposed to be implemented on a per-buffer basis we need to extend vb2_buffer struct with two new members ->need_cache_sync_on_prepare and ->need_cache_sync_on_finish, which will store corresponding user-space hints. In order to preserve the existing behaviour, user-space cache managements flags will be handled only by those drivers that permit user-space cache hints. That's the purpose of vb2_queue ->allow_cache_hints member. Driver must set ->allow_cache_hints during queue initialisation to enable cache management hints mechanism. Only drivers that set ->allow_cache_hints during queue initialisation will handle user-space cache management hints. Otherwise hints will be ignored. Signed-off-by: Sergey Senozhatsky --- include/media/videobuf2-core.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h index a2b2208b02da..4a19170672ac 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h @@ -263,6 +263,10 @@ struct vb2_buffer { * after the 'buf_finish' op is called. * copied_timestamp: the timestamp of this capture buffer was copied * from an output buffer. + * need_cache_sync_on_prepare: when set buffer's ->prepare() function + * performs cache sync/invalidation. + * need_cache_sync_on_finish: when set buffer's ->finish() function + * performs cache sync/invalidation. * queued_entry: entry on the queued buffers list, which holds * all buffers queued from userspace * done_entry: entry on the list that stores all buffers ready @@ -273,6 +277,8 @@ struct vb2_buffer { unsigned int synced:1; unsigned int prepared:1; unsigned int copied_timestamp:1; + unsigned int need_cache_sync_on_prepare:1; + unsigned int need_cache_sync_on_finish:1; struct vb2_plane planes[VB2_MAX_PLANES]; struct list_head queued_entry; @@ -491,6 +497,9 @@ struct vb2_buf_ops { * @uses_requests: requests are used for this queue. Set to 1 the first time * a request is queued. Set to 0 when the queue is canceled. * If this is 1, then you cannot queue buffers directly. + * @allow_cache_hints: when set user-space can pass cache management hints in + * order to skip cache flush/invalidation on ->prepare() or/and + * ->finish(). * @lock: pointer to a mutex that protects the &struct vb2_queue. The * driver can set this to a mutex to let the v4l2 core serialize * the queuing ioctls. If the driver wants to handle locking @@ -564,6 +573,7 @@ struct vb2_queue { unsigned requires_requests:1; unsigned uses_qbuf:1; unsigned uses_requests:1; + unsigned allow_cache_hints:1; struct mutex *lock; void *owner; -- 2.25.0.265.gbab2e86ba0-goog