gpu: ion: add support for more cache operations
authorSundar Raman <a0393242@ti.com>
Tue, 23 Apr 2013 22:39:34 +0000 (17:39 -0500)
committerSundar Raman <a0393242@ti.com>
Fri, 26 Jul 2013 21:01:14 +0000 (16:01 -0500)
Enhance ion_sync_for_device to take in cache direction

Change-Id: I78bef9c2b5cc461b5f49c6019d031a15ce1a36de
Signed-off-by: Sundar Raman <a0393242@ti.com>
drivers/gpu/ion/ion.c
include/linux/ion.h

index 8f477880f040fe5985617acedd617bce7c988a7c..d7c780ff35b445d06a005f10472d268d5b2fd688 100644 (file)
@@ -951,7 +951,7 @@ end:
 }
 EXPORT_SYMBOL(ion_import_dma_buf);
 
 }
 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;
 {
        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;
 
        }
        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;
 }
        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;
                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:
                break;
        }
        case ION_IOC_CUSTOM:
index a55d11fbcbd598d5cf73562fc9b03ede2ee2ed74..31045a150dc5c8ab22a6898dc3f8043838c66be6 100644 (file)
@@ -41,6 +41,21 @@ enum ion_heap_type {
        ION_NUM_HEAPS = 16,
 };
 
        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)
 #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;
 struct ion_fd_data {
        struct ion_handle *handle;
        int fd;
+       enum ion_data_direction dir;
 };
 
 /**
 };
 
 /**