From 2b78a1e4274490ac9e6d1fefa7cb8ea7507ac253 Mon Sep 17 00:00:00 2001 From: Liam Mark Date: Thu, 2 May 2019 09:50:12 -0700 Subject: [PATCH] ion: msm: Expose ION API to query buffer VM information Allow ION clients to be able to determine the VM information associated with an ION buffer, such as the VMIDs it is assigned to as well as the VM permissions. Change-Id: Id0be0b505bc84beff373e4e2ae16b71ec4f09d43 Signed-off-by: Liam Mark [isaacm@codeaurora.org: Relocate changes to new header locations] Signed-off-by: Isaac J. Manjarres --- .../android/ion/heaps/ion_secure_util.c | 1 + include/linux/msm_ion.h | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/drivers/staging/android/ion/heaps/ion_secure_util.c b/drivers/staging/android/ion/heaps/ion_secure_util.c index 66d537713158..61e8ca0a2a30 100644 --- a/drivers/staging/android/ion/heaps/ion_secure_util.c +++ b/drivers/staging/android/ion/heaps/ion_secure_util.c @@ -90,6 +90,7 @@ int ion_populate_vm_list(unsigned long flags, unsigned int *vm_list, } return 0; } +EXPORT_SYMBOL(ion_populate_vm_list); int ion_hyp_unassign_sg(struct sg_table *sgt, int *source_vm_list, int source_nelems, bool clear_page_private) diff --git a/include/linux/msm_ion.h b/include/linux/msm_ion.h index cb2482f5fb48..b3233c394909 100644 --- a/include/linux/msm_ion.h +++ b/include/linux/msm_ion.h @@ -6,6 +6,7 @@ #ifndef _MSM_ION_H #define _MSM_ION_H +#include #include #include @@ -13,6 +14,16 @@ struct device *msm_ion_heap_device_by_id(int heap_id); +static inline unsigned int ion_get_flags_num_vm_elems(unsigned int flags) +{ + unsigned long vm_flags = flags & ION_FLAGS_CP_MASK; + + return ((unsigned int)bitmap_weight(&vm_flags, BITS_PER_LONG)); +} + +int ion_populate_vm_list(unsigned long flags, unsigned int *vm_list, + int nelems); + #else static inline struct device *msm_ion_heap_device_by_id(int heap_id) @@ -20,5 +31,16 @@ static inline struct device *msm_ion_heap_device_by_id(int heap_id) return ERR_PTR(-ENODEV); } +static inline unsigned int ion_get_flags_num_vm_elems(unsigned int flags) +{ + return 0; +} + +static inline int ion_populate_vm_list(unsigned long flags, + unsigned int *vm_list, int nelems) +{ + return -EINVAL; +} + #endif /* CONFIG_ION_MSM_HEAPS */ #endif /* _MSM_ION_H */