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

Commit 66e8f685 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "arm64: dma-mapping: make alloc_noncoherent more robust"

parents 8c294640 3459592f
Loading
Loading
Loading
Loading
+8 −4
Original line number Original line Diff line number Diff line
@@ -294,16 +294,20 @@ static void *arm64_swiotlb_alloc_noncoherent(struct device *dev, size_t size,
			/* remove any dirty cache lines on the kernel alias */
			/* remove any dirty cache lines on the kernel alias */
			__dma_flush_range(ptr, ptr + size);
			__dma_flush_range(ptr, ptr + size);


		map = kmalloc(sizeof(struct page *) << order, flags & ~GFP_DMA);
		map = kmalloc(sizeof(struct page *) << order,
			      (flags & ~GFP_DMA) | __GFP_NOWARN);
		if (!map) {
			map = vmalloc(sizeof(struct page *) << order);
			if (!map)
			if (!map)
				goto no_map;
				goto no_map;
		}


		/* create a coherent mapping */
		/* create a coherent mapping */
		page = virt_to_page(ptr);
		page = virt_to_page(ptr);
		for (i = 0; i < (size >> PAGE_SHIFT); i++)
		for (i = 0; i < (size >> PAGE_SHIFT); i++)
			map[i] = page + i;
			map[i] = page + i;
		coherent_ptr = vmap(map, size >> PAGE_SHIFT, VM_MAP, prot);
		coherent_ptr = vmap(map, size >> PAGE_SHIFT, VM_MAP, prot);
		kfree(map);
		kvfree(map);
		if (!coherent_ptr)
		if (!coherent_ptr)
			goto no_map;
			goto no_map;
	}
	}