From e212e851a3ab65dcbc041345f17b965ede3acc48 Mon Sep 17 00:00:00 2001 From: Alex Waterman Date: Thu, 7 Feb 2019 08:27:03 -0800 Subject: [PATCH] Revert "gpu: nvgpu: Remove force coherency" This reverts commit aec64d8f8bcda4a5270a16032005c7b5d1742656. Causes instability on Xavier Change-Id: Iae5e2d3316a86fba4bb3774367ef8e9c49a7b922 Signed-off-by: Alex Waterman Reviewed-on: https://git-master.nvidia.com/r/2014015 Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-misra Reviewed-by: Mahantesh Kumbar Tested-by: Mahantesh Kumbar Reviewed-by: Terje Bergstrom Reviewed-by: Vinod Gopalakrishnakurup GVS: Gerrit_Virtual_Submit Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/mm/gmmu/page_table.c | 10 +++++++++- drivers/gpu/nvgpu/common/mm/nvgpu_mem.c | 10 ++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/nvgpu/common/mm/gmmu/page_table.c b/drivers/gpu/nvgpu/common/mm/gmmu/page_table.c index 42393b688..0e4d55e97 100644 --- a/drivers/gpu/nvgpu/common/mm/gmmu/page_table.c +++ b/drivers/gpu/nvgpu/common/mm/gmmu/page_table.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2019, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2017-2018, NVIDIA CORPORATION. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -85,6 +85,14 @@ static u64 __nvgpu_gmmu_map(struct vm_gk20a *vm, return 0; } + /* + * If the GPU is IO coherent and the DMA API is giving us IO coherent + * CPU mappings then we gotta make sure we use the IO coherent aperture. + */ + if (nvgpu_is_enabled(g, NVGPU_USE_COHERENT_SYSMEM)) { + flags |= NVGPU_VM_MAP_IO_COHERENT; + } + /* * Later on, when we free this nvgpu_mem's GPU mapping, we are going to * potentially have to free the GPU VA space. If the address passed in diff --git a/drivers/gpu/nvgpu/common/mm/nvgpu_mem.c b/drivers/gpu/nvgpu/common/mm/nvgpu_mem.c index f4528cc88..74f4d1e61 100644 --- a/drivers/gpu/nvgpu/common/mm/nvgpu_mem.c +++ b/drivers/gpu/nvgpu/common/mm/nvgpu_mem.c @@ -64,6 +64,16 @@ u32 nvgpu_aperture_mask(struct gk20a *g, struct nvgpu_mem *mem, { enum nvgpu_aperture ap = mem->aperture; + /* + * Handle the coherent aperture: ideally most of the driver is not + * aware of the difference between coherent and non-coherent sysmem so + * we add this translation step here. + */ + if (nvgpu_is_enabled(g, NVGPU_USE_COHERENT_SYSMEM) && + ap == APERTURE_SYSMEM) { + ap = APERTURE_SYSMEM_COH; + } + return nvgpu_aperture_mask_coh(g, ap, sysmem_mask, sysmem_coh_mask,