Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4434754ybl; Mon, 3 Feb 2020 18:58:48 -0800 (PST) X-Google-Smtp-Source: APXvYqzHaYd0DzOC0njBgkbys26iewBsg6Ya1VZ4HZ/mntSlWbW4aU+sk54LiVehuanmH81YpsuB X-Received: by 2002:a9d:6f82:: with SMTP id h2mr20204323otq.69.1580785117272; Mon, 03 Feb 2020 18:58:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580785117; cv=none; d=google.com; s=arc-20160816; b=avoL1yt4tYBmtJ/yaC+2KqkzP3HSGQNlP0BIq9mbKdKavnsreAd74yR6e0n7leV8w/ Bd+y/AjUpKBPycXVNKHwIXsw6bNAVqmOI2XTHGT7vcmMeIPa0XxAj72xA55A/w8uhOcr IRwxpc/aIYTxIaYgJyFG97JAmJKkt94s62d6+3BGUXIHbJYi66bvb1/iYqoMi/OdbP4z WYrQwufKdsZVJBCq1sOlFHwqi7XCPWkK05EjjtGPkjzGBsBEyEKhkPjFFdAXq2NFW5Ct Gr7z7aVI6/heRHVc2+qRVQNM2toLZENGx5R2nG5MkUyK6JjbcsY5LaBGkafKY0xLu1cU kSiQ== 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=rSyGuFAVZnXzr+zAXWI5hLV+qnkzbpD8GsyCzJNdKrQ=; b=YfeZaKbM2eITkL2Zz5MIzwho1LW07Hn0cx3fBPR3JyCU+LosxObCAVYpO1AmUUZXBQ HFPOCDuBjQO/yQ4EnNxuB/qxfF+AuCnRwCIa+vZkNe0pVc8nQy3n3DcwcBDh02AhLluo pu5gHHFzO0thlSyBFuiTyxoTSHp8w1WvSABk939Erhln6IwqugK716BZJGDBOmTvSX0C a/509KpvzOTfRLzavO+N0vT/0HSzf4inEOsgqpI4LT/KoTXgxBcIqM1C6j1DIDLOOLte XUoFuJ1Uw+PilSEThYNOVnTE8KoXLlERQL9FUjzbTzZCAD6YIA2Dlrj4DiY74InP0UaH x+iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=mxIQk2YL; 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 s129si9506357oig.177.2020.02.03.18.58.25; Mon, 03 Feb 2020 18:58:37 -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=mxIQk2YL; 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 S1726992AbgBDC5O (ORCPT + 99 others); Mon, 3 Feb 2020 21:57:14 -0500 Received: from mail-pl1-f195.google.com ([209.85.214.195]:41890 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727278AbgBDC5M (ORCPT ); Mon, 3 Feb 2020 21:57:12 -0500 Received: by mail-pl1-f195.google.com with SMTP id t14so6640123plr.8 for ; Mon, 03 Feb 2020 18:57:11 -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=rSyGuFAVZnXzr+zAXWI5hLV+qnkzbpD8GsyCzJNdKrQ=; b=mxIQk2YLkshOw7vJ6iQvQQCce+oSmqrmG5XFCsSQJ/4BKhar12+Sifz2M/V7e8nrmr ISbu9DVITcNCb/Vs5/J3sDuDcHN2dg2BsZVowUuljbbW/BTmU6iPtiMCLc3Pi2eYo75S 10iztGHMfd6G/0yJ1hFE4AmJsc9nxccT76B+c= 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=rSyGuFAVZnXzr+zAXWI5hLV+qnkzbpD8GsyCzJNdKrQ=; b=PeXek0kd+WoTbV5MEsHjeJjm38B9N/vD03XQpmmeUY1J/2PXdzbKgnlg1W3SoEosnk i1cpjfPUOOasMDvlu9Fk9hjZdJ16XDB4muBp7hNANlIPei2wJcYsEGFiQPe5BY0rJV04 eRUVV+vGjAdVWc15Scml0nB5G6R9oLk8w2sycqFDhU5S9be2i5pHVCOV7MGgMoF4fALm rqEp/Mz2K2X5YPhXt0HsVbhYHW2JASqkjypdijLyD4NxQpW1oC5vQFEr2m/m1NpyAXkJ 0P8Rmcqt4Y+a+T2dUa4BtfGxsAacTzJS2Gntjn+++bgddMNJhSWwTSoJTdj3ky4p6IHC 9SEg== X-Gm-Message-State: APjAAAX+ShftODYlY/RkTarHO+6PG/xzwH3e/hRUNwueoicg6N419knn KzBw3aOnSFNg08h/dLoC3whhKQ== X-Received: by 2002:a17:90a:7784:: with SMTP id v4mr3136782pjk.134.1580785030594; Mon, 03 Feb 2020 18:57:10 -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.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2020 18:57:10 -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 06/12] videobuf2: factor out planes prepare/finish functions Date: Tue, 4 Feb 2020 11:56:35 +0900 Message-Id: <20200204025641.218376-7-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 Factor out the code, no functional changes. Change-Id: I47044c0ba57ccc47a5d23f36976ce9f1e3b0f67f Signed-off-by: Sergey Senozhatsky --- .../media/common/videobuf2/videobuf2-core.c | 52 +++++++++++-------- 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c index 56fd17eafb6c..46be9c790ff6 100644 --- a/drivers/media/common/videobuf2/videobuf2-core.c +++ b/drivers/media/common/videobuf2/videobuf2-core.c @@ -296,6 +296,32 @@ static void __vb2_buf_dmabuf_put(struct vb2_buffer *vb) __vb2_plane_dmabuf_put(vb, &vb->planes[plane]); } +/* + * __vb2_buf_mem_prepare() - call ->prepare() on buffer's private memory + * to sync caches + */ +static void __vb2_buf_mem_prepare(struct vb2_buffer *vb) +{ + unsigned int plane; + + for (plane = 0; plane < vb->num_planes; ++plane) + call_void_memop(vb, prepare, vb->planes[plane].mem_priv); + vb->synced = 1; +} + +/* + * __vb2_buf_mem_finish() - call ->finish on buffer's private memory + * to sync caches + */ +static void __vb2_buf_mem_finish(struct vb2_buffer *vb) +{ + unsigned int plane; + + for (plane = 0; plane < vb->num_planes; ++plane) + call_void_memop(vb, finish, vb->planes[plane].mem_priv); + vb->synced = 0; +} + /* * __setup_offsets() - setup unique offsets ("cookies") for every plane in * the buffer. @@ -951,7 +977,6 @@ void vb2_buffer_done(struct vb2_buffer *vb, enum vb2_buffer_state state) { struct vb2_queue *q = vb->vb2_queue; unsigned long flags; - unsigned int plane; if (WARN_ON(vb->state != VB2_BUF_STATE_ACTIVE)) return; @@ -971,12 +996,8 @@ void vb2_buffer_done(struct vb2_buffer *vb, enum vb2_buffer_state state) dprintk(4, "done processing on buffer %d, state: %d\n", vb->index, state); - if (state != VB2_BUF_STATE_QUEUED) { - /* sync buffers */ - for (plane = 0; plane < vb->num_planes; ++plane) - call_void_memop(vb, finish, vb->planes[plane].mem_priv); - vb->synced = 0; - } + if (state != VB2_BUF_STATE_QUEUED) + __vb2_buf_mem_finish(vb); spin_lock_irqsave(&q->done_lock, flags); if (state == VB2_BUF_STATE_QUEUED) { @@ -1301,7 +1322,6 @@ static int __buf_prepare(struct vb2_buffer *vb) { struct vb2_queue *q = vb->vb2_queue; enum vb2_buffer_state orig_state = vb->state; - unsigned int plane; int ret; if (q->error) { @@ -1345,11 +1365,7 @@ static int __buf_prepare(struct vb2_buffer *vb) return ret; } - /* sync buffers */ - for (plane = 0; plane < vb->num_planes; ++plane) - call_void_memop(vb, prepare, vb->planes[plane].mem_priv); - - vb->synced = 1; + __vb2_buf_mem_prepare(vb); vb->prepared = 1; vb->state = orig_state; @@ -1969,14 +1985,8 @@ static void __vb2_queue_cancel(struct vb2_queue *q) call_void_vb_qop(vb, buf_request_complete, vb); } - if (vb->synced) { - unsigned int plane; - - for (plane = 0; plane < vb->num_planes; ++plane) - call_void_memop(vb, finish, - vb->planes[plane].mem_priv); - vb->synced = 0; - } + if (vb->synced) + __vb2_buf_mem_finish(vb); if (vb->prepared) { call_void_vb_qop(vb, buf_finish, vb); -- 2.25.0.341.g760bfbb309-goog