drm/amdgpu:fix firmware memoryleak
Subsystems (2)
PATCH 1/1 drm/amdgpu:fix firmware memoryleak
this fix memory leak due to request_firmware after driver unloaded
--- drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 6 ++++++ drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 20 ++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | 5 +++++ 3 files changed, 31 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +6 -0
@@ -92,6 +92,12 @@ static int psp_sw_init(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 ; }
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +20 -0
@@ -384,6 +384,25 @@ static int gfx_v9_0_ring_test_ib(struct amdgpu_ring *ring, long timeout)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) {const char *chip_name;
@@ -1429,6 +1448,7 @@ static int gfx_v9_0_sw_fini(void *handle)gfx_v9_0_mec_fini (adev);gfx_v9_0_ngg_fini (adev); +gfx_v9_0_free_microcode (adev);return 0 ; }
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +5 -0
@@ -1264,6 +1264,11 @@ static int sdma_v4_0_sw_fini(void *handle)for (i =0 ; i < adev->sdma.num_instances; i++)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 ; }
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 1505900920-23446-1-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org
Deucher, Alexander
Reviewed-by Alex DeucherQuoted 8 lines
-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Monk Liu
Sent: Wednesday, September 20, 2017 5:49 AM
To: [email protected]
Cc: Liu, Monk
Subject: [PATCH] drm/amdgpu:fix firmware memoryleak
Quoted 5 lines
this fix memory leak due to
request_firmwareafter driver unloadedChange-Id I7b4724deea0a095189c344eea3801e456e9cced0Signed-off-by Monk Liu <[email protected]>
Bonus points for fixing the gmc modules (mc ucode) as well.
Alex
Quoted 84 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 6 ++++++ drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 20 ++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | 5 +++++ 3 files changed, 31 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +6
-0@@ -92,6 +92,12 @@ static int psp_sw_init(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 ; }drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +19
-0@@ -384,6 +384,25 @@ static int gfx_v9_0_ring_test_ib(struct amdgpu_ring *ring, long timeout)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) {drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +1
-0const char *chip_name;@@ -1429,6 +1448,7 @@ static int gfx_v9_0_sw_fini(void *handle)gfx_v9_0_mec_fini (adev);gfx_v9_0_ngg_fini (adev); +gfx_v9_0_free_microcode (adev);return 0 ; }drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +5
-1@@ -1264,6 +1264,11 @@ static int sdma_v4_0_sw_fini(void *handle)for (i =0 ; i < adev->sdma.num_instances; i++)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 ; } --2.7.4
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx