Hi,
I agree with Nishanth here. Internally, we've added a private field to the platform_heap_data to pass generic board specific data to heaps. Similar to carveout heap:
static struct ion_platform_heap snowball_ion_heap1[] = { [0] = { .type = ION_HEAP_TYPE_DMA, .id = 1, .name = "ion-cma-heap-1", .base = 0, .size = (16 * SZ_1M), .priv = &snowball_ion_device1.dev }, };
----
struct ion_cma_heap { struct ion_heap heap; struct device *dev; }
struct ion_heap *ion_cma_heap_create(struct ion_platform_heap *data) { struct ion_cma_heap *heap;
heap = kzalloc(sizeof(*heap), GFP_KERNEL); if (!heap) return ERR_PTR(-ENOMEM);
heap->dev = data->priv; heap->heap.ops = &ion_cma_ops; heap->heap.type = ION_HEAP_TYPE_DMA;
return &heap->heap; }
And all other accesses become container_of to get the heap. This makes it easier to pass in other data that may not be directly linked to the platform device.
Laura
On 6/13/2012 7:31 PM, Nishanth Peethambaran wrote:
Hi,
I missed out that you are stil creating only one ION miscdevice though multiple ion-driver devices are created.
Isn't it better to add a priv field in the platform heap than modifying the heap creation API? The priv field can be then used for extended purposes for custom heaps (board file and heap implementation needs to know what is being passed in the priv field).
- Nishanth Peethambaran
On Wed, Jun 13, 2012 at 9:05 AM, Benjamin Gaignard benjamin.gaignard@linaro.org wrote:
Hello,
The addition of a private field in ion_platform_heap has been discussed in the previous versions of the patches: http://lists.linaro.org/pipermail/linaro-mm-sig/2012-March/001431.html
Each CMA area need to be linked with one device, so we need to have multiple ion-driver device beacuse there is only one ION device. If we don't link CMA to one device driver, all calls to dma_alloc_coherent will go to the default CMA area.
I'm not sure about your use case, but if you mean that you want to define multiple heaps and let the ION allocate the memory in one of them, it is already what ION does in ion_alloc function by checking heap_mask and flags.
Benjamin
Linaro-mm-sig mailing list Linaro-mm-sig@lists.linaro.org http://lists.linaro.org/mailman/listinfo/linaro-mm-sig