From 7b19a825bd12cf70f3cabaf2a0214afeae03b5bc Mon Sep 17 00:00:00 2001 From: Nicolin Chen Date: Tue, 22 Jan 2019 15:24:55 -0800 Subject: [PATCH] gpu: nvgpu: Remove DMA_NO_KERNEL_MAPPING WAR for coherent chips The commit 3fdd8e38b280 ("gpu: nvgpu: Use our own vmap() for coherent DMA buffers") added an NVGPU_DMA_NO_KERNEL_MAPPING flag for coherent chips to work around a memory mapping bug suspiciously from DMA API. However, this requires dma-mapping code of ARM64 to support a legacy DMA_NO_KERNEL_MAPPING attribute for DMA allocation, which will not likely get upstreamed -- it is not long-term sustainable. So the plan is to remove this flag from ARM64 part. The results of 3D benchmarks and GVS sanity tests show that the system has no regressions in stability, and no mapping issue being observed after removing this WAR. In case that GPU code encounters mapping issue in the future, we should fix from the general DMA API side instead. Bug 2424160 Change-Id: Ice91f2b2c924beb2f83762cb02efbd53fe7df1c0 Signed-off-by: Nicolin Chen Reviewed-on: https://git-master.nvidia.com/r/2001294 Reviewed-by: Konsta Holtta GVS: Gerrit_Virtual_Submit Reviewed-by: Alex Waterman Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/os/linux/linux-dma.c | 30 +------------------------- drivers/gpu/nvgpu/os/linux/nvgpu_mem.c | 12 +++-------- 2 files changed, 4 insertions(+), 38 deletions(-) diff --git a/drivers/gpu/nvgpu/os/linux/linux-dma.c b/drivers/gpu/nvgpu/os/linux/linux-dma.c index abacf27fd..322e9da07 100644 --- a/drivers/gpu/nvgpu/os/linux/linux-dma.c +++ b/drivers/gpu/nvgpu/os/linux/linux-dma.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2017-2019, NVIDIA CORPORATION. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -194,16 +194,6 @@ int nvgpu_dma_alloc_flags_sys(struct gk20a *g, unsigned long flags, flags |= NVGPU_DMA_FORCE_CONTIGUOUS; } - /* - * WAR for IO coherent chips: the DMA API does not seem to generate - * mappings that work correctly. Unclear why - Bug ID: 2040115. - * - * Basically we just tell the DMA API not to map with NO_KERNEL_MAPPING - * and then make a vmap() ourselves. - */ - if (nvgpu_is_enabled(g, NVGPU_USE_COHERENT_SYSMEM)) - flags |= NVGPU_DMA_NO_KERNEL_MAPPING; - /* * Before the debug print so we see this in the total. But during * cleanup in the fail path this has to be subtracted. @@ -240,16 +230,6 @@ int nvgpu_dma_alloc_flags_sys(struct gk20a *g, unsigned long flags, if (err) goto fail_free_dma; - if (nvgpu_is_enabled(g, NVGPU_USE_COHERENT_SYSMEM)) { - mem->cpu_va = vmap(mem->priv.pages, - size >> PAGE_SHIFT, - 0, PAGE_KERNEL); - if (!mem->cpu_va) { - err = -ENOMEM; - goto fail_free_sgt; - } - } - mem->aligned_size = size; mem->aperture = APERTURE_SYSMEM; mem->priv.flags = flags; @@ -258,8 +238,6 @@ int nvgpu_dma_alloc_flags_sys(struct gk20a *g, unsigned long flags, return 0; -fail_free_sgt: - nvgpu_free_sgtable(g, &mem->priv.sgt); fail_free_dma: dma_free_attrs(d, size, alloc_ret, iova, NVGPU_DMA_ATTR(dma_attrs)); mem->cpu_va = NULL; @@ -364,12 +342,6 @@ 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)) { - /* - * Free side of WAR for bug 2040115. - */ - if (nvgpu_is_enabled(g, NVGPU_USE_COHERENT_SYSMEM)) - vunmap(mem->cpu_va); - if (mem->priv.flags) { NVGPU_DEFINE_DMA_ATTRS(dma_attrs); diff --git a/drivers/gpu/nvgpu/os/linux/nvgpu_mem.c b/drivers/gpu/nvgpu/os/linux/nvgpu_mem.c index 6c45a920a..663b7ac36 100644 --- a/drivers/gpu/nvgpu/os/linux/nvgpu_mem.c +++ b/drivers/gpu/nvgpu/os/linux/nvgpu_mem.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2017-2019, NVIDIA CORPORATION. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -163,14 +163,8 @@ int nvgpu_mem_create_from_mem(struct gk20a *g, dest->skip_wmb = src->skip_wmb; dest->size = size; - /* - * Re-use the CPU mapping only if the mapping was made by the DMA API. - * - * Bug 2040115: the DMA API wrapper makes the mapping that we should - * re-use. - */ - if (!(src->priv.flags & NVGPU_DMA_NO_KERNEL_MAPPING) || - nvgpu_is_enabled(g, NVGPU_USE_COHERENT_SYSMEM)) + /* Re-use the CPU mapping only if the mapping was made by the DMA API */ + if (!(src->priv.flags & NVGPU_DMA_NO_KERNEL_MAPPING)) dest->cpu_va = src->cpu_va + (PAGE_SIZE * start_page); dest->priv.pages = src->priv.pages + start_page;