Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp517249ybl; Fri, 10 Jan 2020 02:25:44 -0800 (PST) X-Google-Smtp-Source: APXvYqy3T7jOk3HrrqyfAU4T176oLu6QqqmYATr9icF+WxiHRuZxx6W1GM4JLLObJgu8c0qkDxtc X-Received: by 2002:aca:1103:: with SMTP id 3mr1566482oir.70.1578651944649; Fri, 10 Jan 2020 02:25:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578651944; cv=none; d=google.com; s=arc-20160816; b=M6m95JCkbQ0KU2qGYTx5z3b5RySxgRJlkjjKSAQKUBEgM7BzgnbsCiQoLRJ67dL88c l+I3c1f0R4yuWIL/akhXpDnGxa2AhrDTrHkXHqVq/HcCnX1JSIQz2fcW1P4fnWj4JlFJ CoPt18PbyjfulvWQnJq2HMBFLUebvGuSTzbiHlL6lSD9G2wLod8SzT6p8bbuIvu8ScCv 9WpL2QCjvErWroC2Oia52491bvh9Kkr+d5HK2CzPXP8Q6E2iz5YGF2PutipjOvmy3M7G zIWsL5n4atCK0tbXYtg6+rcwAF7SgiTdwdtXkTy2vFk+4xduWye6xSuOAbOPXGCVVSfZ wzNQ== 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=oJOruGOI/Y+hFDMsJUJEz5BVUPQc/eBntsATfXiA7PE=; b=e/8M5zaCchmNtF1/Zx/7/7UF4zHSSsv/wRxuZjaWyuqR1dymxpI8SWxlIFso9OgQ8i ch2oADeXc35Fmgbic2Mt73mjh8myE5AXbajUgGHs04Gb5JWxuWATC2UusFKzihgs0P7q u7eF+mdO6fZy1EXa8K/VcKYQN4Lta5i6gEqLEzrdL/txPUvNpESgNRyAv+FKtwzjXaC9 dKKj5DbbRpSIdPCp/5G1jUgpLnahbM2kYo9pSruGAmKwgyFSyd3MJWcIwnkzHZ33QLBt pUpEoqEVT6FF/tDVoVzDtU50rDvhL5tTj0Uu6AHEmGJJlw8nBQORwHe2JE1Nlj4eNiJO vLKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xs4all.nl header.s=s1 header.b=VZhVtot9; 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 a15si950169otq.83.2020.01.10.02.25.32; Fri, 10 Jan 2020 02:25:44 -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=VZhVtot9; 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 S1727486AbgAJKYc (ORCPT + 99 others); Fri, 10 Jan 2020 05:24:32 -0500 Received: from lb2-smtp-cloud8.xs4all.net ([194.109.24.25]:49467 "EHLO lb2-smtp-cloud8.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727168AbgAJKYc (ORCPT ); Fri, 10 Jan 2020 05:24:32 -0500 Received: from [IPv6:2001:420:44c1:2577:c967:e1d3:183a:b8ef] ([IPv6:2001:420:44c1:2577:c967:e1d3:183a:b8ef]) by smtp-cloud8.xs4all.net with ESMTPA id prSsilw4kpLtbprSviPwG2; Fri, 10 Jan 2020 11:24:30 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xs4all.nl; s=s1; t=1578651870; bh=oJOruGOI/Y+hFDMsJUJEz5BVUPQc/eBntsATfXiA7PE=; h=Subject:To:From:Message-ID:Date:MIME-Version:Content-Type:From: Subject; b=VZhVtot9C3ctHD3oxwDihsjcC5QhQ/xbXvsqgatFT4cCUe6Z6Mh834QE3pSz0ZyVP 3r80VIXXOOhuVUgcS3DUyqedx+MrUHXdH/bqKSeRaha+xjoeUhxkt/rRpX/ElfqtiY r6PhKgvIXA/L5NFTxayLlYvLjBAs8d4xlaO10nS2wECzWo4EiUDpK3EMFgjBFeut0p UjMtuZiVykKinlknbITrDX4kZSwFWR12et/hyJHwJEDGq/hhrKRaquZoMVlNx57rCF WcMgDMaqV118cV8drmlQcwZnyqNUADkSSyCzwkeAiWmN6E38gIB2UhmFrjULIvxrzC eOD/ieKx2r2AA== Subject: Re: [RFC][PATCH 02/15] videobuf2: handle V4L2 buffer cache flags To: Sergey Senozhatsky , 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 References: <20191217032034.54897-1-senozhatsky@chromium.org> <20191217032034.54897-3-senozhatsky@chromium.org> From: Hans Verkuil Message-ID: Date: Fri, 10 Jan 2020 11:24:26 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <20191217032034.54897-3-senozhatsky@chromium.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-CMAE-Envelope: MS4wfJ0SRNrWZnnf7QXyvMOEx3ymNUl2gdlEC5cFu0Qh9z7JR2EsnbXtT4MJnmLPsM93U135VuGtYRqy04ueiqADgivPuL5CH1GqcOObxBhnN5RcVSm4YQEB LnO5iXLq4lrLjOJUubyxLJBaYlSeLc5YJ/3PVVsK41Owz2qkj6jlfka0ocCaL8btdzMZ4TigWRDdnKal2EW8hfGJybgME8bm09fycf2txJNxTgdz7DURVS+4 /0rmXQXmLm1NSRSjINM9PwX3btxpE5V9D46s0mlRpTbzVtvrXOglspB4VeHyGwb90RF0Kmc5c7Kyuh90Rpa0n3dd9BtO17vYqgfGtfq8tU08gTggyhK4xDCj jKoucD4jsLYAs01uISET79ouSsJ0K0m1sDSR/xsUOXajld09NJf2O5X07WBIUrkFvqA7iBMBdC5uGIiiRKJigKS88ciPbRozp6pJhNDSgN20LhtDEL6JXQo9 eTSrVqkBZYGPLxm/3nNOFvFE1IM0GFXD7T1QDTWiVqQR7wPxMZi9Bw6XpJ+nfxlTKXFaSF9Xtk7H0wPOPCBeLVkg3tWn18ClCxyDdKbRICij/zrW7Np5jHZE hh9gfNGBlpgiwDIrVeFqiO+rM48ZWb1GgCG2V+pw4AtpNdhcCcmB/WImtMSBp6JQnfM= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/17/19 4:20 AM, Sergey Senozhatsky wrote: > Set video buffer cache management flags corresponding to V4L2 cache > flags. > > Both ->prepare() and ->finish() cache management hints should be > passed during this stage (buffer preparation), because there is no > other way for user-space to skip ->finish() cache flush. > > There are two possible alternative approaches: > - The first one is to move cache sync from ->finish() to dqbuf(). > But this breaks some drivers, that need to fix-up buffers before > dequeueing them. > > - The second one is to move ->finish() call from ->done() to dqbuf. Please combine this patch with patch 13/15! > > Signed-off-by: Sergey Senozhatsky > --- > .../media/common/videobuf2/videobuf2-v4l2.c | 22 +++++++++++++++++++ > 1 file changed, 22 insertions(+) > > diff --git a/drivers/media/common/videobuf2/videobuf2-v4l2.c b/drivers/media/common/videobuf2/videobuf2-v4l2.c > index e652f4318284..2fccfe2a57f8 100644 > --- a/drivers/media/common/videobuf2/videobuf2-v4l2.c > +++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c > @@ -337,6 +337,27 @@ static int vb2_fill_vb2_v4l2_buffer(struct vb2_buffer *vb, struct v4l2_buffer *b > return 0; > } > > +static void set_buffer_cache_hints(struct vb2_queue *q, > + struct vb2_buffer *vb, > + struct v4l2_buffer *b) > +{ > + vb->need_cache_sync_on_prepare = 1; > + > + if (q->dma_dir != DMA_TO_DEVICE) What should be done when dma_dir == DMA_BIDIRECTIONAL? > + vb->need_cache_sync_on_finish = 1; > + else > + vb->need_cache_sync_on_finish = 0; > + > + if (!q->allow_cache_hints) > + return; > + > + if (b->flags & V4L2_BUF_FLAG_NO_CACHE_INVALIDATE) > + vb->need_cache_sync_on_finish = 0; > + > + if (b->flags & V4L2_BUF_FLAG_NO_CACHE_CLEAN) > + vb->need_cache_sync_on_prepare = 0; > +} > + > static int vb2_queue_or_prepare_buf(struct vb2_queue *q, struct media_device *mdev, > struct v4l2_buffer *b, bool is_prepare, > struct media_request **p_req) > @@ -381,6 +402,7 @@ static int vb2_queue_or_prepare_buf(struct vb2_queue *q, struct media_device *md > } > > if (!vb->prepared) { > + set_buffer_cache_hints(q, vb, b); > /* Copy relevant information provided by the userspace */ > memset(vbuf->planes, 0, > sizeof(vbuf->planes[0]) * vb->num_planes); > Regards, Hans