From patchwork Thu Apr 13 07:57:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 9679193 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DF12560326 for ; Thu, 13 Apr 2017 11:17:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D414A2860E for ; Thu, 13 Apr 2017 11:17:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C8F5F2862E; Thu, 13 Apr 2017 11:17:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6D0B02860E for ; Thu, 13 Apr 2017 11:17:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B8BF76E872; Thu, 13 Apr 2017 11:17:18 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7115A6E82B for ; Thu, 13 Apr 2017 07:58:27 +0000 (UTC) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga104.jf.intel.com with ESMTP; 13 Apr 2017 00:58:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.37,194,1488873600"; d="scan'208"; a="1134839009" Received: from paasikivi.fi.intel.com ([10.237.72.42]) by fmsmga001.fm.intel.com with ESMTP; 13 Apr 2017 00:58:24 -0700 Received: from nauris.fi.intel.com (nauris.localdomain [192.168.240.2]) by paasikivi.fi.intel.com (Postfix) with ESMTP id DDC9020D74; Thu, 13 Apr 2017 10:57:53 +0300 (EEST) Received: by nauris.fi.intel.com (Postfix, from userid 1000) id 4B48D201AB; Thu, 13 Apr 2017 10:57:19 +0300 (EEST) From: Sakari Ailus To: linux-media@vger.kernel.org Subject: [RFC v3 02/14] vb2: Move buffer cache synchronisation to prepare from queue Date: Thu, 13 Apr 2017 10:57:07 +0300 Message-Id: <1492070239-21532-3-git-send-email-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1492070239-21532-1-git-send-email-sakari.ailus@linux.intel.com> References: <1492070239-21532-1-git-send-email-sakari.ailus@linux.intel.com> X-Mailman-Approved-At: Thu, 13 Apr 2017 11:17:04 +0000 Cc: daniel.vetter@ffwll.ch, dri-devel@lists.freedesktop.org, hverkuil@xs4all.nl, kyungmin.park@samsung.com, posciak@chromium.org, m.szyprowski@samsung.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP The buffer cache should be synchronised in buffer preparation, not when the buffer is queued to the device. Fix this. Mmap buffers do not need cache synchronisation since they are always coherent. Signed-off-by: Sakari Ailus Acked-by: Hans Verkuil --- drivers/media/v4l2-core/videobuf2-core.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c index 8df680d..8bf3369 100644 --- a/drivers/media/v4l2-core/videobuf2-core.c +++ b/drivers/media/v4l2-core/videobuf2-core.c @@ -1227,23 +1227,19 @@ static int __prepare_dmabuf(struct vb2_buffer *vb, const void *pb) static void __enqueue_in_driver(struct vb2_buffer *vb) { struct vb2_queue *q = vb->vb2_queue; - unsigned int plane; vb->state = VB2_BUF_STATE_ACTIVE; atomic_inc(&q->owned_by_drv_count); trace_vb2_buf_queue(q, vb); - /* sync buffers */ - for (plane = 0; plane < vb->num_planes; ++plane) - call_void_memop(vb, prepare, vb->planes[plane].mem_priv); - call_void_vb_qop(vb, buf_queue, vb); } static int __buf_prepare(struct vb2_buffer *vb, const void *pb) { struct vb2_queue *q = vb->vb2_queue; + unsigned int plane; int ret; if (q->error) { @@ -1268,11 +1264,19 @@ static int __buf_prepare(struct vb2_buffer *vb, const void *pb) ret = -EINVAL; } - if (ret) + if (ret) { dprintk(1, "buffer preparation failed: %d\n", ret); - vb->state = ret ? VB2_BUF_STATE_DEQUEUED : VB2_BUF_STATE_PREPARED; + vb->state = VB2_BUF_STATE_DEQUEUED; + return ret; + } - return ret; + /* sync buffers */ + for (plane = 0; plane < vb->num_planes; ++plane) + call_void_memop(vb, prepare, vb->planes[plane].mem_priv); + + vb->state = VB2_BUF_STATE_PREPARED; + + return 0; } int vb2_core_prepare_buf(struct vb2_queue *q, unsigned int index, void *pb)