From a885f682d6cf2476c0cee695942b5f4c2718aa70 Mon Sep 17 00:00:00 2001 From: Alex Waterman Date: Thu, 8 Feb 2018 13:41:29 -0800 Subject: gpu: nvgpu: Get coherency on gv100 + NVLINK working This patch does a couple of things. First it renames NVGPU_DMA_COHERENT to NVGPU_USE_COHERENT_SYSMEM since the former is somewhat ambiguous in meaning. The latter clearly states what must happen: nvgpu needs to treat sysmem as coherent. This flag does simply follow the state of the DMA API but there's no reason to expect a casual reader of the code to know that when the DMA API is coherent nvgpu must treat sysmem as coherent. One thing to note though: when the dGPU is using PCIe and the PCIe controller is coherent, it doesn't actually matter what we do. However, we use this flag for determining how to make CPU mappings in nvgpu_mem_begin() so this flag is still relevant for the CPU side of things. Next this patch adds a check in the core kernel GMMU mapping routine to make sure that when the NVGPU_USE_COHERENT_SYSMEM flag is set that the IO coherent flag is passed into the mapping code. This is the primary fix that made NVLINK start working. Finally the setting of the USE_COHERENT_SYSMEM flag and the NVGPU_SUPPORT_IO_COHERENCE flag were set both for PCIe and for iGPUs. The iGPU also must correctly match it's CPU mappings and GPU mappings for proper operation. JIRA EVLR-2333 Change-Id: Icd5f07167c9f48a0a2e8493e34c9cc6238e56907 Signed-off-by: Alex Waterman Reviewed-on: https://git-master.nvidia.com/r/1654519 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/linux/module.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'drivers/gpu/nvgpu/common/linux/module.c') diff --git a/drivers/gpu/nvgpu/common/linux/module.c b/drivers/gpu/nvgpu/common/linux/module.c index b103fcea..52348db0 100644 --- a/drivers/gpu/nvgpu/common/linux/module.c +++ b/drivers/gpu/nvgpu/common/linux/module.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -1107,6 +1108,7 @@ static int gk20a_probe(struct platform_device *dev) struct gk20a *gk20a; int err; struct gk20a_platform *platform = NULL; + struct device_node *np; if (dev->dev.of_node) { const struct of_device_id *match; @@ -1206,6 +1208,12 @@ static int gk20a_probe(struct platform_device *dev) gk20a->mm.has_physical_mode = !nvgpu_is_hypervisor_mode(gk20a); + np = nvgpu_get_node(gk20a); + if (of_dma_is_coherent(np)) { + __nvgpu_set_enabled(gk20a, NVGPU_USE_COHERENT_SYSMEM, true); + __nvgpu_set_enabled(gk20a, NVGPU_SUPPORT_IO_COHERENCE, true); + } + return 0; return_err: -- cgit v1.2.2