diff --git a/drivers/staging/android/ion/heaps/ion_msm_system_heap.c b/drivers/staging/android/ion/heaps/ion_msm_system_heap.c index 1d78ce811d95..f57918149716 100644 --- a/drivers/staging/android/ion/heaps/ion_msm_system_heap.c +++ b/drivers/staging/android/ion/heaps/ion_msm_system_heap.c @@ -50,9 +50,9 @@ static inline unsigned int order_to_size(int order) return PAGE_SIZE << order; } -static int ion_heap_is_system_heap_type(enum ion_heap_type type) +static int ion_heap_is_msm_system_heap_type(enum ion_heap_type type) { - return type == ((enum ion_heap_type)ION_HEAP_TYPE_SYSTEM); + return type == ((enum ion_heap_type)ION_HEAP_TYPE_MSM_SYSTEM); } static struct page *alloc_buffer_page(struct ion_msm_system_heap *sys_heap, @@ -299,7 +299,7 @@ static int ion_msm_system_heap_allocate(struct ion_heap *heap, if (size / PAGE_SIZE > totalram_pages() / 2) return -ENOMEM; - if (ion_heap_is_system_heap_type(buffer->heap->type) && + if (ion_heap_is_msm_system_heap_type(buffer->heap->type) && is_secure_allocation(buffer->flags)) { pr_info("%s: System heap doesn't support secure allocations\n", __func__); @@ -740,7 +740,7 @@ struct ion_heap *ion_msm_system_heap_create(struct ion_platform_heap *data) heap->heap.msm_heap_ops = &msm_system_heap_ops; heap->heap.ion_heap.ops = &system_heap_ops; heap->heap.ion_heap.buf_ops = msm_ion_dma_buf_ops; - heap->heap.ion_heap.type = ION_HEAP_TYPE_SYSTEM; + heap->heap.ion_heap.type = (enum ion_heap_type)ION_HEAP_TYPE_MSM_SYSTEM; heap->heap.ion_heap.flags = ION_HEAP_FLAG_DEFER_FREE; for (i = 0; i < VMID_LAST; i++) diff --git a/drivers/staging/android/ion/heaps/msm_ion.c b/drivers/staging/android/ion/heaps/msm_ion.c index 6a4cf23e1760..2bed708ab61c 100644 --- a/drivers/staging/android/ion/heaps/msm_ion.c +++ b/drivers/staging/android/ion/heaps/msm_ion.c @@ -100,7 +100,7 @@ static struct heap_types_info { const char *name; int heap_type; } heap_types_info[] = { - MAKE_HEAP_TYPE_MAPPING(SYSTEM), + MAKE_HEAP_TYPE_MAPPING(MSM_SYSTEM), MAKE_HEAP_TYPE_MAPPING(MSM_CARVEOUT), MAKE_HEAP_TYPE_MAPPING(SECURE_CARVEOUT), MAKE_HEAP_TYPE_MAPPING(DMA), @@ -158,7 +158,7 @@ static struct ion_heap *ion_heap_create(struct ion_platform_heap *heap_data) int heap_type = heap_data->type; switch (heap_type) { - case ION_HEAP_TYPE_SYSTEM: + case ION_HEAP_TYPE_MSM_SYSTEM: heap = ion_msm_system_heap_create(heap_data); break; case ION_HEAP_TYPE_MSM_CARVEOUT: diff --git a/drivers/staging/android/ion/ion_buffer.c b/drivers/staging/android/ion/ion_buffer.c index 12f180a84ea8..862da1a32551 100644 --- a/drivers/staging/android/ion/ion_buffer.c +++ b/drivers/staging/android/ion/ion_buffer.c @@ -12,6 +12,7 @@ #include #include "ion_private.h" +#define ION_SYSTEM_HEAP_ID BIT(25) /* this function should only be called while dev->lock is held */ static struct ion_buffer *ion_buffer_create(struct ion_heap *heap, @@ -115,11 +116,25 @@ struct ion_buffer *ion_buffer_alloc(struct ion_device *dev, size_t len, { struct ion_buffer *buffer = NULL; struct ion_heap *heap; + char task_comm[TASK_COMM_LEN]; if (!dev || !len) { return ERR_PTR(-EINVAL); } + /* + * Temporarily reroute generic system heap allocations to the MSM system + * heap. Once clients have stopped using the generic system heap ID, we + * can remove this. + */ + if (heap_id_mask & ION_HEAP_SYSTEM) { + get_task_comm(task_comm, current->group_leader); + pr_warn_ratelimited("%s: Rerouting allocation from generic sys heap to msm sys heap for %s-%d\n", + __func__, task_comm, current->tgid); + heap_id_mask &= ~ION_HEAP_SYSTEM; + heap_id_mask |= ION_SYSTEM_HEAP_ID; + } + /* * traverse the list of heaps available in this system in priority * order. If the heap type is supported by the client, and matches the diff --git a/include/uapi/linux/msm_ion.h b/include/uapi/linux/msm_ion.h index 46eef92343f0..e68fc5540567 100644 --- a/include/uapi/linux/msm_ion.h +++ b/include/uapi/linux/msm_ion.h @@ -22,6 +22,7 @@ enum msm_ion_heap_types { ION_HEAP_TYPE_HYP_CMA, ION_HEAP_TYPE_MSM_CARVEOUT, ION_HEAP_TYPE_SECURE_CARVEOUT, + ION_HEAP_TYPE_MSM_SYSTEM, }; /** diff --git a/include/uapi/linux/msm_ion_ids.h b/include/uapi/linux/msm_ion_ids.h index 9a36cae13063..857661963724 100644 --- a/include/uapi/linux/msm_ion_ids.h +++ b/include/uapi/linux/msm_ion_ids.h @@ -16,7 +16,7 @@ * possible fallbacks) */ -#define ION_SYSTEM_HEAP_ID ION_BIT(0) +/* ION_BIT(0) is reserved for the generic system heap. */ #define ION_QSECOM_TA_HEAP_ID ION_BIT(1) #define ION_CAMERA_HEAP_ID ION_BIT(2) #define ION_DISPLAY_HEAP_ID ION_BIT(3) @@ -31,6 +31,7 @@ #define ION_SPSS_HEAP_ID ION_BIT(14) #define ION_SECURE_CARVEOUT_HEAP_ID ION_BIT(15) #define ION_TUI_CARVEOUT_HEAP_ID ION_BIT(16) +#define ION_SYSTEM_HEAP_ID ION_BIT(25) #define ION_HEAP_ID_RESERVED ION_BIT(31) #endif /* _MSM_ION_IDS_H */