gpu: nvgpu: free memory during module removal

Following pointers(allocated via Kmalloc/DMA) aren't freed during
module removal.

struct nvgpu_gr_config -> gpc_tpc_mask_physical
struct nvgpu_netlist_vars -> ctxsw_regs.etpc.l
struct mm_gk20a -> sysmem_flush
struct nvgpu_pmu_pg -> pg_buf
SGTable corresponding to VPR secure buffer.

Added appropriate free calls.

Bug 3364181

Change-Id: I2105c1f3256b1910f0f514d98f0ee3ae2e34aff7
Signed-off-by: Debarshi Dutta <ddutta@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2586244
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Seshendra Gadagottu <sgadagottu@nvidia.com>
Reviewed-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
This commit is contained in:
Debarshi Dutta
2021-08-31 09:54:53 +05:30
committed by mobile promotions
parent 79fb97100d
commit 33740b41b6
5 changed files with 33 additions and 1 deletions

View File

@@ -201,6 +201,7 @@ static void gr_config_free_mem(struct gk20a *g,
#endif #endif
nvgpu_kfree(g, config->gpc_tpc_mask); nvgpu_kfree(g, config->gpc_tpc_mask);
nvgpu_kfree(g, config->gpc_tpc_count); nvgpu_kfree(g, config->gpc_tpc_count);
nvgpu_kfree(g, config->gpc_tpc_mask_physical);
} }
static bool gr_config_alloc_struct_mem(struct gk20a *g, static bool gr_config_alloc_struct_mem(struct gk20a *g,

View File

@@ -115,6 +115,11 @@ static int nvgpu_alloc_sysmem_flush(struct gk20a *g)
return nvgpu_dma_alloc_sys(g, SZ_4K, &g->mm.sysmem_flush); return nvgpu_dma_alloc_sys(g, SZ_4K, &g->mm.sysmem_flush);
} }
static void nvgpu_free_sysmem_flush(struct gk20a *g)
{
nvgpu_dma_free(g, &g->mm.sysmem_flush);
}
#ifdef CONFIG_NVGPU_DGPU #ifdef CONFIG_NVGPU_DGPU
static void nvgpu_remove_mm_ce_support(struct mm_gk20a *mm) static void nvgpu_remove_mm_ce_support(struct mm_gk20a *mm)
{ {
@@ -172,6 +177,8 @@ static void nvgpu_remove_mm_support(struct mm_gk20a *mm)
nvgpu_vm_put(mm->cde.vm); nvgpu_vm_put(mm->cde.vm);
} }
nvgpu_free_sysmem_flush(g);
#ifdef CONFIG_NVGPU_SW_SEMAPHORE #ifdef CONFIG_NVGPU_SW_SEMAPHORE
nvgpu_semaphore_sea_destroy(g); nvgpu_semaphore_sea_destroy(g);
#endif #endif

View File

@@ -794,6 +794,8 @@ void nvgpu_netlist_deinit_ctx_vars(struct gk20a *g)
nvgpu_kfree(g, netlist_vars->ctxsw_regs.perf_pma.l); nvgpu_kfree(g, netlist_vars->ctxsw_regs.perf_pma.l);
nvgpu_kfree(g, netlist_vars->ctxsw_regs.pm_rop.l); nvgpu_kfree(g, netlist_vars->ctxsw_regs.pm_rop.l);
nvgpu_kfree(g, netlist_vars->ctxsw_regs.pm_ucgpc.l); nvgpu_kfree(g, netlist_vars->ctxsw_regs.pm_ucgpc.l);
nvgpu_kfree(g, netlist_vars->ctxsw_regs.etpc.l);
#if defined(CONFIG_NVGPU_NON_FUSA) #if defined(CONFIG_NVGPU_NON_FUSA)
nvgpu_kfree(g, netlist_vars->ctxsw_regs.sys_compute.l); nvgpu_kfree(g, netlist_vars->ctxsw_regs.sys_compute.l);
nvgpu_kfree(g, netlist_vars->ctxsw_regs.gpc_compute.l); nvgpu_kfree(g, netlist_vars->ctxsw_regs.gpc_compute.l);

View File

@@ -912,6 +912,9 @@ void nvgpu_pmu_pg_deinit(struct gk20a *g, struct nvgpu_pmu *pmu,
if (nvgpu_mem_is_valid(&pg->seq_buf)) { if (nvgpu_mem_is_valid(&pg->seq_buf)) {
nvgpu_dma_unmap_free(vm, &pg->seq_buf); nvgpu_dma_unmap_free(vm, &pg->seq_buf);
} }
if (nvgpu_mem_is_valid(&pg->pg_buf)) {
nvgpu_dma_unmap_free(vm, &pg->pg_buf);
}
nvgpu_mutex_destroy(&pg->elpg_mutex); nvgpu_mutex_destroy(&pg->elpg_mutex);
nvgpu_mutex_destroy(&pg->pg_mutex); nvgpu_mutex_destroy(&pg->pg_mutex);
nvgpu_kfree(g, pg); nvgpu_kfree(g, pg);

View File

@@ -116,6 +116,25 @@ static void gk20a_tegra_secure_page_destroy(struct gk20a *g,
secure_buffer->destroy = NULL; secure_buffer->destroy = NULL;
} }
static void gk20a_free_secure_buffer(struct gk20a *g,
struct nvgpu_mem *mem)
{
if (!nvgpu_mem_is_valid(mem))
return;
if (mem->priv.sgt != NULL) {
sg_free_table(mem->priv.sgt);
}
nvgpu_kfree(g, mem->priv.sgt);
mem->priv.sgt = NULL;
mem->size = 0;
mem->aligned_size = 0;
mem->aperture = APERTURE_INVALID;
}
static int gk20a_tegra_secure_alloc(struct gk20a *g, static int gk20a_tegra_secure_alloc(struct gk20a *g,
struct nvgpu_mem *desc_mem, size_t size, struct nvgpu_mem *desc_mem, size_t size,
global_ctx_mem_destroy_fn *destroy) global_ctx_mem_destroy_fn *destroy)
@@ -156,7 +175,7 @@ static int gk20a_tegra_secure_alloc(struct gk20a *g,
/* This bypasses SMMU for VPR during gmmu_map. */ /* This bypasses SMMU for VPR during gmmu_map. */
sg_dma_address(sgt->sgl) = 0; sg_dma_address(sgt->sgl) = 0;
*destroy = NULL; *destroy = gk20a_free_secure_buffer;
desc_mem->priv.sgt = sgt; desc_mem->priv.sgt = sgt;
desc_mem->size = size; desc_mem->size = size;