[PATCH] drm/amdgpu/gfx6: fix firmware leak on teardown

Willian Oliveira posted 1 patch 2 days, 14 hours ago
drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c | 9 +++++++++
1 file changed, 9 insertions(+)
[PATCH] drm/amdgpu/gfx6: fix firmware leak on teardown
Posted by Willian Oliveira 2 days, 14 hours ago
The firmware requested in gfx_v6_0_init_microcode() is not released
when the GFX block is torn down, leaking the firmware resources.

Add gfx_v6_0_free_microcode() and call it from gfx_v6_0_sw_fini()
to release the PFP, ME, CE and RLC firmware.

Signed-off-by: Willian Oliveira <williandossantosdeoliveira287@gmail.com>
---
 drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c
index 95e939363db6..a5553d181d97 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c
@@ -322,6 +322,14 @@ static const u32 verde_rlc_save_restore_register_list[] =
 	0x00000000
 };
 
+static void gfx_v6_0_free_microcode(struct amdgpu_device *adev)
+{
+	amdgpu_ucode_release(&adev->gfx.pfp_fw);
+	amdgpu_ucode_release(&adev->gfx.me_fw);
+	amdgpu_ucode_release(&adev->gfx.ce_fw);
+	amdgpu_ucode_release(&adev->gfx.rlc_fw);
+}
+
 static int gfx_v6_0_init_microcode(struct amdgpu_device *adev)
 {
 	const char *chip_name;
@@ -3254,6 +3262,7 @@ static int gfx_v6_0_sw_fini(struct amdgpu_ip_block *ip_block)
 		amdgpu_ring_fini(&adev->gfx.compute_ring[i]);
 
 	amdgpu_gfx_rlc_fini(adev);
+	gfx_v6_0_free_microcode(adev);
 
 	return 0;
 }
-- 
2.47.3
Re: [PATCH] drm/amdgpu/gfx6: fix firmware leak on teardown
Posted by Alex Deucher 2 days, 2 hours ago
Applied.  Thanks!

On Mon, Sep 21, 2026 at 10:01 PM Willian Oliveira
<williandossantosdeoliveira287@gmail.com> wrote:
>
> The firmware requested in gfx_v6_0_init_microcode() is not released
> when the GFX block is torn down, leaking the firmware resources.
>
> Add gfx_v6_0_free_microcode() and call it from gfx_v6_0_sw_fini()
> to release the PFP, ME, CE and RLC firmware.
>
> Signed-off-by: Willian Oliveira <williandossantosdeoliveira287@gmail.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c
> index 95e939363db6..a5553d181d97 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c
> @@ -322,6 +322,14 @@ static const u32 verde_rlc_save_restore_register_list[] =
>         0x00000000
>  };
>
> +static void gfx_v6_0_free_microcode(struct amdgpu_device *adev)
> +{
> +       amdgpu_ucode_release(&adev->gfx.pfp_fw);
> +       amdgpu_ucode_release(&adev->gfx.me_fw);
> +       amdgpu_ucode_release(&adev->gfx.ce_fw);
> +       amdgpu_ucode_release(&adev->gfx.rlc_fw);
> +}
> +
>  static int gfx_v6_0_init_microcode(struct amdgpu_device *adev)
>  {
>         const char *chip_name;
> @@ -3254,6 +3262,7 @@ static int gfx_v6_0_sw_fini(struct amdgpu_ip_block *ip_block)
>                 amdgpu_ring_fini(&adev->gfx.compute_ring[i]);
>
>         amdgpu_gfx_rlc_fini(adev);
> +       gfx_v6_0_free_microcode(adev);
>
>         return 0;
>  }
> --
> 2.47.3
>