]> rtime.felk.cvut.cz Git - zynq/linux.git/commitdiff
xilinx: v4l: m2m: Terminate the dma engine before releasing buffers
authorDevarsh Thakkar <devarsh.thakkar@xilinx.com>
Fri, 28 Sep 2018 02:52:04 +0000 (19:52 -0700)
committerMichal Simek <michal.simek@xilinx.com>
Mon, 1 Oct 2018 13:01:50 +0000 (15:01 +0200)
- When the process involving mem2mem driver was stopped abruptly,
  buffers were being returned to videobuf while dmaengines were still
  active causing a kernel panic.

- So now we terminate the dmaengines before returning buffers to videobuf.

- This fixes a hang on control-c for below transcode pipeline involving
  mem2mem driver where FBread->FBwrite block is managed by mem2mem driver.

- Use more specific mplane macro V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE for checking
  the source vb2 buffer queue type as it's type is set as mplane during
  queue initialization.

Pipeline:
H264 Decode->FBread (from PL)->FBwrite (to PS)->HEVC Encode->File

Signed-off-by: Devarsh Thakkar <devarsh.thakkar@xilinx.com>
Reviewed-by: Satish Kumar Nagireddy <satish.nagireddy.nagireddy@xilinx.com>
Reviewed-by: Hyun Kwon <hyun.kwon@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
drivers/media/platform/xilinx/xilinx-m2m.c

index f1459852c23a4db7c38b8dab8c60a1696860ef04..0e848a218c7d7d32e9b5021c5a12adfa0a8845e1 100644 (file)
@@ -222,8 +222,13 @@ static void xvip_m2m_stop_streaming(struct vb2_queue *q)
        struct xvip_m2m_dma *dma = ctx->xdev->dma;
        struct vb2_v4l2_buffer *vbuf;
 
+       if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
+               dmaengine_terminate_sync(dma->chan_tx);
+       else
+               dmaengine_terminate_sync(dma->chan_rx);
+
        for (;;) {
-               if (V4L2_TYPE_IS_OUTPUT(q->type))
+               if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
                        vbuf = v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx);
                else
                        vbuf = v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx);
@@ -234,9 +239,6 @@ static void xvip_m2m_stop_streaming(struct vb2_queue *q)
                v4l2_m2m_buf_done(vbuf, VB2_BUF_STATE_ERROR);
                spin_unlock(&ctx->xdev->queued_lock);
        }
-
-       dmaengine_terminate_sync(dma->chan_tx);
-       dmaengine_terminate_sync(dma->chan_rx);
 }
 
 static const struct vb2_ops m2m_vb2_ops = {