From b9082f076087d5420a5d7fe492ffefb2402397cc Mon Sep 17 00:00:00 2001 From: Alex Waterman Date: Wed, 13 Sep 2017 16:45:52 -0700 Subject: gpu: nvgpu: Add per-GPU total to DMA memory prints Track the total amount of DMA memory currently outstanding for each GPU. Print this total in the DMA debugging/logging prints. Bug 1956137 Change-Id: I929598e5aa388ee84db0badb4eb9f7c6cbe030c7 Signed-off-by: Alex Waterman Reviewed-on: https://git-master.nvidia.com/r/1559518 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/linux/dma.c | 13 ++++++++++++- drivers/gpu/nvgpu/gk20a/gk20a.h | 2 ++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/nvgpu/common/linux/dma.c b/drivers/gpu/nvgpu/common/linux/dma.c index eff60f5b..46b49930 100644 --- a/drivers/gpu/nvgpu/common/linux/dma.c +++ b/drivers/gpu/nvgpu/common/linux/dma.c @@ -100,9 +100,11 @@ static void __dma_dbg(struct gk20a *g, size_t size, unsigned long flags, __nvgpu_log_dbg(g, gpu_dbg_dma, __func__, __LINE__, - "DMA %s: [%s] size=%-7zu aligned=%-7zu %s", + "DMA %s: [%s] size=%-7zu " + "aligned=%-7zu total=%-10llukB %s", what, type, size, PAGE_ALIGN(size), + g->dma_memory_used >> 10, flags_str); if (flags_str) @@ -207,6 +209,12 @@ int nvgpu_dma_alloc_flags_sys(struct gk20a *g, unsigned long flags, int err; dma_addr_t iova; + /* + * Before the debug print so we see this in the total. But during + * cleanup in the fail path this has to be subtracted. + */ + g->dma_memory_used += mem->aligned_size; + dma_dbg_alloc(g, size, flags, "sysmem"); /* @@ -261,6 +269,7 @@ int nvgpu_dma_alloc_flags_sys(struct gk20a *g, unsigned long flags, return 0; fail_free: + g->dma_memory_used -= mem->aligned_size; dma_free_coherent(d, size, mem->cpu_va, iova); mem->cpu_va = NULL; mem->priv.sgt = NULL; @@ -452,6 +461,8 @@ static void nvgpu_dma_free_sys(struct gk20a *g, struct nvgpu_mem *mem) { struct device *d = dev_from_gk20a(g); + g->dma_memory_used -= mem->aligned_size; + dma_dbg_free(g, mem->size, mem->priv.flags, "sysmem"); if (!(mem->mem_flags & NVGPU_MEM_FLAG_SHADOW_COPY) && diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.h b/drivers/gpu/nvgpu/gk20a/gk20a.h index 8ac82428..48b34db7 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/gk20a.h @@ -1269,6 +1269,8 @@ struct gk20a { /* memory training sequence and mclk switch scripts */ u32 mem_config_idx; + u64 dma_memory_used; + #if defined(CONFIG_TEGRA_GK20A_NVHOST) && defined(CONFIG_TEGRA_19x_GPU) phys_addr_t syncpt_unit_base; size_t syncpt_unit_size; -- cgit v1.2.2