mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Julien Massot <julien.massot@collabora.com>
To: linux-media@vger.kernel.org, sakari.ailus@iki.fi
Cc: devicetree@vger.kernel.org, kernel@collabora.com,
	linux-kernel@vger.kernel.org, mchehab@kernel.org,
	robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org,
	conor+dt@kernel.org, Julien Massot <julien.massot@collabora.com>
Subject: [PATCH v7 5/5] drivers: media: max96717: stop the csi receiver before the source
Date: Tue, 30 Apr 2024 15:19:31 +0200	[thread overview]
Message-ID: <20240430131931.166012-6-julien.massot@collabora.com> (raw)
In-Reply-To: <20240430131931.166012-1-julien.massot@collabora.com>

Stopping the CSI source before stopping the serializer
CSI port may make the serializer not respond.
Then all the next writes to the device will fail.

max96717 1-0040: Error writing reg 0x0308: -121
max96717 1-0040: Error writing reg 0x0006: -121

Fix that by stopping the CSI receiver first and then CSI source.

Seen on max96717f revision 4.

Signed-off-by: Julien Massot <julien.massot@collabora.com>
---
 drivers/media/i2c/max96717.c | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/drivers/media/i2c/max96717.c b/drivers/media/i2c/max96717.c
index 1ea76f922bdb..499408837aef 100644
--- a/drivers/media/i2c/max96717.c
+++ b/drivers/media/i2c/max96717.c
@@ -384,24 +384,23 @@ static int max96717_disable_streams(struct v4l2_subdev *sd,
 {
 	struct max96717_priv *priv = sd_to_max96717(sd);
 	u64 sink_streams;
-	int ret;
+
+	/*
+	 * Stop the CSI receiver first then the source,
+	 * otherwise the device may become unresponsive
+	 * while holding the I2C bus low.
+	 */
+	priv->enabled_source_streams &= ~streams_mask;
+	if (!priv->enabled_source_streams)
+		max96717_start_csi(priv, false);
 
 	sink_streams = v4l2_subdev_state_xlate_streams(state,
 						       MAX96717_PAD_SOURCE,
 						       MAX96717_PAD_SINK,
 						       &streams_mask);
 
-	ret = v4l2_subdev_disable_streams(priv->source_sd, priv->source_sd_pad,
-					  sink_streams);
-	if (ret)
-		return ret;
-
-	priv->enabled_source_streams &= ~streams_mask;
-
-	if (!priv->enabled_source_streams)
-		max96717_start_csi(priv, false);
-
-	return 0;
+	return v4l2_subdev_disable_streams(priv->source_sd, priv->source_sd_pad,
+					   sink_streams);
 }
 
 static const struct v4l2_subdev_pad_ops max96717_pad_ops = {
-- 
2.44.0


  parent reply	other threads:[~2024-04-30 13:20 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-30 13:19 [PATCH v7 0/5] Add support for MAX96714/F and MAX96717/F GMSL2 ser/des Julien Massot
2024-04-30 13:19 ` [PATCH v7 1/5] dt-bindings: media: add Maxim MAX96717 GMSL2 Serializer Julien Massot
2024-04-30 13:19 ` [PATCH v7 2/5] dt-bindings: media: add Maxim MAX96714 GMSL2 Deserializer Julien Massot
2024-04-30 13:19 ` [PATCH v7 3/5] media: i2c: add MAX96717 driver Julien Massot
2024-05-31 13:56   ` Sakari Ailus
2024-06-03  7:29   ` Tommaso Merciai
2024-04-30 13:19 ` [PATCH v7 4/5] media: i2c: add MAX96714 driver Julien Massot
2024-04-30 13:19 ` Julien Massot [this message]
2024-05-17 14:16 ` [PATCH v7 0/5] Add support for MAX96714/F and MAX96717/F GMSL2 ser/des Tommaso Merciai
2024-06-06 13:34 ` Tomi Valkeinen
2024-06-06 15:24   ` Laurent Pinchart
2024-06-06 15:55     ` Tomi Valkeinen
2024-06-07  9:27     ` Julien Massot
2024-06-07  9:01   ` Julien Massot

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=20240430131931.166012-6-julien.massot@collabora.com \
    --to=julien.massot@collabora.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=kernel@collabora.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=sakari.ailus@iki.fi \
    /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®