From: Cho KyongHo Date: Mon, 18 Feb 2019 04:19:34 +0000 (+0900) Subject: [RAMEN9610-12270] media: smfc: force unshareable for HWFC buffer X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=1c773b437f4aab237139fa8753e47eb1ecccb5a2;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git [RAMEN9610-12270] media: smfc: force unshareable for HWFC buffer Camera driver has no chance to maintain its destination buffer before reading the buffer by SMFC if HWFC is enabled because SMFC starts reading the buffer before MSCS finishes writing to the buffer. Therefore, we should make SMFC read the buffer with the unshareable attribute. Change-Id: I9e9e326ecaa742fba1995a1bfc3f2ff60e68ef37 Signed-off-by: Cho KyongHo --- diff --git a/drivers/media/platform/exynos/smfc/smfc.c b/drivers/media/platform/exynos/smfc/smfc.c index 75bacb2d32ab..cb975b1f6e29 100644 --- a/drivers/media/platform/exynos/smfc/smfc.c +++ b/drivers/media/platform/exynos/smfc/smfc.c @@ -261,18 +261,6 @@ static int smfc_vb2_buf_prepare(struct vb2_buffer *vb) return -EINVAL; } } - - /* - * FIXME: handle this - * There is no chance to clean CPU caches if HWFC is - * enabled because the compression starts before the - * image producer completes writing. - * Therefore, the image producer (MCSC) and the read DMA - * of JPEG/SMFC should access the memory with the same - * shareability attributes. - if (ctx->enable_hwfc) - clean_cache = false; - */ } else { /* buffer contains JPEG stream to decompress */ int ret = smfc_parse_jpeg_header(ctx, vb); @@ -357,6 +345,31 @@ static void smfc_vb2_stop_streaming(struct vb2_queue *vq) vb2_wait_for_all_buffers(vq); } +static int smfc_vb2_dma_sg_flags(struct vb2_buffer *vb) +{ + int flags = 0; + struct vb2_queue *vq = vb->vb2_queue; + + /* + * There is no chance to clean CPU caches if HWFC is + * enabled because the compression starts before the + * image producer completes writing. + * Therefore, the image producer (MCSC) and the read DMA + * of JPEG/SMFC should access the memory with the same + * shareability attributes. + * MCSC does use shareable memory access for now. Let's make + * unshareable to the shared buffer with MSCS here. + */ + if (V4L2_TYPE_IS_OUTPUT(vq->type)) { + struct smfc_ctx *ctx = vq->drv_priv; + + if (!!(ctx->flags & SMFC_CTX_COMPRESS) && ctx->enable_hwfc) + flags = VB2_DMA_SG_MEMFLAG_IOMMU_UNCACHED; + } + + return flags; +} + static struct vb2_ops smfc_vb2_ops = { .queue_setup = smfc_vb2_queue_setup, .buf_prepare = smfc_vb2_buf_prepare, @@ -366,6 +379,7 @@ static struct vb2_ops smfc_vb2_ops = { .wait_finish = vb2_ops_wait_finish, .wait_prepare = vb2_ops_wait_prepare, .stop_streaming = smfc_vb2_stop_streaming, + .mem_flags = smfc_vb2_dma_sg_flags, }; static int smfc_queue_init(void *priv, struct vb2_queue *src_vq,