public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] media: i2c: imx283: Fix hangs seen when switching modes
@ 2026-02-14 13:05 Jai Luthra
  2026-02-14 13:05 ` [PATCH v2 1/2] media: i2c: imx283: Enter full standby when stopping streaming Jai Luthra
  2026-02-14 13:05 ` [PATCH v2 2/2] media: i2c: imx283: Fix hang when going from large to small resolution Jai Luthra
  0 siblings, 2 replies; 5+ messages in thread
From: Jai Luthra @ 2026-02-14 13:05 UTC (permalink / raw)
  To: Sakari Ailus, Kieran Bingham, Umang Jain, Mauro Carvalho Chehab,
	Hans Verkuil
  Cc: linux-media, linux-kernel, Jai Luthra, stable

This series fixes hangs seen on two different platforms (Raspberry Pi 5
and iMX8MP) while streaming with this sensor when switching between
different modes.

Signed-off-by: Jai Luthra <jai.luthra@ideasonboard.com>
---
Changes in v2:
- Add [PATCH 2/2] that fixes hang seen on i.MX8MP when going from lower
  to higher resolution
- Link to v1: https://lore.kernel.org/r/20260212-imx283-hang-fix-v1-1-57784739604c@ideasonboard.com

---
Jai Luthra (2):
      media: i2c: imx283: Enter full standby when stopping streaming
      media: i2c: imx283: Fix hang when going from large to small resolution

 drivers/media/i2c/imx283.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
---
base-commit: f31142b04437da4dafd42a479936d19db53c5ab6
change-id: 20260212-imx283-hang-fix-8b3f45087ef6

Best regards,
-- 
Jai Luthra <jai.luthra@ideasonboard.com>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 1/2] media: i2c: imx283: Enter full standby when stopping streaming
  2026-02-14 13:05 [PATCH v2 0/2] media: i2c: imx283: Fix hangs seen when switching modes Jai Luthra
@ 2026-02-14 13:05 ` Jai Luthra
  2026-02-15 14:33   ` Kieran Bingham
  2026-02-14 13:05 ` [PATCH v2 2/2] media: i2c: imx283: Fix hang when going from large to small resolution Jai Luthra
  1 sibling, 1 reply; 5+ messages in thread
From: Jai Luthra @ 2026-02-14 13:05 UTC (permalink / raw)
  To: Sakari Ailus, Kieran Bingham, Umang Jain, Mauro Carvalho Chehab,
	Hans Verkuil
  Cc: linux-media, linux-kernel, Jai Luthra, stable

Use IMX283_STANDBY (bit 0) instead of IMX283_STBLOGIC (bit 1) when
stopping streaming. STBLOGIC only puts the sensor logic into standby but
leaves the MIPI interface (along with other components) in an
indeterminate state.

This (presumably) causes the CSI receiver (e.g. Raspberry Pi's CFE) to
miss the LP-11 to HS transition when streaming restarts, resulting in a
hang of 10+ seconds. The issue is most visible when immediately
restarting a full-resolution stream after stopping a 3x3 binned one, so
that runtime suspend hasn't yet been triggered.

Writing IMX283_STANDBY puts the entire sensor into standby. The
imx283_standby_cancel() sequence already handles the full wakeup from
this suspended state.

Cc: stable@vger.kernel.org
Link: https://github.com/raspberrypi/linux/issues/7153
Link: https://github.com/will127534/OneInchEye/issues/12
Fixes: ccb4eb4496fa ("media: i2c: Add imx283 camera sensor driver")
Signed-off-by: Jai Luthra <jai.luthra@ideasonboard.com>
---
 drivers/media/i2c/imx283.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/i2c/imx283.c b/drivers/media/i2c/imx283.c
index 8ab63ad8f385f6e2a2d7432feff0af09a5356dc4..9b3094a57873c6e8ff8c41d058ea3b0012642cac 100644
--- a/drivers/media/i2c/imx283.c
+++ b/drivers/media/i2c/imx283.c
@@ -1158,7 +1158,7 @@ static int imx283_disable_streams(struct v4l2_subdev *sd,
 	if (pad != IMAGE_PAD)
 		return -EINVAL;
 
-	ret = cci_write(imx283->cci, IMX283_REG_STANDBY, IMX283_STBLOGIC, NULL);
+	ret = cci_write(imx283->cci, IMX283_REG_STANDBY, IMX283_STANDBY, NULL);
 	if (ret)
 		dev_err(imx283->dev, "Failed to stop stream\n");
 

-- 
2.53.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v2 2/2] media: i2c: imx283: Fix hang when going from large to small resolution
  2026-02-14 13:05 [PATCH v2 0/2] media: i2c: imx283: Fix hangs seen when switching modes Jai Luthra
  2026-02-14 13:05 ` [PATCH v2 1/2] media: i2c: imx283: Enter full standby when stopping streaming Jai Luthra
@ 2026-02-14 13:05 ` Jai Luthra
  2026-02-15 14:36   ` Kieran Bingham
  1 sibling, 1 reply; 5+ messages in thread
From: Jai Luthra @ 2026-02-14 13:05 UTC (permalink / raw)
  To: Sakari Ailus, Kieran Bingham, Umang Jain, Mauro Carvalho Chehab,
	Hans Verkuil
  Cc: linux-media, linux-kernel, Jai Luthra, stable

When switching between modes (e.g. full resolution to binned),
standby_cancel() previously cleared XMSTA (starting master mode data
output) before the new mode's MDSEL, crop, and timing registers were
programmed in start_streaming(). This caused the sensor to briefly
output MIPI data using the previous mode's configuration.

On receivers like imx-mipi-csis, this leads to FIFO overflow errors
when switching from a higher to a lower resolution, as the receiver is
configured for the new smaller frame size but receives stale
full-resolution data.

Fix this by moving the XMSTA and SYNCDRV register writes from
standby_cancel() to the end of start_streaming(), after all mode,
crop, and timing registers have been configured. Also explicitly stop
master mode (XMSTA=1) when stopping the stream, matching the pattern
used by other Sony sensor drivers (imx290, imx415).

Use named macros IMX283_XMSTA_START/STOP instead of raw 0/BIT(0) for
readability.

Cc: stable@vger.kernel.org
Fixes: ccb4eb4496fa ("media: i2c: Add imx283 camera sensor driver")
Signed-off-by: Jai Luthra <jai.luthra@ideasonboard.com>
---
 drivers/media/i2c/imx283.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/media/i2c/imx283.c b/drivers/media/i2c/imx283.c
index 9b3094a57873c6e8ff8c41d058ea3b0012642cac..1be6164c2d15524690b738aa725a6708e84487d0 100644
--- a/drivers/media/i2c/imx283.c
+++ b/drivers/media/i2c/imx283.c
@@ -129,7 +129,8 @@
 
 /* Master Mode Operation Control */
 #define IMX283_REG_XMSTA		CCI_REG8(0x3105)
-#define   IMX283_XMSTA			BIT(0)
+#define   IMX283_XMSTA_START		0
+#define   IMX283_XMSTA_STOP		BIT(0)
 
 #define IMX283_REG_SYNCDRV		CCI_REG8(0x3107)
 #define   IMX283_SYNCDRV_XHS_XVS	(0xa0 | 0x02)
@@ -1023,8 +1024,6 @@ static int imx283_standby_cancel(struct imx283 *imx283)
 	usleep_range(19000, 20000);
 
 	cci_write(imx283->cci, IMX283_REG_CLAMP, IMX283_CLPSQRST, &ret);
-	cci_write(imx283->cci, IMX283_REG_XMSTA, 0, &ret);
-	cci_write(imx283->cci, IMX283_REG_SYNCDRV, IMX283_SYNCDRV_XHS_XVS, &ret);
 
 	return ret;
 }
@@ -1117,6 +1116,10 @@ static int imx283_start_streaming(struct imx283 *imx283,
 	/* Apply customized values from controls (HMAX/VMAX/SHR) */
 	ret =  __v4l2_ctrl_handler_setup(imx283->sd.ctrl_handler);
 
+	/* Start master mode */
+	cci_write(imx283->cci, IMX283_REG_XMSTA, IMX283_XMSTA_START, &ret);
+	cci_write(imx283->cci, IMX283_REG_SYNCDRV, IMX283_SYNCDRV_XHS_XVS, &ret);
+
 	return ret;
 }
 
@@ -1153,12 +1156,14 @@ static int imx283_disable_streams(struct v4l2_subdev *sd,
 				  u64 streams_mask)
 {
 	struct imx283 *imx283 = to_imx283(sd);
-	int ret;
+	int ret = 0;
 
 	if (pad != IMAGE_PAD)
 		return -EINVAL;
 
-	ret = cci_write(imx283->cci, IMX283_REG_STANDBY, IMX283_STANDBY, NULL);
+	cci_write(imx283->cci, IMX283_REG_XMSTA, IMX283_XMSTA_STOP, &ret);
+	cci_write(imx283->cci, IMX283_REG_STANDBY, IMX283_STANDBY, &ret);
+
 	if (ret)
 		dev_err(imx283->dev, "Failed to stop stream\n");
 

-- 
2.53.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 1/2] media: i2c: imx283: Enter full standby when stopping streaming
  2026-02-14 13:05 ` [PATCH v2 1/2] media: i2c: imx283: Enter full standby when stopping streaming Jai Luthra
@ 2026-02-15 14:33   ` Kieran Bingham
  0 siblings, 0 replies; 5+ messages in thread
From: Kieran Bingham @ 2026-02-15 14:33 UTC (permalink / raw)
  To: Hans Verkuil, Jai Luthra, Mauro Carvalho Chehab, Sakari Ailus,
	Umang Jain
  Cc: linux-media, linux-kernel, Jai Luthra, stable

Quoting Jai Luthra (2026-02-14 13:05:21)
> Use IMX283_STANDBY (bit 0) instead of IMX283_STBLOGIC (bit 1) when
> stopping streaming. STBLOGIC only puts the sensor logic into standby but
> leaves the MIPI interface (along with other components) in an
> indeterminate state.
> 
> This (presumably) causes the CSI receiver (e.g. Raspberry Pi's CFE) to
> miss the LP-11 to HS transition when streaming restarts, resulting in a
> hang of 10+ seconds. The issue is most visible when immediately
> restarting a full-resolution stream after stopping a 3x3 binned one, so
> that runtime suspend hasn't yet been triggered.
> 
> Writing IMX283_STANDBY puts the entire sensor into standby. The
> imx283_standby_cancel() sequence already handles the full wakeup from
> this suspended state.
> 
> Cc: stable@vger.kernel.org
> Link: https://github.com/raspberrypi/linux/issues/7153
> Link: https://github.com/will127534/OneInchEye/issues/12
> Fixes: ccb4eb4496fa ("media: i2c: Add imx283 camera sensor driver")
> Signed-off-by: Jai Luthra <jai.luthra@ideasonboard.com>

Thank you for digging into this! Indeed - I think this series fixes all
my current known issues with this module.

Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

> ---
>  drivers/media/i2c/imx283.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/media/i2c/imx283.c b/drivers/media/i2c/imx283.c
> index 8ab63ad8f385f6e2a2d7432feff0af09a5356dc4..9b3094a57873c6e8ff8c41d058ea3b0012642cac 100644
> --- a/drivers/media/i2c/imx283.c
> +++ b/drivers/media/i2c/imx283.c
> @@ -1158,7 +1158,7 @@ static int imx283_disable_streams(struct v4l2_subdev *sd,
>         if (pad != IMAGE_PAD)
>                 return -EINVAL;
>  
> -       ret = cci_write(imx283->cci, IMX283_REG_STANDBY, IMX283_STBLOGIC, NULL);
> +       ret = cci_write(imx283->cci, IMX283_REG_STANDBY, IMX283_STANDBY, NULL);
>         if (ret)
>                 dev_err(imx283->dev, "Failed to stop stream\n");
>  
> 
> -- 
> 2.53.0
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 2/2] media: i2c: imx283: Fix hang when going from large to small resolution
  2026-02-14 13:05 ` [PATCH v2 2/2] media: i2c: imx283: Fix hang when going from large to small resolution Jai Luthra
@ 2026-02-15 14:36   ` Kieran Bingham
  0 siblings, 0 replies; 5+ messages in thread
From: Kieran Bingham @ 2026-02-15 14:36 UTC (permalink / raw)
  To: Hans Verkuil, Jai Luthra, Mauro Carvalho Chehab, Sakari Ailus,
	Umang Jain
  Cc: linux-media, linux-kernel, Jai Luthra, stable

Quoting Jai Luthra (2026-02-14 13:05:22)
> When switching between modes (e.g. full resolution to binned),
> standby_cancel() previously cleared XMSTA (starting master mode data
> output) before the new mode's MDSEL, crop, and timing registers were
> programmed in start_streaming(). This caused the sensor to briefly
> output MIPI data using the previous mode's configuration.
> 
> On receivers like imx-mipi-csis, this leads to FIFO overflow errors
> when switching from a higher to a lower resolution, as the receiver is
> configured for the new smaller frame size but receives stale
> full-resolution data.
> 
> Fix this by moving the XMSTA and SYNCDRV register writes from
> standby_cancel() to the end of start_streaming(), after all mode,
> crop, and timing registers have been configured. Also explicitly stop
> master mode (XMSTA=1) when stopping the stream, matching the pattern
> used by other Sony sensor drivers (imx290, imx415).
> 
> Use named macros IMX283_XMSTA_START/STOP instead of raw 0/BIT(0) for
> readability.

All seems to make sense and explains (and resolves) the issues I've seen
on my i.MX8MP board with this module.

Thanks for digging into all of this.

Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

 
> Cc: stable@vger.kernel.org
> Fixes: ccb4eb4496fa ("media: i2c: Add imx283 camera sensor driver")
> Signed-off-by: Jai Luthra <jai.luthra@ideasonboard.com>
> ---
>  drivers/media/i2c/imx283.c | 15 ++++++++++-----
>  1 file changed, 10 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/media/i2c/imx283.c b/drivers/media/i2c/imx283.c
> index 9b3094a57873c6e8ff8c41d058ea3b0012642cac..1be6164c2d15524690b738aa725a6708e84487d0 100644
> --- a/drivers/media/i2c/imx283.c
> +++ b/drivers/media/i2c/imx283.c
> @@ -129,7 +129,8 @@
>  
>  /* Master Mode Operation Control */
>  #define IMX283_REG_XMSTA               CCI_REG8(0x3105)
> -#define   IMX283_XMSTA                 BIT(0)
> +#define   IMX283_XMSTA_START           0
> +#define   IMX283_XMSTA_STOP            BIT(0)
>  
>  #define IMX283_REG_SYNCDRV             CCI_REG8(0x3107)
>  #define   IMX283_SYNCDRV_XHS_XVS       (0xa0 | 0x02)
> @@ -1023,8 +1024,6 @@ static int imx283_standby_cancel(struct imx283 *imx283)
>         usleep_range(19000, 20000);
>  
>         cci_write(imx283->cci, IMX283_REG_CLAMP, IMX283_CLPSQRST, &ret);
> -       cci_write(imx283->cci, IMX283_REG_XMSTA, 0, &ret);
> -       cci_write(imx283->cci, IMX283_REG_SYNCDRV, IMX283_SYNCDRV_XHS_XVS, &ret);
>  
>         return ret;
>  }
> @@ -1117,6 +1116,10 @@ static int imx283_start_streaming(struct imx283 *imx283,
>         /* Apply customized values from controls (HMAX/VMAX/SHR) */
>         ret =  __v4l2_ctrl_handler_setup(imx283->sd.ctrl_handler);
>  
> +       /* Start master mode */
> +       cci_write(imx283->cci, IMX283_REG_XMSTA, IMX283_XMSTA_START, &ret);
> +       cci_write(imx283->cci, IMX283_REG_SYNCDRV, IMX283_SYNCDRV_XHS_XVS, &ret);
> +
>         return ret;
>  }
>  
> @@ -1153,12 +1156,14 @@ static int imx283_disable_streams(struct v4l2_subdev *sd,
>                                   u64 streams_mask)
>  {
>         struct imx283 *imx283 = to_imx283(sd);
> -       int ret;
> +       int ret = 0;
>  
>         if (pad != IMAGE_PAD)
>                 return -EINVAL;
>  
> -       ret = cci_write(imx283->cci, IMX283_REG_STANDBY, IMX283_STANDBY, NULL);
> +       cci_write(imx283->cci, IMX283_REG_XMSTA, IMX283_XMSTA_STOP, &ret);
> +       cci_write(imx283->cci, IMX283_REG_STANDBY, IMX283_STANDBY, &ret);
> +
>         if (ret)
>                 dev_err(imx283->dev, "Failed to stop stream\n");
>  
> 
> -- 
> 2.53.0
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-02-15 14:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-14 13:05 [PATCH v2 0/2] media: i2c: imx283: Fix hangs seen when switching modes Jai Luthra
2026-02-14 13:05 ` [PATCH v2 1/2] media: i2c: imx283: Enter full standby when stopping streaming Jai Luthra
2026-02-15 14:33   ` Kieran Bingham
2026-02-14 13:05 ` [PATCH v2 2/2] media: i2c: imx283: Fix hang when going from large to small resolution Jai Luthra
2026-02-15 14:36   ` Kieran Bingham

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox