From 8c5972ac7f551b2cfef69eec3d91d6ce1ccba20d Mon Sep 17 00:00:00 2001 From: Alex Waterman Date: Mon, 15 Jun 2020 18:58:13 -0500 Subject: [PATCH] gpu: nvgpu: Move device de-init call Move the device de-init call to when the gk20a struct is being freed; the device list can live for as long as the gk20a struct does. This will be a problem later, since the current location causes the device structs to get freed and allocatoed over and over. That'll cause gross corruption in the FIFO code when the engine_info struct is replaced with pointers to the device structs. JIRA NVGPU-5421 Change-Id: If4e08ea88dbcae7acd599e3fad29f72ece63b8e0 Signed-off-by: Alex Waterman Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2361269 Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-misra Reviewed-by: svc-mobile-cert Reviewed-by: Deepak Nibade Reviewed-by: Konsta Holtta Reviewed-by: mobile promotions GVS: Gerrit_Virtual_Submit Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/device.c | 7 +++++++ drivers/gpu/nvgpu/common/init/nvgpu_init.c | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/nvgpu/common/device.c b/drivers/gpu/nvgpu/common/device.c index 47da59b89..13a346f06 100644 --- a/drivers/gpu/nvgpu/common/device.c +++ b/drivers/gpu/nvgpu/common/device.c @@ -116,6 +116,13 @@ void nvgpu_device_cleanup(struct gk20a *g) u32 i; struct nvgpu_list_node *devlist; + /* + * Make unit testing a bit easier. + */ + if (g->devs == NULL) { + return; + } + for (i = 0; i < NVGPU_MAX_DEVTYPE; i++) { devlist = &g->devs->devlist_heads[i]; diff --git a/drivers/gpu/nvgpu/common/init/nvgpu_init.c b/drivers/gpu/nvgpu/common/init/nvgpu_init.c index 13a15b3b7..fd37d95ba 100644 --- a/drivers/gpu/nvgpu/common/init/nvgpu_init.c +++ b/drivers/gpu/nvgpu/common/init/nvgpu_init.c @@ -326,8 +326,6 @@ int nvgpu_prepare_poweroff(struct gk20a *g) } #endif - nvgpu_device_cleanup(g); - /* Disable GPCPLL */ if (g->ops.clk.suspend_clk_support != NULL) { g->ops.clk.suspend_clk_support(g); @@ -868,6 +866,8 @@ static void gk20a_free_cb(struct nvgpu_ref *refcount) g->ops.ltc.ltc_remove_support(g); } + nvgpu_device_cleanup(g); + nvgpu_sw_quiesce_remove_support(g); if (g->gfree != NULL) {