Commit c833d8aa authored by Monk Liu's avatar Monk Liu Committed by Alex Deucher

drm/amdgpu:fix firmware memoryleak(v2)

this fix memory leak due to request_firmware after driver
unloaded

v2:
release gmc firmware for gmc6/7/8 as well
Signed-off-by: default avatarMonk Liu <Monk.Liu@amd.com>
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 4ff184d7
...@@ -92,6 +92,12 @@ static int psp_sw_init(void *handle) ...@@ -92,6 +92,12 @@ static int psp_sw_init(void *handle)
static int psp_sw_fini(void *handle) static int psp_sw_fini(void *handle)
{ {
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
release_firmware(adev->psp.sos_fw);
adev->psp.sos_fw = NULL;
release_firmware(adev->psp.asd_fw);
adev->psp.asd_fw = NULL;
return 0; return 0;
} }
......
...@@ -384,6 +384,25 @@ static int gfx_v9_0_ring_test_ib(struct amdgpu_ring *ring, long timeout) ...@@ -384,6 +384,25 @@ static int gfx_v9_0_ring_test_ib(struct amdgpu_ring *ring, long timeout)
return r; return r;
} }
static void gfx_v9_0_free_microcode(struct amdgpu_device *adev)
{
release_firmware(adev->gfx.pfp_fw);
adev->gfx.pfp_fw = NULL;
release_firmware(adev->gfx.me_fw);
adev->gfx.me_fw = NULL;
release_firmware(adev->gfx.ce_fw);
adev->gfx.ce_fw = NULL;
release_firmware(adev->gfx.rlc_fw);
adev->gfx.rlc_fw = NULL;
release_firmware(adev->gfx.mec_fw);
adev->gfx.mec_fw = NULL;
release_firmware(adev->gfx.mec2_fw);
adev->gfx.mec2_fw = NULL;
kfree(adev->gfx.rlc.register_list_format);
}
static int gfx_v9_0_init_microcode(struct amdgpu_device *adev) static int gfx_v9_0_init_microcode(struct amdgpu_device *adev)
{ {
const char *chip_name; const char *chip_name;
...@@ -1429,6 +1448,7 @@ static int gfx_v9_0_sw_fini(void *handle) ...@@ -1429,6 +1448,7 @@ static int gfx_v9_0_sw_fini(void *handle)
gfx_v9_0_mec_fini(adev); gfx_v9_0_mec_fini(adev);
gfx_v9_0_ngg_fini(adev); gfx_v9_0_ngg_fini(adev);
gfx_v9_0_free_microcode(adev);
return 0; return 0;
} }
......
...@@ -901,6 +901,8 @@ static int gmc_v6_0_sw_fini(void *handle) ...@@ -901,6 +901,8 @@ static int gmc_v6_0_sw_fini(void *handle)
gmc_v6_0_gart_fini(adev); gmc_v6_0_gart_fini(adev);
amdgpu_gem_force_release(adev); amdgpu_gem_force_release(adev);
amdgpu_bo_fini(adev); amdgpu_bo_fini(adev);
release_firmware(adev->mc.fw);
adev->mc.fw = NULL;
return 0; return 0;
} }
......
...@@ -1050,6 +1050,8 @@ static int gmc_v7_0_sw_fini(void *handle) ...@@ -1050,6 +1050,8 @@ static int gmc_v7_0_sw_fini(void *handle)
gmc_v7_0_gart_fini(adev); gmc_v7_0_gart_fini(adev);
amdgpu_gem_force_release(adev); amdgpu_gem_force_release(adev);
amdgpu_bo_fini(adev); amdgpu_bo_fini(adev);
release_firmware(adev->mc.fw);
adev->mc.fw = NULL;
return 0; return 0;
} }
......
...@@ -1147,6 +1147,8 @@ static int gmc_v8_0_sw_fini(void *handle) ...@@ -1147,6 +1147,8 @@ static int gmc_v8_0_sw_fini(void *handle)
gmc_v8_0_gart_fini(adev); gmc_v8_0_gart_fini(adev);
amdgpu_gem_force_release(adev); amdgpu_gem_force_release(adev);
amdgpu_bo_fini(adev); amdgpu_bo_fini(adev);
release_firmware(adev->mc.fw);
adev->mc.fw = NULL;
return 0; return 0;
} }
......
...@@ -1264,6 +1264,11 @@ static int sdma_v4_0_sw_fini(void *handle) ...@@ -1264,6 +1264,11 @@ static int sdma_v4_0_sw_fini(void *handle)
for (i = 0; i < adev->sdma.num_instances; i++) for (i = 0; i < adev->sdma.num_instances; i++)
amdgpu_ring_fini(&adev->sdma.instance[i].ring); amdgpu_ring_fini(&adev->sdma.instance[i].ring);
for (i = 0; i < adev->sdma.num_instances; i++) {
release_firmware(adev->sdma.instance[i].fw);
adev->sdma.instance[i].fw = NULL;
}
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment