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,