diff mbox series

[2/3] media: imx: imx7_mipi_csis: Don't take state->lock in .link_setup()

Message ID 20210319011735.26846-3-laurent.pinchart@ideasonboard.com (mailing list archive)
State New
Headers show
Series staging: media: imx: imx7_mipi_csis: miscellaneous fixes | expand

Commit Message

Laurent Pinchart March 19, 2021, 1:17 a.m. UTC
The .link_setup() handler uses state->lock to protect the src_sd field.
This is only used in mipi_csis_s_stream(), which can't race
.link_setup() as the MC core prevents link setup when the pipeline is
streaming. Drop the lock.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/staging/media/imx/imx7-mipi-csis.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

Comments

Rui Miguel Silva March 19, 2021, 10:27 a.m. UTC | #1
Hi Laurent,
On Fri, Mar 19, 2021 at 03:17:34AM +0200, Laurent Pinchart wrote:
> The .link_setup() handler uses state->lock to protect the src_sd field.
> This is only used in mipi_csis_s_stream(), which can't race
> .link_setup() as the MC core prevents link setup when the pipeline is
> streaming. Drop the lock.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com>

------
Cheers,
     Rui
> ---
>  drivers/staging/media/imx/imx7-mipi-csis.c | 13 +++----------
>  1 file changed, 3 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/staging/media/imx/imx7-mipi-csis.c b/drivers/staging/media/imx/imx7-mipi-csis.c
> index c6cd60896969..21774f3e66e0 100644
> --- a/drivers/staging/media/imx/imx7-mipi-csis.c
> +++ b/drivers/staging/media/imx/imx7-mipi-csis.c
> @@ -749,7 +749,6 @@ static int mipi_csis_link_setup(struct media_entity *entity,
>  	struct v4l2_subdev *mipi_sd = media_entity_to_v4l2_subdev(entity);
>  	struct csi_state *state = mipi_sd_to_csis_state(mipi_sd);
>  	struct v4l2_subdev *remote_sd;
> -	int ret = 0;
>  
>  	dev_dbg(state->dev, "link setup %s -> %s", remote_pad->entity->name,
>  		local_pad->entity->name);
> @@ -760,22 +759,16 @@ static int mipi_csis_link_setup(struct media_entity *entity,
>  
>  	remote_sd = media_entity_to_v4l2_subdev(remote_pad->entity);
>  
> -	mutex_lock(&state->lock);
> -
>  	if (flags & MEDIA_LNK_FL_ENABLED) {
> -		if (state->src_sd) {
> -			ret = -EBUSY;
> -			goto out;
> -		}
> +		if (state->src_sd)
> +			return -EBUSY;
>  
>  		state->src_sd = remote_sd;
>  	} else {
>  		state->src_sd = NULL;
>  	}
>  
> -out:
> -	mutex_unlock(&state->lock);
> -	return ret;
> +	return 0;
>  }
>  
>  static struct v4l2_mbus_framefmt *
> -- 
> Regards,
> 
> Laurent Pinchart
>
diff mbox series

Patch

diff --git a/drivers/staging/media/imx/imx7-mipi-csis.c b/drivers/staging/media/imx/imx7-mipi-csis.c
index c6cd60896969..21774f3e66e0 100644
--- a/drivers/staging/media/imx/imx7-mipi-csis.c
+++ b/drivers/staging/media/imx/imx7-mipi-csis.c
@@ -749,7 +749,6 @@  static int mipi_csis_link_setup(struct media_entity *entity,
 	struct v4l2_subdev *mipi_sd = media_entity_to_v4l2_subdev(entity);
 	struct csi_state *state = mipi_sd_to_csis_state(mipi_sd);
 	struct v4l2_subdev *remote_sd;
-	int ret = 0;
 
 	dev_dbg(state->dev, "link setup %s -> %s", remote_pad->entity->name,
 		local_pad->entity->name);
@@ -760,22 +759,16 @@  static int mipi_csis_link_setup(struct media_entity *entity,
 
 	remote_sd = media_entity_to_v4l2_subdev(remote_pad->entity);
 
-	mutex_lock(&state->lock);
-
 	if (flags & MEDIA_LNK_FL_ENABLED) {
-		if (state->src_sd) {
-			ret = -EBUSY;
-			goto out;
-		}
+		if (state->src_sd)
+			return -EBUSY;
 
 		state->src_sd = remote_sd;
 	} else {
 		state->src_sd = NULL;
 	}
 
-out:
-	mutex_unlock(&state->lock);
-	return ret;
+	return 0;
 }
 
 static struct v4l2_mbus_framefmt *