drm/amdgpu: add release firmware for cgs
Subsystems (2)
PATCH 1/2 drm/amdgpu: add release firmware for cgs
From: Monk Liu <[email protected]>
Powerplay uses cgs to load the firmware so add a function to release it as well to avoid leaking it on driver unload.
Signed-off-by Monk Liu <[email protected]>
Reviewed-by Alex Deucher <[email protected]>
Signed-off-by Alex Deucher <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | 12 ++++++++++++ drivers/gpu/drm/amd/include/cgs_common.h | 6 ++++++ 2 files changed, 18 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c +12 -0
@@ -696,6 +696,17 @@ static uint32_t fw_type_convert(struct cgs_device *cgs_device, uint32_t fw_type)return result; } +static int amdgpu_cgs_rel_firmware (struct cgs_device *cgs_device,enum cgs_ucode_id type) +{ +CGS_FUNC_ADEV ; +if ((CGS_UCODE_ID_SMU == type) || (CGS_UCODE_ID_SMU_SK == type)) { +release_firmware (adev->pm.fw); +return 0 ; + } +/* cannot release other firmware because they are not created by cgs */ +return -EINVAL ; +} +static int amdgpu_cgs_get_firmware_info (struct cgs_device *cgs_device,enum cgs_ucode_id type,struct cgs_firmware_info *info)
@@ -1125,6 +1136,7 @@ static const struct cgs_ops amdgpu_cgs_ops = { amdgpu_cgs_pm_query_clock_limits, amdgpu_cgs_set_camera_voltages, amdgpu_cgs_get_firmware_info, + amdgpu_cgs_rel_firmware, amdgpu_cgs_set_powergating_state, amdgpu_cgs_set_clockgating_state, amdgpu_cgs_get_active_displays_info,
drivers/gpu/drm/amd/include/cgs_common.h +6 -0
@@ -581,6 +581,9 @@ typedef int (*cgs_get_firmware_info)(struct cgs_device *cgs_device,enum cgs_ucode_id type, struct cgs_firmware_info *info); +typedef int (*cgs_rel_firmware )(struct cgs_device *cgs_device, +enum cgs_ucode_id type); +typedef int (*cgs_set_powergating_state )(struct cgs_device *cgs_device,enum amd_ip_block_type block_type,enum amd_powergating_state state);
@@ -645,6 +648,7 @@ struct cgs_ops {cgs_set_camera_voltages_t set_camera_voltages;/* Firmware Info */ cgs_get_firmware_info get_firmware_info; +cgs_rel_firmware rel_firmware;/* cg pg interface*/ cgs_set_powergating_state set_powergating_state;cgs_set_clockgating_state set_clockgating_state;
@@ -738,6 +742,8 @@ struct cgs_device CGS_CALL(set_camera_voltages,dev,mask,voltages)#define cgs_get_firmware_info (dev, type, info) \ CGS_CALL(get_firmware_info, dev, type, info) +#define cgs_rel_firmware (dev, type) \ + CGS_CALL(rel_firmware, dev, type)#define cgs_set_powergating_state (dev, block_type, state) \ CGS_CALL(set_powergating_state, dev, block_type, state)#define cgs_set_clockgating_state (dev, block_type, state) \
Signature · 6 lines
2.5.5 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 2/2 drm/amdgpu: fix smu ucode memleak (v2)
From: Monk Liu <[email protected]>
Properly release the smu ucode in powerplay.
v2: agd: add polaris as well
Signed-off-by Monk Liu <[email protected]>
Reviewed-by Alex Deucher <[email protected]>
Signed-off-by Alex Deucher <[email protected]>
--- drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.c | 2 ++ drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smumgr.c | 1 + drivers/gpu/drm/amd/powerplay/smumgr/tonga_smumgr.c | 2 ++ 3 files changed, 5 insertions(+)
drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.c +2 -0
@@ -1014,6 +1014,8 @@ static int fiji_smu_fini(struct pp_smumgr *smumgr)kfree (smumgr->backend); smumgr->backend =NULL ; } + +cgs_rel_firmware (smumgr->device,CGS_UCODE_ID_SMU );return 0 ; }
drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smumgr.c +1 -0
@@ -469,6 +469,7 @@ int polaris10_smu_fini(struct pp_smumgr *smumgr)kfree (smumgr->backend); smumgr->backend =NULL ; } +cgs_rel_firmware (smumgr->device,CGS_UCODE_ID_SMU );return 0 ; }
drivers/gpu/drm/amd/powerplay/smumgr/tonga_smumgr.c +2 -0
@@ -337,6 +337,8 @@ static int tonga_smu_fini(struct pp_smumgr *smumgr)kfree (smumgr->backend); smumgr->backend =NULL ; } + +cgs_rel_firmware (smumgr->device,CGS_UCODE_ID_SMU );return 0 ; }
Signature · 6 lines
2.5.5 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel