drm/amd/pm: re-enable the gfx imu when smu resume
Subsystems (3)
PATCH 1/1 drm/amd/pm: re-enable the gfx imu when smu resume
If the gfx imu is poweroff when suspend, then
it need to be re-enabled when resume.
--- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 40 ++++++++++++++++------- 1 file changed, 28 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +28 -12
@@ -162,10 +162,15 @@ int smu_get_dpm_freq_range(struct smu_context *smu,int smu_set_gfx_power_up_by_imu (struct smu_context *smu) { -if (!smu->ppt_funcs || !smu->ppt_funcs->set_gfx_power_up_by_imu) -return -EOPNOTSUPP ; +int ret =0 ; +struct amdgpu_device *adev = smu->adev; -return smu->ppt_funcs->set_gfx_power_up_by_imu (smu); +if (smu->ppt_funcs->set_gfx_power_up_by_imu) { + ret = smu->ppt_funcs->set_gfx_power_up_by_imu (smu); +if (ret) +dev_err (adev->dev,"Failed to enable gfx imu!\n" ); + } +return ret; }static u32 smu_get_mclk (void *handle,bool low)
@@ -196,6 +201,19 @@ static u32 smu_get_sclk(void *handle, bool low)return clk_freq *100 ; } +static int smu_set_gfx_imu_enable (struct smu_context *smu) +{ +struct amdgpu_device *adev = smu->adev; + +if (adev->firmware.load_type !=AMDGPU_FW_LOAD_PSP ) +return 0 ; + +if (amdgpu_in_reset (smu->adev) || adev->in_s0ix) +return 0 ; + +return smu_set_gfx_power_up_by_imu (smu); +} +static int smu_dpm_set_vcn_enable (struct smu_context *smu,bool enable) {
@@ -1396,15 +1414,9 @@ static int smu_hw_init(void *handle) }if (smu->is_apu) { -if ((smu->ppt_funcs->set_gfx_power_up_by_imu) && -likely (adev->firmware.load_type ==AMDGPU_FW_LOAD_PSP )) { - ret = smu->ppt_funcs->set_gfx_power_up_by_imu (smu); -if (ret) { -dev_err (adev->dev,"Failed to Enable gfx imu!\n" ); -return ret; - } - } - + ret =smu_set_gfx_imu_enable (smu); +if (ret) +return ret;smu_dpm_set_vcn_enable (smu, true);smu_dpm_set_jpeg_enable (smu, true);smu_set_gfx_cgpg (smu, true);
@@ -1681,6 +1693,10 @@ static int smu_resume(void *handle)return ret; } + ret =smu_set_gfx_imu_enable (smu); +if (ret) +return ret; +smu_set_gfx_cgpg (smu, true); smu->disable_uclk_switch =0 ;
Signature · 1 line
2.25.1
[AMD Official Use Only - General]
Quoted 25 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Tim Huang
Sent: Friday, March 24, 2023 3:08 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Zhang, Yifan <[email protected]>; Ma, Li <[email protected]>; Du, Xiaojian <[email protected]>; Huang, Tim <[email protected]>
Subject: [PATCH] drm/amd/pm: re-enable the gfx imu when smu resumeIf the gfx imu is poweroff when suspend, then
it need to be re-enabled when resume.Signed-off-by Tim Huang <[email protected]>--- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 40 ++++++++++++++++------- 1 file changed, 28 insertions(+), 12 deletions(-)drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-0
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c int smu_get_dpm_freq_range(struct smu_context · line 168
Quoted 7 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-2@@ -162,10 +162,15 @@ int smu_get_dpm_freq_range(struct smu_context *smu,int smu_set_gfx_power_up_by_imu (struct smu_context *smu) { -if (!smu->ppt_funcs || !smu->ppt_funcs- >set_gfx_power_up_by_imu) -return -EOPNOTSUPP ;
This assumes that all APUs need to support the ->set_gfx_power_up_by_imu int interface. Otherwise, the driver loading will fail?
Is that expected?
Evan
Quoted 68 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +8
-1+int ret =0 ; +struct amdgpu_device *adev = smu->adev; -return smu->ppt_funcs->set_gfx_power_up_by_imu (smu); +if (smu->ppt_funcs->set_gfx_power_up_by_imu) { + ret = smu->ppt_funcs->set_gfx_power_up_by_imu (smu); +if (ret) +dev_err (adev->dev,"Failed to enable gfx imu!\n" ); + } +return ret; }static u32
smu_get_mclk(void *handle, bool low)drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +16
-9@@ -196,6 +201,19 @@ static u32 smu_get_sclk(void *handle, bool low)return clk_freq *100 ; } +static int smu_set_gfx_imu_enable (struct smu_context *smu) +{ +struct amdgpu_device *adev = smu->adev; + +if (adev->firmware.load_type !=AMDGPU_FW_LOAD_PSP ) +return 0 ; + +if (amdgpu_in_reset (smu->adev) || adev->in_s0ix) +return 0 ; + +return smu_set_gfx_power_up_by_imu (smu); +} +static int smu_dpm_set_vcn_enable (struct smu_context *smu,bool enable) {@@ -1396,15 +1414,9 @@ static int smu_hw_init(void *handle) }if (smu->is_apu) { -if ((smu->ppt_funcs->set_gfx_power_up_by_imu) && -likely (adev->firmware.load_type == AMDGPU_FW_LOAD_PSP)) { - ret = smu->ppt_funcs- >set_gfx_power_up_by_imu (smu); -if (ret) { -dev_err (adev->dev,"Failed to Enable gfx imu!\n"); -return ret; - } - } - + ret =smu_set_gfx_imu_enable (smu); +if (ret) +return ret;drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +4
-1smu_dpm_set_vcn_enable (smu, true);smu_dpm_set_jpeg_enable (smu, true);smu_set_gfx_cgpg (smu, true);@@ -1681,6 +1693,10 @@ static int smu_resume(void *handle)return ret; } + ret =smu_set_gfx_imu_enable (smu); +if (ret) +return ret; +smu_set_gfx_cgpg (smu, true); smu->disable_uclk_switch =0 ; --2.25.1
[Public]
-----Original Message-----
From: Quan, Evan <[email protected]>
Sent: Friday, March 24, 2023 3:17 PM
To: Huang, Tim <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Zhang, Yifan <[email protected]>; Ma, Li <[email protected]>; Du, Xiaojian <[email protected]>; Huang, Tim <[email protected]>
Subject: RE: [PATCH] drm/amd/pm: re-enable the gfx imu when smu resume
[AMD Official Use Only - General]
Quoted 35 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Tim Huang
Sent: Friday, March 24, 2023 3:08 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Zhang, Yifan <[email protected]>; Ma, Li <[email protected]>; Du, Xiaojian <[email protected]>; Huang, Tim <[email protected]>
Subject: [PATCH] drm/amd/pm: re-enable the gfx imu when smu resumeIf the gfx imu is poweroff when suspend, then it need to be re-enabled when resume.
Signed-off-by Tim Huang <[email protected]>--- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 40 ++++++++++++++++------- 1 file changed, 28 insertions(+), 12 deletions(-)drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-2@@ -162,10 +162,15 @@ int smu_get_dpm_freq_range(struct smu_context *smu, int smu_set_gfx_power_up_by_imu(struct smu_context *smu) { -if (!smu->ppt_funcs || !smu->ppt_funcs- >set_gfx_power_up_by_imu) -return -EOPNOTSUPP ;Quoted 3 lines
This assumes that all APUs need to support the ->set_gfx_power_up_by_imu int interface. Otherwise, the driver loading will fail?
Is that expected?
Quoted 1 line
Quoted 1 line
Evan
Only the GFX11 APUs that have the IMU need to support the ->set_gfx_power_up_by_imu interface. Before it should be ok as it only be used for backdoor FW loading in imu_v11_0.c, now It will be used for more case, then return EOPNOTSUPP should not be expected. Thanks.
Tim
Quoted 66 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +8
-1+int ret =0 ; +struct amdgpu_device *adev = smu->adev; -return smu->ppt_funcs->set_gfx_power_up_by_imu (smu); +if (smu->ppt_funcs->set_gfx_power_up_by_imu) { + ret = smu->ppt_funcs->set_gfx_power_up_by_imu (smu); +if (ret) +dev_err (adev->dev,"Failed to enable gfx imu!\n" ); + } +return ret; } static u32 smu_get_mclk(void *handle, bool low) @@ -196,6 +201,19 @@static u32
smu_get_sclk(void *handle, bool low)return clk_freq * 100;}
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +14
-9+static int smu_set_gfx_imu_enable (struct smu_context *smu) { +struct amdgpu_device *adev = smu->adev; + +if (adev->firmware.load_type !=AMDGPU_FW_LOAD_PSP ) +return 0 ; + +if (amdgpu_in_reset (smu->adev) || adev->in_s0ix) +return 0 ; + +return smu_set_gfx_power_up_by_imu (smu); } +static int smu_dpm_set_vcn_enable (struct smu_context *smu,bool enable) {@@ -1396,15 +1414,9 @@ static int smu_hw_init(void *handle) }if (smu->is_apu) { -if ((smu->ppt_funcs->set_gfx_power_up_by_imu) && -likely (adev->firmware.load_type == AMDGPU_FW_LOAD_PSP)) { - ret = smu->ppt_funcs- >set_gfx_power_up_by_imu (smu); -if (ret) { -dev_err (adev->dev,"Failed to Enable gfx imu!\n"); -return ret; - } - } - + ret =smu_set_gfx_imu_enable (smu); +if (ret) +return ret;smu_dpm_set_vcn_enable(smu, true); smu_dpm_set_jpeg_enable(smu, true); smu_set_gfx_cgpg(smu, true);drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +4
-1@@ -1681,6 +1693,10 @@ static int smu_resume(void *handle)return ret; } + ret =smu_set_gfx_imu_enable (smu); +if (ret) +return ret; +smu_set_gfx_cgpg (smu, true); smu->disable_uclk_switch =0 ; --2.25.1
Quoted 86 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Tim Huang
Sent: Friday, March 24, 2023 3:08 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Zhang, Yifan <[email protected]>; Ma, Li <[email protected]>; Du, Xiaojian <[email protected]>; Huang, Tim <[email protected]>
Subject: [PATCH] drm/amd/pm: re-enable the gfx imu when smu resumeIf the gfx imu is poweroff when suspend, then it need to be re-enabled when resume.
Signed-off-by Tim Huang <[email protected]>--- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 40 ++++++++++++++++- ------ 1 file changed, 28 insertions(+), 12 deletions(-)drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +8
-3@@ -162,10 +162,15 @@ int smu_get_dpm_freq_range(struct smu_context *smu, int smu_set_gfx_power_up_by_imu(struct smu_context *smu) { -if (!smu->ppt_funcs || !smu->ppt_funcs->set_gfx_power_up_by_imu) -return -EOPNOTSUPP ; +int ret =0 ; +struct amdgpu_device *adev = smu->adev; -return smu->ppt_funcs->set_gfx_power_up_by_imu (smu); +if (smu->ppt_funcs->set_gfx_power_up_by_imu) { + ret = smu->ppt_funcs->set_gfx_power_up_by_imu (smu); +if (ret) +dev_err (adev->dev,"Failed to enable gfx imu!\n" ); + } +return ret; } static u32 smu_get_mclk(void *handle, bool low) @@ -196,6 +201,19 @@static u32
smu_get_sclk(void *handle, bool low)drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +14
-9return clk_freq *100 ; } +static int smu_set_gfx_imu_enable (struct smu_context *smu) { +struct amdgpu_device *adev = smu->adev; + +if (adev->firmware.load_type !=AMDGPU_FW_LOAD_PSP ) +return 0 ; + +if (amdgpu_in_reset (smu->adev) || adev->in_s0ix) +return 0 ; + +return smu_set_gfx_power_up_by_imu (smu); } +static int smu_dpm_set_vcn_enable (struct smu_context *smu,bool enable) {@@ -1396,15 +1414,9 @@ static int smu_hw_init(void *handle) }if (smu->is_apu) { -if ((smu->ppt_funcs->set_gfx_power_up_by_imu) && -likely (adev->firmware.load_type == AMDGPU_FW_LOAD_PSP)) { - ret = smu->ppt_funcs- >set_gfx_power_up_by_imu (smu); -if (ret) { -dev_err (adev->dev,"Failed to Enable gfx imu!\n"); -return ret; - } - } - + ret =smu_set_gfx_imu_enable (smu); +if (ret) +return ret;drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-0smu_dpm_set_vcn_enable (smu, true);smu_dpm_set_jpeg_enable (smu, true);smu_set_gfx_cgpg (smu, true);
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_resume(void *handle) · line 1698
Quoted 6 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +3
-0@@ -1681,6 +1693,10 @@ static int smu_resume(void *handle)return ret; } + ret =smu_set_gfx_imu_enable (smu); +if (ret) +return ret;
smu_set_gfx_imu_enable in smu_hw_init is valid when sum->is_apu is true. So such check is still necessary in smu_resume?
Regards,
Guchun
Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +0
-1smu_set_gfx_cgpg (smu, true); smu->disable_uclk_switch =0 ; --2.25.1
[Public]
-----Original Message-----
From: Chen, Guchun <[email protected]>
Sent: Friday, March 24, 2023 3:26 PM
To: Huang, Tim <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Zhang, Yifan <[email protected]>; Ma, Li <[email protected]>; Du, Xiaojian <[email protected]>; Huang, Tim <[email protected]>
Subject: RE: [PATCH] drm/amd/pm: re-enable the gfx imu when smu resume
Quoted 93 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Tim Huang
Sent: Friday, March 24, 2023 3:08 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Zhang, Yifan <[email protected]>; Ma, Li <[email protected]>; Du, Xiaojian <[email protected]>; Huang, Tim <[email protected]>
Subject: [PATCH] drm/amd/pm: re-enable the gfx imu when smu resumeIf the gfx imu is poweroff when suspend, then it need to be re-enabled when resume.
Signed-off-by Tim Huang <[email protected]>--- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 40 ++++++++++++++++- ------ 1 file changed, 28 insertions(+), 12 deletions(-)drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +8
-3@@ -162,10 +162,15 @@ int smu_get_dpm_freq_range(struct smu_context *smu, int smu_set_gfx_power_up_by_imu(struct smu_context *smu) { -if (!smu->ppt_funcs || !smu->ppt_funcs->set_gfx_power_up_by_imu) -return -EOPNOTSUPP ; +int ret =0 ; +struct amdgpu_device *adev = smu->adev; -return smu->ppt_funcs->set_gfx_power_up_by_imu (smu); +if (smu->ppt_funcs->set_gfx_power_up_by_imu) { + ret = smu->ppt_funcs->set_gfx_power_up_by_imu (smu); +if (ret) +dev_err (adev->dev,"Failed to enable gfx imu!\n" ); + } +return ret; } static u32 smu_get_mclk(void *handle, bool low) @@ -196,6 +201,19 @@static u32
smu_get_sclk(void *handle, bool low)return clk_freq * 100;}
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +14
-9+static int smu_set_gfx_imu_enable (struct smu_context *smu) { +struct amdgpu_device *adev = smu->adev; + +if (adev->firmware.load_type !=AMDGPU_FW_LOAD_PSP ) +return 0 ; + +if (amdgpu_in_reset (smu->adev) || adev->in_s0ix) +return 0 ; + +return smu_set_gfx_power_up_by_imu (smu); } +static int smu_dpm_set_vcn_enable (struct smu_context *smu,bool enable) {@@ -1396,15 +1414,9 @@ static int smu_hw_init(void *handle) }if (smu->is_apu) { -if ((smu->ppt_funcs->set_gfx_power_up_by_imu) && -likely (adev->firmware.load_type == AMDGPU_FW_LOAD_PSP)) { - ret = smu->ppt_funcs- >set_gfx_power_up_by_imu (smu); -if (ret) { -dev_err (adev->dev,"Failed to Enable gfx imu!\n"); -return ret; - } - } - + ret =smu_set_gfx_imu_enable (smu); +if (ret) +return ret;smu_dpm_set_vcn_enable(smu, true); smu_dpm_set_jpeg_enable(smu, true); smu_set_gfx_cgpg(smu, true);drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +3
-0@@ -1681,6 +1693,10 @@ static int smu_resume(void *handle)return ret; } + ret =smu_set_gfx_imu_enable (smu); +if (ret) +return ret;Quoted 1 line
smu_set_gfx_imu_enableinsmu_hw_initis valid whensum->is_apuis true. So such check is still necessary insmu_resume?
Quoted 2 lines
Quoted 2 lines
Regards,
Guchun
For both hw_init or resume, it should be ok if not have the smu->is_apu checking. Because we will check the valid of smu->ppt_funcs->set_gfx_power_up_by_imu in the final call path,
so, for dGPU or APUs without IMU that did not implement this interface will return 0. Thanks.
Tim
Quoted 5 lines
smu_set_gfx_cgpg(smu, true); smu->disable_uclk_switch = 0;--
2.25.1
[AMD Official Use Only - General]
This patch is :
Best Regards,
Yifan
-----Original Message-----
From: Huang, Tim <[email protected]>
Sent: Friday, March 24, 2023 3:08 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Zhang, Yifan <[email protected]>; Du, Xiaojian <[email protected]>; Ma, Li <[email protected]>; Huang, Tim <[email protected]>
Subject: [PATCH] drm/amd/pm: re-enable the gfx imu when smu resume
If the gfx imu is poweroff when suspend, then it need to be re-enabled when resume.
--- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 40 ++++++++++++++++------- 1 file changed, 28 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +8 -3
@@ -162,10 +162,15 @@ int smu_get_dpm_freq_range(struct smu_context *smu,int smu_set_gfx_power_up_by_imu (struct smu_context *smu) { -if (!smu->ppt_funcs || !smu->ppt_funcs->set_gfx_power_up_by_imu) -return -EOPNOTSUPP ; +int ret =0 ; +struct amdgpu_device *adev = smu->adev; -return smu->ppt_funcs->set_gfx_power_up_by_imu (smu); +if (smu->ppt_funcs->set_gfx_power_up_by_imu) { + ret = smu->ppt_funcs->set_gfx_power_up_by_imu (smu); +if (ret) +dev_err (adev->dev,"Failed to enable gfx imu!\n" ); + } +return ret; } static u32 smu_get_mclk(void *handle, bool low) @@ -196,6 +201,19 @@ static u32 smu_get_sclk(void *handle, bool low) return clk_freq * 100;
}
+static int smu_set_gfx_imu_enable(struct smu_context *smu) {
+ struct amdgpu_device *adev = smu->adev;
+
+ if (adev->firmware.load_type != AMDGPU_FW_LOAD_PSP)
+ return 0;
+
+ if (amdgpu_in_reset(smu->adev) || adev->in_s0ix)
+ return 0;
+
+ return smu_set_gfx_power_up_by_imu(smu); }
+
static int smu_dpm_set_vcn_enable(struct smu_context *smu,
bool enable)
{
@@ -1396,15 +1414,9 @@ static int smu_hw_init(void *handle)
}
if (smu->is_apu) {
- if ((smu->ppt_funcs->set_gfx_power_up_by_imu) &&
- likely(adev->firmware.load_type == AMDGPU_FW_LOAD_PSP)) {
- ret = smu->ppt_funcs->set_gfx_power_up_by_imu(smu);
- if (ret) {
- dev_err(adev->dev, "Failed to Enable gfx imu!\n");
- return ret;
- }
- }
-
+ ret = smu_set_gfx_imu_enable(smu);
+ if (ret)
+ return ret;
smu_dpm_set_vcn_enable(smu, true); smu_dpm_set_jpeg_enable(smu, true); smu_set_gfx_cgpg(smu, true);
@@ -1681,6 +1693,10 @@ static int smu_resume(void *handle)
return ret;
}
+ ret = smu_set_gfx_imu_enable(smu);
+ if (ret)
+ return ret;
+
smu_set_gfx_cgpg(smu, true);
smu->disable_uclk_switch = 0;
--
2.25.1