Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit aa709002 authored by Liam Mark's avatar Liam Mark Committed by Patrick Daly
Browse files

common: dma-mapping: make dma_common_contiguous_remap more robust



Large allocations can result in the dma_common_contiguous_remap
call not being able to succeed because it can't find enough
contiguous memory to setup the mapping.
Make dma_common_contiguous_remap more robust by using vmalloc
as a fallback.

Change-Id: I12ca710b4c24f4ef24bc33a0d1d4922196fb7492
Signed-off-by: default avatarLiam Mark <lmark@codeaurora.org>
Signed-off-by: default avatarPatrick Daly <pdaly@codeaurora.org>
parent 28a88c9d
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -308,7 +308,12 @@ void *dma_common_contiguous_remap(struct page *page, size_t size,
	void *ptr;
	unsigned long pfn;

	pages = kmalloc(sizeof(struct page *) << get_order(size), GFP_KERNEL);
	pages = kmalloc(sizeof(struct page *) << get_order(size),
			GFP_KERNEL | __GFP_NOWARN);

	if (!pages)
		pages = vmalloc(sizeof(struct page *) << get_order(size));

	if (!pages)
		return NULL;

@@ -317,7 +322,7 @@ void *dma_common_contiguous_remap(struct page *page, size_t size,

	ptr = dma_common_pages_remap(pages, size, vm_flags, prot, caller);

	kfree(pages);
	kvfree(pages);

	return ptr;
}