Re: [PATCH v2] drm/amd/pp: Export load_firmware interface
Sorry, Please ignore this patch. Best Regards Rex From: amd-gfx on behalf of Rex Zhu Sent: Thursday, September 27, 2018 9:55 PM To: amd-gfx@lists.freedesktop.org Cc: Zhu, Rex Subject: [PATCH v2] drm/amd/pp: Export load_firmware interface Export this interface for the AMDGPU_FW_LOAD_SMU type. gfx/sdma can request smu to load firmware. Split the smu7/8_start_smu function into two functions 1. start_smu, used for load smu firmware in smu7/8 and check smu firmware version. 2. request_smu_load_fw, used for load other ip's firmware on smu7/8 and add firmware loading staus check. v2: default fw loading type is via smu for VI, driver call smu to load all fw at the begin of hw init. Signed-off-by: Rex Zhu --- drivers/gpu/drm/amd/amdgpu/vi.c| 16 ++ drivers/gpu/drm/amd/powerplay/amd_powerplay.c | 20 drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.c | 4 +- .../gpu/drm/amd/powerplay/smumgr/iceland_smumgr.c | 25 - .../drm/amd/powerplay/smumgr/polaris10_smumgr.c| 4 +- drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.c | 59 +- drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.h | 3 +- drivers/gpu/drm/amd/powerplay/smumgr/smu8_smumgr.c | 46 - .../gpu/drm/amd/powerplay/smumgr/tonga_smumgr.c| 12 - .../gpu/drm/amd/powerplay/smumgr/vegam_smumgr.c| 4 +- 10 files changed, 86 insertions(+), 107 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/vi.c b/drivers/gpu/drm/amd/amdgpu/vi.c index 88b57a5..3384a15 100644 --- a/drivers/gpu/drm/amd/amdgpu/vi.c +++ b/drivers/gpu/drm/amd/amdgpu/vi.c @@ -1222,6 +1222,16 @@ static int vi_common_hw_init(void *handle) /* enable the doorbell aperture */ vi_enable_doorbell_aperture(adev, true); + if (adev->firmware.load_type == AMDGPU_FW_LOAD_SMU) { + if (adev->powerplay.pp_funcs->load_firmware) { + amdgpu_ucode_init_bo(adev); + if (adev->powerplay.pp_funcs->load_firmware(adev->powerplay.pp_handle)) { + adev->firmware.load_type = AMDGPU_FW_LOAD_DIRECT; + amdgpu_ucode_fini_bo(adev); + } + } + } + return 0; } @@ -1235,6 +1245,12 @@ static int vi_common_hw_fini(void *handle) if (amdgpu_sriov_vf(adev)) xgpu_vi_mailbox_put_irq(adev); + if (adev->firmware.load_type == AMDGPU_FW_LOAD_SMU) { + release_firmware(adev->pm.fw); + adev->pm.fw = NULL; + amdgpu_ucode_fini_bo(adev); + } + return 0; } diff --git a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c index aff7c14..5dc8fb9 100644 --- a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c +++ b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c @@ -109,12 +109,6 @@ static int pp_sw_fini(void *handle) hwmgr_sw_fini(hwmgr); - if (adev->firmware.load_type == AMDGPU_FW_LOAD_SMU) { - release_firmware(adev->pm.fw); - adev->pm.fw = NULL; - amdgpu_ucode_fini_bo(adev); - } - return 0; } @@ -124,9 +118,6 @@ static int pp_hw_init(void *handle) struct amdgpu_device *adev = handle; struct pp_hwmgr *hwmgr = adev->powerplay.pp_handle; - if (adev->firmware.load_type == AMDGPU_FW_LOAD_SMU) - amdgpu_ucode_init_bo(adev); - ret = hwmgr_hw_init(hwmgr); if (ret) @@ -275,7 +266,16 @@ static int pp_set_clockgating_state(void *handle, static int pp_dpm_load_fw(void *handle) { - return 0; + struct pp_hwmgr *hwmgr = handle; + int ret = 0; + + if (!hwmgr || !hwmgr->smumgr_funcs) + return -EINVAL; + + if (hwmgr->smumgr_funcs->request_smu_load_fw) + ret = hwmgr->smumgr_funcs->request_smu_load_fw(hwmgr); + + return ret; } static int pp_dpm_fw_loading_complete(void *handle) diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.c index b6b62a7..ffd7d78 100644 --- a/drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.c +++ b/drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.c @@ -310,8 +310,6 @@ static int fiji_start_smu(struct pp_hwmgr *hwmgr) offsetof(SMU73_Firmware_Header, SoftRegisters), &(priv->smu7_data.soft_regs_start), 0x4); - result = smu7_request_smu_load_fw(hwmgr); - return result; } @@ -2643,7 +2641,7 @@ static int fiji_update_dpm_settings(struct pp_hwmgr *hwmgr, .smu_fini = _smu_fini, .start_smu = _start_smu, .check_fw_load_finish = _check_fw_load_finish, - .request_smu_load_fw = _reload_firmware, + .request_smu_load_fw = _request_smu_load_fw,
[PATCH v2] drm/amd/pp: Export load_firmware interface
Export this interface for the AMDGPU_FW_LOAD_SMU type. gfx/sdma can request smu to load firmware. Split the smu7/8_start_smu function into two functions 1. start_smu, used for load smu firmware in smu7/8 and check smu firmware version. 2. request_smu_load_fw, used for load other ip's firmware on smu7/8 and add firmware loading staus check. v2: default fw loading type is via smu for VI, driver call smu to load all fw at the begin of hw init. Signed-off-by: Rex Zhu --- drivers/gpu/drm/amd/amdgpu/vi.c| 16 ++ drivers/gpu/drm/amd/powerplay/amd_powerplay.c | 20 drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.c | 4 +- .../gpu/drm/amd/powerplay/smumgr/iceland_smumgr.c | 25 - .../drm/amd/powerplay/smumgr/polaris10_smumgr.c| 4 +- drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.c | 59 +- drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.h | 3 +- drivers/gpu/drm/amd/powerplay/smumgr/smu8_smumgr.c | 46 - .../gpu/drm/amd/powerplay/smumgr/tonga_smumgr.c| 12 - .../gpu/drm/amd/powerplay/smumgr/vegam_smumgr.c| 4 +- 10 files changed, 86 insertions(+), 107 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/vi.c b/drivers/gpu/drm/amd/amdgpu/vi.c index 88b57a5..3384a15 100644 --- a/drivers/gpu/drm/amd/amdgpu/vi.c +++ b/drivers/gpu/drm/amd/amdgpu/vi.c @@ -1222,6 +1222,16 @@ static int vi_common_hw_init(void *handle) /* enable the doorbell aperture */ vi_enable_doorbell_aperture(adev, true); + if (adev->firmware.load_type == AMDGPU_FW_LOAD_SMU) { + if (adev->powerplay.pp_funcs->load_firmware) { + amdgpu_ucode_init_bo(adev); + if (adev->powerplay.pp_funcs->load_firmware(adev->powerplay.pp_handle)) { + adev->firmware.load_type = AMDGPU_FW_LOAD_DIRECT; + amdgpu_ucode_fini_bo(adev); + } + } + } + return 0; } @@ -1235,6 +1245,12 @@ static int vi_common_hw_fini(void *handle) if (amdgpu_sriov_vf(adev)) xgpu_vi_mailbox_put_irq(adev); + if (adev->firmware.load_type == AMDGPU_FW_LOAD_SMU) { + release_firmware(adev->pm.fw); + adev->pm.fw = NULL; + amdgpu_ucode_fini_bo(adev); + } + return 0; } diff --git a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c index aff7c14..5dc8fb9 100644 --- a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c +++ b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c @@ -109,12 +109,6 @@ static int pp_sw_fini(void *handle) hwmgr_sw_fini(hwmgr); - if (adev->firmware.load_type == AMDGPU_FW_LOAD_SMU) { - release_firmware(adev->pm.fw); - adev->pm.fw = NULL; - amdgpu_ucode_fini_bo(adev); - } - return 0; } @@ -124,9 +118,6 @@ static int pp_hw_init(void *handle) struct amdgpu_device *adev = handle; struct pp_hwmgr *hwmgr = adev->powerplay.pp_handle; - if (adev->firmware.load_type == AMDGPU_FW_LOAD_SMU) - amdgpu_ucode_init_bo(adev); - ret = hwmgr_hw_init(hwmgr); if (ret) @@ -275,7 +266,16 @@ static int pp_set_clockgating_state(void *handle, static int pp_dpm_load_fw(void *handle) { - return 0; + struct pp_hwmgr *hwmgr = handle; + int ret = 0; + + if (!hwmgr || !hwmgr->smumgr_funcs) + return -EINVAL; + + if (hwmgr->smumgr_funcs->request_smu_load_fw) + ret = hwmgr->smumgr_funcs->request_smu_load_fw(hwmgr); + + return ret; } static int pp_dpm_fw_loading_complete(void *handle) diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.c index b6b62a7..ffd7d78 100644 --- a/drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.c +++ b/drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.c @@ -310,8 +310,6 @@ static int fiji_start_smu(struct pp_hwmgr *hwmgr) offsetof(SMU73_Firmware_Header, SoftRegisters), &(priv->smu7_data.soft_regs_start), 0x4); - result = smu7_request_smu_load_fw(hwmgr); - return result; } @@ -2643,7 +2641,7 @@ static int fiji_update_dpm_settings(struct pp_hwmgr *hwmgr, .smu_fini = _smu_fini, .start_smu = _start_smu, .check_fw_load_finish = _check_fw_load_finish, - .request_smu_load_fw = _reload_firmware, + .request_smu_load_fw = _request_smu_load_fw, .request_smu_load_specific_fw = NULL, .send_msg_to_smc = _send_msg_to_smc, .send_msg_to_smc_with_parameter = _send_msg_to_smc_with_parameter, diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/iceland_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/iceland_smumgr.c index 73aa368..68a4836 100644 ---