diff mbox series

[v2,39/77] media: imx: imx7-media-csi: Don't lock access to is_csi2

Message ID 20210215042741.28850-40-laurent.pinchart@ideasonboard.com (mailing list archive)
State New
Headers show
Series media: imx: Miscellaneous fixes and cleanups for i.MX7 | expand

Commit Message

Laurent Pinchart Feb. 15, 2021, 4:27 a.m. UTC
The is_csi2 field can't be accessed concurrently by
imx7_csi_pad_link_validate() and imx7_csi_configure(), as the latter is
called from imx7_csi_s_stream(), which is called after link validation.
Drop the lock.

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

Comments

Rui Miguel Silva March 1, 2021, 9:31 a.m. UTC | #1
Hi Laurent,
On Mon, Feb 15, 2021 at 06:27:03AM +0200, Laurent Pinchart wrote:
> The is_csi2 field can't be accessed concurrently by
> imx7_csi_pad_link_validate() and imx7_csi_configure(), as the latter is
> called from imx7_csi_s_stream(), which is called after link validation.
> Drop the lock.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

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

------
Cheers,
     Rui
> ---
>  drivers/staging/media/imx/imx7-media-csi.c | 11 +++--------
>  1 file changed, 3 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c
> index 2a4b69cc0178..dc25b593eaeb 100644
> --- a/drivers/staging/media/imx/imx7-media-csi.c
> +++ b/drivers/staging/media/imx/imx7-media-csi.c
> @@ -1001,7 +1001,6 @@ static int imx7_csi_pad_link_validate(struct v4l2_subdev *sd,
>  	struct imx_media_video_dev *vdev = csi->vdev;
>  	const struct v4l2_pix_format *out_pix = &vdev->fmt;
>  	struct media_pad *pad;
> -	bool is_csi2;
>  	int ret;
>  
>  	if (!csi->src_sd)
> @@ -1018,7 +1017,7 @@ static int imx7_csi_pad_link_validate(struct v4l2_subdev *sd,
>  	switch (csi->src_sd->entity.function) {
>  	case MEDIA_ENT_F_VID_IF_BRIDGE:
>  		/* The input is the CSI-2 receiver. */
> -		is_csi2 = true;
> +		csi->is_csi2 = true;
>  		break;
>  
>  	case MEDIA_ENT_F_VID_MUX:
> @@ -1027,7 +1026,7 @@ static int imx7_csi_pad_link_validate(struct v4l2_subdev *sd,
>  		if (!pad)
>  			return -ENODEV;
>  
> -		is_csi2 = pad->entity->function == MEDIA_ENT_F_VID_IF_BRIDGE;
> +		csi->is_csi2 = pad->entity->function == MEDIA_ENT_F_VID_IF_BRIDGE;
>  		break;
>  
>  	default:
> @@ -1035,14 +1034,10 @@ static int imx7_csi_pad_link_validate(struct v4l2_subdev *sd,
>  		 * The input is an external entity, it must use the parallel
>  		 * bus.
>  		 */
> -		is_csi2 = false;
> +		csi->is_csi2 = false;
>  		break;
>  	}
>  
> -	mutex_lock(&csi->lock);
> -	csi->is_csi2 = is_csi2;
> -	mutex_unlock(&csi->lock);
> -
>  	/* Validate the sink link, ensure the pixel format is supported. */
>  	switch (out_pix->pixelformat) {
>  	case V4L2_PIX_FMT_UYVY:
> -- 
> Regards,
> 
> Laurent Pinchart
>
diff mbox series

Patch

diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c
index 2a4b69cc0178..dc25b593eaeb 100644
--- a/drivers/staging/media/imx/imx7-media-csi.c
+++ b/drivers/staging/media/imx/imx7-media-csi.c
@@ -1001,7 +1001,6 @@  static int imx7_csi_pad_link_validate(struct v4l2_subdev *sd,
 	struct imx_media_video_dev *vdev = csi->vdev;
 	const struct v4l2_pix_format *out_pix = &vdev->fmt;
 	struct media_pad *pad;
-	bool is_csi2;
 	int ret;
 
 	if (!csi->src_sd)
@@ -1018,7 +1017,7 @@  static int imx7_csi_pad_link_validate(struct v4l2_subdev *sd,
 	switch (csi->src_sd->entity.function) {
 	case MEDIA_ENT_F_VID_IF_BRIDGE:
 		/* The input is the CSI-2 receiver. */
-		is_csi2 = true;
+		csi->is_csi2 = true;
 		break;
 
 	case MEDIA_ENT_F_VID_MUX:
@@ -1027,7 +1026,7 @@  static int imx7_csi_pad_link_validate(struct v4l2_subdev *sd,
 		if (!pad)
 			return -ENODEV;
 
-		is_csi2 = pad->entity->function == MEDIA_ENT_F_VID_IF_BRIDGE;
+		csi->is_csi2 = pad->entity->function == MEDIA_ENT_F_VID_IF_BRIDGE;
 		break;
 
 	default:
@@ -1035,14 +1034,10 @@  static int imx7_csi_pad_link_validate(struct v4l2_subdev *sd,
 		 * The input is an external entity, it must use the parallel
 		 * bus.
 		 */
-		is_csi2 = false;
+		csi->is_csi2 = false;
 		break;
 	}
 
-	mutex_lock(&csi->lock);
-	csi->is_csi2 = is_csi2;
-	mutex_unlock(&csi->lock);
-
 	/* Validate the sink link, ensure the pixel format is supported. */
 	switch (out_pix->pixelformat) {
 	case V4L2_PIX_FMT_UYVY: