From patchwork Tue Sep 22 11:33:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 11792331 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 4A5E16CB for ; Tue, 22 Sep 2020 11:34:38 +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 138F5221EB for ; Tue, 22 Sep 2020 11:34:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="N1huzJjZ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 138F5221EB 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=4P6kqfZ3MrcyW0s3XN88vnL7Jq0YirjPBiq47ncFJgw=; b=N1huzJjZAb/+/x1p1Y7CbhEJKD G5ymzdzOjjlTmp2Z2ml9MwnUbxmm2nSsVBrjpMogssbFC0SgpUVD++DRc4Ac4GrZxOwIHP6SsYvyf +ZOcOw3EX+TRaR3vU4JtNKLJjvTkJlVsyS11HKhZn8DjSNs8pRSOONINGSkzYCxIKRwD0YipNWR4b biUB5ygkOhD18jINJePrxaMZGtI3I1aXp8tUTO6GQRjSRlOgegVCClEDpiO/jjaSbu+c06NE+B2JO LH9j4wOiNVp9eFkECbQV8EOXA3tpRA74Bvoi5JsU9Nt+GKo1jxrr/oi4BBbkL10IqXAr9gKS20YMT 6qCdknVw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kKgZ6-0006Ga-K6; Tue, 22 Sep 2020 11:34:32 +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 1kKgYp-00064a-Ro for linux-rockchip@lists.infradead.org; Tue, 22 Sep 2020 11:34:18 +0000 Received: from guri.fritz.box (p200300c7cf13ec005877be1094b7a29d.dip0.t-ipconnect.de [IPv6:2003:c7:cf13:ec00:5877:be10:94b7:a29d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: dafna) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id D8D3E29B492; Tue, 22 Sep 2020 12:34:09 +0100 (BST) From: Dafna Hirschfeld To: linux-media@vger.kernel.org Subject: [PATCH v3 01/12] media: staging: rkisp1: params: upon stream stop, iterate a local list to return the buffers Date: Tue, 22 Sep 2020 13:33:51 +0200 Message-Id: <20200922113402.12442-2-dafna.hirschfeld@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200922113402.12442-1-dafna.hirschfeld@collabora.com> References: <20200922113402.12442-1-dafna.hirschfeld@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200922_073416_080208_59AB769C X-CRM114-Status: GOOD ( 15.48 ) 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_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 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 3ca2afc51ead..85f3b340c3bf 100644 --- a/drivers/staging/media/rkisp1/rkisp1-params.c +++ b/drivers/staging/media/rkisp1/rkisp1-params.c @@ -1469,32 +1469,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 Tue Sep 22 11:33:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 11792327 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 5352A59D for ; Tue, 22 Sep 2020 11:34: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 08D67221EB for ; Tue, 22 Sep 2020 11:34:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="zE5w3QbS" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 08D67221EB 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=BumsgSKQbA8JLCEtG0/2sqsV0GMeSAxsUdBz8kkHSSg=; b=zE5w3QbSJfeI6iwOc+ZnJNTfRD IisyOA8kzigHyqJlt65/oGm9EN2qBwiWTBsmPj3dqUVLo56EPI6bdRETrQiLG3c8uYuiNu7YTUiDe Z7NTDcDPvdepkbwxYVbmbXO//FFZgnBdcCWlbDgJGERXUySrSjdyc/aMcFMTMQ8Cmn27ssR7F3O3A 4wPAXhoshcJ/dmdushE9Oz5ZlcOUVCuQHj0IRVjeP9s/YR0QVY6t0DMdxrA2ghOQXGOOmIMARpua2 XXh7VSRvdhs136VlgSCafAoBb1d82Pcg6FGdL76Df6Pub2/SHFOZAihgDWZPuJGGZk+5bCD2o9ol8 BNkEEjeQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kKgYw-0006Bn-B2; Tue, 22 Sep 2020 11:34:22 +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 1kKgYp-00064e-Ro for linux-rockchip@lists.infradead.org; Tue, 22 Sep 2020 11:34:17 +0000 Received: from guri.fritz.box (p200300c7cf13ec005877be1094b7a29d.dip0.t-ipconnect.de [IPv6:2003:c7:cf13:ec00:5877:be10:94b7:a29d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: dafna) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 4EFF629B498; Tue, 22 Sep 2020 12:34:10 +0100 (BST) From: Dafna Hirschfeld To: linux-media@vger.kernel.org Subject: [PATCH v3 02/12] media: staging: rkisp1: params: in the isr, return if buffer list is empty Date: Tue, 22 Sep 2020 13:33:52 +0200 Message-Id: <20200922113402.12442-3-dafna.hirschfeld@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200922113402.12442-1-dafna.hirschfeld@collabora.com> References: <20200922113402.12442-1-dafna.hirschfeld@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200922_073416_077555_933A767B X-CRM114-Status: GOOD ( 13.27 ) 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_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 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 85f3b340c3bf..8bd7cc622e4f 100644 --- a/drivers/staging/media/rkisp1/rkisp1-params.c +++ b/drivers/staging/media/rkisp1/rkisp1-params.c @@ -1198,16 +1198,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); rkisp1_isp_isr_other_config(params, new_params); From patchwork Tue Sep 22 11:33:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 11792325 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 49B726CB for ; Tue, 22 Sep 2020 11:34:30 +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 F1320221EB for ; Tue, 22 Sep 2020 11:34:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="DnqoAuap" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F1320221EB 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=tY250PQo73taNREhpw98nY6KZbiwMxTlHhy4ihL9890=; b=DnqoAuapt6P6hqRSX2tcJS5PV6 EG9xWQU8J5Eh14Pxkt2TV910Wt23HH8erCmxAhclfdY5lGTVVZooxb5fr4kT4zhXeVm6C9zwA8E3J Q9Mx+niQn9iJPOyd5wM/o4epnph2aLuxzVo3+CbFbL9rxccEfQ10BnF3Tvi2eimqdMdRnr+Ghwc13 PzU3gVJPnySzxFhVlv8XDErwgJuTb4oU26ToE7NXCsD9lfbnevRDk1O6FnL3ay0j5GLUQbcOZ+Bsq UYfXTEnwVKjuNDcgCdFr5stXlXAD0O1vl4u2SG66n3sC80dh8672aWwCCya5+pmxY5oQniR/KSLQr ALFe5zpw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kKgYr-00066h-Uw; Tue, 22 Sep 2020 11:34:18 +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 1kKgYm-00064h-Nt for linux-rockchip@lists.infradead.org; Tue, 22 Sep 2020 11:34:15 +0000 Received: from guri.fritz.box (p200300c7cf13ec005877be1094b7a29d.dip0.t-ipconnect.de [IPv6:2003:c7:cf13:ec00:5877:be10:94b7:a29d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: dafna) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id B5CB029B49E; Tue, 22 Sep 2020 12:34:10 +0100 (BST) From: Dafna Hirschfeld To: linux-media@vger.kernel.org Subject: [PATCH v3 03/12] media: staging: rkisp1: params: use the new effect value in cproc config Date: Tue, 22 Sep 2020 13:33:53 +0200 Message-Id: <20200922113402.12442-4-dafna.hirschfeld@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200922113402.12442-1-dafna.hirschfeld@collabora.com> References: <20200922113402.12442-1-dafna.hirschfeld@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200922_073412_914555_702294B3 X-CRM114-Status: GOOD ( 13.87 ) 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_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 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 8bd7cc622e4f..ab2deb57b1eb 100644 --- a/drivers/staging/media/rkisp1/rkisp1-params.c +++ b/drivers/staging/media/rkisp1/rkisp1-params.c @@ -552,7 +552,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 Tue Sep 22 11:33:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 11792333 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 681CB59D for ; Tue, 22 Sep 2020 11:34:43 +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 2F75D23600 for ; Tue, 22 Sep 2020 11:34:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="fmkexD3M" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2F75D23600 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=DdAutxfyrhgta9i4fimoK6gqPWG2ZLMvAC2NnVl9JRg=; b=fmkexD3M+Km3wGNzUQvHRADLlW telzXx8bqgzKjNj2ZFEcZB0+naYvk8WLzXSvKInIBwS5O330yDfm9A1vf/7EJqJd2IiqDhC3smLaC 3lHt59yDylPQSpyMkaDX27hgHPy14hJOhMw4tG1Cs+PfUmgwxZRlYpHmNLiN1NOdCB6Fo0Lc+SsjU CFNNXzYRD82IAAfpg8TeVO5Sk6m2aDSn9RCO8woqhTdpfKJBvGWMM9zOJSJbH9Xt4vrK3SgIbbbXH AcgDo/P9FEvkfXfBrHchl94izn6tkt1EecoU82P0kSN4I+Kh24EBX7UxkZe8fgG7PArezlpnFtzZ7 dmSv9ZRg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kKgZ7-0006Gt-Tm; Tue, 22 Sep 2020 11:34:33 +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 1kKgYp-00064k-R1 for linux-rockchip@lists.infradead.org; Tue, 22 Sep 2020 11:34:19 +0000 Received: from guri.fritz.box (p200300c7cf13ec005877be1094b7a29d.dip0.t-ipconnect.de [IPv6:2003:c7:cf13:ec00:5877:be10:94b7:a29d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: dafna) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 297D729B4AE; Tue, 22 Sep 2020 12:34:11 +0100 (BST) From: Dafna Hirschfeld To: linux-media@vger.kernel.org Subject: [PATCH v3 04/12] media: staging: rkisp1: params: avoid using buffer if params is not streaming Date: Tue, 22 Sep 2020 13:33:54 +0200 Message-Id: <20200922113402.12442-5-dafna.hirschfeld@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200922113402.12442-1-dafna.hirschfeld@collabora.com> References: <20200922113402.12442-1-dafna.hirschfeld@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200922_073416_109972_9A0FA8FC X-CRM114-Status: GOOD ( 23.49 ) 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_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 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 --- changes since v2: declare function 'rkisp1_params_apply_params_cfg' as static to fix a warning reported by 'kernel test robot ' --- drivers/staging/media/rkisp1/rkisp1-common.h | 4 -- drivers/staging/media/rkisp1/rkisp1-params.c | 50 ++++++++------------ 2 files changed, 20 insertions(+), 34 deletions(-) diff --git a/drivers/staging/media/rkisp1/rkisp1-common.h b/drivers/staging/media/rkisp1/rkisp1-common.h index 992d8ec4c448..232bee92d0eb 100644 --- a/drivers/staging/media/rkisp1/rkisp1-common.h +++ b/drivers/staging/media/rkisp1/rkisp1-common.h @@ -262,10 +262,8 @@ struct rkisp1_stats { * @rkisp1: pointer to the rkisp1 device * @config_lock: locks the buffer list 'params' and 'is_streaming' * @params: queue of rkisp1_buffer - * @cur_params: the first params values from userspace * @vdev_fmt: v4l2_format of the metadata format * @is_streaming: device is streaming - * @is_first_params: the first params should take effect immediately * @quantization: the quantization configured on the isp's src pad * @raw_type: the bayer pattern on the isp video sink pad */ @@ -275,10 +273,8 @@ struct rkisp1_params { spinlock_t config_lock; /* locks the buffers list 'params' and 'is_streaming' */ 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 ab2deb57b1eb..e8049a50575f 100644 --- a/drivers/staging/media/rkisp1/rkisp1-params.c +++ b/drivers/staging/media/rkisp1/rkisp1-params.c @@ -1185,23 +1185,14 @@ static void rkisp1_isp_isr_meas_config(struct rkisp1_params *params, } } -void rkisp1_params_isr(struct rkisp1_device *rkisp1) +static 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); @@ -1218,6 +1209,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); } @@ -1290,9 +1295,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); } @@ -1420,8 +1425,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; } @@ -1432,20 +1435,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 = vb2_plane_vaddr(vb, 0); spin_lock_irqsave(¶ms->config_lock, flags); From patchwork Tue Sep 22 11:33:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 11792337 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 0F3B859D for ; Tue, 22 Sep 2020 11:34:47 +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 CBBA0221EB for ; Tue, 22 Sep 2020 11:34:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="BwZXWP3E" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CBBA0221EB 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=yHHW+dgfCVVJHLDutn1nqcLSErsPbl+efihjWe6G0rQ=; b=BwZXWP3EEMJrWDxOJPnaj2EA3A mk6GhiBRMEG4/psEwLCllFNMSpxF7NhqRk9+wi+96dsGwIZnMPVqzPrsypwZ+etWnoQ0m9ZM/svvK IFD7lPmsbyzqU4+FR7vQzoM3A4jg3GWzx1syBEyy6AE8+DdpnNVVIt3hVvyuPHOgDTFeSII0CtF0z spKeI7evyUXk0q1pMj6CD/FKrH7C7yezNdqhdeNFhH9/dRp5HwW6LQEVEWpdfgWHh8baZ4uTXQWbE k40L7mPc67BWpQHsyfIqceuuN2phaF5e8ENONa9ifer9ptI7LdTTPzNKcBl8sEjxYJRl07pCMcgEK rTpGdLjw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kKgZE-0006J4-VD; Tue, 22 Sep 2020 11:34:41 +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 1kKgYt-00066D-S2 for linux-rockchip@lists.infradead.org; Tue, 22 Sep 2020 11:34:24 +0000 Received: from guri.fritz.box (p200300c7cf13ec005877be1094b7a29d.dip0.t-ipconnect.de [IPv6:2003:c7:cf13:ec00:5877:be10:94b7:a29d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: dafna) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 90D2B29B4B3; Tue, 22 Sep 2020 12:34:11 +0100 (BST) From: Dafna Hirschfeld To: linux-media@vger.kernel.org Subject: [PATCH v3 05/12] media: staging: rkisp1: params: set vb.sequence to be the isp's frame_sequence + 1 Date: Tue, 22 Sep 2020 13:33:55 +0200 Message-Id: <20200922113402.12442-6-dafna.hirschfeld@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200922113402.12442-1-dafna.hirschfeld@collabora.com> References: <20200922113402.12442-1-dafna.hirschfeld@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200922_073420_337032_1AF52B6E X-CRM114-Status: GOOD ( 13.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_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 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 the ISP finishes processing a frame (RKISP1_CIF_ISP_FRAME). Configurations performed in the params isr will be applied on the next frame. Since frame_sequence is updated on the vertical sync signal, we should use frame_sequence + 1 as the vb.sequence of the params buffer to indicate to userspace on which frame these parameters are being applied. Signed-off-by: Dafna Hirschfeld Acked-by: Helen Koike --- changes since v2: rephrase commit message and inline doc as suggested by Helen. --- 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 e8049a50575f..24a49368df22 100644 --- a/drivers/staging/media/rkisp1/rkisp1-params.c +++ b/drivers/staging/media/rkisp1/rkisp1-params.c @@ -1213,7 +1213,14 @@ static void rkisp1_params_apply_params_cfg(struct rkisp1_params *params, void rkisp1_params_isr(struct rkisp1_device *rkisp1) { - unsigned int frame_sequence = atomic_read(&rkisp1->isp.frame_sequence); + /* + * This isr is called when the ISR finishes processing a frame (RKISP1_CIF_ISP_FRAME). + * Configurations performed here will be applied on the next frame. + * Since frame_sequence is updated on the vertical sync signal, we should use + * frame_sequence + 1 here to indicate to userspace on which frame these parameters + * are being applied. + */ + unsigned int frame_sequence = atomic_read(&rkisp1->isp.frame_sequence) + 1; struct rkisp1_params *params = &rkisp1->params; spin_lock(¶ms->config_lock); From patchwork Tue Sep 22 11:33:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 11792341 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 7E29E6CB for ; Tue, 22 Sep 2020 11:34:50 +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 1B88D221EB for ; Tue, 22 Sep 2020 11:34:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="P3edkQLm" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1B88D221EB 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=uX/xrGM6ZtxBIUaVwFNVNTmJt/y1p8G9KMc6XURXAsQ=; b=P3edkQLm3ChWbHaG5pZkL+fbXX v0V5icPwzDgKdKr+iJaLUC+cz09Ih8/ijYpWwIQqvggP48nCWdOSNre6x+z+l1tJCFiXO8sdj2ZBo TQXj9vq62sy9uiPxNNHmNTyCyJWwrrlCvz0+m8rere77E2Sn09BBcoGhdmzDqDUYRKivymVkDDC1a 1Mo7sHg0V5sYMFe23EUeSANr1ePAbOuA8Cy+mBAkkMxcpW1fZ9gY4/O0NBCGKY8sFu2INSEZM0NA1 U8PbHSZK1ahXjRGz21uu5Nn6tk7ocrDi4+0b3PbDGuO78ERn0JdeqDPrBagykhRimDwZ9vct1smeh 2salRjBA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kKgZI-0006KD-It; Tue, 22 Sep 2020 11:34:44 +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 1kKgYt-00066A-S2 for linux-rockchip@lists.infradead.org; Tue, 22 Sep 2020 11:34:25 +0000 Received: from guri.fritz.box (p200300c7cf13ec005877be1094b7a29d.dip0.t-ipconnect.de [IPv6:2003:c7:cf13:ec00:5877:be10:94b7:a29d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: dafna) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 05C4729B4B9; Tue, 22 Sep 2020 12:34:11 +0100 (BST) From: Dafna Hirschfeld To: linux-media@vger.kernel.org Subject: [PATCH v3 06/12] media: staging: rkisp1: remove atomic operations for frame sequence Date: Tue, 22 Sep 2020 13:33:56 +0200 Message-Id: <20200922113402.12442-7-dafna.hirschfeld@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200922113402.12442-1-dafna.hirschfeld@collabora.com> References: <20200922113402.12442-1-dafna.hirschfeld@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200922_073420_335845_34EF48CF X-CRM114-Status: GOOD ( 20.41 ) 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_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 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 and the incorrect inline comment is removed. Signed-off-by: Dafna Hirschfeld Acked-by: Helen Koike --- changes since v2: add a closing "}" to if condition remove usless inline comment --- drivers/staging/media/rkisp1/rkisp1-capture.c | 2 +- drivers/staging/media/rkisp1/rkisp1-common.h | 2 +- drivers/staging/media/rkisp1/rkisp1-isp.c | 16 +++++----------- drivers/staging/media/rkisp1/rkisp1-params.c | 2 +- drivers/staging/media/rkisp1/rkisp1-stats.c | 3 +-- 5 files changed, 9 insertions(+), 16 deletions(-) diff --git a/drivers/staging/media/rkisp1/rkisp1-capture.c b/drivers/staging/media/rkisp1/rkisp1-capture.c index 0632582a95b4..1c762a369b63 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 232bee92d0eb..51c92a251ea5 100644 --- a/drivers/staging/media/rkisp1/rkisp1-common.h +++ b/drivers/staging/media/rkisp1/rkisp1-common.h @@ -131,7 +131,7 @@ struct rkisp1_isp { const struct rkisp1_isp_mbus_info *src_fmt; struct mutex ops_lock; /* serialize the subdevice ops */ bool is_dphy_errctrl_disabled; - atomic_t frame_sequence; + __u32 frame_sequence; }; /* diff --git a/drivers/staging/media/rkisp1/rkisp1-isp.c b/drivers/staging/media/rkisp1/rkisp1-isp.c index 02eafea92863..0e71d600dd2b 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) @@ -1092,15 +1092,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); } @@ -1115,9 +1108,10 @@ 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) { + rkisp1->isp.frame_sequence++; rkisp1_isp_queue_event_sof(&rkisp1->isp); - + } if (status & RKISP1_CIF_ISP_PIC_SIZE_ERROR) { /* Clear pic_size_error */ isp_err = rkisp1_read(rkisp1, RKISP1_CIF_ISP_ERR); diff --git a/drivers/staging/media/rkisp1/rkisp1-params.c b/drivers/staging/media/rkisp1/rkisp1-params.c index 24a49368df22..7aa76f032728 100644 --- a/drivers/staging/media/rkisp1/rkisp1-params.c +++ b/drivers/staging/media/rkisp1/rkisp1-params.c @@ -1220,7 +1220,7 @@ void rkisp1_params_isr(struct rkisp1_device *rkisp1) * frame_sequence + 1 here to indicate to userspace on which frame these parameters * are being applied. */ - 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 1daab7a318dc..6aa18d970f2b 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 Tue Sep 22 11:33:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 11792339 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 479526CB for ; Tue, 22 Sep 2020 11:34:48 +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 0C744221EB for ; Tue, 22 Sep 2020 11:34:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="bjDvavAF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0C744221EB 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=rDQo2sZJmrecfaVM5vhcbmgpktsj37mmJRKeu5zlcZ8=; b=bjDvavAF+4OhMd+TJPiHqMCc7l fODABjLzdA854w0ONpJYE+oUg3tvlCi+q8r0SVlCFq5pOsfq2Ed2p1+HuHRs70xy1eifoL473bTe8 whgRFeMKUCyrjsiG0gN6kPPibLzrW/8AqlgMtPczyhsQ3MQXcd251mdwNn/Q34e2JBb5o9A9t1MNH 1xB3NQK7zfTRJjY0yW6C6Q4nidlPjz7b6hEZFIJxesOgTjHKqc+/5b6tvZGv3wY3BTCOa+THQcSY7 Cywd04Vqd8Uzq5BtmTxsDjTbsA3jniV0KTa+P8oWhhenMcU7cX+OW7BR/rtlRN0mWFqRUKel0IIwx Ndeu4MhQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kKgZG-0006JW-2A; Tue, 22 Sep 2020 11:34:42 +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 1kKgYt-00066i-S5 for linux-rockchip@lists.infradead.org; Tue, 22 Sep 2020 11:34:24 +0000 Received: from guri.fritz.box (p200300c7cf13ec005877be1094b7a29d.dip0.t-ipconnect.de [IPv6:2003:c7:cf13:ec00:5877:be10:94b7:a29d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: dafna) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 6F65429B4BD; Tue, 22 Sep 2020 12:34:12 +0100 (BST) From: Dafna Hirschfeld To: linux-media@vger.kernel.org Subject: [PATCH v3 07/12] media: staging: rkisp1: isp: add a warning and debugfs var for irq delay Date: Tue, 22 Sep 2020 13:33:57 +0200 Message-Id: <20200922113402.12442-8-dafna.hirschfeld@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200922113402.12442-1-dafna.hirschfeld@collabora.com> References: <20200922113402.12442-1-dafna.hirschfeld@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200922_073420_231215_EE6DF942 X-CRM114-Status: GOOD ( 15.16 ) 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_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 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 --- changes since v2: remove unneeded closing "}" due to fixing "media: staging: rkisp1: remove atomic operations for frame sequence" --- drivers/staging/media/rkisp1/rkisp1-common.h | 1 + drivers/staging/media/rkisp1/rkisp1-dev.c | 2 ++ drivers/staging/media/rkisp1/rkisp1-isp.c | 4 ++++ 3 files changed, 7 insertions(+) diff --git a/drivers/staging/media/rkisp1/rkisp1-common.h b/drivers/staging/media/rkisp1/rkisp1-common.h index 51c92a251ea5..8c79679e67b8 100644 --- a/drivers/staging/media/rkisp1/rkisp1-common.h +++ b/drivers/staging/media/rkisp1/rkisp1-common.h @@ -326,6 +326,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 d85ac10e5494..91584695804b 100644 --- a/drivers/staging/media/rkisp1/rkisp1-dev.c +++ b/drivers/staging/media/rkisp1/rkisp1-dev.c @@ -444,6 +444,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 0e71d600dd2b..9020633c1b3f 100644 --- a/drivers/staging/media/rkisp1/rkisp1-isp.c +++ b/drivers/staging/media/rkisp1/rkisp1-isp.c @@ -1111,6 +1111,10 @@ void rkisp1_isp_isr(struct rkisp1_device *rkisp1) if (status & RKISP1_CIF_ISP_V_START) { 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 Tue Sep 22 11:33:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 11792335 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 1588659D for ; Tue, 22 Sep 2020 11:34:45 +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 D55B2221EB for ; Tue, 22 Sep 2020 11:34:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="zXRUAObE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D55B2221EB 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=qAeiRfuoZqDp11vUxRxx+JdzFO0NNrXFuqV8Cpzcck4=; b=zXRUAObES7SJay8/LifVf+9u/K LkPvbeEo9GuiY4yYctKEQyDPxDH4mJeMCxa6A2G9vOR69YfHW/HY7mEtIZxczr2cVrKOPtErezZAN rVTIh3r/RKQZJtLOirsriQRWOGtm38PdslfeceAku/C5yAgobqPzYslGzUX3YlGZpdZxdI6D217Np o4wYqjgHbHIs2bGVndbXdAjQvPPtiCry2pFxwtyiBLxOwZdCeerXEbo/meeEz7uQZ3cbQf9u0ANT+ GL3+mmShj/k6RUjREmy+l0J0pcEMShNHfbulJ7E4FCrqXZV0EsV4C2wPUXfwk8OZVkF4xpHQhPAlE K/FTaHwA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kKgZB-0006Hy-8J; Tue, 22 Sep 2020 11:34:37 +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 1kKgYt-00066j-S3 for linux-rockchip@lists.infradead.org; Tue, 22 Sep 2020 11:34:21 +0000 Received: from guri.fritz.box (p200300c7cf13ec005877be1094b7a29d.dip0.t-ipconnect.de [IPv6:2003:c7:cf13:ec00:5877:be10:94b7:a29d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: dafna) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id D5EFB29B4C2; Tue, 22 Sep 2020 12:34:12 +0100 (BST) From: Dafna Hirschfeld To: linux-media@vger.kernel.org Subject: [PATCH v3 08/12] media: staging: rkisp1: isp: don't enable signal RKISP1_CIF_ISP_FRAME_IN Date: Tue, 22 Sep 2020 13:33:58 +0200 Message-Id: <20200922113402.12442-9-dafna.hirschfeld@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200922113402.12442-1-dafna.hirschfeld@collabora.com> References: <20200922113402.12442-1-dafna.hirschfeld@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200922_073420_230127_675C875C X-CRM114-Status: GOOD ( 12.81 ) 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_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 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 9020633c1b3f..cb6a94136612 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 Tue Sep 22 11:33:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 11792345 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 26164139F for ; Tue, 22 Sep 2020 11:34:53 +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 E512B23600 for ; Tue, 22 Sep 2020 11:34:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="wR/qe3cA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E512B23600 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=I5MgrVEFhHubqZQaPbc0oLOmwVk2hiFoH3onhrDfaZE=; b=wR/qe3cA9E9SzQbrr/Q6fmN6g2 65avX7LsnrcrEcxG1XUxiQMS8HUd4Ls0FNPyBlMLGxC1zbnUdSYBqHP1lpYGMVLpGk+Nu0Z4Qbv/c 13krm2UdSj6216IFtGhW6+pXUkRZ+mVM/vPO5aGOEPlxSugPvcfkf8I0NT+IgjpuLSsWJ2WWTeG03 jXTa0XALkS8X3XA3MSg70fIV3rsILRxv1TKd4R+8Py0rfApRsqeD/N14dkvSCwZ6/CrPvjfwmlupb 1uNrHxkrEDCWyn+fKw8MvK2uxE+5fHAz8f/c3xbjAAkSftCy5Il9LogaeEbBwVRj+A8Qc1Dgp8h1e oMjUelrQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kKgZJ-0006L1-Er; Tue, 22 Sep 2020 11:34:45 +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 1kKgYt-00066s-S6 for linux-rockchip@lists.infradead.org; Tue, 22 Sep 2020 11:34:23 +0000 Received: from guri.fritz.box (p200300c7cf13ec005877be1094b7a29d.dip0.t-ipconnect.de [IPv6:2003:c7:cf13:ec00:5877:be10:94b7:a29d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: dafna) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 496AA29B4A8; Tue, 22 Sep 2020 12:34:13 +0100 (BST) From: Dafna Hirschfeld To: linux-media@vger.kernel.org Subject: [PATCH v3 09/12] media: staging: rkisp1: stats: protect write to 'is_streaming' in start_streaming cb Date: Tue, 22 Sep 2020 13:33:59 +0200 Message-Id: <20200922113402.12442-10-dafna.hirschfeld@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200922113402.12442-1-dafna.hirschfeld@collabora.com> References: <20200922113402.12442-1-dafna.hirschfeld@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200922_073420_223746_1388084F X-CRM114-Status: GOOD ( 11.18 ) 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_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 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 6aa18d970f2b..51c64f75fe29 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 Tue Sep 22 11:34:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 11792343 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 1B15559D for ; Tue, 22 Sep 2020 11:34:53 +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 DCFC8221EB for ; Tue, 22 Sep 2020 11:34:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Ve+kSiZC" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DCFC8221EB 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=JaMThV4TRVi7thMaFNcLY0cRe3EgNiXOFxkRbzO/w9A=; b=Ve+kSiZC6gkmllgeRxKA6AASuG uvqhspeqx+DnoTC+lR13yBNit71j8I6Bx9/HKptTI/w7H1ArjBL9Y/9he3Py8HlrLtmA5E/ZKLkhu FNh+J1u8YgT2Nlz4pcgCJ+tYWRKlKlEOVnISzVuQh/t44kVlJbWiEn6WOH4RdR1zi7mKt4W65IkvZ sKxpOrFmcsWxKs76kNZNSa7SO0AYJcjgd5VP+dtW1wnUXFL5Avhlu+LoV9UrNFSwNmHSD0WcGrNiP 5nTuCx6YtwuvfHhuyFweli6EMpv7Ju4DsWWvP+ptKBKe43iOprCUNHZuBppawPt2yVEZxIMOxoxzp xqIoTNOQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kKgZK-0006Lg-H9; Tue, 22 Sep 2020 11:34:46 +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 1kKgYt-00066r-S4 for linux-rockchip@lists.infradead.org; Tue, 22 Sep 2020 11:34:24 +0000 Received: from guri.fritz.box (p200300c7cf13ec005877be1094b7a29d.dip0.t-ipconnect.de [IPv6:2003:c7:cf13:ec00:5877:be10:94b7:a29d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: dafna) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id B192829B4A9; Tue, 22 Sep 2020 12:34:13 +0100 (BST) From: Dafna Hirschfeld To: linux-media@vger.kernel.org Subject: [PATCH v3 10/12] media: staging: rkisp1: params: no need to lock default config Date: Tue, 22 Sep 2020 13:34:00 +0200 Message-Id: <20200922113402.12442-11-dafna.hirschfeld@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200922113402.12442-1-dafna.hirschfeld@collabora.com> References: <20200922113402.12442-1-dafna.hirschfeld@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200922_073420_242661_7DF63821 X-CRM114-Status: GOOD ( 14.12 ) 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_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 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 7aa76f032728..f0258b4258ed 100644 --- a/drivers/staging/media/rkisp1/rkisp1-params.c +++ b/drivers/staging/media/rkisp1/rkisp1-params.c @@ -1276,8 +1276,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); @@ -1302,6 +1300,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); From patchwork Tue Sep 22 11:34:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 11792349 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 249676CB for ; Tue, 22 Sep 2020 11:34:56 +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 C4CC6221EB for ; Tue, 22 Sep 2020 11:34:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="qIxlZlU0" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C4CC6221EB 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=tOujSrfx+LIcXt6XIO2CXIA422z/HUnHPND0MiRmy8Y=; b=qIxlZlU0LCgy0tcrhZXLNE++qJ FlQtx1YIbfKBhLe/kQqzK9whTl4x+2WCxLYwbn4vVK4kjqyWs55hX/zgN23twA977akAzPpTxxIxs 6yyfeg2IsL5LyAQJ66igf8+4dlZD1XS7LFpjQHftrcu0PwLuT9c3F5V6a3kI/xPDRnfqFiI2fR/mX TZnlVRAw8VtA1bYvIRLuxUAnwG45mRxE0Zo+77LKZLCFPYtX12X3xiXJxxVAUl0eOZw/6B2qN/2ii TeD4SWj5/U0JE5xzIDOL42l7oA6m9ujmLq/Ixv7tCMMAepqXOikzadFFS1f9+rksOdRTh1xDy6pXN 2TmaG55w==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kKgZM-0006NC-SD; Tue, 22 Sep 2020 11:34:48 +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 1kKgYv-00069M-3Q for linux-rockchip@lists.infradead.org; Tue, 22 Sep 2020 11:34:27 +0000 Received: from guri.fritz.box (p200300c7cf13ec005877be1094b7a29d.dip0.t-ipconnect.de [IPv6:2003:c7:cf13:ec00:5877:be10:94b7:a29d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: dafna) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 2A71029B4CE; Tue, 22 Sep 2020 12:34:14 +0100 (BST) From: Dafna Hirschfeld To: linux-media@vger.kernel.org Subject: [PATCH v3 11/12] media: staging: rkisp1: use the right variants of spin_lock Date: Tue, 22 Sep 2020 13:34:01 +0200 Message-Id: <20200922113402.12442-12-dafna.hirschfeld@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200922113402.12442-1-dafna.hirschfeld@collabora.com> References: <20200922113402.12442-1-dafna.hirschfeld@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200922_073421_471791_7E617952 X-CRM114-Status: GOOD ( 13.81 ) 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_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 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 When locking, use either 'spin_lock' or 'spin_lock_irq' according to the context. There is nowhere need to use 'spin_lock_irqsave'. Outside of irq context, always use 'spin_lock_irq' to be on the safe side. Signed-off-by: Dafna Hirschfeld --- drivers/staging/media/rkisp1/rkisp1-capture.c | 15 ++++++-------- drivers/staging/media/rkisp1/rkisp1-params.c | 20 ++++++++----------- 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/drivers/staging/media/rkisp1/rkisp1-capture.c b/drivers/staging/media/rkisp1/rkisp1-capture.c index 1c762a369b63..012c0825a386 100644 --- a/drivers/staging/media/rkisp1/rkisp1-capture.c +++ b/drivers/staging/media/rkisp1/rkisp1-capture.c @@ -626,9 +626,8 @@ static void rkisp1_handle_buffer(struct rkisp1_capture *cap) { struct rkisp1_isp *isp = &cap->rkisp1->isp; struct rkisp1_buffer *curr_buf; - unsigned long flags; - spin_lock_irqsave(&cap->buf.lock, flags); + spin_lock(&cap->buf.lock); curr_buf = cap->buf.curr; if (curr_buf) { @@ -641,7 +640,7 @@ static void rkisp1_handle_buffer(struct rkisp1_capture *cap) } rkisp1_set_next_buf(cap); - spin_unlock_irqrestore(&cap->buf.lock, flags); + spin_unlock(&cap->buf.lock); } void rkisp1_capture_isr(struct rkisp1_device *rkisp1) @@ -716,7 +715,6 @@ static void rkisp1_vb2_buf_queue(struct vb2_buffer *vb) container_of(vbuf, struct rkisp1_buffer, vb); struct rkisp1_capture *cap = vb->vb2_queue->drv_priv; const struct v4l2_pix_format_mplane *pixm = &cap->pix.fmt; - unsigned long flags; unsigned int i; memset(ispbuf->buff_addr, 0, sizeof(ispbuf->buff_addr)); @@ -741,9 +739,9 @@ static void rkisp1_vb2_buf_queue(struct vb2_buffer *vb) swap(ispbuf->buff_addr[RKISP1_PLANE_CR], ispbuf->buff_addr[RKISP1_PLANE_CB]); - spin_lock_irqsave(&cap->buf.lock, flags); + spin_lock_irq(&cap->buf.lock); list_add_tail(&ispbuf->queue, &cap->buf.queue); - spin_unlock_irqrestore(&cap->buf.lock, flags); + spin_unlock_irq(&cap->buf.lock); } static int rkisp1_vb2_buf_prepare(struct vb2_buffer *vb) @@ -769,10 +767,9 @@ static int rkisp1_vb2_buf_prepare(struct vb2_buffer *vb) static void rkisp1_return_all_buffers(struct rkisp1_capture *cap, enum vb2_buffer_state state) { - unsigned long flags; struct rkisp1_buffer *buf; - spin_lock_irqsave(&cap->buf.lock, flags); + spin_lock_irq(&cap->buf.lock); if (cap->buf.curr) { vb2_buffer_done(&cap->buf.curr->vb.vb2_buf, state); cap->buf.curr = NULL; @@ -787,7 +784,7 @@ static void rkisp1_return_all_buffers(struct rkisp1_capture *cap, list_del(&buf->queue); vb2_buffer_done(&buf->vb.vb2_buf, state); } - spin_unlock_irqrestore(&cap->buf.lock, flags); + spin_unlock_irq(&cap->buf.lock); } /* diff --git a/drivers/staging/media/rkisp1/rkisp1-params.c b/drivers/staging/media/rkisp1/rkisp1-params.c index f0258b4258ed..986d293201e6 100644 --- a/drivers/staging/media/rkisp1/rkisp1-params.c +++ b/drivers/staging/media/rkisp1/rkisp1-params.c @@ -1300,16 +1300,15 @@ static void rkisp1_params_config_parameter(struct rkisp1_params *params) else rkisp1_csm_config(params, false); - spin_lock(¶ms->config_lock); + spin_lock_irq(¶ms->config_lock); /* 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); + spin_unlock_irq(¶ms->config_lock); } -/* Not called when the camera active, thus not isr protection. */ void rkisp1_params_configure(struct rkisp1_params *params, enum rkisp1_fmt_raw_pat_type bayer_pat, enum v4l2_quantization quantization) @@ -1442,12 +1441,11 @@ 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; - unsigned long flags; params_buf->vaddr = vb2_plane_vaddr(vb, 0); - spin_lock_irqsave(¶ms->config_lock, flags); + spin_lock_irq(¶ms->config_lock); list_add_tail(¶ms_buf->queue, ¶ms->params); - spin_unlock_irqrestore(¶ms->config_lock, flags); + spin_unlock_irq(¶ms->config_lock); } static int rkisp1_params_vb2_buf_prepare(struct vb2_buffer *vb) @@ -1465,7 +1463,6 @@ 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; INIT_LIST_HEAD(&tmp_list); @@ -1474,10 +1471,10 @@ static void rkisp1_params_vb2_stop_streaming(struct vb2_queue *vq) * and then we can iterate it and call vb2_buffer_done * without holding the lock */ - spin_lock_irqsave(¶ms->config_lock, flags); + spin_lock_irq(¶ms->config_lock); params->is_streaming = false; list_cut_position(&tmp_list, ¶ms->params, params->params.prev); - spin_unlock_irqrestore(¶ms->config_lock, flags); + spin_unlock_irq(¶ms->config_lock); list_for_each_entry(buf, &tmp_list, queue) vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR); @@ -1487,11 +1484,10 @@ static int rkisp1_params_vb2_start_streaming(struct vb2_queue *queue, unsigned int count) { struct rkisp1_params *params = queue->drv_priv; - unsigned long flags; - spin_lock_irqsave(¶ms->config_lock, flags); + spin_lock_irq(¶ms->config_lock); params->is_streaming = true; - spin_unlock_irqrestore(¶ms->config_lock, flags); + spin_unlock_irq(¶ms->config_lock); return 0; } From patchwork Tue Sep 22 11:34:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 11792347 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 ED3526CB for ; Tue, 22 Sep 2020 11:34:54 +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 9F8E0221EB for ; Tue, 22 Sep 2020 11:34:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="eheNOsQ/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9F8E0221EB 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=ecEeGtPr3fa/NqjDL1hCWX/tSsXIW9Faey3xKRZ4b3I=; b=eheNOsQ/E29uFtVXdqesyCJNcg TaMvQGdSF/UcLtPVwqSOohF8SXt41kigx/DbKBH2gObGKKwLwT0l0DJm8pJzSBtduTBBu4G6TMveB xdtIkBcUFHs4H0THJsj/fF8wphJwsDUOoKRJhzar6gtjc4WvXem8Pq1bx0XufcmLsJ9xtsqcdrrHo SizgJCsQ/fKFXjnwkHOl2vNj+UqcvmapUTrkA+sozwlet3kKDBT+bb/ut34G+DgMD3Kj6EsBiDdRq qdMyeOwx27CcLSbmJOZ7E6Bo0pEe88cyj1QioC2H6H3FuqvHVrkv1xIktF+j9zkYCZcbaEuJ9qQMa F58cYgIw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kKgZL-0006MM-KI; Tue, 22 Sep 2020 11:34:47 +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 1kKgYv-00069o-8e for linux-rockchip@lists.infradead.org; Tue, 22 Sep 2020 11:34:26 +0000 Received: from guri.fritz.box (p200300c7cf13ec005877be1094b7a29d.dip0.t-ipconnect.de [IPv6:2003:c7:cf13:ec00:5877:be10:94b7:a29d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: dafna) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 952E629B4EB; Tue, 22 Sep 2020 12:34:14 +0100 (BST) From: Dafna Hirschfeld To: linux-media@vger.kernel.org Subject: [PATCH v3 12/12] media: staging: rkisp1: cap: protect access to buf with the spin lock Date: Tue, 22 Sep 2020 13:34:02 +0200 Message-Id: <20200922113402.12442-13-dafna.hirschfeld@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200922113402.12442-1-dafna.hirschfeld@collabora.com> References: <20200922113402.12442-1-dafna.hirschfeld@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200922_073421_563400_F2FB4A32 X-CRM114-Status: GOOD ( 13.64 ) 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_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 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 function 'rkisp1_stream_start' calls 'rkisp1_set_next_buf' which access the buffers, so the call should be protected by taking the cap->buf.lock. After this patch, all locks are reviewed and commented so remove the TODO item "review and comment every lock" Signed-off-by: Dafna Hirschfeld --- drivers/staging/media/rkisp1/TODO | 1 - drivers/staging/media/rkisp1/rkisp1-capture.c | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/media/rkisp1/TODO b/drivers/staging/media/rkisp1/TODO index f0c90d1c86a8..9662e9b51c7f 100644 --- a/drivers/staging/media/rkisp1/TODO +++ b/drivers/staging/media/rkisp1/TODO @@ -1,6 +1,5 @@ * Fix pad format size for statistics and parameters entities. * Fix checkpatch errors. -* Review and comment every lock * Handle quantization * streaming paths (mainpath and selfpath) check if the other path is streaming in several places of the code, review this, specially that it doesn't seem it diff --git a/drivers/staging/media/rkisp1/rkisp1-capture.c b/drivers/staging/media/rkisp1/rkisp1-capture.c index 012c0825a386..b9e56dab77af 100644 --- a/drivers/staging/media/rkisp1/rkisp1-capture.c +++ b/drivers/staging/media/rkisp1/rkisp1-capture.c @@ -913,6 +913,7 @@ static void rkisp1_stream_start(struct rkisp1_capture *cap) cap->ops->config(cap); /* Setup a buffer for the next frame */ + spin_lock_irq(&cap->buf.lock); rkisp1_set_next_buf(cap); cap->ops->enable(cap); /* It's safe to config ACTIVE and SHADOW regs for the @@ -930,6 +931,7 @@ static void rkisp1_stream_start(struct rkisp1_capture *cap) RKISP1_CIF_MI_INIT_SOFT_UPD, RKISP1_CIF_MI_INIT); rkisp1_set_next_buf(cap); } + spin_unlock_irq(&cap->buf.lock); cap->is_streaming = true; }