[COMMON] media: smfc: clean the dirty region by CPU in .buf_cleaup
authorCho KyongHo <pullip.cho@samsung.com>
Wed, 22 Jul 2015 08:04:12 +0000 (17:04 +0900)
committerSeungchul Kim <sc377.kim@samsung.com>
Mon, 28 May 2018 05:31:09 +0000 (14:31 +0900)
Even though userspace gives V4L2_BUF_FLAG_NO_CACHE_CLEAN flag in
the v4l2_buffer on qbuf, it just guarantees that the buffer after
the specific offset is not cache dirty by CPU.
If the offset become smaller than the previous, H/W may starts to
write the compressed stream on the area that may have dirty cache
lines.
To prevent the problem, the driver should clean the dirty cache lines
if the offset becomes no longer valied.

Change-Id: I54baba493dd4c179eda740bedba3378d4abe8435
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
drivers/media/platform/exynos/smfc/smfc.c

index 84ac579019089de09fcf25c587e14ac98e76f9b0..2722162fb7e395b983b21a5cc9af20f5950be2f4 100644 (file)
@@ -443,6 +443,19 @@ static void smfc_vb2_buf_finish(struct vb2_buffer *vb)
 {
 }
 
+static void smfc_vb2_buf_cleanup(struct vb2_buffer *vb)
+{
+       struct smfc_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue);
+       if (!V4L2_TYPE_IS_OUTPUT(vb->vb2_queue->type) &&
+                       !!(ctx->flags & SMFC_CTX_COMPRESS)) {
+               /*
+                * TODO: clean the APP segments written by CPU in front
+                * of the start of the JPEG stream to be written by H/W
+                * for the later use of this buffer.
+                */
+       }
+}
+
 static void smfc_vb2_buf_queue(struct vb2_buffer *vb)
 {
        struct smfc_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue);
@@ -470,6 +483,7 @@ static struct vb2_ops smfc_vb2_ops = {
        .queue_setup    = smfc_vb2_queue_setup,
        .buf_prepare    = smfc_vb2_buf_prepare,
        .buf_finish     = smfc_vb2_buf_finish,
+       .buf_cleanup    = smfc_vb2_buf_cleanup,
        .buf_queue      = smfc_vb2_buf_queue,
        .wait_finish    = vb2_ops_wait_finish,
        .wait_prepare   = vb2_ops_wait_prepare,