[PATCH] media: imx-mipi-csis: avoid logging while holding spinlock

Laurent Pinchart laurent.pinchart at ideasonboard.com
Fri Jul 26 03:42:55 PDT 2024


Hi Matthias,

Thank you for the patch.

On Tue, Jul 23, 2024 at 08:09:08AM +0200, Matthias Fend wrote:
> Refactor mipi_csis_log_counters() to prevent calling dev_info() while
> IRQs are disabled. This reduces crucial IRQs off time to a bare minimum.

Should we add

Cc: stable at vger.kernel.org

to get this backported to stable kernels ?

> Signed-off-by: Matthias Fend <matthias.fend at emfend.at>
> ---
>  drivers/media/platform/nxp/imx-mipi-csis.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/media/platform/nxp/imx-mipi-csis.c b/drivers/media/platform/nxp/imx-mipi-csis.c
> index f49b06978f14..0c34d316ed29 100644
> --- a/drivers/media/platform/nxp/imx-mipi-csis.c
> +++ b/drivers/media/platform/nxp/imx-mipi-csis.c
> @@ -857,18 +857,21 @@ static void mipi_csis_log_counters(struct mipi_csis_device *csis, bool non_error
>  {
>  	unsigned int num_events = non_errors ? MIPI_CSIS_NUM_EVENTS
>  				: MIPI_CSIS_NUM_EVENTS - 8;
> +	unsigned int counters[MIPI_CSIS_NUM_EVENTS];
>  	unsigned long flags;
>  	unsigned int i;
>  
>  	spin_lock_irqsave(&csis->slock, flags);
> +	for (i = 0; i < num_events; ++i)
> +		counters[i] =  csis->events[i].counter;
> +	spin_unlock_irqrestore(&csis->slock, flags);
>  
>  	for (i = 0; i < num_events; ++i) {
> -		if (csis->events[i].counter > 0 || csis->debug.enable)
> +		if (counters[i] > 0 || csis->debug.enable)
>  			dev_info(csis->dev, "%s events: %d\n",
>  				 csis->events[i].name,
> -				 csis->events[i].counter);
> +				 counters[i]);

The last two lines now fit in a single line. No need for a v2, I'll
rewrap the code myself, and add the Cc line if you think that's a good
idea.

Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>

>  	}
> -	spin_unlock_irqrestore(&csis->slock, flags);
>  }
>  
>  static int mipi_csis_dump_regs(struct mipi_csis_device *csis)

-- 
Regards,

Laurent Pinchart



More information about the linux-arm-kernel mailing list