Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4434914ybl; Mon, 3 Feb 2020 18:59:00 -0800 (PST) X-Google-Smtp-Source: APXvYqy0idSI+MGYGmvAM2yJU2qR58XJZjcTMhiilDSMgFbcStB3jSAsq3SvYUM8fGBd+ZEiiwr/ X-Received: by 2002:aca:1b11:: with SMTP id b17mr1869695oib.45.1580785139992; Mon, 03 Feb 2020 18:58:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580785139; cv=none; d=google.com; s=arc-20160816; b=t3pFqORRWoclRd2nmhyKllr+S0G/oHvsR3LXmrxkLsHdrlgMQLEIvXGVV00HxoU5ba mSQ99lp0NEZpJus3/VegEKvzYLSO1V8VDBMzY9Z9o+tKuVmayIif9inIiEUiGBRpMa6c T9sCnhQgPPTBWHGmpZHGFRAyVDhMNuZbtDGGyn5F0L+PBsiVQObuhgQuMcw2flHOtnUI 562EULsNtAdSG/av3/YW5bPJx7zjaifSLZcr+i3pDaec+1GdTJ3rNjUI5MG5EXKNAiCs EVNJwXMLkDNCdI1KHvpkypEmDADm5lpJEhYqRcBdhRvlDzXCVs5dh4MEtmKqTQ2hH/Q0 6yqg== 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=T/+Rlp1jPgPXZXDmW6x1Q8uODIAHg+YuyNKI1rs3+AQ=; b=EthTGPhMcjI4/S+Jc2C7UPvJgetIHni9lQdMuwYBk/DfpZQF8MOYm9+caaxr8K14jj poTikV6YZuWoOz571lUtDtSA+wMAWRKyvT2NWVlEEhohD0ojeOulUaXcqELXxxtxAOJl zvukyFjd0L0HePmR4jsFIWyaFj3DpiBcsN1A4xPug11JOiUixLlDd5zqLfB8HyGoKv0L ln5GINhQPWFirQQg+ATur/QFaPNagB9ioSVySCzcfEcypEASq2qqC/BK5KxVbR8d42Vi orBpmLi5dOYHKduR3vgURnQZPoRwl2dMzLzwNY9bpaz80NE9/4sESqyCcOgE5+nZ85dT C0Vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=EmXtHEzC; 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 j10si10575786otn.122.2020.02.03.18.58.47; Mon, 03 Feb 2020 18:58:59 -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=EmXtHEzC; 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 S1727411AbgBDC5e (ORCPT + 99 others); Mon, 3 Feb 2020 21:57:34 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:35038 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727368AbgBDC5c (ORCPT ); Mon, 3 Feb 2020 21:57:32 -0500 Received: by mail-pg1-f196.google.com with SMTP id l24so8911403pgk.2 for ; Mon, 03 Feb 2020 18:57:32 -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=T/+Rlp1jPgPXZXDmW6x1Q8uODIAHg+YuyNKI1rs3+AQ=; b=EmXtHEzCTNUp3JHhN5KhU5HPB15eaWUPG0ltTwgDk3DdzSA1PfYHzVTn+DARhxhgo3 nLvjBLEeGYMn+Hort7T3uc1tofVXrSkMNya6eRirfPIj/Xws052UlgRc+wOaGRCpqAJT 9DM7TnFZsdY71blpcWhOSwZx/fpuJxEyQEWeY= 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=T/+Rlp1jPgPXZXDmW6x1Q8uODIAHg+YuyNKI1rs3+AQ=; b=fQYf/4GYpgIgLjAHcq0CoAW3clrzWNiHcx1BISITc5bQFZNrhRGjfYAMyQCPY74vVp ACz2vI7SePYeobOeAxbLJv10iMz6AVTXOS/ekq0RpqMU5piST7l2nIR50rmNhAN9E5Ok oBvZhwX54LqPEM+R1wfnSN62m8fDge0Z+6ccsHCjjDb4xWHmtii30cl/4pd/xqMXqOMr m2ot+uIKE0tARMcyiaTWwLPuuFuUNCYq4UB6JbQQ1ep6IRqh8sjNxj1LJXjgTcahztLh KOd5UQpX+hx0T1a/wbCgSexIb1EEmVs5y/NrWIuLsZ+73zc73Ca3rdaG/+m2aHpoxdKh x7tg== X-Gm-Message-State: APjAAAVsg3qWFCX3zlMiy5eyf3CGJ2FFLzVuw3/nIWDznmoPNts0PXSE sUXQK54l4cxzx+jfvpuXev/4/g== X-Received: by 2002:a62:7a8a:: with SMTP id v132mr29363613pfc.111.1580785051956; Mon, 03 Feb 2020 18:57:31 -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.57.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2020 18:57:31 -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 12/12] videobuf2: don't test db_attach in dma-contig prepare and finish Date: Tue, 4 Feb 2020 11:56:41 +0900 Message-Id: <20200204025641.218376-13-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 We moved cache management decision making to the upper layer and rely on buffer's need_cache_sync flags and videobuf2 core. If the upper layer (core) has decided to invoke ->prepare() or ->finish() then we must sync. For DMABUF ->need_cache_sync_on_prepare and ->need_cache_sync_on_flush are always false so videobuf core does not call ->prepare() and ->finish() on such buffers. Additionally, scratch the DMABUF comment. Change-Id: I8f6c0b246ccb63f775dcf7881dd5f848c38e7604 Signed-off-by: Sergey Senozhatsky --- drivers/media/common/videobuf2/videobuf2-dma-contig.c | 6 ++---- drivers/media/common/videobuf2/videobuf2-dma-sg.c | 8 -------- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/drivers/media/common/videobuf2/videobuf2-dma-contig.c b/drivers/media/common/videobuf2/videobuf2-dma-contig.c index a387260fb321..6ea0961149d7 100644 --- a/drivers/media/common/videobuf2/videobuf2-dma-contig.c +++ b/drivers/media/common/videobuf2/videobuf2-dma-contig.c @@ -100,8 +100,7 @@ static void vb2_dc_prepare(void *buf_priv) struct vb2_dc_buf *buf = buf_priv; struct sg_table *sgt = buf->dma_sgt; - /* DMABUF exporter will flush the cache for us */ - if (!sgt || buf->db_attach) + if (!sgt) return; dma_sync_sg_for_device(buf->dev, sgt->sgl, sgt->orig_nents, @@ -113,8 +112,7 @@ static void vb2_dc_finish(void *buf_priv) struct vb2_dc_buf *buf = buf_priv; struct sg_table *sgt = buf->dma_sgt; - /* DMABUF exporter will flush the cache for us */ - if (!sgt || buf->db_attach) + if (!sgt) return; dma_sync_sg_for_cpu(buf->dev, sgt->sgl, sgt->orig_nents, buf->dma_dir); diff --git a/drivers/media/common/videobuf2/videobuf2-dma-sg.c b/drivers/media/common/videobuf2/videobuf2-dma-sg.c index bfc99a0cb7b9..1fd25eda0bf2 100644 --- a/drivers/media/common/videobuf2/videobuf2-dma-sg.c +++ b/drivers/media/common/videobuf2/videobuf2-dma-sg.c @@ -198,10 +198,6 @@ static void vb2_dma_sg_prepare(void *buf_priv) struct vb2_dma_sg_buf *buf = buf_priv; struct sg_table *sgt = buf->dma_sgt; - /* DMABUF exporter will flush the cache for us */ - if (buf->db_attach) - return; - dma_sync_sg_for_device(buf->dev, sgt->sgl, sgt->orig_nents, buf->dma_dir); } @@ -211,10 +207,6 @@ static void vb2_dma_sg_finish(void *buf_priv) struct vb2_dma_sg_buf *buf = buf_priv; struct sg_table *sgt = buf->dma_sgt; - /* DMABUF exporter will flush the cache for us */ - if (buf->db_attach) - return; - dma_sync_sg_for_cpu(buf->dev, sgt->sgl, sgt->orig_nents, buf->dma_dir); } -- 2.25.0.341.g760bfbb309-goog