Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp6857692ybf; Fri, 6 Mar 2020 05:58:05 -0800 (PST) X-Google-Smtp-Source: ADFU+vuun6qAOhMnOU9dqAlbtA3wILmfOgavIWIbbNJqacyZtEoR9Wqc7nOdlDVta+tNdPQgCSw9 X-Received: by 2002:a9d:6a9a:: with SMTP id l26mr2698580otq.104.1583503085377; Fri, 06 Mar 2020 05:58:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583503085; cv=none; d=google.com; s=arc-20160816; b=AEAEBK0Ah4pu8l6MxKlzbnsOmRbtCPBM87l7S6Uuvlh8h12FVRQXRvLw3tcu0V3zVB tYq9BZ4QOZoSO8Mep4UGV0m7LNkr9q3rlnNKn2CDnRDUOpuVa8w0UMltSBfA0QwckMvu TZ6QPV3osnfJS1WozXxG0Ppxg0Y5uTnglbgqbj95nAyZt3WUGHVBUkjBVA2Vsg3CCR+X CJjXFx1DLj533Ab8y9j4MdYPVpAtsl7+8gPubuPCDLa4q4OFbjNkQKt6VTCq+MpcjrRM 3YcoytSQIFxY6cHgkxZuV6U0vxRCUaFe18dZ335mb3wgRWrgHcAH04jpd2y89Rrz6jBZ aKOA== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=7C8ejfAlywNN851hAmFB/5ub06nq6fiGYK6/JJLtDDY=; b=oCXe9waGWHssOjpMn06htxfJvP1O6EJe0qCe3lT6d2QuKkNkxZUEly1ZNaE6nqEvsj sPJ+Fs0Sg+Zu6U/I9+skW6gDNJPlSCEkj4To1UzHujwCnci84wfcA9w0Q84QxQ2N8Syd QpZcuXjKx9kr1Fdakyb20hvGNcgU3XquthP//b4Kj9dOuOS2HXsBVEa46jG7MPDb0s4i fpIrdgBHBWs+o78EDDQrJ65oyx7PqQhxKqGCiXYn0tnKOErYeiaHIO5CNcuP+qGveame HFfBsHwBTQ2YgEFqUTJpUB6pAX5/Wu2JRzmKTuchoMGx8xGX5CRW7yCvwlNLnqPsSy4v w5Jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xs4all.nl header.s=s1 header.b=mstb2Lcp; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b24si1391349otq.72.2020.03.06.05.57.52; Fri, 06 Mar 2020 05:58:05 -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=@xs4all.nl header.s=s1 header.b=mstb2Lcp; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726956AbgCFN5M (ORCPT + 99 others); Fri, 6 Mar 2020 08:57:12 -0500 Received: from lb1-smtp-cloud7.xs4all.net ([194.109.24.24]:52963 "EHLO lb1-smtp-cloud7.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726646AbgCFN5L (ORCPT ); Fri, 6 Mar 2020 08:57:11 -0500 Received: from [IPv6:2001:983:e9a7:1:558f:c736:2117:17d1] ([IPv6:2001:983:e9a7:1:558f:c736:2117:17d1]) by smtp-cloud7.xs4all.net with ESMTPA id ADTPj3Az9EE3qADTQjCbJA; Fri, 06 Mar 2020 14:57:09 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xs4all.nl; s=s1; t=1583503029; bh=7C8ejfAlywNN851hAmFB/5ub06nq6fiGYK6/JJLtDDY=; h=Subject:To:From:Message-ID:Date:MIME-Version:Content-Type:From: Subject; b=mstb2LcpHR8PJe5gVVe+QxU8IKeKx+BU4OWJ5GAjwC4MzBA56IJg51BZyn4t7RaXf p8+QCR0T8MwXbBml3/zzdSoMRwYdrbXj1CXdjWZpgHN3cYvMJv+2Z32XanV0JU4bNf iKXg6A/U12KM3+RYsq+bnhdF4FL1g+mzIM13UBU0r9XRTT4XyVdLQU6ZA9HM+IKPu+ JDJdFW4d9EJ0pYojfLRPNgF9hxR8BaZ31FTiBPDWzteleCgq8uCgldcxMsjJWFDVmH RMAnR+pFWo9ZAtLi/OAG9A///glkZB2m/H43pD8CsYp+EVdA62nHMu/87bH6o+p1fe TvMVBAj55beDQ== Subject: Re: [PATCHv4 01/11] videobuf2: add cache management members To: Sergey Senozhatsky , 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 References: <20200302041213.27662-1-senozhatsky@chromium.org> <20200302041213.27662-2-senozhatsky@chromium.org> From: Hans Verkuil Message-ID: <17060663-9c30-de5e-da58-0c847b93e4d3@xs4all.nl> Date: Fri, 6 Mar 2020 14:57:07 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <20200302041213.27662-2-senozhatsky@chromium.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-CMAE-Envelope: MS4wfEgAKs0orUOER4VSkqFKGXXNyskcC09fhd+Y7xYxpI22EsO3XH2NFF5+JuaxQXNPGyALegrne0XA/wbXmSTcqEZfgICUJcXJDpByFEz3SKW3KNI1GjxU pFCA0bOtDcxSvNRJ679z5rLvw9v5GgoDkaJACiWKDLnsVNQbgHfRZ2+ic61ERGPGEEtdmRGl6D8BdFsFpPRhnbgADoMjRAGSjiOFvDm07KRbrrw0zX2Tp7Fl zbxakj6okI4aiuOjC6ptdn1GU0eBaM3wfCtx4FLqSozA5UyXlWp2nwMkWl2dxRYVtL0DrwGqVE5ADgtmY6BCVVA9i2XiWKXsB9pWEn6J4Qu3hQYoenskgUqT RcBdlMOiDtW4+B4SGAjQSf+UCJoxLqkjQTdGRBeYs2Au7FMNWh8tpr6CK10+RU3MfmQohCcy+JeIH9Ba+XZOmPoyhqLVI/OA/iyubs6dczGZ4ZdQGxNcxZAw pqvaz9HTnKl740FnKfdxbcrcyPRRDf6sPg859K8dwU7V9XabUgdN7/noJFUvCoC8xgktAIY4SQ2Sff9YpVDh/ZZ6phLrRh6C/caBVHu6U3Pt/Hq5kBQCArKT ORG27MEip3JZbBQXfiLVhJmZd9fNn/vul4CFD7m0DAyGtQ== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/03/2020 05:12, Sergey Senozhatsky wrote: > 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(). checkpatch complains about a space before a tab in the two lines above. Regards, Hans > * @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; >