drm/amdgpu: release the IMU firmware with the other GFX microcode
Subsystems (2)
PATCH 1/1 drm/amdgpu: release the IMU firmware with the other GFX microcode
The IMU firmware of GFX11 and GFX12 is only released when loading the microcode fails. Every unload or unbind of such a device leaks it. On navi31, binding and unbinding the device leaves:
unreferenced object 0xffff88810dd6cd80 (size 32):
comm "modprobe", pid 2891, jiffies 4294943088
backtrace:
_request_firmware+0x207/0xad0
request_firmware+0x3b/0x60
amdgpu_ucode_request+0x150/0x330 [amdgpu]
amdgpu_device_init+0x2d70/0xa650 [amdgpu]
amdgpu_driver_load_kms+0x1e/0x140 [amdgpu]a struct firmware of 132352 bytes, the size of gc_11_0_0_imu.bin. Release it in the free_microcode() functions; with that it's gone.
--- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 1 + drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 1 + drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c | 1 + 3 files changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +1 -0
@@ -695,6 +695,7 @@ static void gfx_v11_0_free_microcode(struct amdgpu_device *adev)amdgpu_ucode_release (&adev->gfx.me_fw);amdgpu_ucode_release (&adev->gfx.rlc_fw);amdgpu_ucode_release (&adev->gfx.mec_fw); +amdgpu_ucode_release (&adev->gfx.imu_fw);kfree (adev->gfx.rlc.register_list_format); }
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +1 -0
@@ -570,6 +570,7 @@ static void gfx_v12_0_free_microcode(struct amdgpu_device *adev)amdgpu_ucode_release (&adev->gfx.me_fw);amdgpu_ucode_release (&adev->gfx.rlc_fw);amdgpu_ucode_release (&adev->gfx.mec_fw); +amdgpu_ucode_release (&adev->gfx.imu_fw);kfree (adev->gfx.rlc.register_list_format); }
drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c +1 -0
@@ -350,6 +350,7 @@ static void gfx_v12_1_free_microcode(struct amdgpu_device *adev) {amdgpu_ucode_release (&adev->gfx.rlc_fw);amdgpu_ucode_release (&adev->gfx.mec_fw); +amdgpu_ucode_release (&adev->gfx.imu_fw);kfree (adev->gfx.rlc.register_list_format); }
Signature · 1 line
2.50.1
Quoted 14 lines · Jesse Zhang
The IMU firmware of GFX11 and GFX12 is only released when loading the microcode fails. Every unload or unbind of such a device leaks it. On navi31, binding and unbinding the device leaves:
unreferenced object
0xffff88810dd6cd80(size 32):comm "modprobe", pid 2891, jiffies 4294943088 backtrace: _request_firmware+0x207/0xad0 request_firmware+0x3b/0x60 amdgpu_ucode_request+0x150/0x330 [amdgpu] amdgpu_device_init+0x2d70/0xa650 [amdgpu] amdgpu_driver_load_kms+0x1e/0x140 [amdgpu]
Quoted 7 lines
a struct firmware of 132352 bytes, the size of gc_11_0_0_imu.bin. Release it in the
free_microcode()functions; with that it's gone.Fixes 289bcffb9d76 ("drm/amdgpu: support imu for gfx11")Fixes 32d163768989 ("drm/amd/amdgpu: imu fw loading support")Fixes a0f8297068cf ("drm/amdgpu: add imu support for gc 12_1")Signed-off-by Jesse Zhang <[email protected]>
Quoted 45 lines
--- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 1 + drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 1 + drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c | 1 + 3 files changed, 3 insertions(+)drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +1
-0@@ -695,6 +695,7 @@ static void gfx_v11_0_free_microcode(struct amdgpu_device *adev)amdgpu_ucode_release (&adev->gfx.me_fw);amdgpu_ucode_release (&adev->gfx.rlc_fw);amdgpu_ucode_release (&adev->gfx.mec_fw); +amdgpu_ucode_release (&adev->gfx.imu_fw);kfree (adev->gfx.rlc.register_list_format); }drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +1
-0@@ -570,6 +570,7 @@ static void gfx_v12_0_free_microcode(struct amdgpu_device *adev)amdgpu_ucode_release (&adev->gfx.me_fw);amdgpu_ucode_release (&adev->gfx.rlc_fw);amdgpu_ucode_release (&adev->gfx.mec_fw); +amdgpu_ucode_release (&adev->gfx.imu_fw);kfree (adev->gfx.rlc.register_list_format); }drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c +1
-1@@ -350,6 +350,7 @@ static void gfx_v12_1_free_microcode(struct amdgpu_device *adev) {amdgpu_ucode_release (&adev->gfx.rlc_fw);amdgpu_ucode_release (&adev->gfx.mec_fw); +amdgpu_ucode_release (&adev->gfx.imu_fw);kfree (adev->gfx.rlc.register_list_format); } --2.50.1