ion: ioctl compatibility with userland using old api
As far as I can tell, flags passed by userland are now used to determine
buffer caching.
Note in ION_IOC_ALLOC_COMPAT we are currently forcing uncached buffer
allocations (needed to make a choice here). This
may need to change.
Signed-off-by: Flemmard <flemmard@gmail.com>
diff --git a/include/linux/ion.h b/include/linux/ion.h
index 7fee5ff..c56faa4 100644
--- a/include/linux/ion.h
+++ b/include/linux/ion.h
@@ -515,6 +515,13 @@
struct ion_handle *handle;
};
+
+struct ion_allocation_data_compat {
+ size_t len;
+ size_t align;
+ unsigned int flags;
+ struct ion_handle *handle;
+};
/**
* struct ion_fd_data - metadata passed to/from userspace for a handle/fd pair
* @handle: a handle
@@ -550,6 +557,19 @@
unsigned int cmd;
unsigned long arg;
};
+
+struct ion_flush_data {
+ struct ion_handle *handle;
+ int fd;
+ void *vaddr;
+ unsigned int offset;
+ unsigned int length;
+};
+struct ion_flag_data {
+ struct ion_handle *handle;
+ unsigned long flags;
+};
+
#define ION_IOC_MAGIC 'I'
/**
@@ -561,6 +581,9 @@
#define ION_IOC_ALLOC _IOWR(ION_IOC_MAGIC, 0, \
struct ion_allocation_data)
+
+#define ION_IOC_ALLOC_COMPAT _IOWR(ION_IOC_MAGIC, 0, \
+ struct ion_allocation_data_compat)
/**
* DOC: ION_IOC_FREE - free memory
*
@@ -597,6 +620,7 @@
* filed set to the corresponding opaque handle.
*/
#define ION_IOC_IMPORT _IOWR(ION_IOC_MAGIC, 5, struct ion_fd_data)
+#define ION_IOC_IMPORT_COMPAT _IOWR(ION_IOC_MAGIC, 5, int)
/**
* DOC: ION_IOC_CUSTOM - call architecture specific ion ioctl
@@ -606,5 +630,13 @@
*/
#define ION_IOC_CUSTOM _IOWR(ION_IOC_MAGIC, 6, struct ion_custom_data)
+#define ION_IOC_CLEAN_CACHES_COMPAT _IOWR(ION_IOC_MAGIC, 7, \
+ struct ion_flush_data)
+#define ION_IOC_INV_CACHES_COMPAT _IOWR(ION_IOC_MAGIC, 8, \
+ struct ion_flush_data)
+#define ION_IOC_CLEAN_INV_CACHES_COMPAT _IOWR(ION_IOC_MAGIC, 9, \
+ struct ion_flush_data)
+#define ION_IOC_GET_FLAGS_COMPAT _IOWR(ION_IOC_MAGIC, 10, \
+ struct ion_flag_data)
#endif /* _LINUX_ION_H */
diff --git a/include/linux/msm_ion.h b/include/linux/msm_ion.h
index 86dd70a..1437bfa 100644
--- a/include/linux/msm_ion.h
+++ b/include/linux/msm_ion.h
@@ -91,6 +91,17 @@
* Macro should be used with ion_heap_ids defined above.
*/
#define ION_HEAP(bit) (1 << (bit))
+#define ion_full_heap_mask (ION_HEAP(ION_CP_MM_HEAP_ID) | \
+ ION_HEAP(ION_CP_MFC_HEAP_ID) | \
+ ION_HEAP(ION_CP_WB_HEAP_ID) | \
+ ION_HEAP(ION_CAMERA_HEAP_ID) | \
+ ION_HEAP(ION_SF_HEAP_ID) | \
+ ION_HEAP(ION_IOMMU_HEAP_ID) | \
+ ION_HEAP(ION_QSECOM_HEAP_ID) | \
+ ION_HEAP(ION_AUDIO_HEAP_ID) | \
+ ION_HEAP(ION_MM_FIRMWARE_HEAP_ID) | \
+ ION_HEAP(ION_SYSTEM_HEAP_ID) )
+
#define ION_ADSP_HEAP_NAME "adsp"
#define ION_VMALLOC_HEAP_NAME "vmalloc"
@@ -274,6 +285,7 @@
* of the handle, p + offset through p + offset + length will have
* the cache operations performed
*/
+/*
struct ion_flush_data {
struct ion_handle *handle;
int fd;
@@ -281,7 +293,7 @@
unsigned int offset;
unsigned int length;
};
-
+*/
/* struct ion_flag_data - information about flags for this buffer
*
* @handle: handle to get flags from
@@ -290,11 +302,12 @@
* Takes handle as an input and outputs the flags from the handle
* in the flag field.
*/
+/*
struct ion_flag_data {
struct ion_handle *handle;
unsigned long flags;
};
-
+*/
#define ION_IOC_MSM_MAGIC 'M'
/**
@@ -304,6 +317,7 @@
*/
#define ION_IOC_CLEAN_CACHES _IOWR(ION_IOC_MSM_MAGIC, 0, \
struct ion_flush_data)
+
/**
* DOC: ION_IOC_INV_CACHES - invalidate the caches
*
@@ -327,5 +341,4 @@
*/
#define ION_IOC_GET_FLAGS _IOWR(ION_IOC_MSM_MAGIC, 3, \
struct ion_flag_data)
-
#endif