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

Commit e9c975a9 authored by qctecmdr Service's avatar qctecmdr Service Committed by Gerrit - the friendly Code Review server
Browse files

Merge "arm: dma-mapping: map_page map to nearest page"

parents 6b8fa5d8 f942c5b4
Loading
Loading
Loading
Loading
+13 −7
Original line number Diff line number Diff line
@@ -917,9 +917,10 @@ static void __arm_dma_free(struct device *dev, size_t size, void *cpu_addr,
		.page = page,
		.want_vaddr = ((attrs & DMA_ATTR_NO_KERNEL_MAPPING) == 0),
	};
	void *addr = (args.want_vaddr) ? cpu_addr : page;

	buf = arm_dma_buffer_find(cpu_addr);
	if (WARN(!buf, "Freeing invalid buffer %p\n", cpu_addr))
	buf = arm_dma_buffer_find(addr);
	if (WARN(!buf, "Freeing invalid buffer %pK\n", addr))
		return;

	buf->allocator->free(&args);
@@ -1320,8 +1321,8 @@ static struct page **__iommu_alloc_buffer(struct device *dev, size_t size,
					  int coherent_flag)
{
	struct page **pages;
	int count = size >> PAGE_SHIFT;
	int array_size = count * sizeof(struct page *);
	size_t count = size >> PAGE_SHIFT;
	size_t array_size = count * sizeof(struct page *);
	int i = 0;
	int order_idx = 0;

@@ -1981,7 +1982,11 @@ static dma_addr_t arm_coherent_iommu_map_page(struct device *dev, struct page *p
{
	struct dma_iommu_mapping *mapping = to_dma_iommu_mapping(dev);
	dma_addr_t dma_addr;
	int ret, prot, len = PAGE_ALIGN(size + offset);
	int ret, prot, len, start_offset, map_offset;

	map_offset = offset & ~PAGE_MASK;
	start_offset = offset & PAGE_MASK;
	len = PAGE_ALIGN(map_offset + size);

	dma_addr = __alloc_iova(mapping, len);
	if (dma_addr == ARM_MAPPING_ERROR)
@@ -1989,11 +1994,12 @@ static dma_addr_t arm_coherent_iommu_map_page(struct device *dev, struct page *p

	prot = __dma_info_to_prot(dir, attrs);

	ret = iommu_map(mapping->domain, dma_addr, page_to_phys(page), len, prot);
	ret = iommu_map(mapping->domain, dma_addr, page_to_phys(page) +
			start_offset, len, prot);
	if (ret < 0)
		goto fail;

	return dma_addr + offset;
	return dma_addr + map_offset;
fail:
	__free_iova(mapping, dma_addr, len);
	return ARM_MAPPING_ERROR;