ion: flush cache
authorkfx <kfx@rock-chips.com>
Fri, 16 Dec 2011 02:32:41 +0000 (10:32 +0800)
committerkfx <kfx@rock-chips.com>
Fri, 16 Dec 2011 02:32:41 +0000 (10:32 +0800)
drivers/gpu/ion/ion.c
drivers/gpu/ion/rockchip/rockchip_ion.c

index b0fafdacb58cc9e3e0184176966e458b261aa075..16580a8f6ec25d05472cf05ab00f267003474e0f 100755 (executable)
@@ -31,6 +31,7 @@
 #include <linux/debugfs.h>
 #include <linux/android_pmem.h>
 
+#include <asm/cacheflush.h>
 #include "ion_priv.h"
 #define DEBUG
 
@@ -908,15 +909,32 @@ err:
 static long ion_share_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 {
        struct ion_buffer *buffer = filp->private_data;
-       struct pmem_region region;
-
-       region.offset = buffer->priv_phys;
-       region.len = buffer->size;
+       
+       switch (cmd) {
+       case PMEM_GET_PHYS:
+       {
+               struct pmem_region region;
+               region.offset = buffer->priv_phys;
+               region.len = buffer->size;
 
-       if (copy_to_user((void __user *)arg, &region,
+               if (copy_to_user((void __user *)arg, &region,
+                               sizeof(struct pmem_region)))
+                       return -EFAULT;
+               break;
+       }
+       case PMEM_CACHE_FLUSH:
+       {
+               struct pmem_region region;
+               if (copy_from_user(&region, (void __user *)arg,
                                sizeof(struct pmem_region)))
-               return -EFAULT;
+                       return -EFAULT;
+               dmac_flush_range((void *)region.offset, (void *)(region.offset + region.len));
 
+               break;
+       }
+       default:
+               return -ENOTTY;
+       }
        return 0;
 }
 
@@ -965,6 +983,8 @@ static long ion_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
                                             data.flags);
                if (copy_to_user((void __user *)arg, &data, sizeof(data)))
                        return -EFAULT;
+               printk("%s: alloc 0x%x bytes, phy addr is 0x%lx\n",
+                       __func__, data.len, data.handle->buffer->priv_phys);
                break;
        }
        case ION_IOC_FREE:
index 20d3126d1268a1887b803b37865ee400cfd39080..3e8f86745e28b9b1dcfacf5d5c3e47ea2f41ccb8 100755 (executable)
 static int num_heaps;
 static struct ion_heap **heaps;
 
+static long rockchip_custom_ioctl (struct ion_client *client, unsigned int cmd,
+                             unsigned long arg)
+{
+       return 0;
+}
 static int rockchip_ion_probe(struct platform_device *pdev)
 {
     struct ion_device *idev;
@@ -33,12 +38,11 @@ static int rockchip_ion_probe(struct platform_device *pdev)
        num_heaps = pdata->nr;
        heaps = kzalloc(sizeof(struct ion_heap *) * pdata->nr, GFP_KERNEL);
 
-       idev = ion_device_create(NULL);
+       idev = ion_device_create(rockchip_custom_ioctl);
        if (IS_ERR_OR_NULL(idev)) {
                kfree(heaps);
                return PTR_ERR(idev);
        }
-
        /* create the heaps as specified in the board file */
        for (i = 0; i < num_heaps; i++) {
                struct ion_platform_heap *heap_data = &pdata->heaps[i];