Add an IOCTL to check ION ABI version

Userspace needs a way to detect ION ABI version at runtime to determine
heap IDs. CURRENT_ION_ABI_VERSION is set to 2 considering legacy and
upstream versions as 0 and 1.

Bug: 140916230
Test: make

Signed-off-by: Hridya Valsaraju <hridya@google.com>

Change-Id: Ie9d9e23c2d8323620832906d33745d599cbce6be
This commit is contained in:
Hridya Valsaraju
2019-10-02 14:32:19 -07:00
parent c8e152bc7d
commit ecbdae8679
2 changed files with 13 additions and 0 deletions

View File

@@ -27,6 +27,8 @@
#include "ion_private.h"
#define ION_CURRENT_ABI_VERSION 2
static struct ion_device *internal_dev;
/* Entry into ION allocator for rest of the kernel */
@@ -108,6 +110,7 @@ out:
union ion_ioctl_arg {
struct ion_allocation_data allocation;
struct ion_heap_query query;
u32 ion_abi_version;
};
static int validate_ioctl_arg(unsigned int cmd, union ion_ioctl_arg *arg)
@@ -169,6 +172,9 @@ static long ion_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
case ION_IOC_HEAP_QUERY:
ret = ion_query_heaps(&data.query);
break;
case ION_IOC_ABI_VERSION:
data.ion_abi_version = ION_CURRENT_ABI_VERSION;
break;
default:
return -ENOTTY;
}

View File

@@ -159,4 +159,11 @@ struct ion_heap_query {
#define ION_IOC_HEAP_QUERY _IOWR(ION_IOC_MAGIC, 8, \
struct ion_heap_query)
/**
* DOC: ION_IOC_HEAP_ABI_VERSION - return ABI version
*
* Returns ABI version for this driver
*/
#define ION_IOC_ABI_VERSION _IOR(ION_IOC_MAGIC, 9, \
__u32)
#endif /* _UAPI_LINUX_ION_H */