[[linux-4.4.1/__dma_alloc()]] *参照元 [#k683dd86] #backlinks *説明 [#oe7c51fa] -パス: [[linux-4.4.1/arch/arm64/mm/dma-mapping.c]] -FIXME: これは何? --説明 **引数 [#caae2f50] -struct device *dev -- --[[linux-4.4.1/device]] -size_t size -- -dma_addr_t *dma_handle -- --[[linux-4.4.1/dma_addr_t]] -gfp_t flags -- --[[linux-4.4.1/gfp_t]] -struct dma_attrs *attrs -- --[[linux-4.4.1/dma_attrs]] **返り値 [#caf9975a] -void * -- **参考 [#l992fa5a] *実装 [#e675b3a3] static void *__dma_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle, gfp_t flags, struct dma_attrs *attrs) { struct page *page; void *ptr, *coherent_ptr; bool coherent = is_device_dma_coherent(dev); pgprot_t prot = __get_dma_pgprot(attrs, PAGE_KERNEL, false); - --[[linux-4.4.1/page]] --[[linux-4.4.1/is_device_dma_coherent()]] --[[linux-4.4.1/pgprot_t]] --[[linux-4.4.1/__get_dma_pgprot()]] size = PAGE_ALIGN(size); - --[[linux-4.4.1/PAGE_ALIGN()]] if (!coherent && !gfpflags_allow_blocking(flags)) { - --[[linux-4.4.1/gfpflags_allow_blocking()]] struct page *page = NULL; void *addr = __alloc_from_pool(size, &page, flags); if (addr) *dma_handle = phys_to_dma(dev, page_to_phys(page)); - --[[linux-4.4.1/__alloc_from_pool()]] --[[linux-4.4.1/phys_to_dma()]] --[[linux-4.4.1/page_to_phys()]] return addr; } ptr = __dma_alloc_coherent(dev, size, dma_handle, flags, attrs); if (!ptr) goto no_mem; - --[[linux-4.4.1/__dma_alloc_coherent()]] /* no need for non-cacheable mapping if coherent */ if (coherent) return ptr; /* remove any dirty cache lines on the kernel alias */ __dma_flush_range(ptr, ptr + size); - --[[linux-4.4.1/__dma_flush_range()]] /* create a coherent mapping */ page = virt_to_page(ptr); coherent_ptr = dma_common_contiguous_remap(page, size, VM_USERMAP, prot, NULL); if (!coherent_ptr) goto no_map; - --[[linux-4.4.1/virt_to_page()]] --[[linux-4.4.1/dma_common_contiguous_remap()]] return coherent_ptr; no_map: __dma_free_coherent(dev, size, ptr, *dma_handle, attrs); - --[[linux-4.4.1/__dma_free_coherent()]] no_mem: *dma_handle = DMA_ERROR_CODE; return NULL; } *コメント [#n0af5194]