gpu: ion: Refactor platform data
Refactor platform data to allow for better
expansion in the future. Add void * for
elements unique to each heap type.
Change-Id: I435679819c67ce917b5798009eff7e71047fd2ea
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
diff --git a/arch/arm/mach-msm/board-8930.c b/arch/arm/mach-msm/board-8930.c
index b9d51f0..533d4f7 100644
--- a/arch/arm/mach-msm/board-8930.c
+++ b/arch/arm/mach-msm/board-8930.c
@@ -282,6 +282,17 @@
}
#ifdef CONFIG_ION_MSM
+#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
+static struct ion_cp_heap_pdata cp_mm_ion_pdata = {
+ .permission_type = IPT_TYPE_MM_CARVEOUT,
+};
+
+static struct ion_cp_heap_pdata cp_mfc_ion_pdata = {
+ .permission_type = IPT_TYPE_MFC_SHAREDMEM,
+};
+static struct ion_co_heap_pdata co_ion_pdata = {
+};
+#endif
static struct ion_platform_data ion_pdata = {
.nr = MSM_ION_HEAP_NUM,
.heaps = {
@@ -297,6 +308,7 @@
.name = ION_SF_HEAP_NAME,
.size = MSM_ION_SF_SIZE,
.memory_type = ION_EBI_TYPE,
+ .extra_data = &co_ion_pdata,
},
{
.id = ION_CP_MM_HEAP_ID,
@@ -304,7 +316,7 @@
.name = ION_MM_HEAP_NAME,
.size = MSM_ION_MM_SIZE,
.memory_type = ION_EBI_TYPE,
- .permission_type = IPT_TYPE_MM_CARVEOUT,
+ .extra_data = (void *) &cp_mm_ion_pdata,
},
{
.id = ION_CP_MFC_HEAP_ID,
@@ -312,7 +324,7 @@
.name = ION_MFC_HEAP_NAME,
.size = MSM_ION_MFC_SIZE,
.memory_type = ION_EBI_TYPE,
- .permission_type = IPT_TYPE_MFC_SHAREDMEM,
+ .extra_data = (void *) &cp_mfc_ion_pdata,
},
{
.id = ION_IOMMU_HEAP_ID,
diff --git a/arch/arm/mach-msm/board-8960.c b/arch/arm/mach-msm/board-8960.c
index 8b2d9d3..91bee0b 100644
--- a/arch/arm/mach-msm/board-8960.c
+++ b/arch/arm/mach-msm/board-8960.c
@@ -309,6 +309,19 @@
}
#ifdef CONFIG_ION_MSM
+#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
+static struct ion_cp_heap_pdata cp_mm_ion_pdata = {
+ .permission_type = IPT_TYPE_MM_CARVEOUT,
+};
+
+static struct ion_cp_heap_pdata cp_mfc_ion_pdata = {
+ .permission_type = IPT_TYPE_MFC_SHAREDMEM,
+};
+
+static struct ion_co_heap_pdata co_ion_pdata = {
+};
+#endif
+
static struct ion_platform_data ion_pdata = {
.nr = MSM_ION_HEAP_NUM,
.heaps = {
@@ -324,6 +337,7 @@
.name = ION_SF_HEAP_NAME,
.size = MSM_ION_SF_SIZE,
.memory_type = ION_EBI_TYPE,
+ .extra_data = &co_ion_pdata,
},
{
.id = ION_CP_MM_HEAP_ID,
@@ -331,7 +345,7 @@
.name = ION_MM_HEAP_NAME,
.size = MSM_ION_MM_SIZE,
.memory_type = ION_EBI_TYPE,
- .permission_type = IPT_TYPE_MM_CARVEOUT,
+ .extra_data = (void *) &cp_mm_ion_pdata,
},
{
.id = ION_CP_MFC_HEAP_ID,
@@ -339,7 +353,7 @@
.name = ION_MFC_HEAP_NAME,
.size = MSM_ION_MFC_SIZE,
.memory_type = ION_EBI_TYPE,
- .permission_type = IPT_TYPE_MFC_SHAREDMEM,
+ .extra_data = (void *) &cp_mfc_ion_pdata,
},
{
.id = ION_IOMMU_HEAP_ID,
diff --git a/arch/arm/mach-msm/board-msm8x60.c b/arch/arm/mach-msm/board-msm8x60.c
index b5c5837..df04bb2 100644
--- a/arch/arm/mach-msm/board-msm8x60.c
+++ b/arch/arm/mach-msm/board-msm8x60.c
@@ -5239,6 +5239,28 @@
};
#ifdef CONFIG_ION_MSM
+#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
+static struct ion_cp_heap_pdata cp_mm_ion_pdata = {
+ .permission_type = IPT_TYPE_MM_CARVEOUT,
+ .request_region = request_smi_region,
+ .release_region = release_smi_region,
+ .setup_region = setup_smi_region,
+};
+
+static struct ion_cp_heap_pdata cp_mfc_ion_pdata = {
+ .permission_type = IPT_TYPE_MFC_SHAREDMEM,
+ .request_region = request_smi_region,
+ .release_region = release_smi_region,
+ .setup_region = setup_smi_region,
+};
+
+static struct ion_cp_heap_pdata cp_wb_ion_pdata = {
+ .permission_type = IPT_TYPE_MDP_WRITEBACK,
+};
+
+static struct ion_co_heap_pdata co_ion_pdata = {
+};
+#endif
static struct ion_platform_data ion_pdata = {
.nr = MSM_ION_HEAP_NUM,
.heaps = {
@@ -5254,6 +5276,7 @@
.name = ION_SF_HEAP_NAME,
.size = MSM_ION_SF_SIZE,
.memory_type = ION_EBI_TYPE,
+ .extra_data = &co_ion_pdata,
},
{
.id = ION_CP_MM_HEAP_ID,
@@ -5261,10 +5284,7 @@
.name = ION_MM_HEAP_NAME,
.size = MSM_ION_MM_SIZE,
.memory_type = ION_SMI_TYPE,
- .request_region = request_smi_region,
- .release_region = release_smi_region,
- .setup_region = setup_smi_region,
- .permission_type = IPT_TYPE_MM_CARVEOUT,
+ .extra_data = (void *) &cp_mm_ion_pdata,
},
{
.id = ION_CAMERA_HEAP_ID,
@@ -5272,6 +5292,7 @@
.name = ION_CAMERA_HEAP_NAME,
.size = MSM_ION_CAMERA_SIZE,
.memory_type = ION_EBI_TYPE,
+ .extra_data = &co_ion_pdata,
},
{
.id = ION_CP_MFC_HEAP_ID,
@@ -5279,10 +5300,7 @@
.name = ION_MFC_HEAP_NAME,
.size = MSM_ION_MFC_SIZE,
.memory_type = ION_SMI_TYPE,
- .request_region = request_smi_region,
- .release_region = release_smi_region,
- .setup_region = setup_smi_region,
- .permission_type = IPT_TYPE_MFC_SHAREDMEM,
+ .extra_data = (void *) &cp_mfc_ion_pdata,
},
{
.id = ION_CP_WB_HEAP_ID,
@@ -5290,7 +5308,7 @@
.name = ION_WB_HEAP_NAME,
.size = MSM_ION_WB_SIZE,
.memory_type = ION_EBI_TYPE,
- .permission_type = IPT_TYPE_MDP_WRITEBACK,
+ .extra_data = (void *) &cp_wb_ion_pdata,
},
#endif
}
diff --git a/drivers/gpu/ion/ion_carveout_heap.c b/drivers/gpu/ion/ion_carveout_heap.c
index c13abff..1c35f5c 100644
--- a/drivers/gpu/ion/ion_carveout_heap.c
+++ b/drivers/gpu/ion/ion_carveout_heap.c
@@ -409,13 +409,20 @@
carveout_heap->heap.type = ION_HEAP_TYPE_CARVEOUT;
carveout_heap->allocated_bytes = 0;
carveout_heap->total_size = heap_data->size;
- if (heap_data->setup_region)
- carveout_heap->bus_id = heap_data->setup_region();
- if (heap_data->request_region)
- carveout_heap->request_region = heap_data->request_region;
- if (heap_data->release_region)
- carveout_heap->release_region = heap_data->release_region;
+ if (heap_data->extra_data) {
+ struct ion_co_heap_pdata *extra_data =
+ heap_data->extra_data;
+
+ if (extra_data->setup_region)
+ carveout_heap->bus_id = extra_data->setup_region();
+ if (extra_data->request_region)
+ carveout_heap->request_region =
+ extra_data->request_region;
+ if (extra_data->release_region)
+ carveout_heap->release_region =
+ extra_data->release_region;
+ }
return &carveout_heap->heap;
}
diff --git a/drivers/gpu/ion/ion_cp_heap.c b/drivers/gpu/ion/ion_cp_heap.c
index 5c069ce..5737d21 100644
--- a/drivers/gpu/ion/ion_cp_heap.c
+++ b/drivers/gpu/ion/ion_cp_heap.c
@@ -612,7 +612,6 @@
if (ret < 0)
goto destroy_pool;
- cp_heap->permission_type = heap_data->permission_type;
cp_heap->allocated_bytes = 0;
cp_heap->alloc_count = 0;
cp_heap->umap_count = 0;
@@ -621,13 +620,17 @@
cp_heap->heap.ops = &cp_heap_ops;
cp_heap->heap.type = ION_HEAP_TYPE_CP;
cp_heap->heap_secured = NON_SECURED_HEAP;
- if (heap_data->setup_region)
- cp_heap->bus_id = heap_data->setup_region();
- if (heap_data->request_region)
- cp_heap->request_region = heap_data->request_region;
- if (heap_data->release_region)
- cp_heap->release_region = heap_data->release_region;
-
+ if (heap_data->extra_data) {
+ struct ion_cp_heap_pdata *extra_data =
+ heap_data->extra_data;
+ cp_heap->permission_type = extra_data->permission_type;
+ if (extra_data->setup_region)
+ cp_heap->bus_id = extra_data->setup_region();
+ if (extra_data->request_region)
+ cp_heap->request_region = extra_data->request_region;
+ if (extra_data->release_region)
+ cp_heap->release_region = extra_data->release_region;
+ }
return &cp_heap->heap;
destroy_pool:
diff --git a/include/linux/ion.h b/include/linux/ion.h
index 171dba2..fa5017a 100644
--- a/include/linux/ion.h
+++ b/include/linux/ion.h
@@ -144,12 +144,22 @@
ion_phys_addr_t base;
size_t size;
enum ion_memory_types memory_type;
+ void *extra_data;
+};
+
+struct ion_cp_heap_pdata {
enum ion_permission_type permission_type;
int (*request_region)(void *);
int (*release_region)(void *);
void *(*setup_region)(void);
};
+struct ion_co_heap_pdata {
+ int (*request_region)(void *);
+ int (*release_region)(void *);
+ void *(*setup_region)(void);
+};
+
/**
* struct ion_platform_data - array of platform heaps passed from board file
* @nr: number of structures in the array