From 36a650119d97d4ea43eaed76cb956ee15aaed87e Mon Sep 17 00:00:00 2001 From: Joey Date: Thu, 15 Jan 2026 20:49:46 +0100 Subject: [PATCH] kernel: fix legacy ION UAPI include paths The ION staging drivers still reference legacy relative UAPI paths (../uapi/ion.h and ../uapi/msm_ion.h) which no longer exist in modern Android kernels. Update all ION sources to include the canonical UAPI headers from include/uapi/linux instead. This aligns the tree with upstream Android kernel behavior and fixes build failures when using modern toolchains. --- drivers/staging/android/ion/ion.h | 4 +- drivers/staging/android/ion/ion_kernel.h | 2 +- drivers/staging/android/uapi/ion.h | 135 ---------------------- drivers/staging/android/uapi/msm_ion.h | 124 --------------------- include/uapi/linux/ion.h | 136 ++++++++++++++++++++++- include/uapi/linux/msm_ion.h | 125 ++++++++++++++++++++- 6 files changed, 262 insertions(+), 264 deletions(-) delete mode 100644 drivers/staging/android/uapi/ion.h delete mode 100644 drivers/staging/android/uapi/msm_ion.h mode change 120000 => 100644 include/uapi/linux/ion.h mode change 120000 => 100644 include/uapi/linux/msm_ion.h diff --git a/drivers/staging/android/ion/ion.h b/drivers/staging/android/ion/ion.h index f8f9b1397dde..c97bae546ecd 100644 --- a/drivers/staging/android/ion/ion.h +++ b/drivers/staging/android/ion/ion.h @@ -31,8 +31,8 @@ #include #include #include "ion_kernel.h" -#include "../uapi/ion.h" -#include "../uapi/msm_ion.h" +#include +#include #define ION_ADSP_HEAP_NAME "adsp" #define ION_SYSTEM_HEAP_NAME "system" diff --git a/drivers/staging/android/ion/ion_kernel.h b/drivers/staging/android/ion/ion_kernel.h index bfafbeee98a8..f32d01224b35 100644 --- a/drivers/staging/android/ion/ion_kernel.h +++ b/drivers/staging/android/ion/ion_kernel.h @@ -14,7 +14,7 @@ #define _ION_KERNEL_H #include -#include "../uapi/ion.h" +#include #ifdef CONFIG_ION diff --git a/drivers/staging/android/uapi/ion.h b/drivers/staging/android/uapi/ion.h deleted file mode 100644 index c2fb628e12da..000000000000 --- a/drivers/staging/android/uapi/ion.h +++ /dev/null @@ -1,135 +0,0 @@ -/* - * drivers/staging/android/uapi/ion.h - * - * Copyright (C) 2011 Google, Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - */ - -#ifndef _UAPI_LINUX_ION_H -#define _UAPI_LINUX_ION_H - -#include -#include - -/** - * enum ion_heap_types - list of all possible types of heaps - * @ION_HEAP_TYPE_SYSTEM: memory allocated via vmalloc - * @ION_HEAP_TYPE_SYSTEM_CONTIG: memory allocated via kmalloc - * @ION_HEAP_TYPE_CARVEOUT: memory allocated from a prereserved - * carveout heap, allocations are physically - * contiguous - * @ION_HEAP_TYPE_DMA: memory allocated via DMA API - * @ION_NUM_HEAPS: helper for iterating over heaps, a bit mask - * is used to identify the heaps, so only 32 - * total heap types are supported - */ -enum ion_heap_type { - ION_HEAP_TYPE_SYSTEM, - ION_HEAP_TYPE_SYSTEM_CONTIG, - ION_HEAP_TYPE_CARVEOUT, - ION_HEAP_TYPE_CHUNK, - ION_HEAP_TYPE_DMA, - ION_HEAP_TYPE_CUSTOM, /* - * must be last so device specific heaps always - * are at the end of this enum - */ -}; - -#define ION_NUM_HEAP_IDS (sizeof(unsigned int) * 8) - -/** - * allocation flags - the lower 16 bits are used by core ion, the upper 16 - * bits are reserved for use by the heaps themselves. - */ - -/* - * mappings of this buffer should be cached, ion will do cache maintenance - * when the buffer is mapped for dma - */ -#define ION_FLAG_CACHED 1 - -/** - * DOC: Ion Userspace API - * - * create a client by opening /dev/ion - * most operations handled via following ioctls - * - */ - -/** - * struct ion_allocation_data - metadata passed from userspace for allocations - * @len: size of the allocation - * @heap_id_mask: mask of heap ids to allocate from - * @flags: flags passed to heap - * @handle: pointer that will be populated with a cookie to use to - * refer to this allocation - * - * Provided by userspace as an argument to the ioctl - */ -struct ion_allocation_data { - __u64 len; - __u32 heap_id_mask; - __u32 flags; - __u32 fd; - __u32 unused; -}; - -#define MAX_HEAP_NAME 32 - -/** - * struct ion_heap_data - data about a heap - * @name - first 32 characters of the heap name - * @type - heap type - * @heap_id - heap id for the heap - */ -struct ion_heap_data { - char name[MAX_HEAP_NAME]; - __u32 type; - __u32 heap_id; - __u32 reserved0; - __u32 reserved1; - __u32 reserved2; -}; - -/** - * struct ion_heap_query - collection of data about all heaps - * @cnt - total number of heaps to be copied - * @heaps - buffer to copy heap data - */ -struct ion_heap_query { - __u32 cnt; /* Total number of heaps to be copied */ - __u32 reserved0; /* align to 64bits */ - __u64 heaps; /* buffer to be populated */ - __u32 reserved1; - __u32 reserved2; -}; - -#define ION_IOC_MAGIC 'I' - -/** - * DOC: ION_IOC_ALLOC - allocate memory - * - * Takes an ion_allocation_data struct and returns it with the handle field - * populated with the opaque handle for the allocation. - */ -#define ION_IOC_ALLOC _IOWR(ION_IOC_MAGIC, 0, \ - struct ion_allocation_data) -/** - * DOC: ION_IOC_HEAP_QUERY - information about available heaps - * - * Takes an ion_heap_query structure and populates information about - * available Ion heaps. - */ -#define ION_IOC_HEAP_QUERY _IOWR(ION_IOC_MAGIC, 8, \ - struct ion_heap_query) - -#endif /* _UAPI_LINUX_ION_H */ diff --git a/drivers/staging/android/uapi/msm_ion.h b/drivers/staging/android/uapi/msm_ion.h deleted file mode 100644 index 4352bd24f331..000000000000 --- a/drivers/staging/android/uapi/msm_ion.h +++ /dev/null @@ -1,124 +0,0 @@ -#ifndef _UAPI_LINUX_MSM_ION_H -#define _UAPI_LINUX_MSM_ION_H - -#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 - * this kernel is included. - */ -#define TARGET_ION_ABI_VERSION 2 - -enum msm_ion_heap_types { - ION_HEAP_TYPE_MSM_START = 6, - ION_HEAP_TYPE_SECURE_DMA = ION_HEAP_TYPE_MSM_START, - ION_HEAP_TYPE_SYSTEM_SECURE, - ION_HEAP_TYPE_HYP_CMA, - ION_HEAP_TYPE_SECURE_CARVEOUT, -}; - -/** - * 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 - * if specified. Don't swap the order of heap ids unless you know what - * you are doing! - * Id's are spaced by purpose to allow new Id's to be inserted in-between (for - * possible fallbacks) - */ - -enum ion_heap_ids { - INVALID_HEAP_ID = -1, - ION_CP_MM_HEAP_ID = 8, - ION_SECURE_HEAP_ID = 9, - ION_SECURE_DISPLAY_HEAP_ID = 10, - ION_VIDEO_HEAP_ID = 12, - ION_SPSS_HEAP_ID = 13, /* Secure Processor ION heap */ - ION_NON_PIXEL_HEAP_ID = 15, - ION_ADSP_HEAP_ID = 22, - ION_SYSTEM_HEAP_ID = 25, - ION_QSECOM_HEAP_ID = 27, - ION_HEAP_ID_RESERVED = 31 /** Bit reserved for ION_FLAG_SECURE flag */ -}; - -/** - * Newly added heap ids have to be #define(d) since all API changes must - * include a new #define. - */ -#define ION_SECURE_CARVEOUT_HEAP_ID 14 -#define ION_QSECOM_TA_HEAP_ID 19 -#define ION_AUDIO_HEAP_ID 28 -#define ION_CAMERA_HEAP_ID 20 -#define ION_USER_CONTIG_HEAP_ID 26 -/** - * Flags to be used when allocating from the secure heap for - * content protection - */ -#define ION_FLAG_CP_CAMERA_ENCODE ION_BIT(14) -#define ION_FLAG_CP_DSP_EXT ION_BIT(15) -/* ION_FLAG_POOL_FORCE_ALLOC uses ION_BIT(16) */ -#define ION_FLAG_CP_TOUCH ION_BIT(17) -#define ION_FLAG_CP_BITSTREAM ION_BIT(18) -#define ION_FLAG_CP_PIXEL ION_BIT(19) -#define ION_FLAG_CP_NON_PIXEL ION_BIT(20) -#define ION_FLAG_CP_CAMERA ION_BIT(21) -#define ION_FLAG_CP_HLOS ION_BIT(22) -#define ION_FLAG_CP_SPSS_SP ION_BIT(23) -#define ION_FLAG_CP_SPSS_SP_SHARED ION_BIT(24) -#define ION_FLAG_CP_SEC_DISPLAY ION_BIT(25) -#define ION_FLAG_CP_APP ION_BIT(26) -#define ION_FLAG_CP_CAMERA_PREVIEW ION_BIT(27) -/* ION_FLAG_ALLOW_NON_CONTIG uses ION_BIT(28) */ -#define ION_FLAG_CP_CDSP ION_BIT(29) -#define ION_FLAG_CP_SPSS_HLOS_SHARED ION_BIT(30) -/* ION_FLAG_SECURE uses ION_BIT(31) */ - -#define ION_FLAGS_CP_MASK 0x6FFEC000 - -/** - * Flag to allow non continguous allocation of memory from secure - * heap - */ -#define ION_FLAG_ALLOW_NON_CONTIG ION_BIT(28) - -/** - * 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) - -/* - * Used in conjunction with heap which pool memory to force an allocation - * to come from the page allocator directly instead of from the pool allocation - */ -#define ION_FLAG_POOL_FORCE_ALLOC ION_BIT(16) - -/** - * Macro should be used with ion_heap_ids defined above. - */ -#define ION_HEAP(bit) ION_BIT(bit) - -#define ION_IOC_MSM_MAGIC 'M' - -struct ion_prefetch_regions { - __u64 sizes; - __u32 vmid; - __u32 nr_sizes; -}; - -struct ion_prefetch_data { - __u64 unused; - __u64 regions; - __u32 heap_id; - __u32 nr_regions; -}; - -#define ION_IOC_PREFETCH _IOWR(ION_IOC_MSM_MAGIC, 3, \ - struct ion_prefetch_data) - -#define ION_IOC_DRAIN _IOWR(ION_IOC_MSM_MAGIC, 4, \ - struct ion_prefetch_data) - -#endif /* _UAPI_LINUX_MSM_ION_H */ diff --git a/include/uapi/linux/ion.h b/include/uapi/linux/ion.h deleted file mode 120000 index 17e8dbb24265..000000000000 --- a/include/uapi/linux/ion.h +++ /dev/null @@ -1 +0,0 @@ -../../../drivers/staging/android/uapi/ion.h \ No newline at end of file diff --git a/include/uapi/linux/ion.h b/include/uapi/linux/ion.h new file mode 100644 index 000000000000..c2fb628e12da --- /dev/null +++ b/include/uapi/linux/ion.h @@ -0,0 +1,135 @@ +/* + * drivers/staging/android/uapi/ion.h + * + * Copyright (C) 2011 Google, Inc. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#ifndef _UAPI_LINUX_ION_H +#define _UAPI_LINUX_ION_H + +#include +#include + +/** + * enum ion_heap_types - list of all possible types of heaps + * @ION_HEAP_TYPE_SYSTEM: memory allocated via vmalloc + * @ION_HEAP_TYPE_SYSTEM_CONTIG: memory allocated via kmalloc + * @ION_HEAP_TYPE_CARVEOUT: memory allocated from a prereserved + * carveout heap, allocations are physically + * contiguous + * @ION_HEAP_TYPE_DMA: memory allocated via DMA API + * @ION_NUM_HEAPS: helper for iterating over heaps, a bit mask + * is used to identify the heaps, so only 32 + * total heap types are supported + */ +enum ion_heap_type { + ION_HEAP_TYPE_SYSTEM, + ION_HEAP_TYPE_SYSTEM_CONTIG, + ION_HEAP_TYPE_CARVEOUT, + ION_HEAP_TYPE_CHUNK, + ION_HEAP_TYPE_DMA, + ION_HEAP_TYPE_CUSTOM, /* + * must be last so device specific heaps always + * are at the end of this enum + */ +}; + +#define ION_NUM_HEAP_IDS (sizeof(unsigned int) * 8) + +/** + * allocation flags - the lower 16 bits are used by core ion, the upper 16 + * bits are reserved for use by the heaps themselves. + */ + +/* + * mappings of this buffer should be cached, ion will do cache maintenance + * when the buffer is mapped for dma + */ +#define ION_FLAG_CACHED 1 + +/** + * DOC: Ion Userspace API + * + * create a client by opening /dev/ion + * most operations handled via following ioctls + * + */ + +/** + * struct ion_allocation_data - metadata passed from userspace for allocations + * @len: size of the allocation + * @heap_id_mask: mask of heap ids to allocate from + * @flags: flags passed to heap + * @handle: pointer that will be populated with a cookie to use to + * refer to this allocation + * + * Provided by userspace as an argument to the ioctl + */ +struct ion_allocation_data { + __u64 len; + __u32 heap_id_mask; + __u32 flags; + __u32 fd; + __u32 unused; +}; + +#define MAX_HEAP_NAME 32 + +/** + * struct ion_heap_data - data about a heap + * @name - first 32 characters of the heap name + * @type - heap type + * @heap_id - heap id for the heap + */ +struct ion_heap_data { + char name[MAX_HEAP_NAME]; + __u32 type; + __u32 heap_id; + __u32 reserved0; + __u32 reserved1; + __u32 reserved2; +}; + +/** + * struct ion_heap_query - collection of data about all heaps + * @cnt - total number of heaps to be copied + * @heaps - buffer to copy heap data + */ +struct ion_heap_query { + __u32 cnt; /* Total number of heaps to be copied */ + __u32 reserved0; /* align to 64bits */ + __u64 heaps; /* buffer to be populated */ + __u32 reserved1; + __u32 reserved2; +}; + +#define ION_IOC_MAGIC 'I' + +/** + * DOC: ION_IOC_ALLOC - allocate memory + * + * Takes an ion_allocation_data struct and returns it with the handle field + * populated with the opaque handle for the allocation. + */ +#define ION_IOC_ALLOC _IOWR(ION_IOC_MAGIC, 0, \ + struct ion_allocation_data) +/** + * DOC: ION_IOC_HEAP_QUERY - information about available heaps + * + * Takes an ion_heap_query structure and populates information about + * available Ion heaps. + */ +#define ION_IOC_HEAP_QUERY _IOWR(ION_IOC_MAGIC, 8, \ + struct ion_heap_query) + +#endif /* _UAPI_LINUX_ION_H */ diff --git a/include/uapi/linux/msm_ion.h b/include/uapi/linux/msm_ion.h deleted file mode 120000 index 94349d27efa6..000000000000 --- a/include/uapi/linux/msm_ion.h +++ /dev/null @@ -1 +0,0 @@ -../../../drivers/staging/android/uapi/msm_ion.h \ No newline at end of file diff --git a/include/uapi/linux/msm_ion.h b/include/uapi/linux/msm_ion.h new file mode 100644 index 000000000000..4352bd24f331 --- /dev/null +++ b/include/uapi/linux/msm_ion.h @@ -0,0 +1,124 @@ +#ifndef _UAPI_LINUX_MSM_ION_H +#define _UAPI_LINUX_MSM_ION_H + +#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 + * this kernel is included. + */ +#define TARGET_ION_ABI_VERSION 2 + +enum msm_ion_heap_types { + ION_HEAP_TYPE_MSM_START = 6, + ION_HEAP_TYPE_SECURE_DMA = ION_HEAP_TYPE_MSM_START, + ION_HEAP_TYPE_SYSTEM_SECURE, + ION_HEAP_TYPE_HYP_CMA, + ION_HEAP_TYPE_SECURE_CARVEOUT, +}; + +/** + * 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 + * if specified. Don't swap the order of heap ids unless you know what + * you are doing! + * Id's are spaced by purpose to allow new Id's to be inserted in-between (for + * possible fallbacks) + */ + +enum ion_heap_ids { + INVALID_HEAP_ID = -1, + ION_CP_MM_HEAP_ID = 8, + ION_SECURE_HEAP_ID = 9, + ION_SECURE_DISPLAY_HEAP_ID = 10, + ION_VIDEO_HEAP_ID = 12, + ION_SPSS_HEAP_ID = 13, /* Secure Processor ION heap */ + ION_NON_PIXEL_HEAP_ID = 15, + ION_ADSP_HEAP_ID = 22, + ION_SYSTEM_HEAP_ID = 25, + ION_QSECOM_HEAP_ID = 27, + ION_HEAP_ID_RESERVED = 31 /** Bit reserved for ION_FLAG_SECURE flag */ +}; + +/** + * Newly added heap ids have to be #define(d) since all API changes must + * include a new #define. + */ +#define ION_SECURE_CARVEOUT_HEAP_ID 14 +#define ION_QSECOM_TA_HEAP_ID 19 +#define ION_AUDIO_HEAP_ID 28 +#define ION_CAMERA_HEAP_ID 20 +#define ION_USER_CONTIG_HEAP_ID 26 +/** + * Flags to be used when allocating from the secure heap for + * content protection + */ +#define ION_FLAG_CP_CAMERA_ENCODE ION_BIT(14) +#define ION_FLAG_CP_DSP_EXT ION_BIT(15) +/* ION_FLAG_POOL_FORCE_ALLOC uses ION_BIT(16) */ +#define ION_FLAG_CP_TOUCH ION_BIT(17) +#define ION_FLAG_CP_BITSTREAM ION_BIT(18) +#define ION_FLAG_CP_PIXEL ION_BIT(19) +#define ION_FLAG_CP_NON_PIXEL ION_BIT(20) +#define ION_FLAG_CP_CAMERA ION_BIT(21) +#define ION_FLAG_CP_HLOS ION_BIT(22) +#define ION_FLAG_CP_SPSS_SP ION_BIT(23) +#define ION_FLAG_CP_SPSS_SP_SHARED ION_BIT(24) +#define ION_FLAG_CP_SEC_DISPLAY ION_BIT(25) +#define ION_FLAG_CP_APP ION_BIT(26) +#define ION_FLAG_CP_CAMERA_PREVIEW ION_BIT(27) +/* ION_FLAG_ALLOW_NON_CONTIG uses ION_BIT(28) */ +#define ION_FLAG_CP_CDSP ION_BIT(29) +#define ION_FLAG_CP_SPSS_HLOS_SHARED ION_BIT(30) +/* ION_FLAG_SECURE uses ION_BIT(31) */ + +#define ION_FLAGS_CP_MASK 0x6FFEC000 + +/** + * Flag to allow non continguous allocation of memory from secure + * heap + */ +#define ION_FLAG_ALLOW_NON_CONTIG ION_BIT(28) + +/** + * 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) + +/* + * Used in conjunction with heap which pool memory to force an allocation + * to come from the page allocator directly instead of from the pool allocation + */ +#define ION_FLAG_POOL_FORCE_ALLOC ION_BIT(16) + +/** + * Macro should be used with ion_heap_ids defined above. + */ +#define ION_HEAP(bit) ION_BIT(bit) + +#define ION_IOC_MSM_MAGIC 'M' + +struct ion_prefetch_regions { + __u64 sizes; + __u32 vmid; + __u32 nr_sizes; +}; + +struct ion_prefetch_data { + __u64 unused; + __u64 regions; + __u32 heap_id; + __u32 nr_regions; +}; + +#define ION_IOC_PREFETCH _IOWR(ION_IOC_MSM_MAGIC, 3, \ + struct ion_prefetch_data) + +#define ION_IOC_DRAIN _IOWR(ION_IOC_MSM_MAGIC, 4, \ + struct ion_prefetch_data) + +#endif /* _UAPI_LINUX_MSM_ION_H */