From de399ccb0019513a5f9e8f2bcadb02486f99bc80 Mon Sep 17 00:00:00 2001 From: Peter Daifuku Date: Fri, 27 Oct 2017 15:46:53 -0700 Subject: gpu: nvgpu: fix patch buf count update for vidmem gr_gk20a_ctx_patch_write_begin() updates the patch buffer data_count when the associated graphics context memory buffer has been CPU-mapped; it was doing so by looking for a non-null cpu_va. However, if the graphics context has been allocated from vidmem, cpu_va is always 0, so we can't tell if nvgpu_mem_begin() was called for the context buffer or not. Instead: - add a cpu_accessible flag to the nvgpu_mem struct and set it in nvgpu_mem_begin() - return the value of that flag in nvgpu_mem_cpu_accessible() - gr_gk20a_ctx_patch_write_begin() now calls this new function instead of checking cpu_va. Bug 2012077 JIRA ESRM-74 Change-Id: I8401699f30b4ae7154111721c25c7ec3ff95d329 Signed-off-by: Peter Daifuku Reviewed-on: https://git-master.nvidia.com/r/1587293 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/linux/nvgpu_mem.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'drivers/gpu/nvgpu/common/linux/nvgpu_mem.c') diff --git a/drivers/gpu/nvgpu/common/linux/nvgpu_mem.c b/drivers/gpu/nvgpu/common/linux/nvgpu_mem.c index 1dbbd1a0..2bf26602 100644 --- a/drivers/gpu/nvgpu/common/linux/nvgpu_mem.c +++ b/drivers/gpu/nvgpu/common/linux/nvgpu_mem.c @@ -60,6 +60,14 @@ int nvgpu_mem_begin(struct gk20a *g, struct nvgpu_mem *mem) { void *cpu_va; + if (WARN_ON(mem->cpu_accessible)) { + nvgpu_warn(g, "nested"); + return -EBUSY; + } + + /* flag that the intent is to allow CPU access to the memory. */ + mem->cpu_accessible = true; + if (mem->aperture != APERTURE_SYSMEM || g->mm.force_pramin) return 0; @@ -71,17 +79,14 @@ int nvgpu_mem_begin(struct gk20a *g, struct nvgpu_mem *mem) if (!(mem->priv.flags & NVGPU_DMA_NO_KERNEL_MAPPING)) return 0; - if (WARN_ON(mem->cpu_va)) { - nvgpu_warn(g, "nested"); - return -EBUSY; - } - cpu_va = vmap(mem->priv.pages, PAGE_ALIGN(mem->size) >> PAGE_SHIFT, 0, pgprot_writecombine(PAGE_KERNEL)); - if (WARN_ON(!cpu_va)) + if (WARN_ON(!cpu_va)) { + mem->cpu_accessible = false; return -ENOMEM; + } mem->cpu_va = cpu_va; return 0; @@ -89,6 +94,8 @@ int nvgpu_mem_begin(struct gk20a *g, struct nvgpu_mem *mem) void nvgpu_mem_end(struct gk20a *g, struct nvgpu_mem *mem) { + mem->cpu_accessible = false; + if (mem->aperture != APERTURE_SYSMEM || g->mm.force_pramin) return; -- cgit v1.2.2