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 <pengcheng.chen@amlogic.com>
This commit is contained in:
Pengcheng Chen
2019-03-11 17:48:52 +08:00
committed by Tao Zeng
parent 3ae164f020
commit 6ffc87c3cf
3 changed files with 21 additions and 6 deletions

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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)