From 41df3e17a7cc6b00e4673ed1c977d4c58e6f2c46 Mon Sep 17 00:00:00 2001 From: Sagar Kamble Date: Thu, 25 Nov 2021 20:49:20 +0530 Subject: [PATCH] gpu: nvgpu: fix nvgpu remove sequence While removing the nvgpu module, all gpu unmaps should happen before removing the PMU support as ELPG_MS accesses pmu pg structure and ELPG_MS is disabled/enabled while accessing TLB or cache flush. nvgpu_fb_vab_teardown_hal and mmu_fault.info_mem_destroy do gpu unmaps. They were executed post removal of PMU support. Fix the sequence. Bug 3448630 Change-Id: I44925c313c625a2d0f297d1367d69069b3deacef Signed-off-by: Sagar Kamble Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2632490 Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-misra Reviewed-by: svc-mobile-cert Reviewed-by: Vijayakumar Subbu Reviewed-by: mobile promotions Tested-by: mobile promotions GVS: Gerrit_Virtual_Submit --- drivers/gpu/nvgpu/common/mm/mm.c | 11 ----------- drivers/gpu/nvgpu/common/vgpu/init/init_vgpu.c | 13 ++++++++++++- drivers/gpu/nvgpu/os/linux/module.c | 11 +++++++++++ 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/nvgpu/common/mm/mm.c b/drivers/gpu/nvgpu/common/mm/mm.c index 2d5365639..3f2bf54cc 100644 --- a/drivers/gpu/nvgpu/common/mm/mm.c +++ b/drivers/gpu/nvgpu/common/mm/mm.c @@ -143,17 +143,6 @@ static void nvgpu_remove_mm_support(struct mm_gk20a *mm) nvgpu_dma_free(g, &mm->mmu_wr_mem); nvgpu_dma_free(g, &mm->mmu_rd_mem); -#if defined(CONFIG_NVGPU_NON_FUSA) - if (nvgpu_fb_vab_teardown_hal(g) != 0) { - nvgpu_err(g, "failed to teardown VAB"); - } - -#endif - - if (g->ops.mm.mmu_fault.info_mem_destroy != NULL) { - g->ops.mm.mmu_fault.info_mem_destroy(g); - } - if (g->ops.mm.remove_bar2_vm != NULL) { g->ops.mm.remove_bar2_vm(g); } diff --git a/drivers/gpu/nvgpu/common/vgpu/init/init_vgpu.c b/drivers/gpu/nvgpu/common/vgpu/init/init_vgpu.c index 2e81ebb20..993cfdb0f 100644 --- a/drivers/gpu/nvgpu/common/vgpu/init/init_vgpu.c +++ b/drivers/gpu/nvgpu/common/vgpu/init/init_vgpu.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2020, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2014-2021, NVIDIA CORPORATION. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -37,6 +37,7 @@ #include #include #include +#include #include "init_vgpu.h" #include "hal/vgpu/init/init_hal_vgpu.h" @@ -84,6 +85,16 @@ void vgpu_remove_support_common(struct gk20a *g) g->fifo.remove_support(&g->fifo); } +#if defined(CONFIG_NVGPU_NON_FUSA) + if (nvgpu_fb_vab_teardown_hal(g) != 0) { + nvgpu_err(g, "failed to teardown VAB"); + } +#endif + + if (g->ops.mm.mmu_fault.info_mem_destroy != NULL) { + g->ops.mm.mmu_fault.info_mem_destroy(g); + } + nvgpu_pmu_remove_support(g, g->pmu); if (g->mm.remove_support) { diff --git a/drivers/gpu/nvgpu/os/linux/module.c b/drivers/gpu/nvgpu/os/linux/module.c index 72b646d86..e58f18851 100644 --- a/drivers/gpu/nvgpu/os/linux/module.c +++ b/drivers/gpu/nvgpu/os/linux/module.c @@ -65,6 +65,7 @@ #include #include #include +#include #include "platform_gk20a.h" #include "sysfs.h" @@ -1037,6 +1038,16 @@ void gk20a_remove_support(struct gk20a *g) if (g->fifo.remove_support) g->fifo.remove_support(&g->fifo); +#if defined(CONFIG_NVGPU_NON_FUSA) + if (nvgpu_fb_vab_teardown_hal(g) != 0) { + nvgpu_err(g, "failed to teardown VAB"); + } +#endif + + if (g->ops.mm.mmu_fault.info_mem_destroy != NULL) { + g->ops.mm.mmu_fault.info_mem_destroy(g); + } + nvgpu_pmu_remove_support(g, g->pmu); if (g->mm.remove_support)