mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-24 07:50:53 +07:00
dma-direct: fix DMA_ATTR_NO_KERNEL_MAPPING for remapped allocations
We need to return a dma_addr_t even if we don't have a kernel mapping.
Do so by consolidating the phys_to_dma call in a single place and jump
to it from all the branches that return successfully.
Fixes: bfd56cd605
("dma-mapping: support highmem in the generic remap allocator")
Reported-by: Liviu Dudau <liviu@dudau.co.uk
Signed-off-by: Christoph Hellwig <hch@lst.de>
Tested-by: Liviu Dudau <liviu@dudau.co.uk>
This commit is contained in:
parent
06f55fd2d2
commit
8270f3a11c
@ -204,8 +204,7 @@ void *arch_dma_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle,
|
|||||||
ret = dma_alloc_from_pool(size, &page, flags);
|
ret = dma_alloc_from_pool(size, &page, flags);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
return NULL;
|
return NULL;
|
||||||
*dma_handle = phys_to_dma(dev, page_to_phys(page));
|
goto done;
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
page = __dma_direct_alloc_pages(dev, size, dma_handle, flags, attrs);
|
page = __dma_direct_alloc_pages(dev, size, dma_handle, flags, attrs);
|
||||||
@ -215,8 +214,10 @@ void *arch_dma_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle,
|
|||||||
/* remove any dirty cache lines on the kernel alias */
|
/* remove any dirty cache lines on the kernel alias */
|
||||||
arch_dma_prep_coherent(page, size);
|
arch_dma_prep_coherent(page, size);
|
||||||
|
|
||||||
if (attrs & DMA_ATTR_NO_KERNEL_MAPPING)
|
if (attrs & DMA_ATTR_NO_KERNEL_MAPPING) {
|
||||||
return page; /* opaque cookie */
|
ret = page; /* opaque cookie */
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
/* create a coherent mapping */
|
/* create a coherent mapping */
|
||||||
ret = dma_common_contiguous_remap(page, size, VM_USERMAP,
|
ret = dma_common_contiguous_remap(page, size, VM_USERMAP,
|
||||||
@ -227,9 +228,9 @@ void *arch_dma_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
*dma_handle = phys_to_dma(dev, page_to_phys(page));
|
|
||||||
memset(ret, 0, size);
|
memset(ret, 0, size);
|
||||||
|
done:
|
||||||
|
*dma_handle = phys_to_dma(dev, page_to_phys(page));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user