Linux kernel -stable discussions
 help / color / mirror / Atom feed
* [PATCH 0/2] media: amd: isp4: fix stream start failure and deadlock
@ 2026-11-30 22:24 Mateo Amado Ares via B4 Relay
  2026-11-30 22:24 ` [PATCH 1/2] media: amd: isp4: fix self-deadlock in isp4sd_start_stream() error path Mateo Amado Ares via B4 Relay
  2026-11-30 22:24 ` [PATCH 2/2] media: amd: isp4: propagate the capture format to the subdev on stream start Mateo Amado Ares via B4 Relay
  0 siblings, 2 replies; 6+ messages in thread
From: Mateo Amado Ares via B4 Relay @ 2026-11-30 22:24 UTC (permalink / raw)
  To: Bin Du, Nirujogi Pratap, Mauro Carvalho Chehab
  Cc: Sakari Ailus, linux-media, stable, Mateo Amado Ares

On an HP ZBook Ultra G1a (Strix Halo) running 7.3.6, accepting a video
call in Chrome froze the camera until reboot. The hung VIDIOC_STREAMON left
unkillable tasks behind, shutdown could not finish, and the next boot
needed a forced power-off.

Two bugs combined:

- Patch 1: isp4sd_start_stream() calls isp4sd_stop_stream() on its error
  path while already holding ops_mutex, so any stream start failure
  self-deadlocks. Same pattern as the isp4sd_pwron_and_init() fix in
  ef46d80a7015.

- Patch 2: the subdev format is only set by S_FMT and is cleared when a
  stream stops, so a STREAMON without a preceding S_FMT (including a
  STREAMOFF/STREAMON cycle on the same fd) fails with "fail to get out
  prop". This is the failure that hit patch 1's deadlock here.
  The subdev has no device node, so the video node's format is the only
  one userspace can set; patch 2 propagates it on every stream start.
  The alternative, adding .init_state and no longer clearing the format
  in isp4sd_uninit_stream(), is fine with me if you prefer it.

Testing, on the hardware above with the driver rebuilt from v7.3.6
plus these patches:

- A small V4L2 test (S_FMT, REQBUFS, STREAMON, DQBUF, STREAMOFF, then
  STREAMON again without S_FMT) logged the same "fail to get out prop" /
  "fail to setup output" as the original hang. With patch 1 only, the
  second STREAMON returns -EINVAL and the device keeps working. With
  both patches, the second STREAMON streams frames.
- Both patches also build without warnings (W=1, sparse) against
  v7.4-rc4 headers.
- Not tested: an unpatched run of the test, because recovering from the
  hang needs a forced power-off. I can share the test program on request.

I used Claude (an AI assistant) to read the logs and driver source, find
both bugs, and draft the patches, the test and these messages. I
reviewed the changes and ran the tests above myself.

---
Mateo Amado Ares (2):
      media: amd: isp4: fix self-deadlock in isp4sd_start_stream() error path
      media: amd: isp4: propagate the capture format to the subdev on stream start

 drivers/media/platform/amd/isp4/isp4_subdev.c | 15 +++++++++++----
 drivers/media/platform/amd/isp4/isp4_video.c  | 10 ++++++++++
 2 files changed, 21 insertions(+), 4 deletions(-)
---
base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244
change-id: 20261130-isp4-start-stream-deadlock-08e421deb181

Best regards,
--  
Mateo Amado Ares <mateoamadoares@gmail.com>



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

* [PATCH 1/2] media: amd: isp4: fix self-deadlock in isp4sd_start_stream() error path
  2026-11-30 22:24 [PATCH 0/2] media: amd: isp4: fix stream start failure and deadlock Mateo Amado Ares via B4 Relay
@ 2026-11-30 22:24 ` Mateo Amado Ares via B4 Relay
  2026-12-01  3:06   ` Bin Du
  2026-11-30 22:24 ` [PATCH 2/2] media: amd: isp4: propagate the capture format to the subdev on stream start Mateo Amado Ares via B4 Relay
  1 sibling, 1 reply; 6+ messages in thread
From: Mateo Amado Ares via B4 Relay @ 2026-11-30 22:24 UTC (permalink / raw)
  To: Bin Du, Nirujogi Pratap, Mauro Carvalho Chehab
  Cc: Sakari Ailus, linux-media, stable, Mateo Amado Ares

From: Mateo Amado Ares <mateoamadoares@gmail.com>

isp4sd_start_stream() holds ops_mutex via guard(mutex) and, when
isp4sd_init_stream() or isp4sd_setup_output() fails, jumps to
err_stop_stream and calls isp4sd_stop_stream(). That helper takes the
same ops_mutex, re-acquiring a non-recursive mutex already held by the
current thread, so any stream start failure deadlocks in VIDIOC_STREAMON:

  INFO: task ThreadPoolSingl:893936 blocked for more than 245 seconds.
  INFO: task ThreadPoolSingl:893936 is blocked on a mutex likely owned by task ThreadPoolSingl:893936.
   isp4sd_stop_stream.isra.0+0x52/0x200 [amd_isp4_capture]
   isp4sd_enable_streams.cold+0x60/0x2ad [amd_isp4_capture]
   v4l2_subdev_enable_streams+0x27f/0x400 [videodev]
   call_s_stream+0x48/0x110 [videodev]
   isp4vid_qops_start_streaming+0x114/0x190 [amd_isp4_capture]
   vb2_start_streaming+0x67/0x130 [videobuf2_common]
   vb2_core_streamon+0x98/0xf0 [videobuf2_common]

The task is unkillable, every later open of the video node blocks on the
same mutex, and the camera is unusable until reboot.

Move the body of isp4sd_stop_stream() into __isp4sd_stop_stream(), which
expects ops_mutex to be held, and call it from the error path.
isp4sd_stop_stream() keeps taking the lock for the disable_streams path.

This is the same bug as the one fixed in isp4sd_pwron_and_init() by
commit ef46d80a7015 ("media: amd: isp4: fix self-deadlock in
isp4sd_pwron_and_init() error path").

Fixes: 4e5e7a7ddb4a ("media: platform: amd: isp4 subdev and firmware loading handling added")
Cc: stable@vger.kernel.org
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Mateo Amado Ares <mateoamadoares@gmail.com>
---
 drivers/media/platform/amd/isp4/isp4_subdev.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/media/platform/amd/isp4/isp4_subdev.c b/drivers/media/platform/amd/isp4/isp4_subdev.c
index a108d90..08512f0 100644
--- a/drivers/media/platform/amd/isp4/isp4_subdev.c
+++ b/drivers/media/platform/amd/isp4/isp4_subdev.c
@@ -745,15 +745,15 @@ err_module_disable:
 	return -EINVAL;
 }
 
-static int isp4sd_stop_stream(struct isp4_subdev *isp_subdev,
-			      struct v4l2_subdev_state *state, u32 pad)
+static void __isp4sd_stop_stream(struct isp4_subdev *isp_subdev,
+				 struct v4l2_subdev_state *state, u32 pad)
 {
 	struct isp4sd_sensor_info *sensor_info = &isp_subdev->sensor_info;
 	struct isp4sd_output_info *output_info = &sensor_info->output_info;
 	struct isp4_interface *ispif = &isp_subdev->ispif;
 	struct device *dev = isp_subdev->dev;
 
-	guard(mutex)(&isp_subdev->ops_mutex);
+	lockdep_assert_held(&isp_subdev->ops_mutex);
 	dev_dbg(dev, "status %i\n", output_info->start_status);
 
 	if (output_info->start_status == ISP4SD_START_STATUS_STARTED) {
@@ -786,6 +786,13 @@ static int isp4sd_stop_stream(struct isp4_subdev *isp_subdev,
 	}
 
 	isp4sd_uninit_stream(isp_subdev, state, pad);
+}
+
+static int isp4sd_stop_stream(struct isp4_subdev *isp_subdev,
+			      struct v4l2_subdev_state *state, u32 pad)
+{
+	guard(mutex)(&isp_subdev->ops_mutex);
+	__isp4sd_stop_stream(isp_subdev, state, pad);
 
 	/*
 	 * Return success to ensure the stop process proceeds,
@@ -836,7 +843,7 @@ static int isp4sd_start_stream(struct isp4_subdev *isp_subdev,
 	return 0;
 
 err_stop_stream:
-	isp4sd_stop_stream(isp_subdev, state, pad);
+	__isp4sd_stop_stream(isp_subdev, state, pad);
 	return ret;
 }
 

-- 
2.56.1



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

* [PATCH 2/2] media: amd: isp4: propagate the capture format to the subdev on stream start
  2026-11-30 22:24 [PATCH 0/2] media: amd: isp4: fix stream start failure and deadlock Mateo Amado Ares via B4 Relay
  2026-11-30 22:24 ` [PATCH 1/2] media: amd: isp4: fix self-deadlock in isp4sd_start_stream() error path Mateo Amado Ares via B4 Relay
@ 2026-11-30 22:24 ` Mateo Amado Ares via B4 Relay
  2026-12-01  3:47   ` Bin Du
  1 sibling, 1 reply; 6+ messages in thread
From: Mateo Amado Ares via B4 Relay @ 2026-11-30 22:24 UTC (permalink / raw)
  To: Bin Du, Nirujogi Pratap, Mauro Carvalho Chehab
  Cc: Sakari Ailus, linux-media, stable, Mateo Amado Ares

From: Mateo Amado Ares <mateoamadoares@gmail.com>

The subdev pad format is only set from VIDIOC_S_FMT on the video node,
there is no init_state, and isp4sd_uninit_stream() clears it whenever a
stream stops. Any STREAMON not directly preceded by S_FMT, either the
first one with the default format or a STREAMOFF/STREAMON cycle on the
same file handle, therefore reaches isp4sd_setup_output() with a 0x0
format and fails:

  amd_isp_capture amd_isp_capture: fail to get out prop
  amd_isp_capture amd_isp_capture: fail to setup output

Both sequences are valid V4L2 usage. This failure is what triggered the
isp4sd_start_stream() error path deadlock during a browser video call.

Set the video node's current format on the subdev in
isp4vid_qops_start_streaming() before powering up, so the subdev always
streams with the format the video node reports.

Fixes: 2ccf48af2270 ("media: platform: amd: isp4 video node and buffers handling added")
Cc: stable@vger.kernel.org
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Mateo Amado Ares <mateoamadoares@gmail.com>
---
 drivers/media/platform/amd/isp4/isp4_video.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/media/platform/amd/isp4/isp4_video.c b/drivers/media/platform/amd/isp4/isp4_video.c
index 856a2a0..85ee9d5 100644
--- a/drivers/media/platform/amd/isp4/isp4_video.c
+++ b/drivers/media/platform/amd/isp4/isp4_video.c
@@ -540,6 +540,16 @@ static int isp4vid_qops_start_streaming(struct vb2_queue *vq,
 
 	isp_vdev->sequence = 0;
 
+	/*
+	 * The subdev format is only set by VIDIOC_S_FMT and is cleared when a
+	 * stream stops, so propagate the current format on every start.
+	 */
+	ret = isp4vid_set_fmt_2_isp(isp_vdev->isp_sdev, &isp_vdev->format);
+	if (ret) {
+		dev_err(isp_vdev->dev, "fail to set isp format %d\n", ret);
+		goto release_buffers;
+	}
+
 	ret = isp4sd_pwron_and_init(isp_vdev->isp_sdev);
 	if (ret) {
 		dev_err(isp_vdev->dev, "power up isp fail %d\n", ret);

-- 
2.56.1



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

* Re: [PATCH 1/2] media: amd: isp4: fix self-deadlock in isp4sd_start_stream() error path
  2026-11-30 22:24 ` [PATCH 1/2] media: amd: isp4: fix self-deadlock in isp4sd_start_stream() error path Mateo Amado Ares via B4 Relay
@ 2026-12-01  3:06   ` Bin Du
  2026-12-01  3:34     ` Mario Limonciello
  0 siblings, 1 reply; 6+ messages in thread
From: Bin Du @ 2026-12-01  3:06 UTC (permalink / raw)
  To: mateoamadoares, Nirujogi Pratap, Mauro Carvalho Chehab
  Cc: Sakari Ailus, linux-media, stable, Li, King,
	Chan, Benjamin (Koon Pan), Limonciello, Mario,
	devnull+caspar.adriani.proton.me

Hi Mateo,

Thanks for investigating and testing this.

Caspar Adriani submitted the same fix on October 28:
https://lore.kernel.org/all/20261028-isp4-start-stream-deadlock-v1-1-babd80273148@proton.me/

Regards,
Bin

On 12/1/2026 6:24 AM, Mateo Amado Ares via B4 Relay wrote:
> [You don't often get email from devnull+mateoamadoares.gmail.com@kernel.org. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
> 
> From: Mateo Amado Ares <mateoamadoares@gmail.com>
> 
> isp4sd_start_stream() holds ops_mutex via guard(mutex) and, when
> isp4sd_init_stream() or isp4sd_setup_output() fails, jumps to
> err_stop_stream and calls isp4sd_stop_stream(). That helper takes the
> same ops_mutex, re-acquiring a non-recursive mutex already held by the
> current thread, so any stream start failure deadlocks in VIDIOC_STREAMON:
> 
>   INFO: task ThreadPoolSingl:893936 blocked for more than 245 seconds.
>   INFO: task ThreadPoolSingl:893936 is blocked on a mutex likely owned by task ThreadPoolSingl:893936.
>    isp4sd_stop_stream.isra.0+0x52/0x200 [amd_isp4_capture]
>    isp4sd_enable_streams.cold+0x60/0x2ad [amd_isp4_capture]
>    v4l2_subdev_enable_streams+0x27f/0x400 [videodev]
>    call_s_stream+0x48/0x110 [videodev]
>    isp4vid_qops_start_streaming+0x114/0x190 [amd_isp4_capture]
>    vb2_start_streaming+0x67/0x130 [videobuf2_common]
>    vb2_core_streamon+0x98/0xf0 [videobuf2_common]
> 
> The task is unkillable, every later open of the video node blocks on the
> same mutex, and the camera is unusable until reboot.
> 
> Move the body of isp4sd_stop_stream() into __isp4sd_stop_stream(), which
> expects ops_mutex to be held, and call it from the error path.
> isp4sd_stop_stream() keeps taking the lock for the disable_streams path.
> 
> This is the same bug as the one fixed in isp4sd_pwron_and_init() by
> commit ef46d80a7015 ("media: amd: isp4: fix self-deadlock in
> isp4sd_pwron_and_init() error path").
> 
> Fixes: 4e5e7a7ddb4a ("media: platform: amd: isp4 subdev and firmware loading handling added")
> Cc: stable@vger.kernel.org
> Assisted-by: Claude:claude-opus-5-5
> Signed-off-by: Mateo Amado Ares <mateoamadoares@gmail.com>
> ---
>  drivers/media/platform/amd/isp4/isp4_subdev.c | 15 +++++++++++----
>  1 file changed, 11 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/media/platform/amd/isp4/isp4_subdev.c b/drivers/media/platform/amd/isp4/isp4_subdev.c
> index a108d90..08512f0 100644
> --- a/drivers/media/platform/amd/isp4/isp4_subdev.c
> +++ b/drivers/media/platform/amd/isp4/isp4_subdev.c
> @@ -745,15 +745,15 @@ err_module_disable:
>         return -EINVAL;
>  }
> 
> -static int isp4sd_stop_stream(struct isp4_subdev *isp_subdev,
> -                             struct v4l2_subdev_state *state, u32 pad)
> +static void __isp4sd_stop_stream(struct isp4_subdev *isp_subdev,
> +                                struct v4l2_subdev_state *state, u32 pad)
>  {
>         struct isp4sd_sensor_info *sensor_info = &isp_subdev->sensor_info;
>         struct isp4sd_output_info *output_info = &sensor_info->output_info;
>         struct isp4_interface *ispif = &isp_subdev->ispif;
>         struct device *dev = isp_subdev->dev;
> 
> -       guard(mutex)(&isp_subdev->ops_mutex);
> +       lockdep_assert_held(&isp_subdev->ops_mutex);
>         dev_dbg(dev, "status %i\n", output_info->start_status);
> 
>         if (output_info->start_status == ISP4SD_START_STATUS_STARTED) {
> @@ -786,6 +786,13 @@ static int isp4sd_stop_stream(struct isp4_subdev *isp_subdev,
>         }
> 
>         isp4sd_uninit_stream(isp_subdev, state, pad);
> +}
> +
> +static int isp4sd_stop_stream(struct isp4_subdev *isp_subdev,
> +                             struct v4l2_subdev_state *state, u32 pad)
> +{
> +       guard(mutex)(&isp_subdev->ops_mutex);
> +       __isp4sd_stop_stream(isp_subdev, state, pad);
> 
>         /*
>          * Return success to ensure the stop process proceeds,
> @@ -836,7 +843,7 @@ static int isp4sd_start_stream(struct isp4_subdev *isp_subdev,
>         return 0;
> 
>  err_stop_stream:
> -       isp4sd_stop_stream(isp_subdev, state, pad);
> +       __isp4sd_stop_stream(isp_subdev, state, pad);
>         return ret;
>  }
> 
> 
> --
> 2.56.1
> 


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

* Re: [PATCH 1/2] media: amd: isp4: fix self-deadlock in isp4sd_start_stream() error path
  2026-12-01  3:06   ` Bin Du
@ 2026-12-01  3:34     ` Mario Limonciello
  0 siblings, 0 replies; 6+ messages in thread
From: Mario Limonciello @ 2026-12-01  3:34 UTC (permalink / raw)
  To: Bin Du, mateoamadoares, Nirujogi Pratap, Mauro Carvalho Chehab
  Cc: Sakari Ailus, linux-media, stable, Li, King,
	Chan, Benjamin (Koon Pan), devnull+caspar.adriani.proton.me



On 11/30/26 21:06, Bin Du wrote:
> Hi Mateo,
> 
> Thanks for investigating and testing this.
> 
> Caspar Adriani submitted the same fix on October 28:
> https://lore.kernel.org/all/20261028-isp4-start-stream-deadlock-v1-1-babd80273148@proton.me/
> 

What's the hold up on merging that?  It seems it's got tags up the wazoo 
and has been just sitting around.

> Regards,
> Bin
> 
> On 12/1/2026 6:24 AM, Mateo Amado Ares via B4 Relay wrote:
>> [You don't often get email from devnull+mateoamadoares.gmail.com@kernel.org. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>>
>> From: Mateo Amado Ares <mateoamadoares@gmail.com>
>>
>> isp4sd_start_stream() holds ops_mutex via guard(mutex) and, when
>> isp4sd_init_stream() or isp4sd_setup_output() fails, jumps to
>> err_stop_stream and calls isp4sd_stop_stream(). That helper takes the
>> same ops_mutex, re-acquiring a non-recursive mutex already held by the
>> current thread, so any stream start failure deadlocks in VIDIOC_STREAMON:
>>
>>    INFO: task ThreadPoolSingl:893936 blocked for more than 245 seconds.
>>    INFO: task ThreadPoolSingl:893936 is blocked on a mutex likely owned by task ThreadPoolSingl:893936.
>>     isp4sd_stop_stream.isra.0+0x52/0x200 [amd_isp4_capture]
>>     isp4sd_enable_streams.cold+0x60/0x2ad [amd_isp4_capture]
>>     v4l2_subdev_enable_streams+0x27f/0x400 [videodev]
>>     call_s_stream+0x48/0x110 [videodev]
>>     isp4vid_qops_start_streaming+0x114/0x190 [amd_isp4_capture]
>>     vb2_start_streaming+0x67/0x130 [videobuf2_common]
>>     vb2_core_streamon+0x98/0xf0 [videobuf2_common]
>>
>> The task is unkillable, every later open of the video node blocks on the
>> same mutex, and the camera is unusable until reboot.
>>
>> Move the body of isp4sd_stop_stream() into __isp4sd_stop_stream(), which
>> expects ops_mutex to be held, and call it from the error path.
>> isp4sd_stop_stream() keeps taking the lock for the disable_streams path.
>>
>> This is the same bug as the one fixed in isp4sd_pwron_and_init() by
>> commit ef46d80a7015 ("media: amd: isp4: fix self-deadlock in
>> isp4sd_pwron_and_init() error path").
>>
>> Fixes: 4e5e7a7ddb4a ("media: platform: amd: isp4 subdev and firmware loading handling added")
>> Cc: stable@vger.kernel.org
>> Assisted-by: Claude:claude-opus-5-5
>> Signed-off-by: Mateo Amado Ares <mateoamadoares@gmail.com>
>> ---
>>   drivers/media/platform/amd/isp4/isp4_subdev.c | 15 +++++++++++----
>>   1 file changed, 11 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/media/platform/amd/isp4/isp4_subdev.c b/drivers/media/platform/amd/isp4/isp4_subdev.c
>> index a108d90..08512f0 100644
>> --- a/drivers/media/platform/amd/isp4/isp4_subdev.c
>> +++ b/drivers/media/platform/amd/isp4/isp4_subdev.c
>> @@ -745,15 +745,15 @@ err_module_disable:
>>          return -EINVAL;
>>   }
>>
>> -static int isp4sd_stop_stream(struct isp4_subdev *isp_subdev,
>> -                             struct v4l2_subdev_state *state, u32 pad)
>> +static void __isp4sd_stop_stream(struct isp4_subdev *isp_subdev,
>> +                                struct v4l2_subdev_state *state, u32 pad)
>>   {
>>          struct isp4sd_sensor_info *sensor_info = &isp_subdev->sensor_info;
>>          struct isp4sd_output_info *output_info = &sensor_info->output_info;
>>          struct isp4_interface *ispif = &isp_subdev->ispif;
>>          struct device *dev = isp_subdev->dev;
>>
>> -       guard(mutex)(&isp_subdev->ops_mutex);
>> +       lockdep_assert_held(&isp_subdev->ops_mutex);
>>          dev_dbg(dev, "status %i\n", output_info->start_status);
>>
>>          if (output_info->start_status == ISP4SD_START_STATUS_STARTED) {
>> @@ -786,6 +786,13 @@ static int isp4sd_stop_stream(struct isp4_subdev *isp_subdev,
>>          }
>>
>>          isp4sd_uninit_stream(isp_subdev, state, pad);
>> +}
>> +
>> +static int isp4sd_stop_stream(struct isp4_subdev *isp_subdev,
>> +                             struct v4l2_subdev_state *state, u32 pad)
>> +{
>> +       guard(mutex)(&isp_subdev->ops_mutex);
>> +       __isp4sd_stop_stream(isp_subdev, state, pad);
>>
>>          /*
>>           * Return success to ensure the stop process proceeds,
>> @@ -836,7 +843,7 @@ static int isp4sd_start_stream(struct isp4_subdev *isp_subdev,
>>          return 0;
>>
>>   err_stop_stream:
>> -       isp4sd_stop_stream(isp_subdev, state, pad);
>> +       __isp4sd_stop_stream(isp_subdev, state, pad);
>>          return ret;
>>   }
>>
>>
>> --
>> 2.56.1
>>
> 


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

* Re: [PATCH 2/2] media: amd: isp4: propagate the capture format to the subdev on stream start
  2026-11-30 22:24 ` [PATCH 2/2] media: amd: isp4: propagate the capture format to the subdev on stream start Mateo Amado Ares via B4 Relay
@ 2026-12-01  3:47   ` Bin Du
  0 siblings, 0 replies; 6+ messages in thread
From: Bin Du @ 2026-12-01  3:47 UTC (permalink / raw)
  To: mateoamadoares, Nirujogi Pratap, Mauro Carvalho Chehab
  Cc: Sakari Ailus, linux-media, stable, Li, King,
	Chan, Benjamin (Koon Pan), Limonciello, Mario,
	sultan@kerneltoast.com

Hi Mateo,

Thanks for the fix.

On 12/1/2026 6:24 AM, Mateo Amado Ares via B4 Relay wrote:
> 
> From: Mateo Amado Ares <mateoamadoares@gmail.com>
> 
> The subdev pad format is only set from VIDIOC_S_FMT on the video node,
> there is no init_state, and isp4sd_uninit_stream() clears it whenever a
> stream stops. Any STREAMON not directly preceded by S_FMT, either the
> first one with the default format or a STREAMOFF/STREAMON cycle on the
> same file handle, therefore reaches isp4sd_setup_output() with a 0x0
> format and fails:
> 
>   amd_isp_capture amd_isp_capture: fail to get out prop
>   amd_isp_capture amd_isp_capture: fail to setup output
> 
> Both sequences are valid V4L2 usage. This failure is what triggered the
> isp4sd_start_stream() error path deadlock during a browser video call.
> 
> Set the video node's current format on the subdev in
> isp4vid_qops_start_streaming() before powering up, so the subdev always
> streams with the format the video node reports.
> 
> Fixes: 2ccf48af2270 ("media: platform: amd: isp4 video node and buffers handling added")
> Cc: stable@vger.kernel.org
> Assisted-by: Claude:claude-opus-5-5
> Signed-off-by: Mateo Amado Ares <mateoamadoares@gmail.com>
> ---
>  drivers/media/platform/amd/isp4/isp4_video.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/media/platform/amd/isp4/isp4_video.c b/drivers/media/platform/amd/isp4/isp4_video.c
> index 856a2a0..85ee9d5 100644
> --- a/drivers/media/platform/amd/isp4/isp4_video.c
> +++ b/drivers/media/platform/amd/isp4/isp4_video.c
> @@ -540,6 +540,16 @@ static int isp4vid_qops_start_streaming(struct vb2_queue *vq,
> 
>         isp_vdev->sequence = 0;
> 
> +       /*
> +        * The subdev format is only set by VIDIOC_S_FMT and is cleared when a
> +        * stream stops, so propagate the current format on every start.
> +        */
> +       ret = isp4vid_set_fmt_2_isp(isp_vdev->isp_sdev, &isp_vdev->format);
> +       if (ret) {
> +               dev_err(isp_vdev->dev, "fail to set isp format %d\n", ret);
> +               goto release_buffers;
> +       }
> +

Would you consider preserving the format in
isp4sd_uninit_stream() instead of restoring it on every stream start?

The default format is already initialized in isp4vid_dev_init(),
and S_FMT updates it. Preserving it across stream stop would avoid
the additional format-setting call on each start.

Sultan previously suggested this approach, noting that “the subdev
format shouldn't be cleared when streaming stops”:
https://lore.kernel.org/all/auJEaXevXj6hNTsK@sultan-box/

>         ret = isp4sd_pwron_and_init(isp_vdev->isp_sdev);
>         if (ret) {
>                 dev_err(isp_vdev->dev, "power up isp fail %d\n", ret);
> 
> --
> 2.56.1

Regards,
Bin


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

end of thread, other threads:[~2026-12-01  3:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30 22:24 [PATCH 0/2] media: amd: isp4: fix stream start failure and deadlock Mateo Amado Ares via B4 Relay
2026-11-30 22:24 ` [PATCH 1/2] media: amd: isp4: fix self-deadlock in isp4sd_start_stream() error path Mateo Amado Ares via B4 Relay
2026-12-01  3:06   ` Bin Du
2026-12-01  3:34     ` Mario Limonciello
2026-11-30 22:24 ` [PATCH 2/2] media: amd: isp4: propagate the capture format to the subdev on stream start Mateo Amado Ares via B4 Relay
2026-12-01  3:47   ` Bin Du

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