mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-22 09:12:24 +03:00
gpu: nvgpu: Simplify nvgpu_dma_free_sys()
The original free routine has three options:
if (NVGPU_DMA_NO_KERNEL_MAPPING)
dma_free_attrs(d, mem->aligned_size, mem->priv.pages,
else if (other flags)
dma_free_attrs(d, mem->aligned_size, mem->cpu_va,
else /* No flags */
dma_free_coherent(d, mem->aligned_size, mem->cpu_va,
The last dma_free_coherent() can be unwrapped to dma_free_attrs
with its dma_attrs=0, while the former two are identical except
cpu_addr. So this patch merges these three into one single call
but differentiate the cpu_addr and dma_attrs parameters.
Note that the dma_free_attrs returns 0 when flags is not set.
Bug 200444660
Change-Id: I92ec0390138c79c5109973e476ea0ea719d4e2b9
Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2029679
GVS: Gerrit_Virtual_Submit
Reviewed-by: Alex Waterman <alexw@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
committed by
mobile promotions
parent
5128237bc8
commit
ac3c3e2b69
@@ -337,23 +337,16 @@ void nvgpu_dma_free_sys(struct gk20a *g, struct nvgpu_mem *mem)
|
||||
if (!(mem->mem_flags & NVGPU_MEM_FLAG_SHADOW_COPY) &&
|
||||
!(mem->mem_flags & __NVGPU_MEM_FLAG_NO_DMA) &&
|
||||
(mem->cpu_va || mem->priv.pages)) {
|
||||
if (mem->priv.flags) {
|
||||
void *cpu_addr = mem->cpu_va;
|
||||
|
||||
nvgpu_dma_flags_to_attrs(&dma_attrs, mem->priv.flags);
|
||||
/* NO_KERNEL_MAPPING uses pages pointer instead of cpu_va */
|
||||
if (mem->priv.flags & NVGPU_DMA_NO_KERNEL_MAPPING)
|
||||
cpu_addr = mem->priv.pages;
|
||||
|
||||
nvgpu_dma_flags_to_attrs(&dma_attrs, mem->priv.flags);
|
||||
dma_free_attrs(d, mem->aligned_size, cpu_addr,
|
||||
sg_dma_address(mem->priv.sgt->sgl), dma_attrs);
|
||||
|
||||
if (mem->priv.flags & NVGPU_DMA_NO_KERNEL_MAPPING) {
|
||||
dma_free_attrs(d, mem->aligned_size, mem->priv.pages,
|
||||
sg_dma_address(mem->priv.sgt->sgl),
|
||||
dma_attrs);
|
||||
} else {
|
||||
dma_free_attrs(d, mem->aligned_size, mem->cpu_va,
|
||||
sg_dma_address(mem->priv.sgt->sgl),
|
||||
dma_attrs);
|
||||
}
|
||||
} else {
|
||||
dma_free_coherent(d, mem->aligned_size, mem->cpu_va,
|
||||
sg_dma_address(mem->priv.sgt->sgl));
|
||||
}
|
||||
mem->cpu_va = NULL;
|
||||
mem->priv.pages = NULL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user