From: Sundar Raman Date: Tue, 23 Apr 2013 22:39:34 +0000 (-0500) Subject: gpu: ion: add support for more cache operations X-Git-Tag: android-3.8-6AJ.1.1~17^2^2 X-Git-Url: https://git.ti.com/gitweb?p=android-sdk%2Fkernel-video.git;a=commitdiff_plain;h=2474b61d8c1d217982a6caa76bea45e95568d5b3;ds=inline gpu: ion: add support for more cache operations Enhance ion_sync_for_device to take in cache direction Change-Id: I78bef9c2b5cc461b5f49c6019d031a15ce1a36de Signed-off-by: Sundar Raman --- diff --git a/drivers/gpu/ion/ion.c b/drivers/gpu/ion/ion.c index 8f477880f04..d7c780ff35b 100644 --- a/drivers/gpu/ion/ion.c +++ b/drivers/gpu/ion/ion.c @@ -951,7 +951,7 @@ end: } EXPORT_SYMBOL(ion_import_dma_buf); -static int ion_sync_for_device(struct ion_client *client, int fd) +static int ion_sync_for_device(struct ion_client *client, int fd, enum ion_data_direction dir) { struct dma_buf *dmabuf; struct ion_buffer *buffer; @@ -969,8 +969,16 @@ static int ion_sync_for_device(struct ion_client *client, int fd) } buffer = dmabuf->priv; - dma_sync_sg_for_device(NULL, buffer->sg_table->sgl, - buffer->sg_table->nents, DMA_BIDIRECTIONAL); + if(dir == ION_FROM_DEVICE) + dma_sync_sg_for_device(NULL, buffer->sg_table->sgl, + buffer->sg_table->nents, DMA_FROM_DEVICE); + else if(dir == ION_TO_DEVICE) + dma_sync_sg_for_device(NULL, buffer->sg_table->sgl, + buffer->sg_table->nents, DMA_TO_DEVICE); + else if(dir == ION_BIDIRECTIONAL) + dma_sync_sg_for_device(NULL, buffer->sg_table->sgl, + buffer->sg_table->nents, DMA_BIDIRECTIONAL); + dma_buf_put(dmabuf); return 0; } @@ -1053,7 +1061,7 @@ static long ion_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) if (copy_from_user(&data, (void __user *)arg, sizeof(struct ion_fd_data))) return -EFAULT; - ion_sync_for_device(client, data.fd); + ion_sync_for_device(client, data.fd, data.dir); break; } case ION_IOC_CUSTOM: diff --git a/include/linux/ion.h b/include/linux/ion.h index a55d11fbcbd..31045a150dc 100644 --- a/include/linux/ion.h +++ b/include/linux/ion.h @@ -41,6 +41,21 @@ enum ion_heap_type { ION_NUM_HEAPS = 16, }; +/** + * enum ion_data_direction - sync operation arguments + * @ION_BIDIRECTIONAL: memory written to & read from device + * @ION_TO_DEVICE: memory going to be transferred to device + * @ION_FROM_DEVICE: memory populated by device + * @ION_NONE: None of the above + */ +enum ion_data_direction { + ION_BIDIRECTIONAL = 0, + ION_TO_DEVICE = 1, + ION_FROM_DEVICE = 2, + ION_NONE = 3, +}; + + #define ION_HEAP_SYSTEM_MASK (1 << ION_HEAP_TYPE_SYSTEM) #define ION_HEAP_SYSTEM_CONTIG_MASK (1 << ION_HEAP_TYPE_SYSTEM_CONTIG) #define ION_HEAP_CARVEOUT_MASK (1 << ION_HEAP_TYPE_CARVEOUT) @@ -273,6 +288,7 @@ struct ion_allocation_data { struct ion_fd_data { struct ion_handle *handle; int fd; + enum ion_data_direction dir; }; /**