mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.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:36:42 +0300	[thread overview]
Message-ID: <20240929133646.19991-4-laurent.pinchart@ideasonboard.com> (raw)
In-Reply-To: <20240929133646.19991-1-laurent.pinchart@ideasonboard.com>

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 <laurent.pinchart@ideasonboard.com>
---
 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 <linux/kernel.h>
 #include <linux/mfd/syscon.h>
 #include <linux/module.h>
-#include <linux/mutex.h>
 #include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
@@ -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);
 }
-- 
Regards,

Laurent Pinchart


  parent reply	other threads:[~2024-09-29 13:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-29 13:36 [PATCH 0/3] media: imx8mq-mipi-csi2: Simplify power management handling Laurent Pinchart
2024-09-29 13:36 ` [PATCH 1/3] media: imx8mq-mipi-csi2: Drop stream stop/restart at suspend/resume time Laurent Pinchart
2024-09-29 13:36 ` [PATCH 2/3] media: imx8mq-mipi-csi2: Drop ST_SUSPENDED guard Laurent Pinchart
2024-09-29 13:36 ` Laurent Pinchart [this message]
2024-09-29 13:43 [PATCH 0/3] media: imx8mq-mipi-csi2: Simplify power management handling Laurent Pinchart
2024-09-29 13:43 ` [PATCH 3/3] media: imx8mq-mipi-csi2: Drop system suspend/resume handlers Laurent Pinchart

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240929133646.19991-4-laurent.pinchart@ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=guoniu.zhou@oss.nxp.com \
    --cc=imx@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®