From patchwork Fri Jun 15 19:07:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ezequiel Garcia X-Patchwork-Id: 10467385 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 1E06D601C2 for ; Fri, 15 Jun 2018 19:08:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0EC1628E41 for ; Fri, 15 Jun 2018 19:08:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0365628E42; Fri, 15 Jun 2018 19:08:03 +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=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY 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 F207B1FF2D for ; Fri, 15 Jun 2018 19:08:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936373AbeFOTH7 (ORCPT ); Fri, 15 Jun 2018 15:07:59 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:35870 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934701AbeFOTH7 (ORCPT ); Fri, 15 Jun 2018 15:07:59 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: ezequiel) with ESMTPSA id CB18627BAA8 From: Ezequiel Garcia To: linux-media@vger.kernel.org Cc: Hans Verkuil , kernel@collabora.com, Ezequiel Garcia Subject: [PATCH v4 05/17] mtk-mdp: Add locks for capture and output vb2_queues Date: Fri, 15 Jun 2018 16:07:25 -0300 Message-Id: <20180615190737.24139-6-ezequiel@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180615190737.24139-1-ezequiel@collabora.com> References: <20180615190737.24139-1-ezequiel@collabora.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 Use the mutex in struct mtk_mdp_ctx to protect the capture and output vb2_queues. This allows to replace the ad-hoc wait_{prepare, finish} with vb2_ops_wait_{prepare, finish}. Signed-off-by: Ezequiel Garcia --- drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c b/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c index 583d47724ee8..c2e2f5f1ebf1 100644 --- a/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c @@ -394,20 +394,6 @@ static bool mtk_mdp_ctx_state_is_set(struct mtk_mdp_ctx *ctx, u32 mask) return ret; } -static void mtk_mdp_ctx_lock(struct vb2_queue *vq) -{ - struct mtk_mdp_ctx *ctx = vb2_get_drv_priv(vq); - - mutex_lock(&ctx->mdp_dev->lock); -} - -static void mtk_mdp_ctx_unlock(struct vb2_queue *vq) -{ - struct mtk_mdp_ctx *ctx = vb2_get_drv_priv(vq); - - mutex_unlock(&ctx->mdp_dev->lock); -} - static void mtk_mdp_set_frame_size(struct mtk_mdp_frame *frame, int width, int height) { @@ -625,10 +611,10 @@ static const struct vb2_ops mtk_mdp_m2m_qops = { .queue_setup = mtk_mdp_m2m_queue_setup, .buf_prepare = mtk_mdp_m2m_buf_prepare, .buf_queue = mtk_mdp_m2m_buf_queue, - .wait_prepare = mtk_mdp_ctx_unlock, - .wait_finish = mtk_mdp_ctx_lock, .stop_streaming = mtk_mdp_m2m_stop_streaming, .start_streaming = mtk_mdp_m2m_start_streaming, + .wait_prepare = vb2_ops_wait_prepare, + .wait_finish = vb2_ops_wait_finish, }; static int mtk_mdp_m2m_querycap(struct file *file, void *fh, @@ -996,6 +982,7 @@ static int mtk_mdp_m2m_queue_init(void *priv, struct vb2_queue *src_vq, src_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer); src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; src_vq->dev = &ctx->mdp_dev->pdev->dev; + src_vq->lock = &ctx->mdp_dev->lock; ret = vb2_queue_init(src_vq); if (ret) @@ -1010,6 +997,7 @@ static int mtk_mdp_m2m_queue_init(void *priv, struct vb2_queue *src_vq, dst_vq->buf_struct_size = sizeof(struct v4l2_m2m_buffer); dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY; dst_vq->dev = &ctx->mdp_dev->pdev->dev; + dst_vq->lock = &ctx->mdp_dev->lock; return vb2_queue_init(dst_vq); }