From patchwork Sun Sep 29 13:43:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 13815120 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 56E0DCF6499 for ; Sun, 29 Sep 2024 13:46:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=H24heGZOFwke5+du84omb0id4JX0VLJyKIeoEtlCUIY=; b=v+iSuvjEg+8/aWHPIOe8uZsA+O Yit8n8fxA20OKL+1o3OOy7s/NVnZb1OwG5Cp5zzVe6ABO/16uPIE1u/dnhHBOr9S2yN8huFfX7Kng bxYh9kNX/zfcd4E3gy5Lvl2W4m2Af8logI+W783owmGHWYnyG8CtnFV7Rn29mEjuYQrYSuaFyQijQ dF4yF2TsN8aaQKi2X78VHPlGNcaxEkyvIQf22knc3WchnJ9e6uuX3FBTLxJz2Lug1nsT0Cnu9vAdb dJ7id8gBC5wG6YCfpylre/W7gId+WTnYmOZdpuhsv+pVGNoIHIYBq4D5RbNOC1JM61SXj+cTOWQyY vgu34sMg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1suuFm-0000000Eq8x-33m8; Sun, 29 Sep 2024 13:46:26 +0000 Received: from perceval.ideasonboard.com ([213.167.242.64]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1suuDP-0000000Epiv-4B8O for linux-arm-kernel@lists.infradead.org; Sun, 29 Sep 2024 13:44:01 +0000 Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 1CFC8227; Sun, 29 Sep 2024 15:42:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1727617348; bh=OcwnUVuhMtXnLLH9oEg60Lun1uQvDGaKMD6lqbREbb0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JKQrJTuoyPt7+ejGyDLnCW2mztlr/VZtpgN7VvTzCzJX6+0EbERsW2PGTWYkMPCQD 3OR7m1roX3fRg3M76aouuqgA3qFjIByxepQZWOtnQFZMv3Jcq3pXCab3MFIqn3fdNv WOdeNpLty2cQkhnxS4MjfprgeAGNWIng0Xq0UqvY= From: Laurent Pinchart To: rmfrfs@gmail.com, martink@posteo.de, kernel@puri.sm, mchehab@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com Cc: guoniu.zhou@oss.nxp.com, imx@lists.linux.dev, linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] media: imx8mq-mipi-csi2: Drop stream stop/restart at suspend/resume time Date: Sun, 29 Sep 2024 16:43:52 +0300 Message-ID: <20240929134354.20735-2-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240929134354.20735-1-laurent.pinchart@ideasonboard.com> References: <20240929134354.20735-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240929_064400_182974_6F57D0AB X-CRM114-Status: GOOD ( 11.38 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The imx8mq-mipi-csi2 driver stops streaming at suspend time, and restarts it at resume time, in both the runtime and system suspend/resume handlers. This isn't needed: - The device is runtime resumed only from the .s_stream() handler, before starting streaming, and runtime suspended in the same function, after stopping streaming. - For system suspend/resume, the whole capture pipeline is stopped and restarted in a controlled manner by the top-level driver (the CSI bridge in this case). When the system suspend handler is called, streaming will have been stopped already. Drop stream stop/restart from the PM handlers. Signed-off-by: Laurent Pinchart --- drivers/media/platform/nxp/imx8mq-mipi-csi2.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/drivers/media/platform/nxp/imx8mq-mipi-csi2.c b/drivers/media/platform/nxp/imx8mq-mipi-csi2.c index d4a6c5532969..8eb9c7049425 100644 --- a/drivers/media/platform/nxp/imx8mq-mipi-csi2.c +++ b/drivers/media/platform/nxp/imx8mq-mipi-csi2.c @@ -64,7 +64,6 @@ enum { ST_POWERED = 1, - ST_STREAMING = 2, ST_SUSPENDED = 4, }; @@ -420,12 +419,9 @@ static int imx8mq_mipi_csi_s_stream(struct v4l2_subdev *sd, int enable) ret = v4l2_subdev_call(state->src_sd, video, s_stream, 1); if (ret < 0) goto unlock; - - state->state |= ST_STREAMING; } else { v4l2_subdev_call(state->src_sd, video, s_stream, 0); imx8mq_mipi_csi_stop_stream(state); - state->state &= ~ST_STREAMING; } unlock: @@ -668,7 +664,6 @@ static int imx8mq_mipi_csi_pm_resume(struct device *dev) { struct v4l2_subdev *sd = dev_get_drvdata(dev); struct csi_state *state = mipi_sd_to_csi2_state(sd); - struct v4l2_subdev_state *sd_state; int ret = 0; mutex_lock(&state->lock); @@ -677,17 +672,9 @@ static int imx8mq_mipi_csi_pm_resume(struct device *dev) state->state |= ST_POWERED; ret = imx8mq_mipi_csi_clk_enable(state); } - if (state->state & ST_STREAMING) { - sd_state = v4l2_subdev_lock_and_get_active_state(sd); - ret = imx8mq_mipi_csi_start_stream(state, sd_state); - v4l2_subdev_unlock_state(sd_state); - if (ret) - goto unlock; - } state->state &= ~ST_SUSPENDED; -unlock: mutex_unlock(&state->lock); return ret ? -EAGAIN : 0; From patchwork Sun Sep 29 13:43:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 13815121 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8D50ACF6499 for ; Sun, 29 Sep 2024 13:47:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=NB2Fen65XiQw/ftAHOXXAbdH1RHS0sveFsUyfGQ/rtw=; b=Xq+6E4vrjEHfWx2hwTvyFT/sxV ILveZ27uJEzNAdT3ibBewJn+wpnj2neYF+7a5tnU3DdTKeyhX57HUOU3S8dK9A3sFGLL04OcS5Ba2 VMD+YZu3ynopiCXR6LWRrmw0YH25905lO1cPLEGi6ZcQFDV25ucuIV4etkhbiQG3Ui0okigvrpzb0 T1O5oawlMlicf39iE39mh5aUNZP3iko6OBiCT+xN2GNxzn3uFBWI0LHvzhzQShC/t1VfT11cVm+Mi p5Q6l7ib9f5F4mpWYoS4CBaYkBMv+IEZR/knkRQ+oi/+ZoM+yvrurIATBPcLyAV/aMxr8pD+hM3q4 z+UgRbIQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1suuGv-0000000EqQG-0d7c; Sun, 29 Sep 2024 13:47:37 +0000 Received: from perceval.ideasonboard.com ([213.167.242.64]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1suuDR-0000000Epiw-00LI for linux-arm-kernel@lists.infradead.org; Sun, 29 Sep 2024 13:44:02 +0000 Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 805556DE; Sun, 29 Sep 2024 15:42:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1727617349; bh=oMfSYlB7P9eLwoLyD1PZzgkE2aC3vO/4RvgIGutTDEI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DUbrEfjU5GOgNz54YsMVhBoPA5Ag4Lc8j4f07vmRdQ20/4uokamIH8Kz085KY02Xv vN3zHeUBLZKOcbnH2T5A9QBBwCASp7Nlmxi9woCiJbnqEjFqdkcdJ3AuBMd/CoEuLa EKgX4jdPMf11BeQWLU/QFZM3h/Muw6dDq+t/1KFE= From: Laurent Pinchart To: rmfrfs@gmail.com, martink@posteo.de, kernel@puri.sm, mchehab@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com Cc: guoniu.zhou@oss.nxp.com, imx@lists.linux.dev, linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] media: imx8mq-mipi-csi2: Drop ST_SUSPENDED guard Date: Sun, 29 Sep 2024 16:43:53 +0300 Message-ID: <20240929134354.20735-3-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240929134354.20735-1-laurent.pinchart@ideasonboard.com> References: <20240929134354.20735-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240929_064401_189128_0C2D5ED9 X-CRM114-Status: GOOD ( 11.96 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The ST_SUSPENDED flag is set at system suspend and cleared at either system resume or runtime resume. It is then used in two locations: - In .s_stream(), when starting the stream to return -EBUSY if the device is suspended. This can't happen, As the function calls pm_runtime_resume_and_get() just before the check, which clears the ST_SUSPENDED flag. - In imx8mq_mipi_csi_resume() to skip resuming if the device isn't suspended. As imx8mq_mipi_csi_resume() is the system resume handler, the device is by definition suspended. The ST_SUSPENDED flag is therefore not needed. Drop it. Signed-off-by: Laurent Pinchart --- drivers/media/platform/nxp/imx8mq-mipi-csi2.c | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/drivers/media/platform/nxp/imx8mq-mipi-csi2.c b/drivers/media/platform/nxp/imx8mq-mipi-csi2.c index 8eb9c7049425..0f56a40abf33 100644 --- a/drivers/media/platform/nxp/imx8mq-mipi-csi2.c +++ b/drivers/media/platform/nxp/imx8mq-mipi-csi2.c @@ -64,7 +64,6 @@ enum { ST_POWERED = 1, - ST_SUSPENDED = 4, }; enum imx8mq_mipi_csi_clk { @@ -404,11 +403,6 @@ static int imx8mq_mipi_csi_s_stream(struct v4l2_subdev *sd, int enable) mutex_lock(&state->lock); if (enable) { - if (state->state & ST_SUSPENDED) { - ret = -EBUSY; - goto unlock; - } - sd_state = v4l2_subdev_lock_and_get_active_state(sd); ret = imx8mq_mipi_csi_start_stream(state, sd_state); v4l2_subdev_unlock_state(sd_state); @@ -673,8 +667,6 @@ static int imx8mq_mipi_csi_pm_resume(struct device *dev) ret = imx8mq_mipi_csi_clk_enable(state); } - state->state &= ~ST_SUSPENDED; - mutex_unlock(&state->lock); return ret ? -EAGAIN : 0; @@ -682,24 +674,13 @@ static int imx8mq_mipi_csi_pm_resume(struct device *dev) static int imx8mq_mipi_csi_suspend(struct device *dev) { - struct v4l2_subdev *sd = dev_get_drvdata(dev); - struct csi_state *state = mipi_sd_to_csi2_state(sd); - imx8mq_mipi_csi_pm_suspend(dev); - state->state |= ST_SUSPENDED; - return 0; } static int imx8mq_mipi_csi_resume(struct device *dev) { - struct v4l2_subdev *sd = dev_get_drvdata(dev); - struct csi_state *state = mipi_sd_to_csi2_state(sd); - - if (!(state->state & ST_SUSPENDED)) - return 0; - return imx8mq_mipi_csi_pm_resume(dev); } From patchwork Sun Sep 29 13:43:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 13815122 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 02F6BCF6495 for ; Sun, 29 Sep 2024 13:48:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=lbmon8hBScS2tBRN9wwYEGgaWe3VUrOufoxVfPPpGPw=; b=vbAhMQ7xupFJiBfW8JxC1Zz1IR u3Y3v6aT1Ws8x+OdzvYSH5H3EaIe9srdiHwyla1nlZl0noGJpmTaJ+LTirERKPFofmhSHNAERxJpO fUKMG7fI4XzBAhUSnl8+dUur8UTHUqTuRLQ+V3aTf1OtgPlb7K+VLh4C37EDXQ97j58DsjgWVNxH0 Z1/3as359PFKhTTvZc6gFFjLCeArqXfHDak0WaisD4dHXr5ScxF1D44PLPI9XDsjjWCnTHxr/bQit x65tU0mBIc0ZDaX7IaiX5Sk6MN6hxWfIvVfpeZhIlP9BtfyZWOafXDzcogMH9VPwugpfXz0vwQTAd 2drixDyQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1suuI5-0000000EqfP-2ItV; Sun, 29 Sep 2024 13:48:49 +0000 Received: from perceval.ideasonboard.com ([213.167.242.64]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1suuDS-0000000Epjl-1YhF for linux-arm-kernel@lists.infradead.org; Sun, 29 Sep 2024 13:44:03 +0000 Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 02231A98; Sun, 29 Sep 2024 15:42:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1727617351; bh=BJyfg/bYawpzN0ZweGvRjC/Ui3Wm3vXBCxldTdF1wbg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QH6/IGbpbJV+gDlbOlpvqcmDa2n8G2F0GuS8Awursera//bBjtbxgNgndcFHjBrM1 j5B9D9+nEyDTPP2E5qJuwKcFo4+ER+rD+NsMDWVw54Ruoi8QIVlat2zjBWQ6qkBQpa a/UHgG6y+3oWau1+soN0O3VWB+bU4+KDaoVco6T4= From: Laurent Pinchart To: rmfrfs@gmail.com, martink@posteo.de, kernel@puri.sm, mchehab@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com Cc: guoniu.zhou@oss.nxp.com, imx@lists.linux.dev, linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] media: imx8mq-mipi-csi2: Drop system suspend/resume handlers Date: Sun, 29 Sep 2024 16:43:54 +0300 Message-ID: <20240929134354.20735-4-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240929134354.20735-1-laurent.pinchart@ideasonboard.com> References: <20240929134354.20735-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240929_064402_563240_40878B04 X-CRM114-Status: GOOD ( 15.40 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Video capture pipelines are suspended and resumes in a controlled manner by the top-level driver (the CSI bridge driver in this case), to ensure proper synchronization of sources and sinks. There is therefore no need for system suspend/resume handlers in the imx8mq-mipi-csi2 driver. Drop them. Signed-off-by: Laurent Pinchart --- drivers/media/platform/nxp/imx8mq-mipi-csi2.c | 81 +++---------------- 1 file changed, 10 insertions(+), 71 deletions(-) diff --git a/drivers/media/platform/nxp/imx8mq-mipi-csi2.c b/drivers/media/platform/nxp/imx8mq-mipi-csi2.c index 0f56a40abf33..54b2de09692b 100644 --- a/drivers/media/platform/nxp/imx8mq-mipi-csi2.c +++ b/drivers/media/platform/nxp/imx8mq-mipi-csi2.c @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include @@ -62,10 +61,6 @@ #define CSI2RX_CFG_VID_P_FIFO_SEND_LEVEL 0x188 #define CSI2RX_CFG_DISABLE_PAYLOAD_1 0x130 -enum { - ST_POWERED = 1, -}; - enum imx8mq_mipi_csi_clk { CSI2_CLK_CORE, CSI2_CLK_ESC, @@ -116,9 +111,6 @@ struct csi_state { struct v4l2_mbus_config_mipi_csi2 bus; - struct mutex lock; /* Protect state */ - u32 state; - struct regmap *phy_gpr; u8 phy_gpr_reg; @@ -400,27 +392,23 @@ static int imx8mq_mipi_csi_s_stream(struct v4l2_subdev *sd, int enable) return ret; } - mutex_lock(&state->lock); - if (enable) { sd_state = v4l2_subdev_lock_and_get_active_state(sd); ret = imx8mq_mipi_csi_start_stream(state, sd_state); v4l2_subdev_unlock_state(sd_state); if (ret < 0) - goto unlock; + goto out; ret = v4l2_subdev_call(state->src_sd, video, s_stream, 1); if (ret < 0) - goto unlock; + goto out; } else { v4l2_subdev_call(state->src_sd, video, s_stream, 0); imx8mq_mipi_csi_stop_stream(state); } -unlock: - mutex_unlock(&state->lock); - +out: if (!enable || ret < 0) pm_runtime_put(state->dev); @@ -638,59 +626,14 @@ static int imx8mq_mipi_csi_async_register(struct csi_state *state) * Suspend/resume */ -static void imx8mq_mipi_csi_pm_suspend(struct device *dev) -{ - struct v4l2_subdev *sd = dev_get_drvdata(dev); - struct csi_state *state = mipi_sd_to_csi2_state(sd); - - mutex_lock(&state->lock); - - if (state->state & ST_POWERED) { - imx8mq_mipi_csi_stop_stream(state); - imx8mq_mipi_csi_clk_disable(state); - state->state &= ~ST_POWERED; - } - - mutex_unlock(&state->lock); -} - -static int imx8mq_mipi_csi_pm_resume(struct device *dev) -{ - struct v4l2_subdev *sd = dev_get_drvdata(dev); - struct csi_state *state = mipi_sd_to_csi2_state(sd); - int ret = 0; - - mutex_lock(&state->lock); - - if (!(state->state & ST_POWERED)) { - state->state |= ST_POWERED; - ret = imx8mq_mipi_csi_clk_enable(state); - } - - mutex_unlock(&state->lock); - - return ret ? -EAGAIN : 0; -} - -static int imx8mq_mipi_csi_suspend(struct device *dev) -{ - imx8mq_mipi_csi_pm_suspend(dev); - - return 0; -} - -static int imx8mq_mipi_csi_resume(struct device *dev) -{ - return imx8mq_mipi_csi_pm_resume(dev); -} - static int imx8mq_mipi_csi_runtime_suspend(struct device *dev) { struct v4l2_subdev *sd = dev_get_drvdata(dev); struct csi_state *state = mipi_sd_to_csi2_state(sd); int ret; - imx8mq_mipi_csi_pm_suspend(dev); + imx8mq_mipi_csi_stop_stream(state); + imx8mq_mipi_csi_clk_disable(state); ret = icc_set_bw(state->icc_path, 0, 0); if (ret) @@ -711,13 +654,14 @@ static int imx8mq_mipi_csi_runtime_resume(struct device *dev) return ret; } - return imx8mq_mipi_csi_pm_resume(dev); + ret = imx8mq_mipi_csi_clk_enable(state); + + return ret ? -EAGAIN : 0; } static const struct dev_pm_ops imx8mq_mipi_csi_pm_ops = { RUNTIME_PM_OPS(imx8mq_mipi_csi_runtime_suspend, imx8mq_mipi_csi_runtime_resume, NULL) - SYSTEM_SLEEP_PM_OPS(imx8mq_mipi_csi_suspend, imx8mq_mipi_csi_resume) }; /* ----------------------------------------------------------------------------- @@ -854,15 +798,13 @@ static int imx8mq_mipi_csi_probe(struct platform_device *pdev) platform_set_drvdata(pdev, &state->sd); - mutex_init(&state->lock); - ret = imx8mq_mipi_csi_subdev_init(state); if (ret < 0) - goto mutex; + return ret; ret = imx8mq_mipi_csi_init_icc(pdev); if (ret) - goto mutex; + return ret; /* Enable runtime PM. */ pm_runtime_enable(dev); @@ -889,8 +831,6 @@ static int imx8mq_mipi_csi_probe(struct platform_device *pdev) v4l2_async_unregister_subdev(&state->sd); icc: imx8mq_mipi_csi_release_icc(pdev); -mutex: - mutex_destroy(&state->lock); return ret; } @@ -908,7 +848,6 @@ static void imx8mq_mipi_csi_remove(struct platform_device *pdev) imx8mq_mipi_csi_runtime_suspend(&pdev->dev); media_entity_cleanup(&state->sd.entity); v4l2_subdev_cleanup(&state->sd); - mutex_destroy(&state->lock); pm_runtime_set_suspended(&pdev->dev); imx8mq_mipi_csi_release_icc(pdev); }