From: kfx Date: Fri, 16 Dec 2011 02:32:41 +0000 (+0800) Subject: ion: flush cache X-Git-Tag: firefly_0821_release~9710^2~15 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=7932f134b873eb0fe10a69260e165fe617b32d18;p=firefly-linux-kernel-4.4.55.git ion: flush cache --- diff --git a/drivers/gpu/ion/ion.c b/drivers/gpu/ion/ion.c index b0fafdacb58c..16580a8f6ec2 100755 --- a/drivers/gpu/ion/ion.c +++ b/drivers/gpu/ion/ion.c @@ -31,6 +31,7 @@ #include #include +#include #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, ®ion, + if (copy_to_user((void __user *)arg, ®ion, + sizeof(struct pmem_region))) + return -EFAULT; + break; + } + case PMEM_CACHE_FLUSH: + { + struct pmem_region region; + if (copy_from_user(®ion, (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: diff --git a/drivers/gpu/ion/rockchip/rockchip_ion.c b/drivers/gpu/ion/rockchip/rockchip_ion.c index 20d3126d1268..3e8f86745e28 100755 --- a/drivers/gpu/ion/rockchip/rockchip_ion.c +++ b/drivers/gpu/ion/rockchip/rockchip_ion.c @@ -23,6 +23,11 @@ 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];