[AMD Official Use Only - Internal Distribution Only]
before this patch, the driver has same code logic at "drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c"
related patch: drm/amdgpu: fix sdma3 ucode mem leak
commit 14d83e78c578a6c45163fb399ee760fe0d314bad
Author: Monk Liu <Monk.Liu@xxxxxxx>
Date: Mon May 30 15:15:32 2016 +0800
drm/amdgpu: fix sdma3 ucode mem leak
Signed-off-by: Monk Liu <Monk.Liu@xxxxxxx>
Reviewed-by: Christian König <christian.koenig@xxxxxxx>
Signed-off-by: Alex Deucher <alexander.deucher@xxxxxxx>
diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c b/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c
index 33605d4ac2d9..532ea88da66a 100644
--- a/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c
@@ -236,6 +236,15 @@ static void sdma_v3_0_init_golden_registers(struct amdgpu_device *adev)
}
}
+static void sdma_v3_0_free_microcode(struct amdgpu_device *adev)
+{
+ int i;
+ for (i = 0; i < adev->sdma.num_instances; i++) {
+ release_firmware(adev->sdma.instance[i].fw);
+ adev->sdma.instance[i].fw = NULL;
+ }
+}
+
/**
* sdma_v3_0_init_microcode - load ucode images from disk
*
@@ -1256,6 +1265,7 @@ static int sdma_v3_0_sw_fini(void *handle)
for (i = 0; i < adev->sdma.num_instances; i++)
amdgpu_ring_fini(&adev->sdma.instance[i].ring);
+ sdma_v3_0_free_microcode(adev);
return 0;
}
Best Regards,
Kevin
From: Sheng, Wenhui <Wenhui.Sheng@xxxxxxx>
Sent: Thursday, June 18, 2020 5:21 PM To: Wang, Kevin(Yang) <Kevin1.Wang@xxxxxxx>; amd-gfx@xxxxxxxxxxxxxxxxxxxxx <amd-gfx@xxxxxxxxxxxxxxxxxxxxx> Subject: RE: [PATCH 2/2] drm/amdgpu: add fw release for sdma v5_0
[AMD Official Use Only - Internal Distribution Only] [AMD Official Use Only - Internal Distribution Only]
Hmmmm….
Brs Wenhui
From: Wang, Kevin(Yang) <Kevin1.Wang@xxxxxxx>
[AMD Official Use Only - Internal Distribution Only]
afte the API firmware_realease created, the api logic never changed. (the first commit by Linus) and you can use below command to reference the api usage case in our drm driver.
$ grep -nR "release_firmware" -A 5 -B 5 drivers/gpu/drm/ | vim -
Best Regards, Kevin
From: Sheng, Wenhui <Wenhui.Sheng@xxxxxxx>
[AMD Official Use Only - Internal Distribution Only]
[AMD Official Use Only - Internal Distribution Only]
Although we know that release_firmware has null check, but the code is not maintained by ourselves, so I think it’s much more safe to add null check before invoke release_firmware.
Brs Wenhui
From: Wang, Kevin(Yang) <Kevin1.Wang@xxxxxxx>
[AMD Official Use Only - Internal Distribution Only]
From: amd-gfx <amd-gfx-bounces@xxxxxxxxxxxxxxxxxxxxx> on behalf of Wenhui Sheng <Wenhui.Sheng@xxxxxxx>
sdma v5_0 fw isn't released when module exit [kevin]: the kernel api "release_firmware()" will check argument (is NULL pointer). i think the patch don't need to double check it.
+ |
_______________________________________________ amd-gfx mailing list amd-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/amd-gfx