From 18fe52158320b35415207b8da4ac100af71670eb Mon Sep 17 00:00:00 2001 From: "Isaac J. Manjarres" Date: Thu, 19 Sep 2019 10:29:28 -0700 Subject: [PATCH] ion: msm: Update the heap IDs as per the ION core standards Update the heap IDs as per the standard imposed by the ION core (i.e.): SYSTEM_HEAP: (1 << 0) SYSTEM_CONTIG_HEAP: (1 << 1) CARVEOUT_HEAPS: [(1 << 2), (1 << 6)] CHUNK_HEAP: (1 << 7) CMA_HEAPS: [(1 << 8), (1 << 15)] VENDOR_HEAPS: [(1 << 16), (1 << 31)] Since the heap IDs are now bitmasks, as opposed to offsets within a bitmask, update the userspace ION_HEAP() macro/as well as the heap ID treatment in the kernel to account for this as well. Change-Id: I6b7ca1caf89dda03dfb499a362db863168c2753c Signed-off-by: Isaac J. Manjarres --- .../staging/android/ion/heaps/msm_ion_of.c | 2 ++ include/uapi/linux/msm_ion.h | 8 ++---- include/uapi/linux/msm_ion_ids.h | 28 ++++++++++--------- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/drivers/staging/android/ion/heaps/msm_ion_of.c b/drivers/staging/android/ion/heaps/msm_ion_of.c index dea9a4fd8195..bdeea44e0995 100644 --- a/drivers/staging/android/ion/heaps/msm_ion_of.c +++ b/drivers/staging/android/ion/heaps/msm_ion_of.c @@ -408,6 +408,8 @@ struct ion_heap *get_ion_heap(int heap_id) int i; struct ion_heap *heap; + heap_id = __ffs(heap_id); + for (i = 0; i < num_heaps; i++) { heap = heaps[i]; if (heap && heap->id == heap_id) diff --git a/include/uapi/linux/msm_ion.h b/include/uapi/linux/msm_ion.h index a3177803bc5f..a289bbeb99ee 100644 --- a/include/uapi/linux/msm_ion.h +++ b/include/uapi/linux/msm_ion.h @@ -8,8 +8,6 @@ #include #include -#define ION_BIT(nr) (1U << (nr)) - /** * TARGET_ION_ABI_VERSION can be used by user space clients to ensure that at * compile time only their code which uses the appropriate ION APIs for @@ -18,7 +16,7 @@ #define TARGET_ION_ABI_VERSION 2 enum msm_ion_heap_types { - ION_HEAP_TYPE_MSM_START = 6, + ION_HEAP_TYPE_MSM_START = 16, ION_HEAP_TYPE_SECURE_DMA = ION_HEAP_TYPE_MSM_START, ION_HEAP_TYPE_SYSTEM_SECURE, ION_HEAP_TYPE_HYP_CMA, @@ -56,7 +54,7 @@ enum msm_ion_heap_types { * Flag to use when allocating to indicate that a heap is secure. * Do NOT use BIT macro since it is defined in #ifdef __KERNEL__ */ -#define ION_FLAG_SECURE ION_BIT(ION_HEAP_ID_RESERVED) +#define ION_FLAG_SECURE ION_BIT(31) /* * Used in conjunction with heap which pool memory to force an allocation @@ -67,7 +65,7 @@ enum msm_ion_heap_types { /** * Macro should be used with ion_heap_ids defined above. */ -#define ION_HEAP(bit) ION_BIT(bit) +#define ION_HEAP(bit) bit #define ION_IOC_MSM_MAGIC 'M' diff --git a/include/uapi/linux/msm_ion_ids.h b/include/uapi/linux/msm_ion_ids.h index 0be6cc740a35..0baf49a26fbb 100644 --- a/include/uapi/linux/msm_ion_ids.h +++ b/include/uapi/linux/msm_ion_ids.h @@ -5,6 +5,8 @@ #ifndef _MSM_ION_IDS_H #define _MSM_ION_IDS_H +#define ION_BIT(nr) (1U << (nr)) + /** * These are the only ids that should be used for Ion heap ids. * The ids listed are the order in which allocation will be attempted @@ -14,18 +16,18 @@ * possible fallbacks) */ -#define ION_CP_MM_HEAP_ID 8 -#define ION_SECURE_HEAP_ID 9 -#define ION_SECURE_DISPLAY_HEAP_ID 10 -#define ION_SPSS_HEAP_ID 13 -#define ION_SECURE_CARVEOUT_HEAP_ID 14 -#define ION_QSECOM_TA_HEAP_ID 19 -#define ION_CAMERA_HEAP_ID 20 -#define ION_ADSP_HEAP_ID 22 -#define ION_SYSTEM_HEAP_ID 25 -#define ION_USER_CONTIG_HEAP_ID 26 -#define ION_QSECOM_HEAP_ID 27 -#define ION_AUDIO_HEAP_ID 28 -#define ION_HEAP_ID_RESERVED 31 +#define ION_SYSTEM_HEAP_ID ION_BIT(0) +#define ION_QSECOM_TA_HEAP_ID ION_BIT(8) +#define ION_CAMERA_HEAP_ID ION_BIT(9) +#define ION_ADSP_HEAP_ID ION_BIT(11) +#define ION_USER_CONTIG_HEAP_ID ION_BIT(13) +#define ION_QSECOM_HEAP_ID ION_BIT(14) +#define ION_AUDIO_HEAP_ID ION_BIT(15) +#define ION_CP_MM_HEAP_ID ION_BIT(16) +#define ION_SECURE_HEAP_ID ION_BIT(17) +#define ION_SECURE_DISPLAY_HEAP_ID ION_BIT(18) +#define ION_SPSS_HEAP_ID ION_BIT(21) +#define ION_SECURE_CARVEOUT_HEAP_ID ION_BIT(22) +#define ION_HEAP_ID_RESERVED ION_BIT(31) #endif /* _MSM_ION_IDS_H */