On Mon, Jun 1, 2020 at 3:31 AM Evan Quan <evan.quan@xxxxxxx> wrote: > > To avoid possible memory leak. > > Change-Id: I4740eac7fc2c6e934ec8f503e5a98057f0902f4a > Signed-off-by: Evan Quan <evan.quan@xxxxxxx> Reviewed-by: Alex Deucher <alexander.deucher@xxxxxxx> > --- > drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 2 ++ > drivers/gpu/drm/amd/powerplay/arcturus_ppt.c | 1 + > drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 1 + > drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h | 2 ++ > drivers/gpu/drm/amd/powerplay/navi10_ppt.c | 1 + > drivers/gpu/drm/amd/powerplay/smu_internal.h | 2 ++ > drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 9 +++++++++ > 7 files changed, 18 insertions(+) > > diff --git a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c > index b353ac1b0f07..197fef6f59a8 100644 > --- a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c > +++ b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c > @@ -1127,6 +1127,8 @@ static int smu_sw_fini(void *handle) > return ret; > } > > + smu_fini_microcode(smu); > + > return 0; > } > > diff --git a/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c b/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c > index c5c23126ec2d..db2d86e3953b 100644 > --- a/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c > +++ b/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c > @@ -2435,6 +2435,7 @@ static const struct pptable_funcs arcturus_ppt_funcs = { > .i2c_eeprom_fini = arcturus_i2c_eeprom_control_fini, > .init_microcode = smu_v11_0_init_microcode, > .load_microcode = smu_v11_0_load_microcode, > + .fini_microcode = smu_v11_0_fini_microcode, > .init_smc_tables = smu_v11_0_init_smc_tables, > .fini_smc_tables = smu_v11_0_fini_smc_tables, > .init_power = smu_v11_0_init_power, > diff --git a/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h b/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h > index 7fed2556213f..718aecde88c0 100644 > --- a/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h > +++ b/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h > @@ -495,6 +495,7 @@ struct pptable_funcs { > int (*get_dpm_clock_table)(struct smu_context *smu, struct dpm_clocks *clock_table); > int (*init_microcode)(struct smu_context *smu); > int (*load_microcode)(struct smu_context *smu); > + void (*fini_microcode)(struct smu_context *smu); > int (*init_smc_tables)(struct smu_context *smu); > int (*fini_smc_tables)(struct smu_context *smu); > int (*init_power)(struct smu_context *smu); > diff --git a/drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h b/drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h > index 8d317e05f65b..4da5f5e87c81 100644 > --- a/drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h > +++ b/drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h > @@ -145,6 +145,8 @@ enum smu_v11_0_baco_seq { > > int smu_v11_0_init_microcode(struct smu_context *smu); > > +void smu_v11_0_fini_microcode(struct smu_context *smu); > + > int smu_v11_0_load_microcode(struct smu_context *smu); > > int smu_v11_0_init_smc_tables(struct smu_context *smu); > diff --git a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c > index caa4355b601e..ebbbe38dfb63 100644 > --- a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c > +++ b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c > @@ -2311,6 +2311,7 @@ static const struct pptable_funcs navi10_ppt_funcs = { > .update_pcie_parameters = navi10_update_pcie_parameters, > .init_microcode = smu_v11_0_init_microcode, > .load_microcode = smu_v11_0_load_microcode, > + .fini_microcode = smu_v11_0_fini_microcode, > .init_smc_tables = smu_v11_0_init_smc_tables, > .fini_smc_tables = smu_v11_0_fini_smc_tables, > .init_power = smu_v11_0_init_power, > diff --git a/drivers/gpu/drm/amd/powerplay/smu_internal.h b/drivers/gpu/drm/amd/powerplay/smu_internal.h > index 0c7d5f0b1cd1..dbdb870011d3 100644 > --- a/drivers/gpu/drm/amd/powerplay/smu_internal.h > +++ b/drivers/gpu/drm/amd/powerplay/smu_internal.h > @@ -27,6 +27,8 @@ > > #define smu_init_microcode(smu) \ > ((smu)->ppt_funcs->init_microcode ? (smu)->ppt_funcs->init_microcode((smu)) : 0) > +#define smu_fini_microcode(smu) \ > + ((smu)->ppt_funcs->fini_microcode ? (smu)->ppt_funcs->fini_microcode((smu)) : 0) > #define smu_init_smc_tables(smu) \ > ((smu)->ppt_funcs->init_smc_tables ? (smu)->ppt_funcs->init_smc_tables((smu)) : 0) > #define smu_fini_smc_tables(smu) \ > diff --git a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c > index e2b1c619151f..10ae4575ccb2 100644 > --- a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c > +++ b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c > @@ -195,6 +195,15 @@ int smu_v11_0_init_microcode(struct smu_context *smu) > return err; > } > > +void smu_v11_0_fini_microcode(struct smu_context *smu) > +{ > + struct amdgpu_device *adev = smu->adev; > + > + release_firmware(adev->pm.fw); > + adev->pm.fw = NULL; > + adev->pm.fw_version = 0; > +} > + > int smu_v11_0_load_microcode(struct smu_context *smu) > { > struct amdgpu_device *adev = smu->adev; > -- > 2.26.2 > > _______________________________________________ > amd-gfx mailing list > amd-gfx@xxxxxxxxxxxxxxxxxxxxx > https://lists.freedesktop.org/mailman/listinfo/amd-gfx _______________________________________________ amd-gfx mailing list amd-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/amd-gfx