*参照元 [#ke80853a] #backlinks *説明 [#f1caced6] -パス: [[linux-4.4.1/drivers/staging/android/ion/ion_cma_heap.c]] -FIXME: これは何? --説明 **引数 [#b8c93305] -struct ion_heap *heap -- --[[linux-4.4.1/]] -struct ion_buffer *buffer -- --[[linux-4.4.1/]] -unsigned long len -- --[[linux-4.4.1/]] -unsigned long align -- --[[linux-4.4.1/]] -unsigned long flags -- --[[linux-4.4.1/]] **返り値 [#dd184e5f] - -- **参考 [#rc834b84] *実装 [#n977d501] /* ION CMA heap operations functions */ static int ion_cma_allocate(struct ion_heap *heap, struct ion_buffer *buffer, unsigned long len, unsigned long align, unsigned long flags) { struct ion_cma_heap *cma_heap = to_cma_heap(heap); struct device *dev = cma_heap->dev; struct ion_cma_buffer_info *info; - --[[linux-4.4.1/ion_cma_heap]] --[[linux-4.4.1/to_cma_heap()]] --[[linux-4.4.1/device]] --[[linux-4.4.1/ion_cma_buffer_info]] dev_dbg(dev, "Request buffer allocation len %ld\n", len); - --[[linux-4.4.1/dev_dbg()]] if (buffer->flags & ION_FLAG_CACHED) return -EINVAL; if (align > PAGE_SIZE) return -EINVAL; info = kzalloc(sizeof(struct ion_cma_buffer_info), GFP_KERNEL); if (!info) return ION_CMA_ALLOCATE_FAILED; - --[[linux-4.4.1/kzalloc()]] info->cpu_addr = dma_alloc_coherent(dev, len, &(info->handle), GFP_HIGHUSER | __GFP_ZERO); if (!info->cpu_addr) { dev_err(dev, "Fail to allocate buffer\n"); goto err; } - --[[linux-4.4.1/dma_alloc_coherent()]] info->table = kmalloc(sizeof(struct sg_table), GFP_KERNEL); if (!info->table) goto free_mem; - --[[linux-4.4.1/kmalloc()]] --[[linux-4.4.1/sg_table]] if (dma_get_sgtable(dev, info->table, info->cpu_addr, info->handle, len)) goto free_table; - --[[linux-4.4.1/dma_get_sgtable()]] /* keep this for memory release */ buffer->priv_virt = info; dev_dbg(dev, "Allocate buffer %p\n", buffer); return 0; free_table: kfree(info->table); - --[[linux-4.4.1/kfree()]] free_mem: dma_free_coherent(dev, len, info->cpu_addr, info->handle); - --[[linux-4.4.1/dma_free_coherent()]] err: kfree(info); return ION_CMA_ALLOCATE_FAILED; } *コメント [#i1e16b2b]