From patchwork Fri Dec 16 01:24:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 9477163 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 ECEF560827 for ; Fri, 16 Dec 2016 01:24:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E969528876 for ; Fri, 16 Dec 2016 01:24:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DE4E7288A7; Fri, 16 Dec 2016 01:24:01 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8900D28876 for ; Fri, 16 Dec 2016 01:24:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757198AbcLPBX7 (ORCPT ); Thu, 15 Dec 2016 20:23:59 -0500 Received: from galahad.ideasonboard.com ([185.26.127.97]:50169 "EHLO galahad.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757012AbcLPBX5 (ORCPT ); Thu, 15 Dec 2016 20:23:57 -0500 Received: from avalon.bb.dnainternet.fi (dfj612ybrt5fhg77mgycy-3.rev.dnainternet.fi [IPv6:2001:14ba:21f5:5b00:2e86:4862:ef6a:2804]) by galahad.ideasonboard.com (Postfix) with ESMTPSA id 5A7D6202DC; Fri, 16 Dec 2016 02:23:40 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1481851420; bh=gTVof5yZeoF9xvXwUtc13rLTb9z54ljDkvA6h5rbUmU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ieej+p8fMG6Nxbske3hglkHqlYO53dA4O0RdVw3Y+znwr3+FHF+OFGgkjNqELtRmQ HYxhF1hc6OtD+hsdZOOAieWI68QT/ujmrk2xYPN2+E8j8QD1fqAW4str0Jm0TFDl2y Vph3MWoPXfUvmuJCh6Tec6TKH4xOJgzE1ggYdnlc= From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: dri-devel@lists.freedesktop.org, Pawel Osciak , Marek Szyprowski , Kyungmin Park , Hans Verkuil , Sumit Semwal , Rob Clark , Daniel Vetter , Laura Abbott , Sakari Ailus Subject: [RFC v2 02/11] vb2: Move buffer cache synchronisation to prepare from queue Date: Fri, 16 Dec 2016 03:24:16 +0200 Message-Id: <20161216012425.11179-3-laurent.pinchart+renesas@ideasonboard.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20161216012425.11179-1-laurent.pinchart+renesas@ideasonboard.com> References: <20161216012425.11179-1-laurent.pinchart+renesas@ideasonboard.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Sakari Ailus 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 --- 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 5379c8718010..8ba48703b189 100644 --- a/drivers/media/v4l2-core/videobuf2-core.c +++ b/drivers/media/v4l2-core/videobuf2-core.c @@ -1225,23 +1225,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) { @@ -1266,11 +1262,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)