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 <alexw@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1559518
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Alex Waterman
2017-09-13 16:45:52 -07:00
committed by mobile promotions
parent 3821811214
commit b9082f0760
2 changed files with 14 additions and 1 deletions

View File

@@ -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) &&

View File

@@ -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;