Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 149000cb authored by Isaac J. Manjarres's avatar Isaac J. Manjarres
Browse files

ion: Update the system heap type to MSM_SYSTEM and update sys heap ID



In preparation for restoring the GKI system heap, move the existing
system heap into the vendor heap space, leaving the GKI system heap
ID slot empty. For now, alias allocations targeted at ION_HEAP_SYSTEM to
ION_SYSTEM_HEAP_ID until all clients have migrated. Once that
happens, we can remove the aliasing.

Change-Id: Ib1bd74c2a54ebfdcb14da2b04f237ae1b88db189
Signed-off-by: default avatarIsaac J. Manjarres <isaacm@codeaurora.org>
parent 9cae2378
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -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++)
+2 −2
Original line number Diff line number Diff line
@@ -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:
+15 −0
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@
#include <linux/dma-noncoherent.h>

#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
+1 −0
Original line number Diff line number Diff line
@@ -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,
};

/**
+2 −1
Original line number Diff line number Diff line
@@ -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 */