Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4434067ybl; Mon, 3 Feb 2020 18:57:57 -0800 (PST) X-Google-Smtp-Source: APXvYqx0K69i9BmASLCKErQ3KdJ47S8avcb06coOcTvVsTQhkiUELR6X08WzveDMplOIelhUbII+ X-Received: by 2002:a05:6830:154c:: with SMTP id l12mr20128103otp.275.1580785076935; Mon, 03 Feb 2020 18:57:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580785076; cv=none; d=google.com; s=arc-20160816; b=sWoc1eqcXRLrBriQY67mFtGxeWs+9MsLJHVqCVRGKz1mYYRSR7h+bIfVnzAumG1X5d KN5MdUmTkQOlO6Z3EaX0PO8PpB2TEE6P74aOYVO8emgs6PFat+G3VTSuenDYCeqbbB79 2vHYfJm7ID3QdhF6/Fh7nz+woRZDI3NSnfB8g++h5aX5dxeZccwpO8dNJDe+xp4TdYjz F5F4PFiOeRUYXg597TmVPGSVFhpAngUFjWa2vv3uPU1n8MXDyEFKU9jGqBbVRealRprU oFJjerKZnLCpbaYDxpixDRcVssv8juGP+OC1NVuPnQfw/0xrvOv5IEwCxgBbHqWoz+m4 jq6A== 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=lhU4J28AzAlrdMUPALtytVfuN5Yhod7wdbGSvYMz3F8=; b=SHm636XqrZ8jMGade7bqUTFB1A7KOpSASX5UHjWlxsTyKTLLmQtnqJzLzvR4CPIhEL MtNKFy+7ofX7FQE6cN8D7ny8CsjMYnETido46P5uyt9VwIdEAxTIvonuQap54yP0yI2u cpcuEyIvJUhv5U0zx4ELcCAr7EDoVWo9jiQWHgTG8QUZpvGyQI6zeXG2BWfcM22KZU0x tlGMgBJWmOjdEbFetY/qn49E6nTAmfuINjyyF5qcMU2wRkvK+rj8ZbtxYB+1hJZaTkAV fYf1wX+qy2gLW1xI/39YP/5UCtJBySaov/hrrARAdfbtSUG4DYDjjt3EH4k+ruZxUybl h8lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=muHmPuyo; 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 p83si9586685oih.198.2020.02.03.18.57.45; Mon, 03 Feb 2020 18:57: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=muHmPuyo; 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 S1727140AbgBDC4x (ORCPT + 99 others); Mon, 3 Feb 2020 21:56:53 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:40704 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727159AbgBDC4w (ORCPT ); Mon, 3 Feb 2020 21:56:52 -0500 Received: by mail-pf1-f194.google.com with SMTP id q8so8661959pfh.7 for ; Mon, 03 Feb 2020 18:56:52 -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=lhU4J28AzAlrdMUPALtytVfuN5Yhod7wdbGSvYMz3F8=; b=muHmPuyoCTTbGsxdFeW4XnvKzj5kxEDC1dK1cy56ahD5bPl9L5v9UYWOTrPmxKWB3I 1Lk/FXpJ/3WXExHGrbVLXmCif8cxKj3WShbNj332c01j6jMtfin4+WtIl+M5B/2XRBbP iBVPpf9rHg3n6feFJx6toqhUAsSuLJjVJEh5g= 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=lhU4J28AzAlrdMUPALtytVfuN5Yhod7wdbGSvYMz3F8=; b=M5Xd21OmCREex2rq/3IUREL5KIui7Ym3A8Myuyc2zKCfgjHW4GzK89xixgmX7qo8Cl Ud96SCFS4vWnQpvenSquRMvwcV97cyB+Y1tny1FLungIgTC5zZZ+8U3EXnwvVnKqK+Uh TOOfIhd/l3Ai+CatRxvrNZkCqBbvAmtTxxup4BB19rIc92BmK+UOVuvZ/srtWDTjQMfu ewKphV8iQYp5rNwTAp3uyXOoA1dd7WKoAuH60pCuTJnXfR04Pb7P7t2lbyfxexIJOlO8 7gIx/vKLCOBMEuerw5ERSk/VJmlS0OHVDk0RFSaOoNVmhTm58YV+xu1+DvQ1CO00yekP Cy8Q== X-Gm-Message-State: APjAAAXnCukasVlvNWDmyZsGdtXZvUumSka97+FrI9G4TPeUUIBG6fXP sdqmsPDEN7dAttbg4JiNh7PjHg== X-Received: by 2002:a63:610a:: with SMTP id v10mr16629313pgb.211.1580785012160; Mon, 03 Feb 2020 18:56:52 -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.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2020 18:56:51 -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 01/12] videobuf2: add cache management members Date: Tue, 4 Feb 2020 11:56:30 +0900 Message-Id: <20200204025641.218376-2-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 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 memebers ->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. Change-Id: I52beec2a0d021b7a3715b4f6ae4bfd9dc5e94f0d 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..026004180440 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: do not sync/invalidate cache from + * buffer's ->prepare() callback. + * need_cache_sync_on_finish: do not sync/invalidate cache from buffer's + * ->finish() callback. * 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.341.g760bfbb309-goog