gpu: ion: Add support for carveout heaps on msm targets
Add infrastructure for supporting ion carveout heaps.
The memory type should be specified in the board file using
mach/ion.h. The ion platform driver will be responsible for
allocating the correct memory.
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
diff --git a/arch/arm/mach-msm/devices.h b/arch/arm/mach-msm/devices.h
index 6297505..012ba27 100644
--- a/arch/arm/mach-msm/devices.h
+++ b/arch/arm/mach-msm/devices.h
@@ -165,4 +165,6 @@
extern struct pil_device peripheral_dsps;
extern struct platform_device led_pdev;
+
+extern struct platform_device ion_dev;
#endif
diff --git a/arch/arm/mach-msm/include/mach/ion.h b/arch/arm/mach-msm/include/mach/ion.h
new file mode 100644
index 0000000..4d12249
--- /dev/null
+++ b/arch/arm/mach-msm/include/mach/ion.h
@@ -0,0 +1,23 @@
+/**
+ *
+ * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * 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 __MACH_ION_H_
+#define __MACH_ION_H_
+
+enum ion_memory_types {
+ ION_EBI_TYPE,
+ ION_SMI_TYPE,
+};
+
+#endif
diff --git a/drivers/gpu/ion/msm/msm_ion.c b/drivers/gpu/ion/msm/msm_ion.c
index 35a6063..6b1a59a 100644
--- a/drivers/gpu/ion/msm/msm_ion.c
+++ b/drivers/gpu/ion/msm/msm_ion.c
@@ -14,6 +14,9 @@
#include <linux/ion.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
+#include <linux/memory_alloc.h>
+#include <mach/ion.h>
+#include <mach/msm_memtypes.h>
#include "../ion_priv.h"
struct ion_device *idev;
@@ -25,6 +28,22 @@
{
return ion_client_create(idev, heap_mask, name);
}
+EXPORT_SYMBOL(msm_ion_client_create);
+
+static unsigned long msm_ion_get_base(unsigned long size, int memory_type)
+{
+ switch (memory_type) {
+ case ION_EBI_TYPE:
+ return allocate_contiguous_ebi_nomap(size, PAGE_SIZE);
+ break;
+ case ION_SMI_TYPE:
+ return allocate_contiguous_memory_nomap(size, MEMTYPE_SMI,
+ PAGE_SIZE);
+ break;
+ default:
+ return 0;
+ }
+}
static int msm_ion_probe(struct platform_device *pdev)
{
@@ -51,6 +70,17 @@
for (i = 0; i < num_heaps; i++) {
struct ion_platform_heap *heap_data = &pdata->heaps[i];
+ if (heap_data->type == ION_HEAP_TYPE_CARVEOUT) {
+ heap_data->base = msm_ion_get_base(heap_data->size,
+ heap_data->memory_type);
+ if (!heap_data->base) {
+ pr_err("%s: could not get memory for heap %s"
+ " (id %x)\n", __func__, heap_data->name,
+ heap_data->id);
+ continue;
+ }
+ }
+
heaps[i] = ion_heap_create(heap_data);
if (IS_ERR_OR_NULL(heaps[i])) {
err = PTR_ERR(heaps[i]);
diff --git a/include/linux/ion.h b/include/linux/ion.h
index 5a855e9..d6dcf38 100644
--- a/include/linux/ion.h
+++ b/include/linux/ion.h
@@ -18,6 +18,7 @@
#define _LINUX_ION_H
#include <linux/types.h>
+#include <mach/ion.h>
struct ion_handle;
/**
@@ -42,6 +43,25 @@
#define ION_HEAP_SYSTEM_CONTIG_MASK (1 << ION_HEAP_TYPE_SYSTEM_CONTIG)
#define ION_HEAP_CARVEOUT_MASK (1 << ION_HEAP_TYPE_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!
+ */
+
+enum ion_heap_ids {
+ ION_HEAP_SYSTEM_ID,
+ ION_HEAP_SYSTEM_CONTIG_ID,
+ ION_HEAP_EBI_ID,
+ ION_HEAP_SMI_ID,
+};
+
+#define ION_KMALLOC_HEAP_NAME "kmalloc"
+#define ION_VMALLOC_HEAP_NAME "vmalloc"
+#define ION_EBI1_HEAP_NAME "EBI1"
+
#ifdef __KERNEL__
struct ion_device;
struct ion_heap;
@@ -72,6 +92,7 @@
const char *name;
ion_phys_addr_t base;
size_t size;
+ enum ion_memory_types memory_type;
};
/**