From 6ffc87c3cfa9359b6b455c7ac1de95dad82c785b Mon Sep 17 00:00:00 2001 From: Pengcheng Chen Date: Mon, 11 Mar 2019 17:48:52 +0800 Subject: [PATCH] gdc: ge2d: output dma_buf need flush when alloc [1/1] PD#SWPL-5685 Problem: gdc output mismatch Solution: output dma_buf need flush when alloc Verify: verified by w400 Change-Id: Ie206b4f51bd1338420f63e0e06563b67d6d63c88 Signed-off-by: Pengcheng Chen --- drivers/amlogic/media/common/ge2d/ge2d_dmabuf.c | 9 +++++++-- drivers/amlogic/media/gdc/app/gdc_dmabuf.c | 9 +++++++-- drivers/amlogic/media/gdc/app/gdc_module.c | 9 +++++++-- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/drivers/amlogic/media/common/ge2d/ge2d_dmabuf.c b/drivers/amlogic/media/common/ge2d/ge2d_dmabuf.c index 9a6087a..41ff5de 100644 --- a/drivers/amlogic/media/common/ge2d/ge2d_dmabuf.c +++ b/drivers/amlogic/media/common/ge2d/ge2d_dmabuf.c @@ -378,8 +378,8 @@ int ge2d_dma_buffer_alloc(struct aml_dma_buffer *buffer, struct device *dev, struct ge2d_dmabuf_req_s *ge2d_req_buf) { - struct aml_dma_buf *dma_buf; void *buf; + struct aml_dma_buf *dma_buf; unsigned int size; int index; @@ -416,6 +416,11 @@ int ge2d_dma_buffer_alloc(struct aml_dma_buffer *buffer, buffer->gd_buffer[index].alloc = 1; mutex_unlock(&(buffer->lock)); ge2d_req_buf->index = index; + dma_buf = (struct aml_dma_buf *)buf; + if (dma_buf->dma_dir == DMA_FROM_DEVICE) + dma_sync_single_for_cpu(dma_buf->dev, + dma_buf->dma_addr, + dma_buf->size, DMA_FROM_DEVICE); return 0; } @@ -646,7 +651,7 @@ void ge2d_dma_buffer_cache_flush(struct device *dev, int fd) return; } if (buf->size > 0) - dma_sync_single_for_device(buf->dev, buf->dma_addr, + dma_sync_single_for_cpu(buf->dev, buf->dma_addr, buf->size, DMA_FROM_DEVICE); dma_buf_put(dmabuf); } diff --git a/drivers/amlogic/media/gdc/app/gdc_dmabuf.c b/drivers/amlogic/media/gdc/app/gdc_dmabuf.c index d215799..a4408ab 100644 --- a/drivers/amlogic/media/gdc/app/gdc_dmabuf.c +++ b/drivers/amlogic/media/gdc/app/gdc_dmabuf.c @@ -380,8 +380,8 @@ int gdc_dma_buffer_alloc(struct aml_dma_buffer *buffer, struct device *dev, struct gdc_dmabuf_req_s *gdc_req_buf) { - struct aml_dma_buf *dma_buf; void *buf; + struct aml_dma_buf *dma_buf; unsigned int size; int index; @@ -417,6 +417,11 @@ int gdc_dma_buffer_alloc(struct aml_dma_buffer *buffer, buffer->gd_buffer[index].alloc = 1; mutex_unlock(&(buffer->lock)); gdc_req_buf->index = index; + dma_buf = (struct aml_dma_buf *)buf; + if (dma_buf->dma_dir == DMA_FROM_DEVICE) + dma_sync_single_for_cpu(dma_buf->dev, + dma_buf->dma_addr, + dma_buf->size, DMA_FROM_DEVICE); return 0; } @@ -643,7 +648,7 @@ void gdc_dma_buffer_cache_flush(struct device *dev, int fd) return; } if (buf->size > 0) - dma_sync_single_for_device(buf->dev, buf->dma_addr, + dma_sync_single_for_cpu(buf->dev, buf->dma_addr, buf->size, DMA_FROM_DEVICE); dma_buf_put(dmabuf); } diff --git a/drivers/amlogic/media/gdc/app/gdc_module.c b/drivers/amlogic/media/gdc/app/gdc_module.c index 657cd40..c13693e 100644 --- a/drivers/amlogic/media/gdc/app/gdc_module.c +++ b/drivers/amlogic/media/gdc/app/gdc_module.c @@ -53,6 +53,9 @@ static const struct of_device_id gdc_dt_match[] = { {} }; MODULE_DEVICE_TABLE(of, gdc_dt_match); +static void meson_gdc_cache_flush(struct device *dev, + dma_addr_t addr, + size_t size); ////// static int meson_gdc_open(struct inode *inode, struct file *file) @@ -80,7 +83,7 @@ static int meson_gdc_open(struct inode *inode, struct file *file) fh->gdev = gdc_dev; - gdc_log(LOG_CRIT, "Success open\n"); + gdc_log(LOG_INFO, "Success open\n"); return rc; } @@ -146,7 +149,7 @@ static int meson_gdc_release(struct inode *inode, struct file *file) fh = NULL; if (ret == 0) - gdc_log(LOG_CRIT, "Success release\n"); + gdc_log(LOG_INFO, "Success release\n"); else gdc_log(LOG_ERR, "Error release\n"); @@ -181,6 +184,8 @@ static long meson_gdc_set_buff(void *f_fh, fh->o_paddr = page_to_phys(cma_pages); fh->o_kaddr = phys_to_virt(fh->o_paddr); fh->o_len = len; + meson_gdc_cache_flush(&fh->gdev->pdev->dev, + fh->o_paddr, fh->o_len); break; case CONFIG_BUFF_TYPE: if (fh->c_paddr != 0 && fh->c_kaddr != NULL) -- 2.7.4