Re: [PATCH 2/5] media: imx: imx-mipi-csis: Drop powered flag

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Jacopo,

Thank you for the patch.

On Mon, Mar 14, 2022 at 11:39:38AM +0100, Jacopo Mondi wrote:
> The mipi_csis_device.powered flag only serves for the purpose of
> not accessing registers in mipi_csis_log_status() when the interface
> is not powered up.
> 
> Instead of manually tracking the power state, rely on
> pm_runtime_get_if_in_use() to remove the 'powered' flag. Also remove
> the locking in the function as runtime_pm() is refcounted and there's no
> risk of the interface being powered down behind our backs.
> 
> Signed-off-by: Jacopo Mondi <jacopo@xxxxxxxxxx>
> ---
>  drivers/media/platform/imx/imx-mipi-csis.c | 13 ++++---------
>  1 file changed, 4 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/media/platform/imx/imx-mipi-csis.c b/drivers/media/platform/imx/imx-mipi-csis.c
> index 60e7f0452582..b76bb129a416 100644
> --- a/drivers/media/platform/imx/imx-mipi-csis.c
> +++ b/drivers/media/platform/imx/imx-mipi-csis.c
> @@ -327,10 +327,9 @@ struct mipi_csis_device {
>  	u32 hs_settle;
>  	u32 clk_settle;
>  
> -	struct mutex lock;	/* Protect csis_fmt, format_mbus and powered */
> +	struct mutex lock;	/* Protect csis_fmt and format_mbus */
>  	const struct csis_pix_format *csis_fmt;
>  	struct v4l2_mbus_framefmt format_mbus[CSIS_PADS_NUM];
> -	bool powered;
>  
>  	spinlock_t slock;	/* Protect events */
>  	struct mipi_csis_event events[MIPI_CSIS_NUM_EVENTS];
> @@ -1174,11 +1173,11 @@ static int mipi_csis_log_status(struct v4l2_subdev *sd)
>  {
>  	struct mipi_csis_device *csis = sd_to_mipi_csis_device(sd);
>  
> -	mutex_lock(&csis->lock);
>  	mipi_csis_log_counters(csis, true);
> -	if (csis->debug.enable && csis->powered)
> +	if (csis->debug.enable && pm_runtime_get_if_in_use(csis->dev)) {
>  		mipi_csis_dump_regs(csis);
> -	mutex_unlock(&csis->lock);
> +		pm_runtime_put(csis->dev);

I was going to write that you could move runtime PM to
mipi_csis_dump_regs(), and then noticed patch 5/5 that does so. Is there
any reason it can't be done here already (essentially squashing this
with 5/5) ?

Reviewed-by: Laurent Pinchart <laurent.pinchart@xxxxxxxxxxxxxxxx>

> +	}
>  
>  	return 0;
>  }
> @@ -1344,8 +1343,6 @@ static int __maybe_unused mipi_csis_runtime_suspend(struct device *dev)
>  
>  	mipi_csis_clk_disable(csis);
>  
> -	csis->powered = false;
> -
>  unlock:
>  	mutex_unlock(&csis->lock);
>  
> @@ -1366,8 +1363,6 @@ static int __maybe_unused mipi_csis_runtime_resume(struct device *dev)
>  
>  	mipi_csis_clk_enable(csis);
>  
> -	csis->powered = true;
> -
>  unlock:
>  	mutex_unlock(&csis->lock);
>  

-- 
Regards,

Laurent Pinchart



[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux