aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSundar Raman2013-04-23 17:39:34 -0500
committerSundar Raman2013-07-26 16:01:14 -0500
commit2474b61d8c1d217982a6caa76bea45e95568d5b3 (patch)
tree2f7edac2a0addd749ece099a9c59df60bcb523cc
parent473f405fbacba955b461a0f3c4cea09dfdf74980 (diff)
downloadkernel-video-2474b61d8c1d217982a6caa76bea45e95568d5b3.tar.gz
kernel-video-2474b61d8c1d217982a6caa76bea45e95568d5b3.tar.xz
kernel-video-2474b61d8c1d217982a6caa76bea45e95568d5b3.zip
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 <a0393242@ti.com>
-rw-r--r--drivers/gpu/ion/ion.c16
-rw-r--r--include/linux/ion.h16
2 files changed, 28 insertions, 4 deletions
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:
951} 951}
952EXPORT_SYMBOL(ion_import_dma_buf); 952EXPORT_SYMBOL(ion_import_dma_buf);
953 953
954static int ion_sync_for_device(struct ion_client *client, int fd) 954static int ion_sync_for_device(struct ion_client *client, int fd, enum ion_data_direction dir)
955{ 955{
956 struct dma_buf *dmabuf; 956 struct dma_buf *dmabuf;
957 struct ion_buffer *buffer; 957 struct ion_buffer *buffer;
@@ -969,8 +969,16 @@ static int ion_sync_for_device(struct ion_client *client, int fd)
969 } 969 }
970 buffer = dmabuf->priv; 970 buffer = dmabuf->priv;
971 971
972 dma_sync_sg_for_device(NULL, buffer->sg_table->sgl, 972 if(dir == ION_FROM_DEVICE)
973 buffer->sg_table->nents, DMA_BIDIRECTIONAL); 973 dma_sync_sg_for_device(NULL, buffer->sg_table->sgl,
974 buffer->sg_table->nents, DMA_FROM_DEVICE);
975 else if(dir == ION_TO_DEVICE)
976 dma_sync_sg_for_device(NULL, buffer->sg_table->sgl,
977 buffer->sg_table->nents, DMA_TO_DEVICE);
978 else if(dir == ION_BIDIRECTIONAL)
979 dma_sync_sg_for_device(NULL, buffer->sg_table->sgl,
980 buffer->sg_table->nents, DMA_BIDIRECTIONAL);
981
974 dma_buf_put(dmabuf); 982 dma_buf_put(dmabuf);
975 return 0; 983 return 0;
976} 984}
@@ -1053,7 +1061,7 @@ static long ion_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
1053 if (copy_from_user(&data, (void __user *)arg, 1061 if (copy_from_user(&data, (void __user *)arg,
1054 sizeof(struct ion_fd_data))) 1062 sizeof(struct ion_fd_data)))
1055 return -EFAULT; 1063 return -EFAULT;
1056 ion_sync_for_device(client, data.fd); 1064 ion_sync_for_device(client, data.fd, data.dir);
1057 break; 1065 break;
1058 } 1066 }
1059 case ION_IOC_CUSTOM: 1067 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 {
41 ION_NUM_HEAPS = 16, 41 ION_NUM_HEAPS = 16,
42}; 42};
43 43
44/**
45 * enum ion_data_direction - sync operation arguments
46 * @ION_BIDIRECTIONAL: memory written to & read from device
47 * @ION_TO_DEVICE: memory going to be transferred to device
48 * @ION_FROM_DEVICE: memory populated by device
49 * @ION_NONE: None of the above
50 */
51enum ion_data_direction {
52 ION_BIDIRECTIONAL = 0,
53 ION_TO_DEVICE = 1,
54 ION_FROM_DEVICE = 2,
55 ION_NONE = 3,
56};
57
58
44#define ION_HEAP_SYSTEM_MASK (1 << ION_HEAP_TYPE_SYSTEM) 59#define ION_HEAP_SYSTEM_MASK (1 << ION_HEAP_TYPE_SYSTEM)
45#define ION_HEAP_SYSTEM_CONTIG_MASK (1 << ION_HEAP_TYPE_SYSTEM_CONTIG) 60#define ION_HEAP_SYSTEM_CONTIG_MASK (1 << ION_HEAP_TYPE_SYSTEM_CONTIG)
46#define ION_HEAP_CARVEOUT_MASK (1 << ION_HEAP_TYPE_CARVEOUT) 61#define ION_HEAP_CARVEOUT_MASK (1 << ION_HEAP_TYPE_CARVEOUT)
@@ -273,6 +288,7 @@ struct ion_allocation_data {
273struct ion_fd_data { 288struct ion_fd_data {
274 struct ion_handle *handle; 289 struct ion_handle *handle;
275 int fd; 290 int fd;
291 enum ion_data_direction dir;
276}; 292};
277 293
278/** 294/**