drm/amdgpu: Change PG enable sequence
Subsystems (2)
PATCH 1/2 drm/amdgpu: Change PG enable sequence
Enable PG state after CG enabled.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 29 +++++++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 4 ---- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 5 ----- 3 files changed, 29 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +29 -0
@@ -1734,6 +1734,34 @@ static int amdgpu_device_ip_late_set_cg_state(struct amdgpu_device *adev)return 0 ; } +static int amdgpu_device_ip_late_set_pg_state (struct amdgpu_device *adev) +{ +int i =0 , r; + +if (amdgpu_emu_mode ==1 ) +return 0 ; + +for (i =0 ; i < adev->num_ip_blocks; i++) { +if (!adev->ip_blocks[i].status.valid) +continue ; +/* skip CG for VCE/UVD, it's handled specially */ +if (adev->ip_blocks[i].version->type !=AMD_IP_BLOCK_TYPE_UVD && + adev->ip_blocks[i].version->type !=AMD_IP_BLOCK_TYPE_VCE && + adev->ip_blocks[i].version->type !=AMD_IP_BLOCK_TYPE_VCN && + adev->ip_blocks[i].version->funcs->set_powergating_state) { +/* enable powergating to save power */ + r = adev->ip_blocks[i].version->funcs->set_powergating_state ((void *)adev, +AMD_PG_STATE_GATE ); +if (r) { +DRM_ERROR ("set_powergating_state(gate) of IP block <%s> failed %d\n" , + adev->ip_blocks[i].version->funcs->name, r); +return r; + } + } + } +return 0 ; +} +/** * amdgpu_device_ip_late_init - run late init for hardware IPs *
@@ -1891,6 +1919,7 @@ static void amdgpu_device_ip_late_init_func_handler(struct work_struct *work)struct amdgpu_device *adev = container_of(work, struct amdgpu_device, late_init_work.work);amdgpu_device_ip_late_set_cg_state (adev); +amdgpu_device_ip_late_set_pg_state (adev); }/**
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +0 -4
@@ -5542,10 +5542,6 @@ static int gfx_v8_0_late_init(void *handle)if (r)return r; -amdgpu_device_ip_set_powergating_state (adev, -AMD_IP_BLOCK_TYPE_GFX , -AMD_PG_STATE_GATE ); -return 0 ; }
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +0 -5
@@ -3406,11 +3406,6 @@ static int gfx_v9_0_late_init(void *handle)if (r)return r; - r =amdgpu_device_ip_set_powergating_state (adev,AMD_IP_BLOCK_TYPE_GFX , -AMD_PG_STATE_GATE ); -if (r) -return r; -return 0 ; }
Signature · 6 lines
1.9.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 1528199477-7467-1-git-send-email-Rex.Zhu-5C7GfCeVMHo@public.gmane.org
PATCH 2/2 drm/amdgpu: Make gfx_off control by GFX ip
v3: 1. Delete the dead gfx off code in powerplay late_init.
2. Revert v2.
3. call smu to power on gfx at the begin of ip_suspend/device_fini
4. only power off gfx ip in the end of gfx power gate function
v2: Delete the dead gfx off code in ip_suspend.
gfx off should be controlled by GFX IP.
Powerplay only export interface to gfx ip.
This logic is same as uvd/vce cg/pg.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 12 ++++++------ drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 4 ++++ drivers/gpu/drm/amd/powerplay/amd_powerplay.c | 8 -------- drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c | 4 ++-- 4 files changed, 12 insertions(+), 16 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +6 -6
@@ -1830,6 +1830,8 @@ static int amdgpu_device_ip_fini(struct amdgpu_device *adev) adev->ip_blocks[i].version->funcs->name, r);return r; } +if (adev->powerplay.pp_funcs->set_powergating_by_smu) +amdgpu_dpm_set_powergating_by_smu (adev,AMD_IP_BLOCK_TYPE_GFX , false); r = adev->ip_blocks[i].version->funcs->hw_fini ((void *)adev);/* XXX handle errors */ if (r) {
@@ -1940,12 +1942,6 @@ int amdgpu_device_ip_suspend(struct amdgpu_device *adev)if (amdgpu_sriov_vf (adev))amdgpu_virt_request_full_gpu (adev, false); -/* ungate SMC block powergating */ -if (adev->powerplay.pp_feature &PP_GFXOFF_MASK ) -amdgpu_device_ip_set_powergating_state (adev, -AMD_IP_BLOCK_TYPE_SMC , -AMD_CG_STATE_UNGATE ); -/* ungate SMC block first */ r =amdgpu_device_ip_set_clockgating_state (adev,AMD_IP_BLOCK_TYPE_SMC ,AMD_CG_STATE_UNGATE );
@@ -1953,6 +1949,10 @@ int amdgpu_device_ip_suspend(struct amdgpu_device *adev)DRM_ERROR ("set_clockgating_state(ungate) SMC failed %d\n" , r); } +/* call smu to disable gfx off feature first when suspend */ +if (adev->powerplay.pp_funcs->set_powergating_by_smu) +amdgpu_dpm_set_powergating_by_smu (adev,AMD_IP_BLOCK_TYPE_GFX , false); +for (i = adev->num_ip_blocks -1 ; i >=0 ; i--) {if (!adev->ip_blocks[i].status.valid)continue ;
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +4 -0
@@ -3712,6 +3712,10 @@ static int gfx_v9_0_set_powergating_state(void *handle,/* update mgcg state */ gfx_v9_0_update_gfx_mg_power_gating (adev, enable); + +/* set gfx off through smu */ +if (enable && adev->powerplay.pp_funcs->set_powergating_by_smu) +amdgpu_dpm_set_powergating_by_smu (adev,AMD_IP_BLOCK_TYPE_GFX , true);break ;default :break ;
drivers/gpu/drm/amd/powerplay/amd_powerplay.c +0 -8
@@ -180,7 +180,6 @@ static int pp_late_init(void *handle) {struct amdgpu_device *adev = handle;struct pp_hwmgr *hwmgr = adev->powerplay.pp_handle; -int ret;if (hwmgr && hwmgr->pm_en) {mutex_lock (&hwmgr->smu_lock);
@@ -191,13 +190,6 @@ static int pp_late_init(void *handle)if (adev->pm.smu_prv_buffer_size !=0 )pp_reserve_vram_for_smu (adev); -if (hwmgr->hwmgr_func->gfx_off_control && - (hwmgr->feature_mask &PP_GFXOFF_MASK )) { - ret = hwmgr->hwmgr_func->gfx_off_control (hwmgr, true); -if (ret) -pr_err ("gfx off enabling failed!\n" ); - } -return 0 ; }
drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c +2 -2
@@ -314,7 +314,7 @@ static int smu10_disable_gfx_off(struct pp_hwmgr *hwmgr)static int smu10_disable_dpm_tasks (struct pp_hwmgr *hwmgr) { -return smu10_disable_gfx_off (hwmgr); +return 0 ; }static int smu10_enable_gfx_off (struct pp_hwmgr *hwmgr)
@@ -329,7 +329,7 @@ static int smu10_enable_gfx_off(struct pp_hwmgr *hwmgr)static int smu10_enable_dpm_tasks (struct pp_hwmgr *hwmgr) { -return smu10_enable_gfx_off (hwmgr); +return 0 ; }static int smu10_gfx_off_control (struct pp_hwmgr *hwmgr,bool enable)
Signature · 6 lines
1.9.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 1528199477-7467-2-git-send-email-Rex.Zhu-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 2/2] drm/amdgpu: Make gfx_off control by GFX ip
Quoted 45 lines · Rex Zhu
v3: 1. Delete the dead gfx off code in powerplay
late_init.
2. Revert v2.
3. call smu to power on gfx at the begin of ip_suspend/device_fini
4. only power off gfx ip in the end of gfx power gate function
v2: Delete the dead gfx off code inip_suspend.gfx off should be controlled by GFX IP.
Powerplay only export interface to gfx ip.
This logic is same as uvd/vce cg/pg.Signed-off-by Rex Zhu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 12 ++++++------ drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 4 ++++ drivers/gpu/drm/amd/powerplay/amd_powerplay.c | 8 -------- drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c | 4 ++-- 4 files changed, 12 insertions(+), 16 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2
-6@@ -1830,6 +1830,8 @@ static int amdgpu_device_ip_fini(struct amdgpu_device *adev) adev->ip_blocks[i].version->funcs->name, r);return r; } +if (adev->powerplay.pp_funcs->set_powergating_by_smu) +amdgpu_dpm_set_powergating_by_smu (adev,AMD_IP_BLOCK_TYPE_GFX , false); r = adev->ip_blocks[i].version->funcs->hw_fini ((void *)adev);/* XXX handle errors */ if (r) {@@ -1940,12 +1942,6 @@ int amdgpu_device_ip_suspend(struct amdgpu_device *adev)if (amdgpu_sriov_vf (adev))amdgpu_virt_request_full_gpu (adev, false); -/* ungate SMC block powergating */ -if (adev->powerplay.pp_feature &PP_GFXOFF_MASK ) -amdgpu_device_ip_set_powergating_state (adev, -AMD_IP_BLOCK_TYPE_SMC , -AMD_CG_STATE_UNGATE ); -/* ungate SMC block first */ r =amdgpu_device_ip_set_clockgating_state (adev,AMD_IP_BLOCK_TYPE_SMC ,AMD_CG_STATE_UNGATE );
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_ip_suspend(struct amdgpu_device *adev) · line 1955
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4
-0@@ -1953,6 +1949,10 @@ int amdgpu_device_ip_suspend(struct amdgpu_device *adev)DRM_ERROR ("set_clockgating_state(ungate) SMC failed %d\n" , r); } +/* call smu to disable gfx off feature first when suspend */ +if (adev->powerplay.pp_funcs->set_powergating_by_smu) +amdgpu_dpm_set_powergating_by_smu (adev,AMD_IP_BLOCK_TYPE_GFX , false); +
Still has risk for s3, we would better not put PG disabling (gfxoff) behind of CG disabling, even here is SMC clockgating. It is to avoid any MMU using when gfx is in "off" state.
Thanks,
Ray
Quoted 73 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0for (i = adev->num_ip_blocks -1 ; i >=0 ; i--) {if (!adev->ip_blocks[i].status.valid)continue ;drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +4
-0@@ -3712,6 +3712,10 @@ static int gfx_v9_0_set_powergating_state(void *handle,/* update mgcg state */ gfx_v9_0_update_gfx_mg_power_gating (adev, enable); + +/* set gfx off through smu */ +if (enable && adev->powerplay.pp_funcs->set_powergating_by_smu) +amdgpu_dpm_set_powergating_by_smu (adev,AMD_IP_BLOCK_TYPE_GFX , true);break ;default :break ;drivers/gpu/drm/amd/powerplay/amd_powerplay.c +0
-8@@ -180,7 +180,6 @@ static int pp_late_init(void *handle) {struct amdgpu_device *adev = handle;struct pp_hwmgr *hwmgr = adev->powerplay.pp_handle; -int ret;if (hwmgr && hwmgr->pm_en) {mutex_lock (&hwmgr->smu_lock);@@ -191,13 +190,6 @@ static int pp_late_init(void *handle)if (adev->pm.smu_prv_buffer_size !=0 )pp_reserve_vram_for_smu (adev); -if (hwmgr->hwmgr_func->gfx_off_control && - (hwmgr->feature_mask &PP_GFXOFF_MASK )) { - ret = hwmgr->hwmgr_func->gfx_off_control (hwmgr, true); -if (ret) -pr_err ("gfx off enabling failed!\n" ); - } -return 0 ; }drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c +2
-2@@ -314,7 +314,7 @@ static int smu10_disable_gfx_off(struct pp_hwmgr *hwmgr)static int smu10_disable_dpm_tasks (struct pp_hwmgr *hwmgr) { -return smu10_disable_gfx_off (hwmgr); +return 0 ; }static int smu10_enable_gfx_off (struct pp_hwmgr *hwmgr)@@ -329,7 +329,7 @@ static int smu10_enable_gfx_off(struct pp_hwmgr *hwmgr)static int smu10_enable_dpm_tasks (struct pp_hwmgr *hwmgr) { -return smu10_enable_gfx_off (hwmgr); +return 0 ; }static int smu10_gfx_off_control (struct pp_hwmgr *hwmgr,bool enable)Signature · 6 lines
1.9.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH 2/2] drm/amdgpu: Make gfx_off control by GFX ip
Quoted 3 lines
Still has risk for s3, we would better not put PG disabling (gfxoff) behind of CG disabling, even here is SMC clockgating. It is to avoid any MMU using when gfx is in "off" state.
I think logically we need to power on/off GFX ip through SMU, so first ungate SMU block first.
Currently, it is not a big deal, because SMU don't support CG/PG on all legacy asics.
Best Regards
Rex
________________________________
From: Huang Rui <[email protected]>
Sent: Wednesday, June 6, 2018 10:33 AM
To: Zhu, Rex
Cc: [email protected]
Subject: Re: [PATCH 2/2] drm/amdgpu: Make gfx_off control by GFX ip
Quoted 45 lines · Rex Zhu
v3: 1. Delete the dead gfx off code in powerplay
late_init.
2. Revert v2.
3. call smu to power on gfx at the begin of ip_suspend/device_fini
4. only power off gfx ip in the end of gfx power gate function
v2: Delete the dead gfx off code inip_suspend.gfx off should be controlled by GFX IP.
Powerplay only export interface to gfx ip.
This logic is same as uvd/vce cg/pg.Signed-off-by Rex Zhu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 12 ++++++------ drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 4 ++++ drivers/gpu/drm/amd/powerplay/amd_powerplay.c | 8 -------- drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c | 4 ++-- 4 files changed, 12 insertions(+), 16 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2
-6@@ -1830,6 +1830,8 @@ static int amdgpu_device_ip_fini(struct amdgpu_device *adev) adev->ip_blocks[i].version->funcs->name, r);return r; } +if (adev->powerplay.pp_funcs->set_powergating_by_smu) +amdgpu_dpm_set_powergating_by_smu (adev,AMD_IP_BLOCK_TYPE_GFX , false); r = adev->ip_blocks[i].version->funcs->hw_fini ((void *)adev);/* XXX handle errors */ if (r) {@@ -1940,12 +1942,6 @@ int amdgpu_device_ip_suspend(struct amdgpu_device *adev)if (amdgpu_sriov_vf (adev))amdgpu_virt_request_full_gpu (adev, false); -/* ungate SMC block powergating */ -if (adev->powerplay.pp_feature &PP_GFXOFF_MASK ) -amdgpu_device_ip_set_powergating_state (adev, -AMD_IP_BLOCK_TYPE_SMC , -AMD_CG_STATE_UNGATE ); -/* ungate SMC block first */ r =amdgpu_device_ip_set_clockgating_state (adev,AMD_IP_BLOCK_TYPE_SMC ,AMD_CG_STATE_UNGATE );
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_ip_suspend(struct amdgpu_device *adev) · line 1955
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4
-0@@ -1953,6 +1949,10 @@ int amdgpu_device_ip_suspend(struct amdgpu_device *adev)DRM_ERROR ("set_clockgating_state(ungate) SMC failed %d\n" , r); } +/* call smu to disable gfx off feature first when suspend */ +if (adev->powerplay.pp_funcs->set_powergating_by_smu) +amdgpu_dpm_set_powergating_by_smu (adev,AMD_IP_BLOCK_TYPE_GFX , false); +
Still has risk for s3, we would better not put PG disabling (gfxoff) behind of CG disabling, even here is SMC clockgating. It is to avoid any MMU using when gfx is in "off" state.
Thanks,
Ray
Quoted 69 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0
-0for (i = adev->num_ip_blocks -1 ; i >=0 ; i--) {if (!adev->ip_blocks[i].status.valid)continue ;drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +4
-0@@ -3712,6 +3712,10 @@ static int gfx_v9_0_set_powergating_state(void *handle,/* update mgcg state */ gfx_v9_0_update_gfx_mg_power_gating (adev, enable); + +/* set gfx off through smu */ +if (enable && adev->powerplay.pp_funcs->set_powergating_by_smu) +amdgpu_dpm_set_powergating_by_smu (adev,AMD_IP_BLOCK_TYPE_GFX , true);break ;default :break ;drivers/gpu/drm/amd/powerplay/amd_powerplay.c +0
-8@@ -180,7 +180,6 @@ static int pp_late_init(void *handle) {struct amdgpu_device *adev = handle;struct pp_hwmgr *hwmgr = adev->powerplay.pp_handle; -int ret;if (hwmgr && hwmgr->pm_en) {mutex_lock (&hwmgr->smu_lock);@@ -191,13 +190,6 @@ static int pp_late_init(void *handle)if (adev->pm.smu_prv_buffer_size !=0 )pp_reserve_vram_for_smu (adev); -if (hwmgr->hwmgr_func->gfx_off_control && - (hwmgr->feature_mask &PP_GFXOFF_MASK )) { - ret = hwmgr->hwmgr_func->gfx_off_control (hwmgr, true); -if (ret) -pr_err ("gfx off enabling failed!\n" ); - } -return 0 ; }drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c +2
-3@@ -314,7 +314,7 @@ static int smu10_disable_gfx_off(struct pp_hwmgr *hwmgr)static int smu10_disable_dpm_tasks (struct pp_hwmgr *hwmgr) { -return smu10_disable_gfx_off (hwmgr); +return 0 ; }static int smu10_enable_gfx_off (struct pp_hwmgr *hwmgr)@@ -329,7 +329,7 @@ static int smu10_enable_gfx_off(struct pp_hwmgr *hwmgr)static int smu10_enable_dpm_tasks (struct pp_hwmgr *hwmgr) { -return smu10_enable_gfx_off (hwmgr); +return 0 ; }static int smu10_gfx_off_control (struct pp_hwmgr *hwmgr,bool enable) --1.9.1
Quoted 4 lines
_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
amd-gfx Info Page - freedesktop.org<https://lists.freedesktop.org/mailman/listinfo/amd-gfx>
lists.freedesktop.org
Subscribing to amd-gfx: Subscribe to amd-gfx by filling out the following form. Use of all freedesktop.org lists is subject to our Code of Conduct.
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx