| From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
| From: Hridya Valsaraju <hridya@google.com> |
| Date: Wed, 2 Oct 2019 14:32:19 -0700 |
| Subject: ANDROID: 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 |
| --- |
| drivers/staging/android/ion/ion.c | 6 ++++++ |
| include/uapi/linux/ion.h | 7 +++++++ |
| 2 files changed, 13 insertions(+) |
| |
| diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c |
| index 68091d17cfb8..1f9096f13877 100644 |
| --- a/drivers/staging/android/ion/ion.c |
| +++ b/drivers/staging/android/ion/ion.c |
| @@ -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 @@ static int ion_query_heaps(struct ion_heap_query *query) |
| 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; |
| } |
| diff --git a/include/uapi/linux/ion.h b/include/uapi/linux/ion.h |
| index ad773e5fa4d2..fdb2eba7f500 100644 |
| --- a/include/uapi/linux/ion.h |
| +++ b/include/uapi/linux/ion.h |
| @@ -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 */ |