Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp121102ybl; Mon, 27 Jan 2020 23:37:29 -0800 (PST) X-Google-Smtp-Source: APXvYqzH0ZRlfKjUewQLPu3o5HD5rlXXhhegCCWtY1MJVcpNWXB6KAHm+kS/lstZX4ewwfQvbJZ3 X-Received: by 2002:a9d:1706:: with SMTP id i6mr6231157ota.151.1580197049359; Mon, 27 Jan 2020 23:37:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580197049; cv=none; d=google.com; s=arc-20160816; b=Ga5cdDIOlLvi1LpTqs+2B1QBX3kha4OB1amiPvWI7CLSoUfG6g2kyv82og4Qlr/cY9 6nqWT6hnqWkyaL5y0jIvhfNGLTC/LYsGK31Ss23vuJmNF0MMP4dJyQY9gyfjY1aglFPA rQBE4sBv0D5M4h1XIjnDCXmJuD53mDwFqeBKPDaYoEVOFhb1kXTLKzCXBGP3uhvHP7to wszCubmq2ZHe5EgE4Vfq/MNZJQ1nxjj/zYQnn8wG7rooEp+iv+T4VQtuRi+cuC2WOjbw yFMd4L0WcGRCn1oELypycjTArNbmNUsbmRzPfCi2ihyMUV/tSf+UV8RiZCtbbDEm0Qxn 0ijw== 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=CQgtos6gVXtQDMK7WmwCsXfSvCY2uCU1KZAKWAc3CIg=; b=bdkStUyZsaYv+GPerKCHJqpWGyEcCPIhFW8vqXTb7D5MvOeiYJ9gyH0q68P7t2HuiR 7SgZeIAmlsHWI/XwO8e1aGrzcn8hKz5D9WKChe8xSPsOaF1ad6uOeYCgn/bdt9Z/nBeu tLZzB3DgfZ062tvv8601JcZZUlafb3vvA1Sw1zWXkY/ULlqwh0h7gYcTjcLcS7lGXSCS TmLgniLoUChckBUSLsdivbK4unvBfU6ub+KJi7XT+nRapsu97uA+z0WgkDnN1B6jDQFz 34uR+gc3mFlcEzzp0N6UJ3pmxM5h+FtRuzkmcUjipFvN3YANDkQ151aifQEtL4tJ6URD 6ejA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=P9e0Kdar; 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 f18si8504389otl.29.2020.01.27.23.37.15; Mon, 27 Jan 2020 23:37:29 -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=P9e0Kdar; 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 S1725971AbgA1He7 (ORCPT + 99 others); Tue, 28 Jan 2020 02:34:59 -0500 Received: from mail-pj1-f65.google.com ([209.85.216.65]:39841 "EHLO mail-pj1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725810AbgA1He6 (ORCPT ); Tue, 28 Jan 2020 02:34:58 -0500 Received: by mail-pj1-f65.google.com with SMTP id e9so625046pjr.4 for ; Mon, 27 Jan 2020 23:34:58 -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=CQgtos6gVXtQDMK7WmwCsXfSvCY2uCU1KZAKWAc3CIg=; b=P9e0Kdarb9HU/R4jyBXu0ELCXOnKWoyCdO28ibit/UvII7D1Ejvp2NlWrmR3ugjbSB MEqZUiWmVgVEX1cArwhO7c78ZBDpnds+coC29Tcc2lhbo6r0q8xxzizOqRDJFmL3U0LA pTekCxsV4OBncs/dt7P5surmwuS1ts7K14+oY= 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=CQgtos6gVXtQDMK7WmwCsXfSvCY2uCU1KZAKWAc3CIg=; b=uCioHnkOsPxFPCaUUMvdcJLQ62Kdc5cYglHY/6q43dIT0SSWFgZRBnmaOMv88WH2LI P8Z4NlgSGJZGI9z0sw5KjS/9B5/tpzxL5wxg9sNxwTB2AsIGHJhaRjTYSl02CF9nzZaH 3M3gh6FVC/CUUwmT1366xsrRnXdNZocGgbkofMGQHzZOlTvEbigSz4nWx08n/jOeRbfB m3of5jlWMTW+J2ZQtgZiTbtcta9pC4za0gvpSYbG1+cXL+oJplqu93891RvTAyLDc36A aRFEYmJnXXxKMU12pKrwTF+9eCVQgBwgHgiWIEJawB+Wh/lA4E1Zjar9LYnSR7KQLuOy utTA== X-Gm-Message-State: APjAAAUZKM7aoRAwwtwtZ2ms8QLblwm8vv1RzL6O+TeC3R04V7xxkzuu IqwLp33yGJQhR/DwXPBkx6ZSnQ== X-Received: by 2002:a17:90a:31cf:: with SMTP id j15mr3239618pjf.120.1580196897974; Mon, 27 Jan 2020 23:34:57 -0800 (PST) Received: from localhost ([2401:fa00:8f:203:5bbb:c872:f2b1:f53b]) by smtp.gmail.com with ESMTPSA id i4sm18626553pgc.51.2020.01.27.23.34.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jan 2020 23:34:57 -0800 (PST) Date: Tue, 28 Jan 2020 16:34:55 +0900 From: Sergey Senozhatsky To: Tomasz Figa Cc: Sergey Senozhatsky , Hans Verkuil , Hans Verkuil , Mauro Carvalho Chehab , Kyungmin Park , Marek Szyprowski , Sakari Ailus , Laurent Pinchart , Pawel Osciak , Linux Media Mailing List , Linux Kernel Mailing List Subject: Re: [RFC][PATCH 13/15] videobuf2: do not sync buffers for DMABUF queues Message-ID: <20200128073455.GC115889@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> <20200124022544.GD158382@google.com> <20200124073250.GA100275@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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/28 16:22), Tomasz Figa wrote: [..] > > > > 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; > > > } > > > > I personally would prefer this to be above ->allow_cache_hints check, > > IOW to be independent. Because we need to skip flush/invalidation for > > DMABUF anyway, that's what allocators do in ->prepare() and ->finish() > > currently. > > I think it's even more than personal preference. We shouldn't even > attempt to sync imported DMA-bufs, so the code above may result in > incorrect behavior. Sure. Allocators test buf->db_attach in prepare()/finish(). This patchset removes that logic, because we move it to the core code. But if the conclusion will be to clear ->need_cache_sync_on_finish/prepare only when ->allow_cache_hints was set, then buf->db_attach bail out must stay in allocators. And this is where I have preferences :) -ss