From patchwork Sat Aug 15 10:37:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 11715415 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ABA1B722 for ; Sat, 15 Aug 2020 11:51:31 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6F14E23118 for ; Sat, 15 Aug 2020 11:51:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="w+OKT29C" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6F14E23118 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=EAFIoaivVGtP1LwPbjmQb8tEZFSs5j3cBKiFT/Dls6s=; b=w+OKT29CmU1r5rUfJ2My3YjHSg CMbwTeLOa2dnjIS7xZXlYDF117U6OfzDpz/lotmLK2xvdjMdo+KUhfNkhILuonmAFzMMsWhz/ai4I dURzCRwyizGMJ2eJmw5ikdp6cmDRMSyVM0Es4ifrZmg+YL1r/a54jIfUTsP4SRjfTN86hmyu9hH4V fb12Z91/NJ8ORey2ydSAXp40LsZjY8VAcBVIUGfmF5keb0eD2nJTCWldzBaHCHU9tE8TALJGbEDo+ K3uQvMHeny9ix5ZaiOM2Zti1bSvo9t9JenHCp4DipwndseXsC9PrQBPE6QFdqR0DleK41C6VhtgUz QYOv115g==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k6uia-0006Gd-V6; Sat, 15 Aug 2020 11:51:25 +0000 Received: from bhuna.collabora.co.uk ([2a00:1098:0:82:1000:25:2eeb:e3e3]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k6tZT-0001AW-SC for linux-rockchip@lists.infradead.org; Sat, 15 Aug 2020 10:37:58 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: dafna) with ESMTPSA id B756B29A7CE From: Dafna Hirschfeld To: linux-media@vger.kernel.org Subject: [PATCH v2 01/14] media: staging: rkisp1: call params isr only upon frame out Date: Sat, 15 Aug 2020 12:37:21 +0200 Message-Id: <20200815103734.31153-2-dafna.hirschfeld@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200815103734.31153-1-dafna.hirschfeld@collabora.com> References: <20200815103734.31153-1-dafna.hirschfeld@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200815_063756_095202_2395F2B9 X-CRM114-Status: GOOD ( 14.34 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mchehab@kernel.org, dafna.hirschfeld@collabora.com, dafna3@gmail.com, tfiga@chromium.org, hverkuil@xs4all.nl, linux-rockchip@lists.infradead.org, helen.koike@collabora.com, laurent.pinchart@ideasonboard.com, sakari.ailus@linux.intel.com, kernel@collabora.com, ezequiel@collabora.com MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org Currently the params isr is called and then returned when isp-frame interrupt is not set. This condition is already tested in the isp's isr so move the call under the condition in the isp's isr. Signed-off-by: Dafna Hirschfeld Acked-by: Helen Koike --- drivers/staging/media/rkisp1/rkisp1-common.h | 2 +- drivers/staging/media/rkisp1/rkisp1-isp.c | 12 ++++---- drivers/staging/media/rkisp1/rkisp1-params.c | 29 +++++++++----------- 3 files changed, 20 insertions(+), 23 deletions(-) diff --git a/drivers/staging/media/rkisp1/rkisp1-common.h b/drivers/staging/media/rkisp1/rkisp1-common.h index 3dc51d703f73..29eaadc58489 100644 --- a/drivers/staging/media/rkisp1/rkisp1-common.h +++ b/drivers/staging/media/rkisp1/rkisp1-common.h @@ -313,7 +313,7 @@ void rkisp1_isp_isr(struct rkisp1_device *rkisp1); void rkisp1_mipi_isr(struct rkisp1_device *rkisp1); void rkisp1_capture_isr(struct rkisp1_device *rkisp1); void rkisp1_stats_isr(struct rkisp1_stats *stats, u32 isp_ris); -void rkisp1_params_isr(struct rkisp1_device *rkisp1, u32 isp_mis); +void rkisp1_params_isr(struct rkisp1_device *rkisp1); int rkisp1_capture_devs_register(struct rkisp1_device *rkisp1); void rkisp1_capture_devs_unregister(struct rkisp1_device *rkisp1); diff --git a/drivers/staging/media/rkisp1/rkisp1-isp.c b/drivers/staging/media/rkisp1/rkisp1-isp.c index 6ec1e9816e9f..ad2ece78abbf 100644 --- a/drivers/staging/media/rkisp1/rkisp1-isp.c +++ b/drivers/staging/media/rkisp1/rkisp1-isp.c @@ -1141,12 +1141,12 @@ void rkisp1_isp_isr(struct rkisp1_device *rkisp1) isp_ris = rkisp1_read(rkisp1, RKISP1_CIF_ISP_RIS); if (isp_ris & RKISP1_STATS_MEAS_MASK) rkisp1_stats_isr(&rkisp1->stats, isp_ris); + /* + * Then update changed configs. Some of them involve + * lot of register writes. Do those only one per frame. + * Do the updates in the order of the processing flow. + */ + rkisp1_params_isr(rkisp1); } - /* - * Then update changed configs. Some of them involve - * lot of register writes. Do those only one per frame. - * Do the updates in the order of the processing flow. - */ - rkisp1_params_isr(rkisp1, status); } diff --git a/drivers/staging/media/rkisp1/rkisp1-params.c b/drivers/staging/media/rkisp1/rkisp1-params.c index 797e79de659c..6d69df36c495 100644 --- a/drivers/staging/media/rkisp1/rkisp1-params.c +++ b/drivers/staging/media/rkisp1/rkisp1-params.c @@ -1193,12 +1193,13 @@ static void rkisp1_isp_isr_meas_config(struct rkisp1_params *params, } } -void rkisp1_params_isr(struct rkisp1_device *rkisp1, u32 isp_mis) +void rkisp1_params_isr(struct rkisp1_device *rkisp1) { unsigned int frame_sequence = atomic_read(&rkisp1->isp.frame_sequence); struct rkisp1_params *params = &rkisp1->params; struct rkisp1_params_cfg *new_params; struct rkisp1_buffer *cur_buf = NULL; + u32 isp_ctrl; spin_lock(¶ms->config_lock); if (!params->is_streaming) { @@ -1217,24 +1218,20 @@ void rkisp1_params_isr(struct rkisp1_device *rkisp1, u32 isp_mis) new_params = (struct rkisp1_params_cfg *)(cur_buf->vaddr[0]); - if (isp_mis & RKISP1_CIF_ISP_FRAME) { - u32 isp_ctrl; + rkisp1_isp_isr_other_config(params, new_params); + rkisp1_isp_isr_meas_config(params, new_params); - rkisp1_isp_isr_other_config(params, new_params); - rkisp1_isp_isr_meas_config(params, new_params); + /* update shadow register immediately */ + isp_ctrl = rkisp1_read(params->rkisp1, RKISP1_CIF_ISP_CTRL); + isp_ctrl |= RKISP1_CIF_ISP_CTRL_ISP_CFG_UPD; + rkisp1_write(params->rkisp1, isp_ctrl, RKISP1_CIF_ISP_CTRL); - /* update shadow register immediately */ - isp_ctrl = rkisp1_read(params->rkisp1, RKISP1_CIF_ISP_CTRL); - isp_ctrl |= RKISP1_CIF_ISP_CTRL_ISP_CFG_UPD; - rkisp1_write(params->rkisp1, isp_ctrl, RKISP1_CIF_ISP_CTRL); - - spin_lock(¶ms->config_lock); - list_del(&cur_buf->queue); - spin_unlock(¶ms->config_lock); + spin_lock(¶ms->config_lock); + list_del(&cur_buf->queue); + spin_unlock(¶ms->config_lock); - cur_buf->vb.sequence = frame_sequence; - vb2_buffer_done(&cur_buf->vb.vb2_buf, VB2_BUF_STATE_DONE); - } + cur_buf->vb.sequence = frame_sequence; + vb2_buffer_done(&cur_buf->vb.vb2_buf, VB2_BUF_STATE_DONE); } static const struct rkisp1_cif_isp_awb_meas_config rkisp1_awb_params_default_config = { From patchwork Sat Aug 15 10:37:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 11715373 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 02EBA13A4 for ; Sat, 15 Aug 2020 10:38:03 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C9FAA22EBF for ; Sat, 15 Aug 2020 10:38:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="JjFTY2az" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C9FAA22EBF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=HvDnZHMVMs1Vc09mo/9k+D4Wz9mO7bgdiGQwRRya1qY=; b=JjFTY2azVUIBT4/kocWqUJNoIg QlA3Vc3sP5JVi2KLU9OddgUZ+GjxQlEg11kHsES4eI7pynhQ7739g4Giw0oU06tH9tqdnCy6T4WdH QbSFepVGpC1QfdjIQKlsIiqky0NP1JtqbmCCxbHsgiRg+2WmozsQ123vy12L9OyXBsFQgRdsK6ZGi sYw9fok4wCsbRd5h5QQ1Jmnabe847OuKBC0IbAbVeO8VEw1FQUdNy1DYI8tmaJ+voSpJ598eQUOAD hDUW0FCd580x9Tt+nkHP3rhrfKqVazaf2a3twFkHyN1FB2v8WpAiH5ZWI1vMJIV3WPN1m0OvId0qe VOdiZEAA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k6tZW-0001Ev-Gj; Sat, 15 Aug 2020 10:37:58 +0000 Received: from bhuna.collabora.co.uk ([2a00:1098:0:82:1000:25:2eeb:e3e3]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k6tZT-0001AX-SC for linux-rockchip@lists.infradead.org; Sat, 15 Aug 2020 10:37:56 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: dafna) with ESMTPSA id 3FD3829A68C From: Dafna Hirschfeld To: linux-media@vger.kernel.org Subject: [PATCH v2 02/14] media: staging: rkisp1: params: use rkisp1_param_set_bits to set reg in isr Date: Sat, 15 Aug 2020 12:37:22 +0200 Message-Id: <20200815103734.31153-3-dafna.hirschfeld@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200815103734.31153-1-dafna.hirschfeld@collabora.com> References: <20200815103734.31153-1-dafna.hirschfeld@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200815_063756_013831_96A73312 X-CRM114-Status: UNSURE ( 9.29 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mchehab@kernel.org, dafna.hirschfeld@collabora.com, dafna3@gmail.com, tfiga@chromium.org, hverkuil@xs4all.nl, linux-rockchip@lists.infradead.org, helen.koike@collabora.com, laurent.pinchart@ideasonboard.com, sakari.ailus@linux.intel.com, kernel@collabora.com, ezequiel@collabora.com MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org replace a read and write of RKISP1_CIF_ISP_CTRL register in the isr with the 'rkisp1_param_set_bits' function that does that. Signed-off-by: Dafna Hirschfeld Acked-by: Helen Koike --- drivers/staging/media/rkisp1/rkisp1-params.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/media/rkisp1/rkisp1-params.c b/drivers/staging/media/rkisp1/rkisp1-params.c index 6d69df36c495..8d881f1df1e6 100644 --- a/drivers/staging/media/rkisp1/rkisp1-params.c +++ b/drivers/staging/media/rkisp1/rkisp1-params.c @@ -1199,7 +1199,6 @@ void rkisp1_params_isr(struct rkisp1_device *rkisp1) struct rkisp1_params *params = &rkisp1->params; struct rkisp1_params_cfg *new_params; struct rkisp1_buffer *cur_buf = NULL; - u32 isp_ctrl; spin_lock(¶ms->config_lock); if (!params->is_streaming) { @@ -1222,9 +1221,7 @@ void rkisp1_params_isr(struct rkisp1_device *rkisp1) rkisp1_isp_isr_meas_config(params, new_params); /* update shadow register immediately */ - isp_ctrl = rkisp1_read(params->rkisp1, RKISP1_CIF_ISP_CTRL); - isp_ctrl |= RKISP1_CIF_ISP_CTRL_ISP_CFG_UPD; - rkisp1_write(params->rkisp1, isp_ctrl, RKISP1_CIF_ISP_CTRL); + rkisp1_param_set_bits(params, RKISP1_CIF_ISP_CTRL, RKISP1_CIF_ISP_CTRL_ISP_CFG_UPD); spin_lock(¶ms->config_lock); list_del(&cur_buf->queue); From patchwork Sat Aug 15 10:37:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 11715375 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A8F4113A4 for ; Sat, 15 Aug 2020 10:38:05 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7CAD422EBF for ; Sat, 15 Aug 2020 10:38:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="SGXP2lpR" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7CAD422EBF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=SQWnC8h2ylTbc3DXsSal7rofkb1YBorokuds/Mgyzl8=; b=SGXP2lpRjee4oWi4Dlvt+yIjW5 wtQTGblEUS8Ycy6FjfJ0v434D4OasOsEqyZWCu7f4iflYQLL2HXSZg3/41cpBIhB6rVtpEBU30jf6 MhCRyS0P+OIlqOd1Y8vauB/aWf5EEXCyNCcuk9DgHzeZVe/IKn4Qpj/IBRBY9ztKVquMA6mwFxn+w MTQdPpZeXc672QVzInI2EOsBjlDr6kW1s5eVkUQNxezUZNcSzioeqVNrS7hVlfGijf46jhM1Tx9+D 370OLI6LCndeYYFxyPPLt4U9gPzZWNlUA+EzDWfRgBHnOesHGFNywl7qMUJbB1Tx2EQU60QNnpyHD Rhur0Zgw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k6tZY-0001GP-7J; Sat, 15 Aug 2020 10:38:00 +0000 Received: from bhuna.collabora.co.uk ([2a00:1098:0:82:1000:25:2eeb:e3e3]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k6tZT-0001AY-SD for linux-rockchip@lists.infradead.org; Sat, 15 Aug 2020 10:37:56 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: dafna) with ESMTPSA id BAA8029A948 From: Dafna Hirschfeld To: linux-media@vger.kernel.org Subject: [PATCH v2 03/14] media: staging: rkisp1: params: use the new effect value in cproc config Date: Sat, 15 Aug 2020 12:37:23 +0200 Message-Id: <20200815103734.31153-4-dafna.hirschfeld@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200815103734.31153-1-dafna.hirschfeld@collabora.com> References: <20200815103734.31153-1-dafna.hirschfeld@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200815_063756_091544_FDD8C688 X-CRM114-Status: GOOD ( 12.53 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mchehab@kernel.org, dafna.hirschfeld@collabora.com, dafna3@gmail.com, tfiga@chromium.org, hverkuil@xs4all.nl, linux-rockchip@lists.infradead.org, helen.koike@collabora.com, laurent.pinchart@ideasonboard.com, sakari.ailus@linux.intel.com, kernel@collabora.com, ezequiel@collabora.com MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org The cproc (color processing) configuration needs to know if an image effect is configured. The code uses the image effect in 'cur_params' which is the first params buffer queued in the stream. This is the wrong place to read the value. The value should be taken from the current params buffer. Signed-off-by: Dafna Hirschfeld Acked-by: Helen Koike --- drivers/staging/media/rkisp1/rkisp1-params.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/media/rkisp1/rkisp1-params.c b/drivers/staging/media/rkisp1/rkisp1-params.c index 8d881f1df1e6..eb77b4ed8655 100644 --- a/drivers/staging/media/rkisp1/rkisp1-params.c +++ b/drivers/staging/media/rkisp1/rkisp1-params.c @@ -560,7 +560,7 @@ static void rkisp1_cproc_config(struct rkisp1_params *params, const struct rkisp1_cif_isp_cproc_config *arg) { struct rkisp1_cif_isp_isp_other_cfg *cur_other_cfg = - ¶ms->cur_params.others; + container_of(arg, struct rkisp1_cif_isp_isp_other_cfg, cproc_config); struct rkisp1_cif_isp_ie_config *cur_ie_config = &cur_other_cfg->ie_config; u32 effect = cur_ie_config->effect; From patchwork Sat Aug 15 10:37:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 11715379 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6B1F914F6 for ; Sat, 15 Aug 2020 10:38:09 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 44D6822EBF for ; Sat, 15 Aug 2020 10:38:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Mp2IO2my" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 44D6822EBF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=45NYRH+yT68m2NqnWv57YfMhRi+6gujKVCiVX/JDOP8=; b=Mp2IO2myed/a/lkzI1pErLJV4c ts+CbxDyTlRxgrRD625cx2l59bRBgLXOYJ8ic/ydxGcFPL/5MzvtMN2WwpJo/oScmqb7p1HLJICSF zKa7ntQ1LO525MGLvsXrfELET8h2sV2+xoHnnohtEZdDCbGQOhe7d5UmY7ekDajdo/E0eGrKeo3k+ 6c8YzyANmNsi5Ktb8z9V6bcLNvpe6uXrkNf6+faYjLh4A17qC07SdGBNuspBIK8MDEle4dnxNtkR7 CEDjlb7/y9BD3H0FXM9aV9gFqhCILnUtqSqtOO1jEzN5PCZbvTjLB0y0fG/no6HaVSJviBGrX03lO Nxu6YeUg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k6tZc-0001KC-Pf; Sat, 15 Aug 2020 10:38:04 +0000 Received: from bhuna.collabora.co.uk ([2a00:1098:0:82:1000:25:2eeb:e3e3]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k6tZU-0001Ad-FK for linux-rockchip@lists.infradead.org; Sat, 15 Aug 2020 10:37:58 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: dafna) with ESMTPSA id 4292629A94D From: Dafna Hirschfeld To: linux-media@vger.kernel.org Subject: [PATCH v2 04/14] media: staging: rkisp1: params: don't release lock in isr before buffer is done Date: Sat, 15 Aug 2020 12:37:24 +0200 Message-Id: <20200815103734.31153-5-dafna.hirschfeld@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200815103734.31153-1-dafna.hirschfeld@collabora.com> References: <20200815103734.31153-1-dafna.hirschfeld@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200815_063756_659201_C9E0392A X-CRM114-Status: GOOD ( 11.09 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mchehab@kernel.org, dafna.hirschfeld@collabora.com, dafna3@gmail.com, tfiga@chromium.org, hverkuil@xs4all.nl, linux-rockchip@lists.infradead.org, helen.koike@collabora.com, laurent.pinchart@ideasonboard.com, sakari.ailus@linux.intel.com, kernel@collabora.com, ezequiel@collabora.com MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org In the irq handler 'rkisp1_params_isr', the lock 'config_lock' should be held as long as the current buffer is used. Otherwise the stop_streaming calback might remove it from the list and pass it to userspace while it is referenced in the irq handler. Signed-off-by: Dafna Hirschfeld Acked-by: Helen Koike --- drivers/staging/media/rkisp1/rkisp1-params.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/media/rkisp1/rkisp1-params.c b/drivers/staging/media/rkisp1/rkisp1-params.c index eb77b4ed8655..0c2bb2eefb22 100644 --- a/drivers/staging/media/rkisp1/rkisp1-params.c +++ b/drivers/staging/media/rkisp1/rkisp1-params.c @@ -1210,10 +1210,11 @@ void rkisp1_params_isr(struct rkisp1_device *rkisp1) if (!list_empty(¶ms->params)) cur_buf = list_first_entry(¶ms->params, struct rkisp1_buffer, queue); - spin_unlock(¶ms->config_lock); - if (!cur_buf) + if (!cur_buf) { + spin_unlock(¶ms->config_lock); return; + } new_params = (struct rkisp1_params_cfg *)(cur_buf->vaddr[0]); @@ -1223,12 +1224,11 @@ void rkisp1_params_isr(struct rkisp1_device *rkisp1) /* update shadow register immediately */ rkisp1_param_set_bits(params, RKISP1_CIF_ISP_CTRL, RKISP1_CIF_ISP_CTRL_ISP_CFG_UPD); - spin_lock(¶ms->config_lock); list_del(&cur_buf->queue); - spin_unlock(¶ms->config_lock); cur_buf->vb.sequence = frame_sequence; vb2_buffer_done(&cur_buf->vb.vb2_buf, VB2_BUF_STATE_DONE); + spin_unlock(¶ms->config_lock); } static const struct rkisp1_cif_isp_awb_meas_config rkisp1_awb_params_default_config = { From patchwork Sat Aug 15 10:37:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 11715377 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 15D8F14F6 for ; Sat, 15 Aug 2020 10:38:06 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E1FD422EBF for ; Sat, 15 Aug 2020 10:38:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="uZTcc3kW" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E1FD422EBF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=awz6Lv8iBwQs9ORT1t1paVE5Ps7Q6HEldlefjQzzs0w=; b=uZTcc3kWpDHslSnxrFEcj0HhrC B5ewl020Ruh+l3dG0Xb/qhNe3Y7iOrBkS3rsQ8+9pVAS0e2sIn6VXlw+v7p4jcYA42QOgabrSiDGa exaviQNK6ZC9LgUBeHA9X2uBhJajTZ9f5vMR4NzKWpgaUvmPV8e7fs/VLpo6Rzkz+XnowhPGev82p MNJh1qvLfiQnPN7uuM5dnXFTozn93dr/EQYak8qEbP5gkAvPKalg3zAHYJ6os18UQceluWAmqanbI V2jq0JXxaS3dtbqQ1p6uNM2HCFkuC6+9lUnKTfeH8RXl83pJYXtcPpVV90vTDY2igPY+EqXgaWRqg G1iVX6WQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k6tZZ-0001Hd-Mf; Sat, 15 Aug 2020 10:38:01 +0000 Received: from bhuna.collabora.co.uk ([46.235.227.227]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k6tZU-0001Bu-Qi for linux-rockchip@lists.infradead.org; Sat, 15 Aug 2020 10:37:58 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: dafna) with ESMTPSA id CC80829A955 From: Dafna Hirschfeld To: linux-media@vger.kernel.org Subject: [PATCH v2 05/14] media: staging: rkisp1: params: upon stream stop, iterate a local list to return the buffers Date: Sat, 15 Aug 2020 12:37:25 +0200 Message-Id: <20200815103734.31153-6-dafna.hirschfeld@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200815103734.31153-1-dafna.hirschfeld@collabora.com> References: <20200815103734.31153-1-dafna.hirschfeld@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200815_063757_009586_CE04C042 X-CRM114-Status: GOOD ( 14.42 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [46.235.227.227 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mchehab@kernel.org, dafna.hirschfeld@collabora.com, dafna3@gmail.com, tfiga@chromium.org, hverkuil@xs4all.nl, linux-rockchip@lists.infradead.org, helen.koike@collabora.com, laurent.pinchart@ideasonboard.com, sakari.ailus@linux.intel.com, kernel@collabora.com, ezequiel@collabora.com MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org The code in '.stop_streaming' callback releases and acquire the lock at each iteration when returning the buffers. Holding the lock disables interrupts so it should be minimized. To make the code cleaner and still minimize holding the lock, the buffer list is first moved to a local list and then can be iterated without the lock. Signed-off-by: Dafna Hirschfeld Acked-by: Helen Koike --- drivers/staging/media/rkisp1/rkisp1-params.c | 31 +++++++------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/drivers/staging/media/rkisp1/rkisp1-params.c b/drivers/staging/media/rkisp1/rkisp1-params.c index 0c2bb2eefb22..6a76c586e916 100644 --- a/drivers/staging/media/rkisp1/rkisp1-params.c +++ b/drivers/staging/media/rkisp1/rkisp1-params.c @@ -1477,32 +1477,23 @@ static void rkisp1_params_vb2_stop_streaming(struct vb2_queue *vq) { struct rkisp1_params *params = vq->drv_priv; struct rkisp1_buffer *buf; + struct list_head tmp_list; unsigned long flags; - unsigned int i; - /* stop params input firstly */ + INIT_LIST_HEAD(&tmp_list); + + /* + * we first move the buffers into a local list 'tmp_list' + * and then we can iterate it and call vb2_buffer_done + * without holding the lock + */ spin_lock_irqsave(¶ms->config_lock, flags); params->is_streaming = false; + list_cut_position(&tmp_list, ¶ms->params, params->params.prev); spin_unlock_irqrestore(¶ms->config_lock, flags); - for (i = 0; i < RKISP1_ISP_PARAMS_REQ_BUFS_MAX; i++) { - spin_lock_irqsave(¶ms->config_lock, flags); - if (!list_empty(¶ms->params)) { - buf = list_first_entry(¶ms->params, - struct rkisp1_buffer, queue); - list_del(&buf->queue); - spin_unlock_irqrestore(¶ms->config_lock, - flags); - } else { - spin_unlock_irqrestore(¶ms->config_lock, - flags); - break; - } - - if (buf) - vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR); - buf = NULL; - } + list_for_each_entry(buf, &tmp_list, queue) + vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR); } static int From patchwork Sat Aug 15 10:37:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 11715381 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EDBED13A4 for ; Sat, 15 Aug 2020 10:38:11 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C79722310B for ; Sat, 15 Aug 2020 10:38:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="1dH+MsyN" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C79722310B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=PXVOBI22L6Yzbtfu7pc5afy1iExH7rJ2nVP5NnSWXHY=; b=1dH+MsyNKue+N+D6FfUDALeTpF Ozu3PbwL8Ta8JMYYRX1p12DajvoZMjFw/tt1NR9NiXvO2mFrI2uKx0eGoCwMiIWCMxQLwt34XbZVP W9RVAQ+ubXS797zVjb+zUAFSuiG770qtV4of3tiIhVIyAHg5poIjY6cwl+/lJmEhV+WE55cJnnPPv 8ugF7MMGryNIJ02C7tle2aRJMuX8cNKd/VP7U2h8TafAx76yu+KIq0rkpHcLXfk/7aQ2OXl9svfNi sBQPi6x3AGsIios3c9wDd4r6bfrUBpgORtvphYSOC/wNqUQ2fRkfr7tLd5+grnZUU5SwaKUUziTW3 EqId/naA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k6tZe-0001Kx-H1; Sat, 15 Aug 2020 10:38:06 +0000 Received: from bhuna.collabora.co.uk ([2a00:1098:0:82:1000:25:2eeb:e3e3]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k6tZV-0001Ca-2Y for linux-rockchip@lists.infradead.org; Sat, 15 Aug 2020 10:37:58 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: dafna) with ESMTPSA id AC8D929A958 From: Dafna Hirschfeld To: linux-media@vger.kernel.org Subject: [PATCH v2 06/14] media: staging: rkisp1: params: in the isr, return if buffer list is empty Date: Sat, 15 Aug 2020 12:37:26 +0200 Message-Id: <20200815103734.31153-7-dafna.hirschfeld@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200815103734.31153-1-dafna.hirschfeld@collabora.com> References: <20200815103734.31153-1-dafna.hirschfeld@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200815_063757_245070_0A6D6022 X-CRM114-Status: GOOD ( 11.95 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mchehab@kernel.org, dafna.hirschfeld@collabora.com, dafna3@gmail.com, tfiga@chromium.org, hverkuil@xs4all.nl, linux-rockchip@lists.infradead.org, helen.koike@collabora.com, laurent.pinchart@ideasonboard.com, sakari.ailus@linux.intel.com, kernel@collabora.com, ezequiel@collabora.com MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org Currently the code in the isr checks if the buffer list is not empty before referencing a buffer and then check again if the buffer is not NULL. Instead we can save one 'if' statement by returning if the buffers list is empty. Also remove non-helpful inline doc 'get one empty buffer' Signed-off-by: Dafna Hirschfeld Acked-by: Helen Koike --- drivers/staging/media/rkisp1/rkisp1-params.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/staging/media/rkisp1/rkisp1-params.c b/drivers/staging/media/rkisp1/rkisp1-params.c index 6a76c586e916..86bbd01e18c7 100644 --- a/drivers/staging/media/rkisp1/rkisp1-params.c +++ b/drivers/staging/media/rkisp1/rkisp1-params.c @@ -1206,16 +1206,14 @@ void rkisp1_params_isr(struct rkisp1_device *rkisp1) return; } - /* get one empty buffer */ - if (!list_empty(¶ms->params)) - cur_buf = list_first_entry(¶ms->params, - struct rkisp1_buffer, queue); - - if (!cur_buf) { + if (list_empty(¶ms->params)) { spin_unlock(¶ms->config_lock); return; } + cur_buf = list_first_entry(¶ms->params, + struct rkisp1_buffer, queue); + new_params = (struct rkisp1_params_cfg *)(cur_buf->vaddr[0]); rkisp1_isp_isr_other_config(params, new_params); From patchwork Sat Aug 15 10:37:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 11715387 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 877C113A4 for ; Sat, 15 Aug 2020 10:38:14 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 60F7022EBF for ; Sat, 15 Aug 2020 10:38:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="KNLatYNQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 60F7022EBF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=uwt+5BC4Gjzu5goZZavB+Mu3XqWUGVqHb+RrrhVGZtc=; b=KNLatYNQTGQQpiC2pDnXhUrWUL +IpcgILK8PQpKlq7aFvp4OUR2T0ECJnHxzh5VTC/WqLa1Wzsi9Pup2bOSvNeLuhvQcu/H3O0HN6tO KSVMkNZchb4SGGe3gTcDeZ9L9rJur90Qtu3Bf4NtumZ1NT87CoaJhGewlz+pdCEZMnuK804d4L29O K5eREBIgYGZ/XZ+mo9kSjuMh4QeRQIeDPz1LmlLAJTz3wX8Sy3sFwVDNctcJ4qOyH5OLG/TAQguVq Ljyk6HVQayjv/vq/mwMuifYbYv9FsRdIb2Z6K0gsPudOfe41+kq1/c8AtUhf0oFznCn7gSe6KFp++ KPArjEqw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k6tZh-0001N0-RU; Sat, 15 Aug 2020 10:38:09 +0000 Received: from bhuna.collabora.co.uk ([46.235.227.227]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k6tZV-0001DT-J8 for linux-rockchip@lists.infradead.org; Sat, 15 Aug 2020 10:38:01 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: dafna) with ESMTPSA id 7FA3229A95F From: Dafna Hirschfeld To: linux-media@vger.kernel.org Subject: [PATCH v2 07/14] media: staging: rkisp1: params: avoid using buffer if params is not streaming Date: Sat, 15 Aug 2020 12:37:27 +0200 Message-Id: <20200815103734.31153-8-dafna.hirschfeld@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200815103734.31153-1-dafna.hirschfeld@collabora.com> References: <20200815103734.31153-1-dafna.hirschfeld@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200815_063757_841902_9DD4921E X-CRM114-Status: GOOD ( 20.29 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [46.235.227.227 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mchehab@kernel.org, dafna.hirschfeld@collabora.com, dafna3@gmail.com, tfiga@chromium.org, hverkuil@xs4all.nl, linux-rockchip@lists.infradead.org, helen.koike@collabora.com, laurent.pinchart@ideasonboard.com, sakari.ailus@linux.intel.com, kernel@collabora.com, ezequiel@collabora.com MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org Currently, the first buffer queued in the params node is returned immediately to userspace and a copy of it is saved in the field 'cur_params'. The copy is later used for the first configuration when the stream is initiated by one of selfpath/mainpath capture nodes. There are 3 problems with this implementation: - The first params buffer is applied and returned to userspace even if userspace never calls to streamon on the params node. - If the first params buffer is queued after the stream started on the params node then it will return to userspace but will never be used. - The frame_sequence of the first buffer is set to -1 if the main/selfpath did not start streaming. A correct implementation is to apply the first params buffer when stream is started from mainpath/selfpath and only if params is also streaming. The patch adds a new function 'rkisp1_params_apply_params_cfg' which takes a buffer from the buffers queue, apply it and returns it to userspace. The function is called from the irq handler and when main/selfpath stream starts - in the function 'rkisp1_params_config_parameter' Also remove the fields 'cur_params', 'is_first_params' which are no more needed. Signed-off-by: Dafna Hirschfeld Reported-by: kernel test robot Acked-by: Helen Koike --- drivers/staging/media/rkisp1/rkisp1-common.h | 5 -- drivers/staging/media/rkisp1/rkisp1-params.c | 49 ++++++++------------ 2 files changed, 19 insertions(+), 35 deletions(-) diff --git a/drivers/staging/media/rkisp1/rkisp1-common.h b/drivers/staging/media/rkisp1/rkisp1-common.h index 29eaadc58489..9b41935c6597 100644 --- a/drivers/staging/media/rkisp1/rkisp1-common.h +++ b/drivers/staging/media/rkisp1/rkisp1-common.h @@ -197,9 +197,6 @@ struct rkisp1_stats { /* * struct rkisp1_params - ISP input parameters device - * - * @cur_params: Current ISP parameters - * @is_first_params: the first params should take effect immediately */ struct rkisp1_params { struct rkisp1_vdev_node vnode; @@ -207,10 +204,8 @@ struct rkisp1_params { spinlock_t config_lock; struct list_head params; - struct rkisp1_params_cfg cur_params; struct v4l2_format vdev_fmt; bool is_streaming; - bool is_first_params; enum v4l2_quantization quantization; enum rkisp1_fmt_raw_pat_type raw_type; diff --git a/drivers/staging/media/rkisp1/rkisp1-params.c b/drivers/staging/media/rkisp1/rkisp1-params.c index 86bbd01e18c7..134b5c9a94c1 100644 --- a/drivers/staging/media/rkisp1/rkisp1-params.c +++ b/drivers/staging/media/rkisp1/rkisp1-params.c @@ -1193,23 +1193,13 @@ static void rkisp1_isp_isr_meas_config(struct rkisp1_params *params, } } -void rkisp1_params_isr(struct rkisp1_device *rkisp1) +void rkisp1_params_apply_params_cfg(struct rkisp1_params *params, unsigned int frame_sequence) { - unsigned int frame_sequence = atomic_read(&rkisp1->isp.frame_sequence); - struct rkisp1_params *params = &rkisp1->params; struct rkisp1_params_cfg *new_params; struct rkisp1_buffer *cur_buf = NULL; - spin_lock(¶ms->config_lock); - if (!params->is_streaming) { - spin_unlock(¶ms->config_lock); - return; - } - - if (list_empty(¶ms->params)) { - spin_unlock(¶ms->config_lock); + if (list_empty(¶ms->params)) return; - } cur_buf = list_first_entry(¶ms->params, struct rkisp1_buffer, queue); @@ -1226,6 +1216,20 @@ void rkisp1_params_isr(struct rkisp1_device *rkisp1) cur_buf->vb.sequence = frame_sequence; vb2_buffer_done(&cur_buf->vb.vb2_buf, VB2_BUF_STATE_DONE); +} + +void rkisp1_params_isr(struct rkisp1_device *rkisp1) +{ + unsigned int frame_sequence = atomic_read(&rkisp1->isp.frame_sequence); + struct rkisp1_params *params = &rkisp1->params; + + spin_lock(¶ms->config_lock); + if (!params->is_streaming) { + spin_unlock(¶ms->config_lock); + return; + } + rkisp1_params_apply_params_cfg(params, frame_sequence); + spin_unlock(¶ms->config_lock); } @@ -1298,9 +1302,9 @@ static void rkisp1_params_config_parameter(struct rkisp1_params *params) else rkisp1_csm_config(params, false); - /* override the default things */ - rkisp1_isp_isr_other_config(params, ¶ms->cur_params); - rkisp1_isp_isr_meas_config(params, ¶ms->cur_params); + /* apply the first buffer if there is one already */ + if (params->is_streaming) + rkisp1_params_apply_params_cfg(params, 0); spin_unlock(¶ms->config_lock); } @@ -1428,8 +1432,6 @@ static int rkisp1_params_vb2_queue_setup(struct vb2_queue *vq, sizes[0] = sizeof(struct rkisp1_params_cfg); INIT_LIST_HEAD(¶ms->params); - params->is_first_params = true; - return 0; } @@ -1440,20 +1442,7 @@ static void rkisp1_params_vb2_buf_queue(struct vb2_buffer *vb) container_of(vbuf, struct rkisp1_buffer, vb); struct vb2_queue *vq = vb->vb2_queue; struct rkisp1_params *params = vq->drv_priv; - struct rkisp1_params_cfg *new_params; unsigned long flags; - unsigned int frame_sequence = - atomic_read(¶ms->rkisp1->isp.frame_sequence); - - if (params->is_first_params) { - new_params = (struct rkisp1_params_cfg *) - (vb2_plane_vaddr(vb, 0)); - vbuf->sequence = frame_sequence; - vb2_buffer_done(¶ms_buf->vb.vb2_buf, VB2_BUF_STATE_DONE); - params->is_first_params = false; - params->cur_params = *new_params; - return; - } params_buf->vaddr[0] = vb2_plane_vaddr(vb, 0); spin_lock_irqsave(¶ms->config_lock, flags); From patchwork Sat Aug 15 10:37:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 11715383 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B804C14F6 for ; Sat, 15 Aug 2020 10:38:12 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 91D6122EBF for ; Sat, 15 Aug 2020 10:38:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="tguOUiMK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 91D6122EBF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ybhX1qvcbTpcunUuQoEIi2v/UAK1+dsrrcZW6EHi/Ks=; b=tguOUiMKg8XiWiXp3iNMFsK7J/ zISaB7RaBYOdo9EqvmbVgPyRoxvvNJTsrJjuCpWTNr60+PJKPnRM3SHreelwcL5le8vHrnBShkI/o GjW1m1dm5mJTkeMsfXltcpXtK+NOwOnt8WYzyPkfHk/w+5gZPP0sVWFW7g0qHKnmPcnNoxpBKXHgx NO9p0LdESfVwVcTM43NIyrq7ADzNILsSuJriS+FGfvZvF33TrC/An34Iw4DeepmLIGcg1HTBJpwg0 tomDN3k+opAKQfXRWqioq4ddb13V6DuVWe793Ah7eSgd/kxE2HgdREWqCVUWjAyzYdzZEPW5AvWpS eZjueVHQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k6tZh-0001Mc-7R; Sat, 15 Aug 2020 10:38:09 +0000 Received: from bhuna.collabora.co.uk ([2a00:1098:0:82:1000:25:2eeb:e3e3]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k6tZW-0001Dz-4h for linux-rockchip@lists.infradead.org; Sat, 15 Aug 2020 10:38:01 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: dafna) with ESMTPSA id 0BD3729A962 From: Dafna Hirschfeld To: linux-media@vger.kernel.org Subject: [PATCH v2 08/14] media: staging: rkisp1: params: set vb.sequence to be the isp's frame_sequence + 1 Date: Sat, 15 Aug 2020 12:37:28 +0200 Message-Id: <20200815103734.31153-9-dafna.hirschfeld@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200815103734.31153-1-dafna.hirschfeld@collabora.com> References: <20200815103734.31153-1-dafna.hirschfeld@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200815_063758_285809_C189F855 X-CRM114-Status: GOOD ( 11.29 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mchehab@kernel.org, dafna.hirschfeld@collabora.com, dafna3@gmail.com, tfiga@chromium.org, hverkuil@xs4all.nl, linux-rockchip@lists.infradead.org, helen.koike@collabora.com, laurent.pinchart@ideasonboard.com, sakari.ailus@linux.intel.com, kernel@collabora.com, ezequiel@collabora.com MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org The params isr is called when a frame is out of the isp. The parameters are applied immediately since the isr updates the shadow registers. Therefore the params are first applied on the next frame. We want the vb.sequence to be the frame that the params are applied to. So we set vb.sequence to be the isp's frame_sequence + 1 Signed-off-by: Dafna Hirschfeld Acked-by: Helen Koike --- drivers/staging/media/rkisp1/rkisp1-params.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/staging/media/rkisp1/rkisp1-params.c b/drivers/staging/media/rkisp1/rkisp1-params.c index 134b5c9a94c1..4b4391c0a2a0 100644 --- a/drivers/staging/media/rkisp1/rkisp1-params.c +++ b/drivers/staging/media/rkisp1/rkisp1-params.c @@ -1220,7 +1220,14 @@ void rkisp1_params_apply_params_cfg(struct rkisp1_params *params, unsigned int f void rkisp1_params_isr(struct rkisp1_device *rkisp1) { - unsigned int frame_sequence = atomic_read(&rkisp1->isp.frame_sequence); + /* + * The params isr is called when a frame is out of the isp. The parameters + * are applied immediately since the isr updates the shadow registers. + * Therefore the params are first applied on the next frame. + * We want the vb.sequence to be the frame that the params are applied to. + * So we set vb.sequence to be the isp's frame_sequence + 1 + */ + unsigned int frame_sequence = atomic_read(&rkisp1->isp.frame_sequence) + 1; struct rkisp1_params *params = &rkisp1->params; spin_lock(¶ms->config_lock); From patchwork Sat Aug 15 10:37:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 11715391 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 517AA16B1 for ; Sat, 15 Aug 2020 10:38:16 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2AFBC22EBF for ; Sat, 15 Aug 2020 10:38:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="UjCUFjGB" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2AFBC22EBF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=zlDbDE4GmzyZ2ha+tLXOgWXRal+NhrZxc0VanD/MJf4=; b=UjCUFjGBCcv1FP5Irw7M47xI2w X3B/zc/pLDbn0rddM0vKvwCNYiFWZgjXUR2kzWVBXmKRdMZs77Dw2j9ugl7eu0mEcdTIEr7Rvn0a0 ZAfQR3eyUTJoVwUEnXxL4K/Nj//qbEDSN02FpC49O0rlvzsjhMHno0v6LGjVsOweS2GecXW7DQOhK uLYEkjgyfYLOBpBzxEJ9sqSJZMzFklFFcy6VLAjqJizQx2L/fhA1NiJQ/IFdwQhZJMmvuHdxvJX/z ymzKDQI1/guba7Fz04PlZU3yc3v6rzzbJ0+RkGJP2ZgNnGdnTxEfsL7W8aynR9VXiHhChmZB/AJ3U HBQgSILQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k6tZj-0001Np-9c; Sat, 15 Aug 2020 10:38:11 +0000 Received: from bhuna.collabora.co.uk ([46.235.227.227]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k6tZW-0001Ee-LC for linux-rockchip@lists.infradead.org; Sat, 15 Aug 2020 10:38:04 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: dafna) with ESMTPSA id 8AADF28D80C From: Dafna Hirschfeld To: linux-media@vger.kernel.org Subject: [PATCH v2 09/14] media: staging: rkisp1: remove atomic operations for frame sequence Date: Sat, 15 Aug 2020 12:37:29 +0200 Message-Id: <20200815103734.31153-10-dafna.hirschfeld@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200815103734.31153-1-dafna.hirschfeld@collabora.com> References: <20200815103734.31153-1-dafna.hirschfeld@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200815_063758_946475_FA3502EC X-CRM114-Status: GOOD ( 18.58 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [46.235.227.227 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mchehab@kernel.org, dafna.hirschfeld@collabora.com, dafna3@gmail.com, tfiga@chromium.org, hverkuil@xs4all.nl, linux-rockchip@lists.infradead.org, helen.koike@collabora.com, laurent.pinchart@ideasonboard.com, sakari.ailus@linux.intel.com, kernel@collabora.com, ezequiel@collabora.com MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org The isp.frame_sequence is now read only from the irq handlers that are all fired from the same interrupt so there is not need for atomic operation. In addition the frame seq incrementation is moved from rkisp1_isp_queue_event_sof to rkisp1_isp_isr to make the code clearer. Signed-off-by: Dafna Hirschfeld Acked-by: Helen Koike --- drivers/staging/media/rkisp1/rkisp1-capture.c | 2 +- drivers/staging/media/rkisp1/rkisp1-common.h | 2 +- drivers/staging/media/rkisp1/rkisp1-isp.c | 20 +++++++++---------- drivers/staging/media/rkisp1/rkisp1-params.c | 2 +- drivers/staging/media/rkisp1/rkisp1-stats.c | 3 +-- 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/drivers/staging/media/rkisp1/rkisp1-capture.c b/drivers/staging/media/rkisp1/rkisp1-capture.c index c05280950ea0..d7017afc5405 100644 --- a/drivers/staging/media/rkisp1/rkisp1-capture.c +++ b/drivers/staging/media/rkisp1/rkisp1-capture.c @@ -632,7 +632,7 @@ static void rkisp1_handle_buffer(struct rkisp1_capture *cap) curr_buf = cap->buf.curr; if (curr_buf) { - curr_buf->vb.sequence = atomic_read(&isp->frame_sequence); + curr_buf->vb.sequence = isp->frame_sequence; curr_buf->vb.vb2_buf.timestamp = ktime_get_boottime_ns(); curr_buf->vb.field = V4L2_FIELD_NONE; vb2_buffer_done(&curr_buf->vb.vb2_buf, VB2_BUF_STATE_DONE); diff --git a/drivers/staging/media/rkisp1/rkisp1-common.h b/drivers/staging/media/rkisp1/rkisp1-common.h index 9b41935c6597..79edece6ee77 100644 --- a/drivers/staging/media/rkisp1/rkisp1-common.h +++ b/drivers/staging/media/rkisp1/rkisp1-common.h @@ -112,7 +112,7 @@ struct rkisp1_isp { const struct rkisp1_isp_mbus_info *src_fmt; struct mutex ops_lock; bool is_dphy_errctrl_disabled; - atomic_t frame_sequence; + __u32 frame_sequence; }; struct rkisp1_vdev_node { diff --git a/drivers/staging/media/rkisp1/rkisp1-isp.c b/drivers/staging/media/rkisp1/rkisp1-isp.c index ad2ece78abbf..1ffe7cc7bb12 100644 --- a/drivers/staging/media/rkisp1/rkisp1-isp.c +++ b/drivers/staging/media/rkisp1/rkisp1-isp.c @@ -940,7 +940,7 @@ static int rkisp1_isp_s_stream(struct v4l2_subdev *sd, int enable) if (rkisp1->active_sensor->mbus_type != V4L2_MBUS_CSI2_DPHY) return -EINVAL; - atomic_set(&rkisp1->isp.frame_sequence, -1); + rkisp1->isp.frame_sequence = -1; mutex_lock(&isp->ops_lock); ret = rkisp1_config_cif(rkisp1); if (ret) @@ -1093,15 +1093,8 @@ static void rkisp1_isp_queue_event_sof(struct rkisp1_isp *isp) struct v4l2_event event = { .type = V4L2_EVENT_FRAME_SYNC, }; + event.u.frame_sync.frame_sequence = isp->frame_sequence; - /* - * Increment the frame sequence on the vsync signal. - * This will allow applications to detect dropped. - * Note that there is a debugfs counter for dropped - * frames, but using this event is more accurate. - */ - event.u.frame_sync.frame_sequence = - atomic_inc_return(&isp->frame_sequence); v4l2_event_queue(isp->sd.devnode, &event); } @@ -1116,7 +1109,14 @@ void rkisp1_isp_isr(struct rkisp1_device *rkisp1) rkisp1_write(rkisp1, status, RKISP1_CIF_ISP_ICR); /* Vertical sync signal, starting generating new frame */ - if (status & RKISP1_CIF_ISP_V_START) + if (status & RKISP1_CIF_ISP_V_START) { + /* + * Increment the frame sequence on the vsync signal. + * This will allow applications to detect dropped. + * Note that there is a debugfs counter for dropped + * frames, but using this event is more accurate. + */ + rkisp1->isp.frame_sequence++; rkisp1_isp_queue_event_sof(&rkisp1->isp); if (status & RKISP1_CIF_ISP_PIC_SIZE_ERROR) { diff --git a/drivers/staging/media/rkisp1/rkisp1-params.c b/drivers/staging/media/rkisp1/rkisp1-params.c index 4b4391c0a2a0..cc242ad5106e 100644 --- a/drivers/staging/media/rkisp1/rkisp1-params.c +++ b/drivers/staging/media/rkisp1/rkisp1-params.c @@ -1227,7 +1227,7 @@ void rkisp1_params_isr(struct rkisp1_device *rkisp1) * We want the vb.sequence to be the frame that the params are applied to. * So we set vb.sequence to be the isp's frame_sequence + 1 */ - unsigned int frame_sequence = atomic_read(&rkisp1->isp.frame_sequence) + 1; + unsigned int frame_sequence = rkisp1->isp.frame_sequence + 1; struct rkisp1_params *params = &rkisp1->params; spin_lock(¶ms->config_lock); diff --git a/drivers/staging/media/rkisp1/rkisp1-stats.c b/drivers/staging/media/rkisp1/rkisp1-stats.c index 87e4104d20dd..52417b388854 100644 --- a/drivers/staging/media/rkisp1/rkisp1-stats.c +++ b/drivers/staging/media/rkisp1/rkisp1-stats.c @@ -307,8 +307,7 @@ rkisp1_stats_send_measurement(struct rkisp1_stats *stats, u32 isp_ris) { struct rkisp1_stat_buffer *cur_stat_buf; struct rkisp1_buffer *cur_buf = NULL; - unsigned int frame_sequence = - atomic_read(&stats->rkisp1->isp.frame_sequence); + unsigned int frame_sequence = stats->rkisp1->isp.frame_sequence; u64 timestamp = ktime_get_ns(); /* get one empty buffer */ From patchwork Sat Aug 15 10:37:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 11715389 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DE79914F6 for ; Sat, 15 Aug 2020 10:38:15 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B7D7222EBF for ; Sat, 15 Aug 2020 10:38:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="hPz6JCmu" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B7D7222EBF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=7X7u8kuXVY3VQktxR60eR2DRyCYupP2b7+/RbBpbTks=; b=hPz6JCmuj6+xTC1GC86PWsHz30 czJMKjaQBKfv/Ar71aER9ntYvuwZA47mlurqndZc3rOBNU6rP4ETPhKaSKgjLeWVAkC9zF8LjXq3E t8UWB74CVqClF+qjAGd9FwDHb6ozFkCDnU3XtMorH+6yJzT3pfq/C1ylqDiHpwrTKbWFDh6SY5HOY Z6ykpZNEnft9qqRAaVgPKVfuDqhazH6OmLUC7/1wGK4SNICv/gEwzRA6B+rLzdPYST+5qw7tkepWt DkxF/qzKGPTjp3u4bMndfUvH3Qt+EFLJrIU82CumrSbQiIh3PBM/OTo2r3zEy7lWJK3DEBH64yJv9 TftyxNrw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k6tZk-0001OF-3A; Sat, 15 Aug 2020 10:38:12 +0000 Received: from bhuna.collabora.co.uk ([2a00:1098:0:82:1000:25:2eeb:e3e3]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k6tZX-0001F2-7E for linux-rockchip@lists.infradead.org; Sat, 15 Aug 2020 10:38:04 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: dafna) with ESMTPSA id 1514229A949 From: Dafna Hirschfeld To: linux-media@vger.kernel.org Subject: [PATCH v2 10/14] media: staging: rkisp1: isp: add a warning and debugfs var for irq delay Date: Sat, 15 Aug 2020 12:37:30 +0200 Message-Id: <20200815103734.31153-11-dafna.hirschfeld@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200815103734.31153-1-dafna.hirschfeld@collabora.com> References: <20200815103734.31153-1-dafna.hirschfeld@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200815_063759_424490_2456664F X-CRM114-Status: GOOD ( 13.54 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mchehab@kernel.org, dafna.hirschfeld@collabora.com, dafna3@gmail.com, tfiga@chromium.org, hverkuil@xs4all.nl, linux-rockchip@lists.infradead.org, helen.koike@collabora.com, laurent.pinchart@ideasonboard.com, sakari.ailus@linux.intel.com, kernel@collabora.com, ezequiel@collabora.com MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org The signal RKISP1_CIF_ISP_FRAME is set when the ISP completes outputting the frame to the next block in the pipeline. In order to keep buffer synchronization we assume that the RKISP1_CIF_ISP_V_START signal never arrives together with the RKISP1_CIF_ISP_FRAME signal. In case those signals arrive together then the code is not able to tell if the RKISP1_CIF_ISP_FRAME signal relates to the frame of the current v-start or the previous. This patch adds a WARN_ONCE and a debugfs var to catch it. Signed-off-by: Dafna Hirschfeld --- drivers/staging/media/rkisp1/rkisp1-common.h | 1 + drivers/staging/media/rkisp1/rkisp1-dev.c | 2 ++ drivers/staging/media/rkisp1/rkisp1-isp.c | 5 +++++ 3 files changed, 8 insertions(+) diff --git a/drivers/staging/media/rkisp1/rkisp1-common.h b/drivers/staging/media/rkisp1/rkisp1-common.h index 79edece6ee77..5aed0e37850a 100644 --- a/drivers/staging/media/rkisp1/rkisp1-common.h +++ b/drivers/staging/media/rkisp1/rkisp1-common.h @@ -228,6 +228,7 @@ struct rkisp1_debug { unsigned long outform_size_error; unsigned long img_stabilization_size_error; unsigned long inform_size_error; + unsigned long irq_delay; unsigned long mipi_error; unsigned long stats_error; unsigned long stop_timeout[2]; diff --git a/drivers/staging/media/rkisp1/rkisp1-dev.c b/drivers/staging/media/rkisp1/rkisp1-dev.c index a0eb8f08708b..557de940286b 100644 --- a/drivers/staging/media/rkisp1/rkisp1-dev.c +++ b/drivers/staging/media/rkisp1/rkisp1-dev.c @@ -445,6 +445,8 @@ static void rkisp1_debug_init(struct rkisp1_device *rkisp1) &debug->img_stabilization_size_error); debugfs_create_ulong("inform_size_error", 0444, debug->debugfs_dir, &debug->inform_size_error); + debugfs_create_ulong("irq_delay", 0444, debug->debugfs_dir, + &debug->irq_delay); debugfs_create_ulong("mipi_error", 0444, debug->debugfs_dir, &debug->mipi_error); debugfs_create_ulong("stats_error", 0444, debug->debugfs_dir, diff --git a/drivers/staging/media/rkisp1/rkisp1-isp.c b/drivers/staging/media/rkisp1/rkisp1-isp.c index 1ffe7cc7bb12..33cfad19dde2 100644 --- a/drivers/staging/media/rkisp1/rkisp1-isp.c +++ b/drivers/staging/media/rkisp1/rkisp1-isp.c @@ -1118,6 +1118,11 @@ void rkisp1_isp_isr(struct rkisp1_device *rkisp1) */ rkisp1->isp.frame_sequence++; rkisp1_isp_queue_event_sof(&rkisp1->isp); + if (status & RKISP1_CIF_ISP_FRAME) { + WARN_ONCE(1, "irq delay is too long, buffers might not be in sync\n"); + rkisp1->debug.irq_delay++; + } + } if (status & RKISP1_CIF_ISP_PIC_SIZE_ERROR) { /* Clear pic_size_error */ From patchwork Sat Aug 15 10:37:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 11715385 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F376414F6 for ; Sat, 15 Aug 2020 10:38:13 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CD0AA2310B for ; Sat, 15 Aug 2020 10:38:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="IOcDQoiq" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CD0AA2310B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=EIwZNuFL0KDPRdCLLc0+PWrJz5FJpNAdfvoQyCIq7R0=; b=IOcDQoiqSrf7qLovLYPHVUUq2M ENKy9m/NJ0wFSVnOU2v0GjYzrEP0ih5YWJ5B7CkBv8lUcRb5KB87FUbREiwLpwH48ASa+U1nPl7ne Zy5FYPoNLPLLDPklqXo3v0iMZcPtFmhdwKXzCBzQPzaj4vs7nNalSFfCjrETCaZeZCERnEc7gDNYM lfhIXCvkQi+9NlGsBhxICdnRnBslCy2D4B4Asubv2PDMp+9qr2gxYWONB+f65tdvqw4aGrjHn++z4 1kpuKiKJFNecYEbDrO0+cBEcPJOfOZeTUW7nD7F/RR0SQyLwusubxRsxuc4acjkSfUwaYKNAyYnwo NlbyuQMQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k6tZi-0001NO-Dk; Sat, 15 Aug 2020 10:38:10 +0000 Received: from bhuna.collabora.co.uk ([46.235.227.227]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k6tZX-0001Fh-N3 for linux-rockchip@lists.infradead.org; Sat, 15 Aug 2020 10:38:03 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: dafna) with ESMTPSA id 8FA4B29A94A From: Dafna Hirschfeld To: linux-media@vger.kernel.org Subject: [PATCH v2 11/14] media: staging: rkisp1: isp: don't enable signal RKISP1_CIF_ISP_FRAME_IN Date: Sat, 15 Aug 2020 12:37:31 +0200 Message-Id: <20200815103734.31153-12-dafna.hirschfeld@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200815103734.31153-1-dafna.hirschfeld@collabora.com> References: <20200815103734.31153-1-dafna.hirschfeld@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200815_063759_916654_952849E8 X-CRM114-Status: GOOD ( 12.05 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [46.235.227.227 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mchehab@kernel.org, dafna.hirschfeld@collabora.com, dafna3@gmail.com, tfiga@chromium.org, hverkuil@xs4all.nl, linux-rockchip@lists.infradead.org, helen.koike@collabora.com, laurent.pinchart@ideasonboard.com, sakari.ailus@linux.intel.com, kernel@collabora.com, ezequiel@collabora.com MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org The signal RKISP1_CIF_ISP_FRAME_IN is not used in the isr so there is no need to enable it. Signed-off-by: Dafna Hirschfeld Acked-by: Helen Koike --- drivers/staging/media/rkisp1/rkisp1-isp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/media/rkisp1/rkisp1-isp.c b/drivers/staging/media/rkisp1/rkisp1-isp.c index 33cfad19dde2..912eb6ad4e0a 100644 --- a/drivers/staging/media/rkisp1/rkisp1-isp.c +++ b/drivers/staging/media/rkisp1/rkisp1-isp.c @@ -348,7 +348,7 @@ static int rkisp1_config_isp(struct rkisp1_device *rkisp1) rkisp1_write(rkisp1, sink_crop->height, RKISP1_CIF_ISP_OUT_V_SIZE); irq_mask |= RKISP1_CIF_ISP_FRAME | RKISP1_CIF_ISP_V_START | - RKISP1_CIF_ISP_PIC_SIZE_ERROR | RKISP1_CIF_ISP_FRAME_IN; + RKISP1_CIF_ISP_PIC_SIZE_ERROR; rkisp1_write(rkisp1, irq_mask, RKISP1_CIF_ISP_IMSC); if (src_fmt->pixel_enc == V4L2_PIXEL_ENC_BAYER) { From patchwork Sat Aug 15 10:37:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 11715393 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 68DCB13A4 for ; Sat, 15 Aug 2020 10:38:16 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4323C2310B for ; Sat, 15 Aug 2020 10:38:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="gMg3zPWz" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4323C2310B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=c7UW0LqN3XDIfN0NkTHoGhYWk7w/Z5PtzRJDYsLsnHM=; b=gMg3zPWzXq4BS4abaYQdMZeCBw 5T4rxIwpoJ2OcIkZnzOhDtRk2xjrYCKeg08VtZe1WfvlTWEcZyh9e40rK4Pp42WpVo6+uQC639X2M y2H8vYRrXDWe9d6k6U8VYqJAsZQbNRAsDbE8RTYEPQum5YXjj00F7+lhnjYT6P4Eu8WBjcynE8cVY AMBF3F6nH3XueLIn7f/JrdZizQuJy7j5nDOi50MJW3DSLRhHRFdBXNK2L1MPgP2vnRsZaAHOWugRy 38qPImscu66+bYuNhWENTEFGGsd22dJvz26T2Np7Uer3zhIPImf975fQKBnuyUt3m10ICIcSZ3k8T w7/+jKqg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k6tZk-0001Or-PF; Sat, 15 Aug 2020 10:38:12 +0000 Received: from bhuna.collabora.co.uk ([46.235.227.227]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k6tZY-0001GM-Ag for linux-rockchip@lists.infradead.org; Sat, 15 Aug 2020 10:38:05 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: dafna) with ESMTPSA id 1CA0A29A7CE From: Dafna Hirschfeld To: linux-media@vger.kernel.org Subject: [PATCH v2 12/14] media: staging: rkisp1: stats: protect write to 'is_streaming' in start_streaming cb Date: Sat, 15 Aug 2020 12:37:32 +0200 Message-Id: <20200815103734.31153-13-dafna.hirschfeld@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200815103734.31153-1-dafna.hirschfeld@collabora.com> References: <20200815103734.31153-1-dafna.hirschfeld@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200815_063800_546420_F5C890A1 X-CRM114-Status: UNSURE ( 9.85 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [46.235.227.227 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mchehab@kernel.org, dafna.hirschfeld@collabora.com, dafna3@gmail.com, tfiga@chromium.org, hverkuil@xs4all.nl, linux-rockchip@lists.infradead.org, helen.koike@collabora.com, laurent.pinchart@ideasonboard.com, sakari.ailus@linux.intel.com, kernel@collabora.com, ezequiel@collabora.com MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org The field stats->is_streaming is written in 'start_streaming' callback without the stats->lock protection. The isr might run together with the callback so 'spin_lock_irq' should be used. Signed-off-by: Dafna Hirschfeld Acked-by: Helen Koike --- drivers/staging/media/rkisp1/rkisp1-stats.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/media/rkisp1/rkisp1-stats.c b/drivers/staging/media/rkisp1/rkisp1-stats.c index 52417b388854..c86beba709db 100644 --- a/drivers/staging/media/rkisp1/rkisp1-stats.c +++ b/drivers/staging/media/rkisp1/rkisp1-stats.c @@ -157,7 +157,9 @@ rkisp1_stats_vb2_start_streaming(struct vb2_queue *queue, unsigned int count) { struct rkisp1_stats *stats = queue->drv_priv; + spin_lock_irq(&stats->lock); stats->is_streaming = true; + spin_unlock_irq(&stats->lock); return 0; } From patchwork Sat Aug 15 10:37:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 11715397 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 63C3A14F6 for ; Sat, 15 Aug 2020 10:38:19 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3CC4222EBF for ; Sat, 15 Aug 2020 10:38:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="UjjfWs4X" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3CC4222EBF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=vhX9tpJp0CERE61p2ClS78rjdz3uWSaG31L6Zw6DOrg=; b=UjjfWs4Xo4XWtK+9iLQYyMVSmq j7ShZGUirNnVWtIwU7iCLDgQ80eLLI1VPhkxRzVZdCPs/JnfmMc1t2IZ256XZww6rl8XMLDYNUZOq N5GQlXeKyZIILcE/wSXDHic0LVRrZAFJYBBqWcLHc16fFaN5TczusvG3PoWM5IXyHE5ybEXe9Nt7K XeG/kXNbL4UhgWG9HTZ4N+8fS+yjJiW5h7kFIw2ZKj6vE+SUP4uy4UmYz1/6PDnerlHT5GjIQf/uI 2lD+qnn3q15qx8vpMNX6S570RTPyDdDLJncBicILGRXmuswWJ5fuTRMoPfexNUKjk+atvlchPtYra g5ZTL49Q==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k6tZm-0001Q3-Hj; Sat, 15 Aug 2020 10:38:14 +0000 Received: from bhuna.collabora.co.uk ([2a00:1098:0:82:1000:25:2eeb:e3e3]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k6tZY-0001Gu-QS for linux-rockchip@lists.infradead.org; Sat, 15 Aug 2020 10:38:06 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: dafna) with ESMTPSA id A43D229A975 From: Dafna Hirschfeld To: linux-media@vger.kernel.org Subject: [PATCH v2 13/14] media: staging: rkisp1: call media_pipeline_start/stop from stats and params Date: Sat, 15 Aug 2020 12:37:33 +0200 Message-Id: <20200815103734.31153-14-dafna.hirschfeld@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200815103734.31153-1-dafna.hirschfeld@collabora.com> References: <20200815103734.31153-1-dafna.hirschfeld@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200815_063801_012073_0E969A8C X-CRM114-Status: GOOD ( 10.69 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mchehab@kernel.org, dafna.hirschfeld@collabora.com, dafna3@gmail.com, tfiga@chromium.org, hverkuil@xs4all.nl, linux-rockchip@lists.infradead.org, helen.koike@collabora.com, laurent.pinchart@ideasonboard.com, sakari.ailus@linux.intel.com, kernel@collabora.com, ezequiel@collabora.com MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org The stats and params video nodes register a media entity and therefore they need to call media_pipeline_start/stop. Signed-off-by: Dafna Hirschfeld --- drivers/staging/media/rkisp1/rkisp1-params.c | 9 +++++++++ drivers/staging/media/rkisp1/rkisp1-stats.c | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/drivers/staging/media/rkisp1/rkisp1-params.c b/drivers/staging/media/rkisp1/rkisp1-params.c index cc242ad5106e..7d5c21fa630e 100644 --- a/drivers/staging/media/rkisp1/rkisp1-params.c +++ b/drivers/staging/media/rkisp1/rkisp1-params.c @@ -1488,14 +1488,23 @@ static void rkisp1_params_vb2_stop_streaming(struct vb2_queue *vq) list_for_each_entry(buf, &tmp_list, queue) vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR); + + media_pipeline_stop(¶ms->vnode.vdev.entity); } static int rkisp1_params_vb2_start_streaming(struct vb2_queue *queue, unsigned int count) { struct rkisp1_params *params = queue->drv_priv; + struct media_entity *entity = ¶ms->vnode.vdev.entity; unsigned long flags; + int ret; + ret = media_pipeline_start(entity, ¶ms->rkisp1->pipe); + if (ret) { + dev_err(params->rkisp1->dev, "params: start pipeline failed %d\n", ret); + return ret; + } spin_lock_irqsave(¶ms->config_lock, flags); params->is_streaming = true; spin_unlock_irqrestore(¶ms->config_lock, flags); diff --git a/drivers/staging/media/rkisp1/rkisp1-stats.c b/drivers/staging/media/rkisp1/rkisp1-stats.c index c86beba709db..b314fb6a4562 100644 --- a/drivers/staging/media/rkisp1/rkisp1-stats.c +++ b/drivers/staging/media/rkisp1/rkisp1-stats.c @@ -150,12 +150,21 @@ static void rkisp1_stats_vb2_stop_streaming(struct vb2_queue *vq) vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR); } spin_unlock_irq(&stats->lock); + media_pipeline_stop(&stats->vnode.vdev.entity); } static int rkisp1_stats_vb2_start_streaming(struct vb2_queue *queue, unsigned int count) { struct rkisp1_stats *stats = queue->drv_priv; + struct media_entity *entity = &stats->vnode.vdev.entity; + int ret; + + ret = media_pipeline_start(entity, &stats->rkisp1->pipe); + if (ret) { + dev_err(stats->rkisp1->dev, "stats: start pipeline failed %d\n", ret); + return ret; + } spin_lock_irq(&stats->lock); stats->is_streaming = true; From patchwork Sat Aug 15 10:37:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 11715395 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1DC9A14F6 for ; Sat, 15 Aug 2020 10:38:18 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EB5E322EBF for ; Sat, 15 Aug 2020 10:38:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ziz8jU0K" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EB5E322EBF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Z5qTb2rK3ijeHkojHDYCLY7qqYaQPX2eb3i80CjAEdI=; b=ziz8jU0KzZ5Yi6DKOiqJhAltQl L1CHRla740trn41/GPagzHB5gGSqQM9nHY4D4o7DAcmZutMNyxon4CsqpHE69HGRWy4p7LJF5naIF g7np2dYSUeV3uG8rATcvl9Kax75mSGQUXvPGh+ahWqNI98KnXbJyWTr2ar5+Y2KatmLMWTxFYeXkA H/BaDRWB2r3FnaRG3qqYRfYxLqeSvlNCjXbv74D5KRSxoWC7AEb5kZgLGnOBG3GvTUQpYHm2CBxc6 nl3Y2EnvpzD5n9a6UECGXLdfEokra9WNolHnrghB0ZJsEhadNj4Vd5ExExVExV0Bg6BhGk1Ds0UAX Q4AYGoIQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k6tZl-0001PR-LL; Sat, 15 Aug 2020 10:38:13 +0000 Received: from bhuna.collabora.co.uk ([2a00:1098:0:82:1000:25:2eeb:e3e3]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k6tZZ-0001HD-DG for linux-rockchip@lists.infradead.org; Sat, 15 Aug 2020 10:38:06 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: dafna) with ESMTPSA id 2D7EA29A94E From: Dafna Hirschfeld To: linux-media@vger.kernel.org Subject: [PATCH v2 14/14] media: staging: rkisp1: params: no need to lock default config Date: Sat, 15 Aug 2020 12:37:34 +0200 Message-Id: <20200815103734.31153-15-dafna.hirschfeld@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200815103734.31153-1-dafna.hirschfeld@collabora.com> References: <20200815103734.31153-1-dafna.hirschfeld@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200815_063801_639016_F847CB7E X-CRM114-Status: GOOD ( 12.88 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mchehab@kernel.org, dafna.hirschfeld@collabora.com, dafna3@gmail.com, tfiga@chromium.org, hverkuil@xs4all.nl, linux-rockchip@lists.infradead.org, helen.koike@collabora.com, laurent.pinchart@ideasonboard.com, sakari.ailus@linux.intel.com, kernel@collabora.com, ezequiel@collabora.com MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org In the function 'rkisp1_params_config_parameter' the lock is taken while applying the default config. But the lock only needs to protect the buffers list and the 'is_streaming' field, so move the locking to lock only what is needed. Signed-off-by: Dafna Hirschfeld Acked-by: Helen Koike --- drivers/staging/media/rkisp1/rkisp1-params.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/media/rkisp1/rkisp1-params.c b/drivers/staging/media/rkisp1/rkisp1-params.c index 7d5c21fa630e..6c71da311294 100644 --- a/drivers/staging/media/rkisp1/rkisp1-params.c +++ b/drivers/staging/media/rkisp1/rkisp1-params.c @@ -1283,8 +1283,6 @@ static void rkisp1_params_config_parameter(struct rkisp1_params *params) { struct rkisp1_cif_isp_hst_config hst = rkisp1_hst_params_default_config; - spin_lock(¶ms->config_lock); - rkisp1_awb_meas_config(params, &rkisp1_awb_params_default_config); rkisp1_awb_meas_enable(params, &rkisp1_awb_params_default_config, true); @@ -1309,6 +1307,8 @@ static void rkisp1_params_config_parameter(struct rkisp1_params *params) else rkisp1_csm_config(params, false); + spin_lock(¶ms->config_lock); + /* apply the first buffer if there is one already */ if (params->is_streaming) rkisp1_params_apply_params_cfg(params, 0);