mirror of
https://github.com/followmsi/android_kernel_google_msm.git
synced 2024-11-06 23:17:41 +00:00
1382bb05d7
New heap type ION_HEAP_TYPE_DMA where allocation is done with dma_alloc_coherent API. device coherent_dma_mask must be set to DMA_BIT_MASK(32). ion_platform_heap private field is used to retrieve the device linked to CMA, if NULL the default CMA area is used. ion_cma_get_sgtable is a copy of dma_common_get_sgtable function which should be in kernel 3.5 Change-Id: I9ae54a3a021cb3513c2b0e8c58b69f3ae118561b Signed-off-by: Benjamin Gaignard <benjamin.gaignard@linaro.org> [lauraa: Fix context in ion_priv.h/ion.h and omit Makefile change for now] Signed-off-by: Laura Abbott <lauraa@codeaurora.org> Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
97 lines
2.4 KiB
C
97 lines
2.4 KiB
C
/*
|
|
* drivers/gpu/ion/ion_heap.c
|
|
*
|
|
* Copyright (C) 2011 Google, Inc.
|
|
* Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved.
|
|
*
|
|
* 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.
|
|
*
|
|
*/
|
|
|
|
#include <linux/err.h>
|
|
#include <linux/ion.h>
|
|
#include "ion_priv.h"
|
|
#include <linux/msm_ion.h>
|
|
|
|
struct ion_heap *ion_heap_create(struct ion_platform_heap *heap_data)
|
|
{
|
|
struct ion_heap *heap = NULL;
|
|
|
|
switch ((int) heap_data->type) {
|
|
case ION_HEAP_TYPE_SYSTEM_CONTIG:
|
|
heap = ion_system_contig_heap_create(heap_data);
|
|
break;
|
|
case ION_HEAP_TYPE_SYSTEM:
|
|
heap = ion_system_heap_create(heap_data);
|
|
break;
|
|
case ION_HEAP_TYPE_CARVEOUT:
|
|
heap = ion_carveout_heap_create(heap_data);
|
|
break;
|
|
case ION_HEAP_TYPE_IOMMU:
|
|
heap = ion_iommu_heap_create(heap_data);
|
|
break;
|
|
case ION_HEAP_TYPE_CP:
|
|
heap = ion_cp_heap_create(heap_data);
|
|
break;
|
|
#ifdef CONFIG_CMA
|
|
case ION_HEAP_TYPE_DMA:
|
|
heap = ion_cma_heap_create(heap_data);
|
|
break;
|
|
#endif
|
|
default:
|
|
pr_err("%s: Invalid heap type %d\n", __func__,
|
|
heap_data->type);
|
|
return ERR_PTR(-EINVAL);
|
|
}
|
|
|
|
if (IS_ERR_OR_NULL(heap)) {
|
|
pr_err("%s: error creating heap %s type %d base %lu size %u\n",
|
|
__func__, heap_data->name, heap_data->type,
|
|
heap_data->base, heap_data->size);
|
|
return ERR_PTR(-EINVAL);
|
|
}
|
|
|
|
heap->name = heap_data->name;
|
|
heap->id = heap_data->id;
|
|
heap->priv = heap_data->priv;
|
|
return heap;
|
|
}
|
|
|
|
void ion_heap_destroy(struct ion_heap *heap)
|
|
{
|
|
if (!heap)
|
|
return;
|
|
|
|
switch ((int) heap->type) {
|
|
case ION_HEAP_TYPE_SYSTEM_CONTIG:
|
|
ion_system_contig_heap_destroy(heap);
|
|
break;
|
|
case ION_HEAP_TYPE_SYSTEM:
|
|
ion_system_heap_destroy(heap);
|
|
break;
|
|
case ION_HEAP_TYPE_CARVEOUT:
|
|
ion_carveout_heap_destroy(heap);
|
|
break;
|
|
case ION_HEAP_TYPE_IOMMU:
|
|
ion_iommu_heap_destroy(heap);
|
|
break;
|
|
case ION_HEAP_TYPE_CP:
|
|
ion_cp_heap_destroy(heap);
|
|
break;
|
|
#ifdef CONFIG_CMA
|
|
case ION_HEAP_TYPE_DMA:
|
|
ion_cma_heap_destroy(heap);
|
|
break;
|
|
#endif
|
|
default:
|
|
pr_err("%s: Invalid heap type %d\n", __func__,
|
|
heap->type);
|
|
}
|
|
}
|