media: vsp1: Add underrun debug print
authorTomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
Thu, 16 Feb 2023 09:41:15 +0000 (11:41 +0200)
committerHans Verkuil <hverkuil-cisco@xs4all.nl>
Tue, 11 Apr 2023 15:53:14 +0000 (17:53 +0200)
Print underrun interrupts with ratelimited print.

Note that we don't enable the underrun interrupt. If we have underruns,
we don't want to get flooded with interrupts about them. It's enough to
see that an underrun happened at the end of a frame.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
drivers/media/platform/renesas/vsp1/vsp1_drm.c
drivers/media/platform/renesas/vsp1/vsp1_drv.c
drivers/media/platform/renesas/vsp1/vsp1_pipe.h
drivers/media/platform/renesas/vsp1/vsp1_regs.h

index c6f25200982c8525eb91bf907797379572691402..5da1bc991750215d1a99450361786613f1b60e54 100644 (file)
@@ -710,6 +710,9 @@ int vsp1_du_setup_lif(struct device *dev, unsigned int pipe_index,
                return 0;
        }
 
+       /* Reset the underrun counter */
+       pipe->underrun_count = 0;
+
        drm_pipe->width = cfg->width;
        drm_pipe->height = cfg->height;
        pipe->interlaced = cfg->interlaced;
index c1c28f98bd10c49bc0f16435ea2eea2977fdad5b..a9db84be48220fecab7f22a4b8c0bda6a0b3e027 100644 (file)
@@ -45,7 +45,8 @@
 
 static irqreturn_t vsp1_irq_handler(int irq, void *data)
 {
-       u32 mask = VI6_WPF_IRQ_STA_DFE | VI6_WPF_IRQ_STA_FRE;
+       u32 mask = VI6_WPF_IRQ_STA_DFE | VI6_WPF_IRQ_STA_FRE |
+                  VI6_WPF_IRQ_STA_UND;
        struct vsp1_device *vsp1 = data;
        irqreturn_t ret = IRQ_NONE;
        unsigned int i;
@@ -60,6 +61,14 @@ static irqreturn_t vsp1_irq_handler(int irq, void *data)
                status = vsp1_read(vsp1, VI6_WPF_IRQ_STA(i));
                vsp1_write(vsp1, VI6_WPF_IRQ_STA(i), ~status & mask);
 
+               if ((status & VI6_WPF_IRQ_STA_UND) && wpf->entity.pipe) {
+                       wpf->entity.pipe->underrun_count++;
+
+                       dev_warn_ratelimited(vsp1->dev,
+                               "Underrun occurred at WPF%u (total underruns %u)\n",
+                               i, wpf->entity.pipe->underrun_count);
+               }
+
                if (status & VI6_WPF_IRQ_STA_DFE) {
                        vsp1_pipeline_frame_end(wpf->entity.pipe);
                        ret = IRQ_HANDLED;
index ae646c9ef337317ad1b7c1b589f3bfd080af363e..674b5748d929e2ad95e221423d909f7705b9a0db 100644 (file)
@@ -148,6 +148,8 @@ struct vsp1_pipeline {
        unsigned int partitions;
        struct vsp1_partition *partition;
        struct vsp1_partition *part_table;
+
+       u32 underrun_count;
 };
 
 void vsp1_pipeline_reset(struct vsp1_pipeline *pipe);
index d94343ae57a1a97d23408035a9548410fbd78cc8..7eca82e0ba7ec5e02a5f3b9a30ccdcb48db39ed2 100644 (file)
 #define VI6_STATUS_SYS_ACT(n)          BIT((n) + 8)
 
 #define VI6_WPF_IRQ_ENB(n)             (0x0048 + (n) * 12)
+#define VI6_WPF_IRQ_ENB_UNDE           BIT(16)
 #define VI6_WPF_IRQ_ENB_DFEE           BIT(1)
 #define VI6_WPF_IRQ_ENB_FREE           BIT(0)
 
 #define VI6_WPF_IRQ_STA(n)             (0x004c + (n) * 12)
+#define VI6_WPF_IRQ_STA_UND            BIT(16)
 #define VI6_WPF_IRQ_STA_DFE            BIT(1)
 #define VI6_WPF_IRQ_STA_FRE            BIT(0)