Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp152812ybl; Thu, 23 Jan 2020 20:29:31 -0800 (PST) X-Google-Smtp-Source: APXvYqyrLKLkU/tIhZEPIdwzQdCf86LCbPV9cL3FlokCaf3szqL8C5koNXampwwwDIygaMtQtUCC X-Received: by 2002:aca:4ec5:: with SMTP id c188mr881649oib.1.1579840171259; Thu, 23 Jan 2020 20:29:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579840171; cv=none; d=google.com; s=arc-20160816; b=YiIa+w3dpaWd1A+n1Q7THN4AOEjgONAKA2G3voGu9/JYCFIO/wtfvllth0tImGBIGI 2msxFJhsp5JkQQkTrRTk2rM3MGYfFzUxo1CTE84LxzEP8PlwHTwB2wYLxXZ5GOu3KWMc Yewt67v7lzI5pFzgfVEelPUBaKYL+bbIetP7VgohpcngnOEN4iMvVqBlTu+q1v0+0l+Z RYy6Q65K2QFAwkrn9AOQdLFpSCKYeEt91haD8jE0DsEr96we/CxZPsTqyaF8Fcklkka1 S/cT7Huws/TB9ErjoKzpuPQVQaFRfMSlue02d9qXGJr5yKzcoWpjL3k1EAS29WnLz9Tv 2ILA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=wZkNXk/j/FX4H35zLUUfeB6UVmty3DCVgibb2jFr+W8=; b=HFGKUnxx4XJqjUpSPguZgVc/XXiVJDtMqrurQFHSVh4WKipX4gBuCuNdlFZGTAQHkv 6PtQjqowKSotXl4ZL+20MCeRxcgTvGuPrdr2IJmQhTcg+D9RMIUu5qZjwlhJ9A6k4PSE jwE/k/Sa1eaMtf1mQzELnrp+B76cb20u5ZbN5DN5B/B+XuCZyKN6J5mcMkyBIhx6zZw5 zQ/1/EZMN6Wk1iZCiVEjzCf2XPiiqQUW6JgNZTHWPGWwTCtweuIvJH1sOgZaZWVnUiNQ ZiSBDLlxp410S9KokG8CYRijRcMyGRFzy+yJlKduR8DQgfbk9y2cmVuB4mfJw1VPfnAp Rbxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=UK2NnWBX; 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 64si1180835otx.50.2020.01.23.20.29.06; Thu, 23 Jan 2020 20:29:31 -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=UK2NnWBX; 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 S1730313AbgAXCZr (ORCPT + 99 others); Thu, 23 Jan 2020 21:25:47 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:35429 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729340AbgAXCZr (ORCPT ); Thu, 23 Jan 2020 21:25:47 -0500 Received: by mail-pl1-f196.google.com with SMTP id g6so151815plt.2 for ; Thu, 23 Jan 2020 18:25:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=wZkNXk/j/FX4H35zLUUfeB6UVmty3DCVgibb2jFr+W8=; b=UK2NnWBXt+4l5lehVqqDx8Y0/xUQNfAFnsRbtbMhYt8sGV95QRl7EXnoveOqh4TNa5 8CFJNYb04cwyZwxa8RgQdRIAfnPLIVhWGMFEcaES6aoKziZdpPfuFNoAPerOZP6CrWVU W50XTuUuNfc65LzzwtOl1bpcYRxp4goeZjy70= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=wZkNXk/j/FX4H35zLUUfeB6UVmty3DCVgibb2jFr+W8=; b=TvWMbd1Nl5Eo+EmXQ+DDMMgugN7LOL5kCIWlUtahqnrbILJoW7O/prllHO+2vdyWu3 KKa2XeB9PAlXYorc1OdNdMdUnE4uU67ISOx6LTYbf0eCyVb5KS1cguHoFBTRL/GssyFH T86Bgo+ABPuAuoUVEEh4cGwNoEwbi56Q+d4GXXcF4wJ3TNZzGht0a9J+vbE2pSuAzhIX yCuSM7I0Np8qxrput439XpocE2DS/20SJpsUXV4gUqasr3q4T+huU731NGzgRbeuhF8l MqA27HgGptla7hpDKfQ2ymFUL3uL62eU7QaDSCsMQSA7gDQVNYrcZKm5jQEnTwwRgWcz Mcbg== X-Gm-Message-State: APjAAAVLVHdWdZsZyJf1YAMv79UKz7hoxYYOcnrPwx6F1mFYMss0wRjK EUqvR2zqX3v/cIwwQkXP28V7mA== X-Received: by 2002:a17:902:aa41:: with SMTP id c1mr1240730plr.105.1579832746732; Thu, 23 Jan 2020 18:25:46 -0800 (PST) Received: from localhost ([2401:fa00:8f:203:5bbb:c872:f2b1:f53b]) by smtp.gmail.com with ESMTPSA id d23sm4004936pfo.176.2020.01.23.18.25.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jan 2020 18:25:46 -0800 (PST) Date: Fri, 24 Jan 2020 11:25:44 +0900 From: Sergey Senozhatsky To: Hans Verkuil Cc: Sergey Senozhatsky , Hans Verkuil , Tomasz Figa , Mauro Carvalho Chehab , Kyungmin Park , Marek Szyprowski , Sakari Ailus , Laurent Pinchart , Pawel Osciak , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [RFC][PATCH 13/15] videobuf2: do not sync buffers for DMABUF queues Message-ID: <20200124022544.GD158382@google.com> References: <20191217032034.54897-1-senozhatsky@chromium.org> <20191217032034.54897-14-senozhatsky@chromium.org> <2d0e1a9b-6c5e-ff70-9862-32c8b8aaf65f@xs4all.nl> <20200122050515.GB49953@google.com> <57f711a0-6183-74f6-ab24-ebe414cb6881@xs4all.nl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <57f711a0-6183-74f6-ab24-ebe414cb6881@xs4all.nl> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On (20/01/23 12:35), Hans Verkuil wrote: > On 1/22/20 6:05 AM, Sergey Senozhatsky wrote: > > On (20/01/10 11:30), Hans Verkuil wrote: [..] > But whatever was written in the buffer is going to be overwritten anyway. > > Unless I am mistaken the current situation is that the cache syncs are done > in both prepare and finish, regardless of the DMA direction. > > I would keep that behavior to avoid introducing any unexpected regressions. OK. > Then, if q->allow_cache_hint is set, then default to a cache sync (cache clean) > in the prepare for OUTPUT buffers and a cache sync (cache invalidate) in the > finish for CAPTURE buffers. We alter default cache sync behaviour based both on queue ->memory type and queue ->dma_dir. Shall both of those cases depend on ->allow_cache_hints, or q->memory can be independent? static void set_buffer_cache_hints(struct vb2_queue *q, struct vb2_buffer *vb, struct v4l2_buffer *b) { if (!q->allow_cache_hints) return; /* * DMA exporter should take care of cache syncs, so we can avoid * explicit ->prepare()/->finish() syncs. For other ->memory types * we always need ->prepare() or/and ->finish() cache sync. */ if (q->memory == VB2_MEMORY_DMABUF) { vb->need_cache_sync_on_finish = 0; vb->need_cache_sync_on_prepare = 0; return; } /* * ->finish() cache sync can be avoided when queue direction is * TO_DEVICE. */ if (q->dma_dir == DMA_TO_DEVICE) vb->need_cache_sync_on_finish = 0; else vb->need_cache_sync_on_finish = 1; /* * ->prepare() cache sync can be avoided when queue direction is * FROM_DEVICE. */ if (q->dma_dir == DMA_FROM_DEVICE) vb->need_cache_sync_on_prepare = 0; else vb->need_cache_sync_on_prepare = 1; 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; }