[PATCH 07/18] media: coda: Add fake IRQ check

Sergey Khimich posted 18 patches 9 months, 1 week ago
[PATCH 07/18] media: coda: Add fake IRQ check
Posted by Sergey Khimich 9 months, 1 week ago
From: Sergey Khimich <serghox@gmail.com>

Sometimes we receive fake interrupts. It's better to check
status register and trace fake irq if occurred.

Signed-off-by: Sergey Khimich <serghox@gmail.com>
---
 .../media/platform/chips-media/coda/coda-bit.c   | 16 +++++++++++++++-
 drivers/media/platform/chips-media/coda/trace.h  | 16 ++++++++++++++++
 2 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/chips-media/coda/coda-bit.c b/drivers/media/platform/chips-media/coda/coda-bit.c
index 84ded154adfe..3e3bb3d64ec9 100644
--- a/drivers/media/platform/chips-media/coda/coda-bit.c
+++ b/drivers/media/platform/chips-media/coda/coda-bit.c
@@ -2635,9 +2635,23 @@ irqreturn_t coda_irq_handler(int irq, void *data)
 {
 	struct coda_dev *dev = data;
 	struct coda_ctx *ctx;
+	u32 status;
 
 	/* read status register to attend the IRQ */
-	coda_read(dev, CODA_REG_BIT_INT_STATUS);
+	status = coda_read(dev, CODA_REG_BIT_INT_STATUS);
+	if (!status) {
+		/*
+		 * Sometimes we received wrong interrupts
+		 * That's why we check status
+		 * and if one of it is zero - wait next interrupts
+		 * You need check your HW configuration
+		 */
+		dev_warn_ratelimited(dev->dev, "Fake irq status=0x%X\n",
+				     status);
+		trace_coda_wrong_irq(dev);
+		return IRQ_HANDLED;
+	}
+
 	coda_write(dev, 0, CODA_REG_BIT_INT_REASON);
 	coda_write(dev, CODA_REG_BIT_INT_CLEAR_SET,
 		      CODA_REG_BIT_INT_CLEAR);
diff --git a/drivers/media/platform/chips-media/coda/trace.h b/drivers/media/platform/chips-media/coda/trace.h
index abc6a01a74e9..15a96bab10ad 100644
--- a/drivers/media/platform/chips-media/coda/trace.h
+++ b/drivers/media/platform/chips-media/coda/trace.h
@@ -10,6 +10,22 @@
 
 #include "coda.h"
 
+TRACE_EVENT(coda_wrong_irq,
+	TP_PROTO(struct coda_dev *dev),
+
+	TP_ARGS(dev),
+
+	TP_STRUCT__entry(
+		__field(struct coda_dev *, dev)
+	),
+
+	TP_fast_assign(
+		__entry->dev = dev;
+	),
+
+	TP_printk(" dev = 0x%p", __entry->dev)
+);
+
 TRACE_EVENT(coda_bit_run,
 	TP_PROTO(struct coda_ctx *ctx, int cmd),
 
-- 
2.30.2
Re: [PATCH 07/18] media: coda: Add fake IRQ check
Posted by Nicolas Dufresne 6 months, 3 weeks ago
Hi,

Le vendredi 14 mars 2025 à 18:29 +0300, Sergey Khimich a écrit :
> From: Sergey Khimich <serghox@gmail.com>
> 
> Sometimes we receive fake interrupts. It's better to check
> status register and trace fake irq if occurred.
> 
> Signed-off-by: Sergey Khimich <serghox@gmail.com>
> ---
>  .../media/platform/chips-media/coda/coda-bit.c   | 16 +++++++++++++++-
>  drivers/media/platform/chips-media/coda/trace.h  | 16 ++++++++++++++++
>  2 files changed, 31 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/platform/chips-media/coda/coda-bit.c b/drivers/media/platform/chips-media/coda/coda-bit.c
> index 84ded154adfe..3e3bb3d64ec9 100644
> --- a/drivers/media/platform/chips-media/coda/coda-bit.c
> +++ b/drivers/media/platform/chips-media/coda/coda-bit.c
> @@ -2635,9 +2635,23 @@ irqreturn_t coda_irq_handler(int irq, void *data)
>  {
>  	struct coda_dev *dev = data;
>  	struct coda_ctx *ctx;
> +	u32 status;
>  
>  	/* read status register to attend the IRQ */
> -	coda_read(dev, CODA_REG_BIT_INT_STATUS);
> +	status = coda_read(dev, CODA_REG_BIT_INT_STATUS);
> +	if (!status) {
> +		/*
> +		 * Sometimes we received wrong interrupts
> +		 * That's why we check status
> +		 * and if one of it is zero - wait next interrupts
> +		 * You need check your HW configuration
> +		 */
> +		dev_warn_ratelimited(dev->dev, "Fake irq status=0x%X\n",
> +				     status);
> +		trace_coda_wrong_irq(dev);
> +		return IRQ_HANDLED;

How often is sometimes ? Does it cause any issues, frame loss ? If not, I would say
drop the warning and just swallow it.

Nicolas

> +	}
> +
>  	coda_write(dev, 0, CODA_REG_BIT_INT_REASON);
>  	coda_write(dev, CODA_REG_BIT_INT_CLEAR_SET,
>  		      CODA_REG_BIT_INT_CLEAR);
> diff --git a/drivers/media/platform/chips-media/coda/trace.h b/drivers/media/platform/chips-media/coda/trace.h
> index abc6a01a74e9..15a96bab10ad 100644
> --- a/drivers/media/platform/chips-media/coda/trace.h
> +++ b/drivers/media/platform/chips-media/coda/trace.h
> @@ -10,6 +10,22 @@
>  
>  #include "coda.h"
>  
> +TRACE_EVENT(coda_wrong_irq,
> +	TP_PROTO(struct coda_dev *dev),
> +
> +	TP_ARGS(dev),
> +
> +	TP_STRUCT__entry(
> +		__field(struct coda_dev *, dev)
> +	),
> +
> +	TP_fast_assign(
> +		__entry->dev = dev;
> +	),
> +
> +	TP_printk(" dev = 0x%p", __entry->dev)
> +);
> +
>  TRACE_EVENT(coda_bit_run,
>  	TP_PROTO(struct coda_ctx *ctx, int cmd),
>