case ION_IOC_SYNC:
return filp->f_op->unlocked_ioctl(filp, cmd,
(unsigned long)compat_ptr(arg));
+#ifdef CONFIG_AMLOGIC_MODIFY
+ case ION_IOC_INVALID_CACHE:
+ return filp->f_op->unlocked_ioctl(filp, cmd,
+ (unsigned long)compat_ptr(arg));
+#endif
default:
return -ENOIOCTLCMD;
}
case ION_IOC_FREE:
case ION_IOC_CUSTOM:
return _IOC_WRITE;
+#ifdef CONFIG_AMLOGIC_MODIFY
+ case ION_IOC_INVALID_CACHE:
+ return _IOC_WRITE;
+#endif
default:
return _IOC_DIR(cmd);
}
ret = ion_sync_for_device(client, data.fd.fd);
break;
}
+#ifdef CONFIG_AMLOGIC_MODIFY
+ case ION_IOC_INVALID_CACHE:
+ {
+ ret = ion_sync_for_cpu(client, data.fd.fd);
+ break;
+ }
+#endif
case ION_IOC_CUSTOM:
{
if (!dev->custom_ioctl)
#include "ion.h"
#include "ion_priv.h"
#include "compat_ion.h"
+#ifdef CONFIG_AMLOGIC_MODIFY
+#include <linux/of_device.h>
+#endif
bool ion_buffer_fault_user_mappings(struct ion_buffer *buffer)
{
return 0;
}
+#ifdef CONFIG_AMLOGIC_MODIFY
+int ion_sync_for_cpu(struct ion_client *client, int fd)
+{
+ struct dma_buf *dmabuf;
+ struct ion_buffer *buffer;
+ struct miscdevice *mdev;
+
+ dmabuf = dma_buf_get(fd);
+ if (IS_ERR(dmabuf))
+ return PTR_ERR(dmabuf);
+
+ /* if this memory came from ion */
+ if (dmabuf->ops != &dma_buf_ops) {
+ pr_err("%s: can not sync dmabuf from another exporter\n",
+ __func__);
+ dma_buf_put(dmabuf);
+ return -EINVAL;
+ }
+ buffer = dmabuf->priv;
+ mdev = &client->dev->dev;
+
+ dma_sync_sg_for_cpu(mdev->this_device,
+ buffer->sg_table->sgl,
+ buffer->sg_table->nents,
+ DMA_FROM_DEVICE);
+
+ dma_buf_put(dmabuf);
+
+ return 0;
+}
+#endif
+
int ion_query_heaps(struct ion_client *client, struct ion_heap_query *query)
{
struct ion_device *dev = client->dev;
{
struct ion_device *idev;
int ret;
-
+#ifdef CONFIG_AMLOGIC_MODIFY
+ struct miscdevice *mdev;
+#endif
idev = kzalloc(sizeof(*idev), GFP_KERNEL);
if (!idev)
return ERR_PTR(-ENOMEM);
kfree(idev);
return ERR_PTR(ret);
}
-
+#ifdef CONFIG_AMLOGIC_MODIFY
+ mdev = &idev->dev;
+ of_dma_configure(mdev->this_device, mdev->this_device->of_node);
+#endif
idev->debug_root = debugfs_create_dir("ion", NULL);
if (!idev->debug_root) {
pr_err("ion: failed to create debugfs root directory.\n");
int ion_sync_for_device(struct ion_client *client, int fd);
+#ifdef CONFIG_AMLOGIC_MODIFY
+int ion_sync_for_cpu(struct ion_client *client, int fd);
+#endif
+
struct ion_handle *ion_handle_get_by_id_nolock(struct ion_client *client,
int id);
#define ION_IOC_HEAP_QUERY _IOWR(ION_IOC_MAGIC, 8, \
struct ion_heap_query)
+#ifdef CONFIG_AMLOGIC_MODIFY
+/**
+ * DOC: ION_IOC_INVALID_CACHE - invalid cache before
+ * cpu read the memory and after device write the memory.
+ * this will make the buffer in memory coherent.
+ */
+#define ION_IOC_INVALID_CACHE _IOWR(ION_IOC_MAGIC, 9, struct ion_fd_data)
+#endif
+
#endif /* _UAPI_LINUX_ION_H */