Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp1170711ybh; Thu, 12 Mar 2020 18:47:57 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuWiueGqSh8I4TltPCTHV0bEWNUqsb3ZtMRm0gLxNwka+YdlMGPP+4CnuzTqtCkGa5G0X6+ X-Received: by 2002:aca:f591:: with SMTP id t139mr4929176oih.153.1584064077247; Thu, 12 Mar 2020 18:47:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584064077; cv=none; d=google.com; s=arc-20160816; b=JVolBhtSR3PVeozSJ1J8Pk1aSyXwdrtJmrakbjG8qb4At35n/1DIhTl5S2b34yB3Yw uek44aP+495P7wjHkVd/r2apgXbEpKTWowhoD94npCvR5oT8CfumtpfTtS4uk9UlrfVK 6TyrPYxSSjei62bysskzJi8Hpb9BAV0FWC3ySprAnwO8tEvgtO0JQMPMoctnSjXagRSK PrEVYKrZVYrzooOmgqulxONyDHvhREBSe43pUi/DgMxD1vLcUqEK4elzSZNVpfTl5nmN BgMbK9e83j+LLBy4POLpMswHdcjtbzC0psZDLzhfpcbnoCZDHmCT+QBRL2vCagpA+Qzo PPOw== 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; bh=PY65rt5yqVQsOtAgIWuSFoj1bEGnbhO5VN70Jc2+YVU=; b=NNx3gD7HQbdNmOSlSyTSn8ivD+UaGwe3hykgAb/LAwQUJ0lP1GZ0TXKJyp+HaoWupk 2fkjwId52oSmcOkm491lWS8Xj3qykvV8wqgj/hkqX5mTH2v1804Y08nlvPxuhadLrNbm d6bmpujNqIJHMiAB1J1/0NutyF2MIo86dCGbxomoIgiED0nB8WWjzISN0gG2kqiL+mBO gN4PcsCDXwRdAfoV5aQBu/OPzMzwb/AiYgKGQXj7UF3snTZ6zrUMkNZkc+O7NRuUfIBn ePbJxM6bDwLik3lXMADtATTDfgntN51jf2u9AG0ndqJsIPETan2cEXuy+bHg1kI1fjoV Iudg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l7si3587070otq.9.2020.03.12.18.47.45; Thu, 12 Mar 2020 18:47:57 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726582AbgCMBqw (ORCPT + 99 others); Thu, 12 Mar 2020 21:46:52 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:48536 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726423AbgCMBqw (ORCPT ); Thu, 12 Mar 2020 21:46:52 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: koike) with ESMTPSA id E643B28DA67 From: Helen Koike To: linux-media@vger.kernel.org Cc: mchehab@kernel.org, linux-kernel@vger.kernel.org, tfiga@chromium.org, linux-rockchip@lists.infradead.org, hans.verkuil@cisco.com, kernel@collabora.com, Helen Koike Subject: [PATCH 3/3] media: staging: rkisp1: cap: serialize start/stop stream Date: Thu, 12 Mar 2020 22:46:26 -0300 Message-Id: <20200313014626.3103091-4-helen.koike@collabora.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200313014626.3103091-1-helen.koike@collabora.com> References: <20200313014626.3103091-1-helen.koike@collabora.com> 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 In order to support simultaneous streaming from both capture devices, start/stop vb2 calls need to be serialized to allow multiple concurrent calls. This is required to synchronize who starts/stops the shared entities in the pipeline. Signed-off-by: Helen Koike --- drivers/staging/media/rkisp1/rkisp1-capture.c | 9 +++++++++ drivers/staging/media/rkisp1/rkisp1-common.h | 2 ++ drivers/staging/media/rkisp1/rkisp1-dev.c | 2 ++ 3 files changed, 13 insertions(+) diff --git a/drivers/staging/media/rkisp1/rkisp1-capture.c b/drivers/staging/media/rkisp1/rkisp1-capture.c index e665381b5af0..30d7a72aa554 100644 --- a/drivers/staging/media/rkisp1/rkisp1-capture.c +++ b/drivers/staging/media/rkisp1/rkisp1-capture.c @@ -935,6 +935,8 @@ static void rkisp1_vb2_stop_streaming(struct vb2_queue *queue) struct rkisp1_device *rkisp1 = cap->rkisp1; int ret; + mutex_lock(&cap->rkisp1->stream_lock); + rkisp1_stream_stop(cap); media_pipeline_stop(&node->vdev.entity); ret = rkisp1_pipeline_sink_walk(&node->vdev.entity, NULL, @@ -954,6 +956,8 @@ static void rkisp1_vb2_stop_streaming(struct vb2_queue *queue) dev_err(rkisp1->dev, "power down failed error:%d\n", ret); rkisp1_dummy_buf_destroy(cap); + + mutex_unlock(&cap->rkisp1->stream_lock); } /* @@ -998,6 +1002,8 @@ rkisp1_vb2_start_streaming(struct vb2_queue *queue, unsigned int count) struct media_entity *entity = &cap->vnode.vdev.entity; int ret; + mutex_lock(&cap->rkisp1->stream_lock); + ret = rkisp1_dummy_buf_create(cap); if (ret) goto err_ret_buffers; @@ -1027,6 +1033,8 @@ rkisp1_vb2_start_streaming(struct vb2_queue *queue, unsigned int count) goto err_pipe_disable; } + mutex_unlock(&cap->rkisp1->stream_lock); + return 0; err_pipe_disable: @@ -1040,6 +1048,7 @@ rkisp1_vb2_start_streaming(struct vb2_queue *queue, unsigned int count) rkisp1_dummy_buf_destroy(cap); err_ret_buffers: rkisp1_return_all_buffers(cap, VB2_BUF_STATE_QUEUED); + mutex_unlock(&cap->rkisp1->stream_lock); return ret; } diff --git a/drivers/staging/media/rkisp1/rkisp1-common.h b/drivers/staging/media/rkisp1/rkisp1-common.h index 369a401b098a..f74fca3985e3 100644 --- a/drivers/staging/media/rkisp1/rkisp1-common.h +++ b/drivers/staging/media/rkisp1/rkisp1-common.h @@ -244,6 +244,7 @@ struct rkisp1_debug { * @rkisp1_capture: capture video device * @stats: ISP statistics output device * @params: ISP input parameters device + * @stream_lock: lock to serialize start/stop streaming in capture devices. */ struct rkisp1_device { void __iomem *base_addr; @@ -263,6 +264,7 @@ struct rkisp1_device { struct rkisp1_params params; struct media_pipeline pipe; struct vb2_alloc_ctx *alloc_ctx; + struct mutex stream_lock; struct rkisp1_debug debug; }; diff --git a/drivers/staging/media/rkisp1/rkisp1-dev.c b/drivers/staging/media/rkisp1/rkisp1-dev.c index 558126e66465..2977c494925f 100644 --- a/drivers/staging/media/rkisp1/rkisp1-dev.c +++ b/drivers/staging/media/rkisp1/rkisp1-dev.c @@ -472,6 +472,8 @@ static int rkisp1_probe(struct platform_device *pdev) dev_set_drvdata(dev, rkisp1); rkisp1->dev = dev; + mutex_init(&rkisp1->stream_lock); + rkisp1->base_addr = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(rkisp1->base_addr)) return PTR_ERR(rkisp1->base_addr); -- 2.25.0