lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240924224619.GO7165@pendragon.ideasonboard.com>
Date: Wed, 25 Sep 2024 01:46:19 +0300
From: Laurent Pinchart <laurent.pinchart@...asonboard.com>
To: Prabhakar <prabhakar.csengg@...il.com>
Cc: Sakari Ailus <sakari.ailus@...ux.intel.com>,
	Kieran Bingham <kieran.bingham@...asonboard.com>,
	Tomi Valkeinen <tomi.valkeinen@...asonboard.com>,
	Jacopo Mondi <jacopo.mondi@...asonboard.com>,
	Mauro Carvalho Chehab <mchehab@...nel.org>,
	Hans Verkuil <hverkuil-cisco@...all.nl>,
	linux-media@...r.kernel.org, linux-kernel@...r.kernel.org,
	linux-renesas-soc@...r.kernel.org,
	Biju Das <biju.das.jz@...renesas.com>,
	Fabrizio Castro <fabrizio.castro.jz@...esas.com>,
	Lad Prabhakar <prabhakar.mahadev-lad.rj@...renesas.com>
Subject: Re: [PATCH v2 06/11] media: i2c: ov5645: Drop `power_lock` mutex

On Tue, Sep 10, 2024 at 06:06:05PM +0100, Prabhakar wrote:
> From: Lad Prabhakar <prabhakar.mahadev-lad.rj@...renesas.com>
> 
> Drop mutex while applying controls and just rely on
> pm_runtime_get_if_in_use() call.

Here too the commit message should explain why the mutex can be dropped.
Given that it is only used in .s_ctrl(), and the control framework
serializes calls to the function, the mutex is not needed.

> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@...renesas.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@...asonboard.com>

> ---
>  drivers/media/i2c/ov5645.c | 12 +-----------
>  1 file changed, 1 insertion(+), 11 deletions(-)
> 
> diff --git a/drivers/media/i2c/ov5645.c b/drivers/media/i2c/ov5645.c
> index 45687d004004..25c60afcc0ec 100644
> --- a/drivers/media/i2c/ov5645.c
> +++ b/drivers/media/i2c/ov5645.c
> @@ -106,8 +106,6 @@ struct ov5645 {
>  	u8 timing_tc_reg20;
>  	u8 timing_tc_reg21;
>  
> -	struct mutex power_lock; /* lock to protect power state */
> -
>  	struct gpio_desc *enable_gpio;
>  	struct gpio_desc *rst_gpio;
>  };
> @@ -782,11 +780,8 @@ static int ov5645_s_ctrl(struct v4l2_ctrl *ctrl)
>  					     struct ov5645, ctrls);
>  	int ret;
>  
> -	mutex_lock(&ov5645->power_lock);
> -	if (!pm_runtime_get_if_in_use(ov5645->dev)) {
> -		mutex_unlock(&ov5645->power_lock);
> +	if (!pm_runtime_get_if_in_use(ov5645->dev))
>  		return 0;
> -	}
>  
>  	switch (ctrl->id) {
>  	case V4L2_CID_SATURATION:
> @@ -817,7 +812,6 @@ static int ov5645_s_ctrl(struct v4l2_ctrl *ctrl)
>  
>  	pm_runtime_mark_last_busy(ov5645->dev);
>  	pm_runtime_put_autosuspend(ov5645->dev);
> -	mutex_unlock(&ov5645->power_lock);
>  
>  	return ret;
>  }
> @@ -1124,8 +1118,6 @@ static int ov5645_probe(struct i2c_client *client)
>  	if (IS_ERR(ov5645->rst_gpio))
>  		return dev_err_probe(dev, PTR_ERR(ov5645->rst_gpio), "cannot get reset gpio\n");
>  
> -	mutex_init(&ov5645->power_lock);
> -
>  	v4l2_ctrl_handler_init(&ov5645->ctrls, 9);
>  	v4l2_ctrl_new_std(&ov5645->ctrls, &ov5645_ctrl_ops,
>  			  V4L2_CID_SATURATION, -4, 4, 1, 0);
> @@ -1245,7 +1237,6 @@ static int ov5645_probe(struct i2c_client *client)
>  	media_entity_cleanup(&ov5645->sd.entity);
>  free_ctrl:
>  	v4l2_ctrl_handler_free(&ov5645->ctrls);
> -	mutex_destroy(&ov5645->power_lock);
>  
>  	return ret;
>  }
> @@ -1262,7 +1253,6 @@ static void ov5645_remove(struct i2c_client *client)
>  	if (!pm_runtime_status_suspended(ov5645->dev))
>  		ov5645_set_power_off(ov5645->dev);
>  	pm_runtime_set_suspended(ov5645->dev);
> -	mutex_destroy(&ov5645->power_lock);
>  }
>  
>  static const struct i2c_device_id ov5645_id[] = {

-- 
Regards,

Laurent Pinchart

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ