On Wed, 8 Apr 2020 13:59:02 +0200 Christoph Hellwig wrote: > > @@ -62,24 +42,20 @@ void *dma_common_pages_remap(struct page **pages, size_t size, > void *dma_common_contiguous_remap(struct page *page, size_t size, > pgprot_t prot, const void *caller) > { > - int i; > + int count = size >> PAGE_SHIFT; > struct page **pages; > - struct vm_struct *area; > + void *vaddr; > + int i; > > - pages = kmalloc(sizeof(struct page *) << get_order(size), GFP_KERNEL); > + pages = kmalloc_array(count, sizeof(struct page *), GFP_KERNEL); Is it making sense to vmalloc pages as long as array size is bigger than PAGE_SIZE? > if (!pages) > return NULL; > - > - for (i = 0; i < (size >> PAGE_SHIFT); i++) > + for (i = 0; i < count; i++) > pages[i] = nth_page(page, i); > - > - area = __dma_common_pages_remap(pages, size, prot, caller); > - > + vaddr = vmap(pages, count, VM_DMA_COHERENT, prot); > kfree(pages); > > - if (!area) > - return NULL; > - return area->addr; > + return vaddr; > }