* [PATCH] media: imx-mipi-csis: avoid logging while holding spinlock
@ 2024-07-23 6:09 Matthias Fend
2024-07-25 15:21 ` Rui Miguel Silva
2024-07-26 10:42 ` Laurent Pinchart
0 siblings, 2 replies; 5+ messages in thread
From: Matthias Fend @ 2024-07-23 6:09 UTC (permalink / raw)
To: Rui Miguel Silva, Laurent Pinchart, Martin Kepplinger,
Purism Kernel Team, Mauro Carvalho Chehab, Shawn Guo,
Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam
Cc: linux-media, imx, linux-arm-kernel, linux-kernel
Refactor mipi_csis_log_counters() to prevent calling dev_info() while
IRQs are disabled. This reduces crucial IRQs off time to a bare minimum.
Signed-off-by: Matthias Fend <matthias.fend@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]);
}
- spin_unlock_irqrestore(&csis->slock, flags);
}
static int mipi_csis_dump_regs(struct mipi_csis_device *csis)
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] media: imx-mipi-csis: avoid logging while holding spinlock
2024-07-23 6:09 [PATCH] media: imx-mipi-csis: avoid logging while holding spinlock Matthias Fend
@ 2024-07-25 15:21 ` Rui Miguel Silva
2024-07-26 10:42 ` Laurent Pinchart
1 sibling, 0 replies; 5+ messages in thread
From: Rui Miguel Silva @ 2024-07-25 15:21 UTC (permalink / raw)
To: Matthias Fend, Laurent Pinchart, Martin Kepplinger,
Purism Kernel Team, Mauro Carvalho Chehab, Shawn Guo,
Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam
Cc: linux-media, imx, linux-arm-kernel, linux-kernel
Hey Matthias,
Many thanks for the patch.
Matthias Fend <matthias.fend@emfend.at> writes:
> Refactor mipi_csis_log_counters() to prevent calling dev_info() while
> IRQs are disabled. This reduces crucial IRQs off time to a bare minimum.
>
> Signed-off-by: Matthias Fend <matthias.fend@emfend.at>
LGTM
Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com>
Cheers,
Rui
> ---
> 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]);
> }
> - spin_unlock_irqrestore(&csis->slock, flags);
> }
>
> static int mipi_csis_dump_regs(struct mipi_csis_device *csis)
> --
> 2.25.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] media: imx-mipi-csis: avoid logging while holding spinlock
2024-07-23 6:09 [PATCH] media: imx-mipi-csis: avoid logging while holding spinlock Matthias Fend
2024-07-25 15:21 ` Rui Miguel Silva
@ 2024-07-26 10:42 ` Laurent Pinchart
2024-07-26 12:16 ` Matthias Fend
1 sibling, 1 reply; 5+ messages in thread
From: Laurent Pinchart @ 2024-07-26 10:42 UTC (permalink / raw)
To: Matthias Fend
Cc: Rui Miguel Silva, Martin Kepplinger, Purism Kernel Team,
Mauro Carvalho Chehab, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, linux-media, imx,
linux-arm-kernel, linux-kernel
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@vger.kernel.org
to get this backported to stable kernels ?
> Signed-off-by: Matthias Fend <matthias.fend@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@ideasonboard.com>
> }
> - spin_unlock_irqrestore(&csis->slock, flags);
> }
>
> static int mipi_csis_dump_regs(struct mipi_csis_device *csis)
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] media: imx-mipi-csis: avoid logging while holding spinlock
2024-07-26 10:42 ` Laurent Pinchart
@ 2024-07-26 12:16 ` Matthias Fend
2024-07-29 9:32 ` Laurent Pinchart
0 siblings, 1 reply; 5+ messages in thread
From: Matthias Fend @ 2024-07-26 12:16 UTC (permalink / raw)
To: Laurent Pinchart
Cc: Rui Miguel Silva, Martin Kepplinger, Purism Kernel Team,
Mauro Carvalho Chehab, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, linux-media, imx,
linux-arm-kernel, linux-kernel
Hi Laurent,
Am 26.07.2024 um 12:42 schrieb Laurent Pinchart:
> 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@vger.kernel.org
>
> to get this backported to stable kernels ?
Hard for me to tell. Since this problem only occurs when you explicitly
trigger the debug output from this driver, it probably only affects very
few end users. So I'm not sure if a backport would be worth it.
>
>> Signed-off-by: Matthias Fend <matthias.fend@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.
Thanks! Regarding Cc, I would like to leave it up to you; you have the
necessary experience and overview to judge that.
~Matthias
>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>
>> }
>> - spin_unlock_irqrestore(&csis->slock, flags);
>> }
>>
>> static int mipi_csis_dump_regs(struct mipi_csis_device *csis)
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] media: imx-mipi-csis: avoid logging while holding spinlock
2024-07-26 12:16 ` Matthias Fend
@ 2024-07-29 9:32 ` Laurent Pinchart
0 siblings, 0 replies; 5+ messages in thread
From: Laurent Pinchart @ 2024-07-29 9:32 UTC (permalink / raw)
To: Matthias Fend
Cc: Rui Miguel Silva, Martin Kepplinger, Purism Kernel Team,
Mauro Carvalho Chehab, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, linux-media, imx,
linux-arm-kernel, linux-kernel
On Fri, Jul 26, 2024 at 02:16:07PM +0200, Matthias Fend wrote:
> Hi Laurent,
>
> Am 26.07.2024 um 12:42 schrieb Laurent Pinchart:
> > 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@vger.kernel.org
> >
> > to get this backported to stable kernels ?
>
> Hard for me to tell. Since this problem only occurs when you explicitly
> trigger the debug output from this driver, it probably only affects very
> few end users. So I'm not sure if a backport would be worth it.
I slept over it and decided not to Cc stable.
> >> Signed-off-by: Matthias Fend <matthias.fend@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.
>
> Thanks! Regarding Cc, I would like to leave it up to you; you have the
> necessary experience and overview to judge that.
>
> ~Matthias
>
> > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> >
> >> }
> >> - spin_unlock_irqrestore(&csis->slock, flags);
> >> }
> >>
> >> static int mipi_csis_dump_regs(struct mipi_csis_device *csis)
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-07-29 9:34 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-23 6:09 [PATCH] media: imx-mipi-csis: avoid logging while holding spinlock Matthias Fend
2024-07-25 15:21 ` Rui Miguel Silva
2024-07-26 10:42 ` Laurent Pinchart
2024-07-26 12:16 ` Matthias Fend
2024-07-29 9:32 ` Laurent Pinchart
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).