Linux Media Controller development
 help / color / mirror / Atom feed
* [PATCH] media: mali-c55: Serialise the ISP enable in the params and stats paths
@ 2026-11-14 16:49 David Carlier
  2026-11-23  8:30 ` Linus Walleij
  2026-11-24  8:34 ` Jacopo Mondi
  0 siblings, 2 replies; 3+ messages in thread
From: David Carlier @ 2026-11-14 16:49 UTC (permalink / raw)
  To: linux-media, Daniel Scally, Jacopo Mondi
  Cc: Nayden Kanchev, Mauro Carvalho Chehab, Hans Verkuil,
	Linus Walleij, linux-kernel, David Carlier, stable

Only the capture devices hold isp->capture_lock around the
mali_c55_pipeline_ready() check and the ISP enable or disable. When the
last two queues to start are on different video devices, both can see
a ready pipeline and both enable the ISP. The second call fails with
-EALREADY and its queue's start_streaming_called flag is cleared, so
the ISP is never disabled again and every later start fails.

Take capture_lock in the params and stats paths too.

Fixes: d5f281f3dd29 ("media: mali-c55: Add Mali-C55 ISP driver")
Cc: stable@vger.kernel.org
Signed-off-by: David Carlier <devnexen@gmail.com>
---
 drivers/media/platform/arm/mali-c55/mali-c55-params.c | 4 ++++
 drivers/media/platform/arm/mali-c55/mali-c55-stats.c  | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/drivers/media/platform/arm/mali-c55/mali-c55-params.c b/drivers/media/platform/arm/mali-c55/mali-c55-params.c
index 16e895e3488e..6515c78c1bb2 100644
--- a/drivers/media/platform/arm/mali-c55/mali-c55-params.c
+++ b/drivers/media/platform/arm/mali-c55/mali-c55-params.c
@@ -762,6 +762,8 @@ static int mali_c55_params_start_streaming(struct vb2_queue *q,
 	struct mali_c55 *mali_c55 = params->mali_c55;
 	int ret;
 
+	guard(mutex)(&mali_c55->isp.capture_lock);
+
 	ret = pm_runtime_resume_and_get(mali_c55->dev);
 	if (ret)
 		goto err_return_buffers;
@@ -796,6 +798,8 @@ static void mali_c55_params_stop_streaming(struct vb2_queue *q)
 	struct mali_c55 *mali_c55 = params->mali_c55;
 	struct mali_c55_isp *isp = &mali_c55->isp;
 
+	guard(mutex)(&isp->capture_lock);
+
 	if (mali_c55_pipeline_ready(mali_c55)) {
 		if (v4l2_subdev_is_streaming(&isp->sd))
 			v4l2_subdev_disable_streams(&isp->sd,
diff --git a/drivers/media/platform/arm/mali-c55/mali-c55-stats.c b/drivers/media/platform/arm/mali-c55/mali-c55-stats.c
index a9c28b090b2a..cbd2a2f77da3 100644
--- a/drivers/media/platform/arm/mali-c55/mali-c55-stats.c
+++ b/drivers/media/platform/arm/mali-c55/mali-c55-stats.c
@@ -146,6 +146,8 @@ static int mali_c55_stats_start_streaming(struct vb2_queue *q,
 	struct mali_c55 *mali_c55 = stats->mali_c55;
 	int ret;
 
+	guard(mutex)(&mali_c55->isp.capture_lock);
+
 	ret = pm_runtime_resume_and_get(mali_c55->dev);
 	if (ret)
 		goto err_return_buffers;
@@ -180,6 +182,8 @@ static void mali_c55_stats_stop_streaming(struct vb2_queue *q)
 	struct mali_c55 *mali_c55 = stats->mali_c55;
 	struct mali_c55_isp *isp = &mali_c55->isp;
 
+	guard(mutex)(&isp->capture_lock);
+
 	if (mali_c55_pipeline_ready(mali_c55)) {
 		if (v4l2_subdev_is_streaming(&isp->sd))
 			v4l2_subdev_disable_streams(&isp->sd,
-- 
2.55.0


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

* Re: [PATCH] media: mali-c55: Serialise the ISP enable in the params and stats paths
  2026-11-14 16:49 [PATCH] media: mali-c55: Serialise the ISP enable in the params and stats paths David Carlier
@ 2026-11-23  8:30 ` Linus Walleij
  2026-11-24  8:34 ` Jacopo Mondi
  1 sibling, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2026-11-23  8:30 UTC (permalink / raw)
  To: David Carlier
  Cc: linux-media, Daniel Scally, Jacopo Mondi, Nayden Kanchev,
	Mauro Carvalho Chehab, Hans Verkuil, linux-kernel, stable

On Sat, Nov 14, 2026 at 5:49 PM David Carlier <devnexen@gmail.com> wrote:

> Only the capture devices hold isp->capture_lock around the
> mali_c55_pipeline_ready() check and the ISP enable or disable. When the
> last two queues to start are on different video devices, both can see
> a ready pipeline and both enable the ISP. The second call fails with
> -EALREADY and its queue's start_streaming_called flag is cleared, so
> the ISP is never disabled again and every later start fails.
>
> Take capture_lock in the params and stats paths too.
>
> Fixes: d5f281f3dd29 ("media: mali-c55: Add Mali-C55 ISP driver")
> Cc: stable@vger.kernel.org
> Signed-off-by: David Carlier <devnexen@gmail.com>

This looks reasonable, have you tested the patch on hardware?
FWIW:
Reviewed-by: Linus Walleij <linusw@kernel.org>

Yours,
Linus Walleij

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

* Re: [PATCH] media: mali-c55: Serialise the ISP enable in the params and stats paths
  2026-11-14 16:49 [PATCH] media: mali-c55: Serialise the ISP enable in the params and stats paths David Carlier
  2026-11-23  8:30 ` Linus Walleij
@ 2026-11-24  8:34 ` Jacopo Mondi
  1 sibling, 0 replies; 3+ messages in thread
From: Jacopo Mondi @ 2026-11-24  8:34 UTC (permalink / raw)
  To: David Carlier
  Cc: linux-media, Daniel Scally, Jacopo Mondi, Nayden Kanchev,
	Mauro Carvalho Chehab, Hans Verkuil, Linus Walleij, linux-kernel,
	stable

Hi David

On Sat, Nov 14, 2026 at 04:49:33PM +0000, David Carlier wrote:
> Only the capture devices hold isp->capture_lock around the
> mali_c55_pipeline_ready() check and the ISP enable or disable. When the
> last two queues to start are on different video devices, both can see
> a ready pipeline and both enable the ISP. The second call fails with
> -EALREADY and its queue's start_streaming_called flag is cleared, so
> the ISP is never disabled again and every later start fails.
>
> Take capture_lock in the params and stats paths too.

Should we then:

        lockdep_assert_held(&mali_c55->isp.capture_lock);

in mali_c55_pipeline_ready() ?

>
> Fixes: d5f281f3dd29 ("media: mali-c55: Add Mali-C55 ISP driver")
> Cc: stable@vger.kernel.org
> Signed-off-by: David Carlier <devnexen@gmail.com>
> ---
>  drivers/media/platform/arm/mali-c55/mali-c55-params.c | 4 ++++
>  drivers/media/platform/arm/mali-c55/mali-c55-stats.c  | 4 ++++
>  2 files changed, 8 insertions(+)
>
> diff --git a/drivers/media/platform/arm/mali-c55/mali-c55-params.c b/drivers/media/platform/arm/mali-c55/mali-c55-params.c
> index 16e895e3488e..6515c78c1bb2 100644
> --- a/drivers/media/platform/arm/mali-c55/mali-c55-params.c
> +++ b/drivers/media/platform/arm/mali-c55/mali-c55-params.c
> @@ -762,6 +762,8 @@ static int mali_c55_params_start_streaming(struct vb2_queue *q,
>  	struct mali_c55 *mali_c55 = params->mali_c55;
>  	int ret;
>
> +	guard(mutex)(&mali_c55->isp.capture_lock);
> +
>  	ret = pm_runtime_resume_and_get(mali_c55->dev);
>  	if (ret)
>  		goto err_return_buffers;
> @@ -796,6 +798,8 @@ static void mali_c55_params_stop_streaming(struct vb2_queue *q)
>  	struct mali_c55 *mali_c55 = params->mali_c55;
>  	struct mali_c55_isp *isp = &mali_c55->isp;
>
> +	guard(mutex)(&isp->capture_lock);
> +
>  	if (mali_c55_pipeline_ready(mali_c55)) {
>  		if (v4l2_subdev_is_streaming(&isp->sd))
>  			v4l2_subdev_disable_streams(&isp->sd,
> diff --git a/drivers/media/platform/arm/mali-c55/mali-c55-stats.c b/drivers/media/platform/arm/mali-c55/mali-c55-stats.c
> index a9c28b090b2a..cbd2a2f77da3 100644
> --- a/drivers/media/platform/arm/mali-c55/mali-c55-stats.c
> +++ b/drivers/media/platform/arm/mali-c55/mali-c55-stats.c
> @@ -146,6 +146,8 @@ static int mali_c55_stats_start_streaming(struct vb2_queue *q,
>  	struct mali_c55 *mali_c55 = stats->mali_c55;
>  	int ret;
>
> +	guard(mutex)(&mali_c55->isp.capture_lock);
> +
>  	ret = pm_runtime_resume_and_get(mali_c55->dev);
>  	if (ret)
>  		goto err_return_buffers;
> @@ -180,6 +182,8 @@ static void mali_c55_stats_stop_streaming(struct vb2_queue *q)
>  	struct mali_c55 *mali_c55 = stats->mali_c55;
>  	struct mali_c55_isp *isp = &mali_c55->isp;
>
> +	guard(mutex)(&isp->capture_lock);
> +
>  	if (mali_c55_pipeline_ready(mali_c55)) {
>  		if (v4l2_subdev_is_streaming(&isp->sd))
>  			v4l2_subdev_disable_streams(&isp->sd,
> --
> 2.55.0
>

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

end of thread, other threads:[~2026-11-24  8:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-14 16:49 [PATCH] media: mali-c55: Serialise the ISP enable in the params and stats paths David Carlier
2026-11-23  8:30 ` Linus Walleij
2026-11-24  8:34 ` Jacopo Mondi

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