From nobody Thu Nov 28 21:46:45 2024 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 054FE17C9A3; Sun, 29 Sep 2024 13:44:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727617444; cv=none; b=oxkqp2FJXkVB0U1e1gk7z6pJUxAzqzCRuP55qzAwYsVnpUNSbixKl0Zd7ExtsSw186cLvjCekOqGUma8XN8+EUDl7PZwb/YcWSSfWkqQMzgbfbLCshFj9Lky0QR96Ybgp7ebPeNcqw61K/FLF1OETbJh2+JGZhLBmrOlhUI1VAA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727617444; c=relaxed/simple; bh=BJyfg/bYawpzN0ZweGvRjC/Ui3Wm3vXBCxldTdF1wbg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SEtvs8nobhMXRMx4ErjfexnxOwvshTTaCc95qGaZCKx4+JAILuMtJH5vTX0jWvG8X8s8R+Ok611g6kcTdsnu7lMjyYhxn3A01l8wvyIoDedzNcoaln/qM98FnCvZybWgrfmegIIRwwdRNIx28/VC1izvLFLS65fnCBnbbaCcvUE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=QH6/IGbp; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="QH6/IGbp" 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 =20 -enum { - ST_POWERED =3D 1, -}; - enum imx8mq_mipi_csi_clk { CSI2_CLK_CORE, CSI2_CLK_ESC, @@ -116,9 +111,6 @@ struct csi_state { =20 struct v4l2_mbus_config_mipi_csi2 bus; =20 - struct mutex lock; /* Protect state */ - u32 state; - struct regmap *phy_gpr; u8 phy_gpr_reg; =20 @@ -400,27 +392,23 @@ static int imx8mq_mipi_csi_s_stream(struct v4l2_subde= v *sd, int enable) return ret; } =20 - mutex_lock(&state->lock); - if (enable) { sd_state =3D v4l2_subdev_lock_and_get_active_state(sd); ret =3D imx8mq_mipi_csi_start_stream(state, sd_state); v4l2_subdev_unlock_state(sd_state); =20 if (ret < 0) - goto unlock; + goto out; =20 ret =3D 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); } =20 -unlock: - mutex_unlock(&state->lock); - +out: if (!enable || ret < 0) pm_runtime_put(state->dev); =20 @@ -638,59 +626,14 @@ static int imx8mq_mipi_csi_async_register(struct csi_= state *state) * Suspend/resume */ =20 -static void imx8mq_mipi_csi_pm_suspend(struct device *dev) -{ - struct v4l2_subdev *sd =3D dev_get_drvdata(dev); - struct csi_state *state =3D 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 &=3D ~ST_POWERED; - } - - mutex_unlock(&state->lock); -} - -static int imx8mq_mipi_csi_pm_resume(struct device *dev) -{ - struct v4l2_subdev *sd =3D dev_get_drvdata(dev); - struct csi_state *state =3D mipi_sd_to_csi2_state(sd); - int ret =3D 0; - - mutex_lock(&state->lock); - - if (!(state->state & ST_POWERED)) { - state->state |=3D ST_POWERED; - ret =3D 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 =3D dev_get_drvdata(dev); struct csi_state *state =3D mipi_sd_to_csi2_state(sd); int ret; =20 - imx8mq_mipi_csi_pm_suspend(dev); + imx8mq_mipi_csi_stop_stream(state); + imx8mq_mipi_csi_clk_disable(state); =20 ret =3D icc_set_bw(state->icc_path, 0, 0); if (ret) @@ -711,13 +654,14 @@ static int imx8mq_mipi_csi_runtime_resume(struct devi= ce *dev) return ret; } =20 - return imx8mq_mipi_csi_pm_resume(dev); + ret =3D imx8mq_mipi_csi_clk_enable(state); + + return ret ? -EAGAIN : 0; } =20 static const struct dev_pm_ops imx8mq_mipi_csi_pm_ops =3D { 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) }; =20 /* -----------------------------------------------------------------------= ------ @@ -854,15 +798,13 @@ static int imx8mq_mipi_csi_probe(struct platform_devi= ce *pdev) =20 platform_set_drvdata(pdev, &state->sd); =20 - mutex_init(&state->lock); - ret =3D imx8mq_mipi_csi_subdev_init(state); if (ret < 0) - goto mutex; + return ret; =20 ret =3D imx8mq_mipi_csi_init_icc(pdev); if (ret) - goto mutex; + return ret; =20 /* 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); =20 return ret; } @@ -908,7 +848,6 @@ static void imx8mq_mipi_csi_remove(struct platform_devi= ce *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); } --=20 Regards, Laurent Pinchart