Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp1864829ybf; Sun, 1 Mar 2020 20:13:42 -0800 (PST) X-Google-Smtp-Source: APXvYqw/tRO7rAMP55cLLV3s3ktC1hrTBvv7W2gXqJN4xInjkZ/pIEPCiyJeo3AIkddBqbtpIwXh X-Received: by 2002:aca:fcd8:: with SMTP id a207mr10665377oii.56.1583122422138; Sun, 01 Mar 2020 20:13:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583122422; cv=none; d=google.com; s=arc-20160816; b=N8M2JQCZFhWjB7Uk5Mmj8WEh9kegWvg9LlVRKR9JHEWLFFnuhb2SeB+L3g3O5jvZP1 HDD6WJ1ghiTvnW5ZO9aSWYUMpzIWruNPADyGaPUY/MIRlXJBZpqyQhW/WDVTs4rbwd59 LuqfXcWJ1NzZm7Kcdbe/NKOVxyA4bEpVDmgPccKByClUyElhIfejxOfjoObH8MZeJEoe JkaAzKW7RUWtB0AE9eA/MPV7jkli0kJeSjXERFdbrmyXePNC2CYDCy3ipA8++o1eQYD5 iAnZXf+MpsuwYXq/pmQMtbwj04KpLWaAcBwJw30R6e1NL/IVwyjkmXOF5iP9c0OskjbD Facw== 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=eaNPcBjkoKZw1bZcJWbUbEpJEQzWw7qCsLqY7OuM15k=; b=jEYZhmRw5KYreoicSvG+wOKXBBJpesAkkIIDlQIlu9A5DSN2KUmJh45wQeg+q6QKKn ryKYJlkDKmVkHEPn7o1n0iBC0+2YAXr8XC7fSnz+xUMYZ0sXNLvEpeLZ8AyA+JMxg/QN 9rJjyEZQPLwFGj/K+1/JBL1C5Q5/CE+99Z1TZd+NURMiX0ziUfyf1hhfEPiZAZmgDg4q sKMGVkgce3smIMQyMEj1cu6pGrxwdR0aLBu8yNtM0knrjwuObYbj/x+IzjNGfE3HhdCE 8WMitzVZ1/OF627Tgi2LE3r34ijQoGHe5W/eTeWOgz35da4Mofa1jXv4edePINf3s77p 9DGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="oWp+xew/"; 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 f17si5551307otq.96.2020.03.01.20.13.30; Sun, 01 Mar 2020 20:13:42 -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="oWp+xew/"; 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 S1727158AbgCBEM5 (ORCPT + 99 others); Sun, 1 Mar 2020 23:12:57 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:46684 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727053AbgCBEM4 (ORCPT ); Sun, 1 Mar 2020 23:12:56 -0500 Received: by mail-pf1-f194.google.com with SMTP id o24so4875711pfp.13 for ; Sun, 01 Mar 2020 20:12:56 -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=eaNPcBjkoKZw1bZcJWbUbEpJEQzWw7qCsLqY7OuM15k=; b=oWp+xew/5VjbY2VZwDp/ZZ+7rQIDc5nONr9JZ0WBHtYgxkp8TZKiW6Xt4YDwrvz/wQ 48yqizhHxj8W+QO0pIzDkLiTUq8OlPJp90EVOR8A/tYZgWea2xDVx9T89gpr0Xd3WfN3 T0EeKnLT5zM4RdcMPkPrY5pyjmF83jONU0rms= 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=eaNPcBjkoKZw1bZcJWbUbEpJEQzWw7qCsLqY7OuM15k=; b=g/qDqvzih/OzfULdd0vefrALv4HiQ4J4+0TwBdOyJYVQVBMY7xl/2MdmednHAGkbqT v4sUHv5++a4sR54VGUqTTLyvbOnKkzLg/lboKdtAhtQ5aW/1THizYoTr9ZmLo89j0Mnk LU8ljIXBUIhX+0AsaRIvusDiYI8MEJW6BodIdm6tIvx9og/e3MVfWwBCnmF4nZZOwn9O OD3mN7g6Es3mDsz86ioxOQYu/GJImBHi6bOpFA8ZaD/rdlVSjH/kXnK2Ie+5xfa7jkMV OdzHgV0GBb/X+xN4BYgWBppqRzi2FTuiinr8NgGABPs+WENdzGC4FKKlJvMCqsmTWOgy HRCQ== X-Gm-Message-State: APjAAAXazBmYsZlu6juoJmYUTfkkrnXvk6+ajVWcPWGOqisnlxIFixSI T0NhpLbnDDFhaiaoctiJnA0wwQ== X-Received: by 2002:a63:2b0a:: with SMTP id r10mr18087328pgr.213.1583122375798; Sun, 01 Mar 2020 20:12:55 -0800 (PST) Received: from tigerii.tok.corp.google.com ([2401:fa00:8f:203:5bbb:c872:f2b1:f53b]) by smtp.gmail.com with ESMTPSA id d82sm1698114pfd.187.2020.03.01.20.12.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Mar 2020 20:12:55 -0800 (PST) From: Sergey Senozhatsky To: Hans Verkuil , Tomasz Figa Cc: Mauro Carvalho Chehab , Kyungmin Park , Marek Szyprowski , Sakari Ailus , Laurent Pinchart , Pawel Osciak , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Sergey Senozhatsky Subject: [PATCHv4 06/11] videobuf2: factor out planes prepare/finish functions Date: Mon, 2 Mar 2020 13:12:08 +0900 Message-Id: <20200302041213.27662-7-senozhatsky@chromium.org> X-Mailer: git-send-email 2.25.0.265.gbab2e86ba0-goog In-Reply-To: <20200302041213.27662-1-senozhatsky@chromium.org> References: <20200302041213.27662-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. 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 3ca0545db7ee..c2a1eadb26cf 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.265.gbab2e86ba0-goog