drm/amd/powerplay: fix memory leakage when reload (v2)
authorYintian Tao <yttao@amd.com>
Thu, 4 Jan 2018 03:45:23 +0000 (11:45 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 10 Jan 2018 20:44:50 +0000 (15:44 -0500)
add smu_free_memory when smu fini to prevent memory leakage

v2: squash in typo fix (Yintian) and warning (Harry)

Signed-off-by: Yintian Tao <yttao@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.c

index cb95e882b98f9f2ccdcd9ef92776709d614d3d99..311ff371861899c5434eced750aabf8330c814a2 100644 (file)
@@ -648,6 +648,12 @@ int smu7_init(struct pp_hwmgr *hwmgr)
 
 int smu7_smu_fini(struct pp_hwmgr *hwmgr)
 {
+       struct smu7_smumgr *smu_data = (struct smu7_smumgr *)(hwmgr->smu_backend);
+
+       smu_free_memory(hwmgr->device, (void *) smu_data->header_buffer.handle);
+       if (!cgs_is_virtualization_enabled(hwmgr->device))
+               smu_free_memory(hwmgr->device, (void *) smu_data->smu_buffer.handle);
+
        kfree(hwmgr->smu_backend);
        hwmgr->smu_backend = NULL;
        cgs_rel_firmware(hwmgr->device, CGS_UCODE_ID_SMU);