drm/amdgpu:fix memleak
authorMonk Liu <Monk.Liu@amd.com>
Tue, 14 Nov 2017 08:55:14 +0000 (16:55 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 16 Nov 2017 18:36:24 +0000 (13:36 -0500)
those RLC used buffers are not cleared in GFX's sw_fini

Signed-off-by: Monk Liu <Monk.Liu@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c

index 00868764a0dd2cfedbc0317a3f1b7e6216d88424..5c8a7a48a4adb16834ab5893e2341c03a5899d7d 100644 (file)
@@ -4670,6 +4670,14 @@ static int gfx_v7_0_sw_fini(void *handle)
        gfx_v7_0_cp_compute_fini(adev);
        gfx_v7_0_rlc_fini(adev);
        gfx_v7_0_mec_fini(adev);
+       amdgpu_bo_free_kernel(&adev->gfx.rlc.clear_state_obj,
+                               &adev->gfx.rlc.clear_state_gpu_addr,
+                               (void **)&adev->gfx.rlc.cs_ptr);
+       if (adev->gfx.rlc.cp_table_size) {
+               amdgpu_bo_free_kernel(&adev->gfx.rlc.cp_table_obj,
+                               &adev->gfx.rlc.cp_table_gpu_addr,
+                               (void **)&adev->gfx.rlc.cp_table_ptr);
+       }
        gfx_v7_0_free_microcode(adev);
 
        return 0;
index b8002ac3e53691d159050159cb03c5b0ec009e61..9ecdf621a74a14994e9f657d161e8aa9c5cc3a52 100644 (file)
@@ -2118,6 +2118,15 @@ static int gfx_v8_0_sw_fini(void *handle)
 
        gfx_v8_0_mec_fini(adev);
        gfx_v8_0_rlc_fini(adev);
+       amdgpu_bo_free_kernel(&adev->gfx.rlc.clear_state_obj,
+                               &adev->gfx.rlc.clear_state_gpu_addr,
+                               (void **)&adev->gfx.rlc.cs_ptr);
+       if ((adev->asic_type == CHIP_CARRIZO) ||
+           (adev->asic_type == CHIP_STONEY)) {
+               amdgpu_bo_free_kernel(&adev->gfx.rlc.cp_table_obj,
+                               &adev->gfx.rlc.cp_table_gpu_addr,
+                               (void **)&adev->gfx.rlc.cp_table_ptr);
+       }
        gfx_v8_0_free_microcode(adev);
 
        return 0;
index bc32bbde1165ae43f54f83d9d34cd1a6405b272f..da43813d67a4ad56ddecb79ac0a749afe29abc43 100644 (file)
@@ -1468,6 +1468,14 @@ static int gfx_v9_0_sw_fini(void *handle)
 
        gfx_v9_0_mec_fini(adev);
        gfx_v9_0_ngg_fini(adev);
+       amdgpu_bo_free_kernel(&adev->gfx.rlc.clear_state_obj,
+                               &adev->gfx.rlc.clear_state_gpu_addr,
+                               (void **)&adev->gfx.rlc.cs_ptr);
+       if (adev->asic_type == CHIP_RAVEN) {
+               amdgpu_bo_free_kernel(&adev->gfx.rlc.cp_table_obj,
+                               &adev->gfx.rlc.cp_table_gpu_addr,
+                               (void **)&adev->gfx.rlc.cp_table_ptr);
+       }
        gfx_v9_0_free_microcode(adev);
 
        return 0;