GFX/UVD PG (v2)
Subsystems (2)
This stream changes a comment in patch #2 and re-works the init sequence for powerplay in patch #4 by removing the enable_clock_power_gatings_tasks task from the initialize task list.
In theory that should be better as now other blocks won't be powered off before init.
_______________________________________________
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): [email protected]
PATCH 1/4 drm/amd/uvd6: Implement PG and clean up MGCG
Move the CG state into the adev.uvd structure to allow for parallel UVD instances. Also prevent uvd start if in the PG state (will be enhanced later to support powerplay). Also avoid setting CG state in start since DPM will call set_clockgating_state anyways.
Adds static PG to the DPM implementation.
Finally, added a mutex around PG transistions so that the userspace can poll TILE/PGFSM registers without a race condition on the FW state.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 + drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 14 ++++++- drivers/gpu/drm/amd/amdgpu/cz_dpm.c | 60 +++++++++++++++++++++++++++--- drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c | 38 ++++++++++--------- 4 files changed, 88 insertions(+), 26 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -0
@@ -1690,6 +1690,8 @@ struct amdgpu_uvd {bool address_64_bit;struct amd_sched_entity entity;uint32_t srbm_soft_reset; +int cg_state, pg_state; +struct mutex pg_lock; };/*
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +12 -2
@@ -2335,22 +2335,26 @@ static ssize_t amdgpu_debugfs_regs_read(struct file *f, char __user *buf,struct amdgpu_device *adev = f->f_inode->i_private;ssize_t result =0 ;int r; -bool use_bank; +bool use_pg_lock, use_bank;unsigned instance_bank, sh_bank, se_bank;if (size &0x3 || *pos &0x3 )return -EINVAL ; +/* are we reading UVD registers for which a PG lock is necessary? */ + use_pg_lock = (*pos >>23 ) &1 ; +if (*pos & (1ULL <<62 )) { se_bank = (*pos >>24 ) &0x3FF ; sh_bank = (*pos >>34 ) &0x3FF ; instance_bank = (*pos >>44 ) &0x3FF ; use_bank =1 ; - *pos &=0xFFFFFF ; }else { use_bank =0 ; } + *pos &=0x3FFFF ; +if (use_bank) {if (sh_bank >= adev->gfx.config.max_sh_per_se || se_bank >= adev->gfx.config.max_shader_engines)
@@ -2360,6 +2364,9 @@ static ssize_t amdgpu_debugfs_regs_read(struct file *f, char __user *buf, sh_bank, instance_bank); } +if (use_pg_lock) +mutex_lock (&adev->uvd.pg_lock); +while (size) {uint32_t value;
@@ -2385,6 +2392,9 @@ end:mutex_unlock (&adev->grbm_idx_mutex); } +if (use_pg_lock) +mutex_unlock (&adev->uvd.pg_lock); +return result; }
drivers/gpu/drm/amd/amdgpu/cz_dpm.c +54 -6
98 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c +20 -18
@@ -101,6 +101,8 @@ static int uvd_v6_0_sw_init(void *handle)int r;struct amdgpu_device *adev = (struct amdgpu_device *)handle; +mutex_init (&adev->uvd.pg_lock); +/* UVD TRAP */ r =amdgpu_irq_add_id (adev,124 , &adev->uvd.irq);if (r)
@@ -387,6 +389,13 @@ static int uvd_v6_0_start(struct amdgpu_device *adev)uint32_t mp_swap_cntl;int i, j, r; +/* is power gated? then we can't start (TODO: re-enable power) */ +if (adev->uvd.pg_state) +return -EINVAL ; + +/* set CG state to -1 for unset */ + adev->uvd.cg_state =-1 ; +/* disable DPG */ WREG32_P (mmUVD_POWER_STATUS,0 , ~UVD_POWER_STATUS__UVD_PG_MODE_MASK );
@@ -396,15 +405,10 @@ static int uvd_v6_0_start(struct amdgpu_device *adev)uvd_v6_0_mc_resume (adev); -/* Set dynamic clock gating in S/W control mode */ -if (adev->cg_flags &AMD_CG_SUPPORT_UVD_MGCG ) { -uvd_v6_0_set_sw_clock_gating (adev); - }else { -/* disable clock gating */ -uint32_t data =RREG32 (mmUVD_CGC_CTRL); - data &= ~UVD_CGC_CTRL__DYN_CLOCK_MODE_MASK ; -WREG32 (mmUVD_CGC_CTRL, data); - } +/* disable clock gating */ + tmp =RREG32 (mmUVD_CGC_CTRL); + tmp &= ~UVD_CGC_CTRL__DYN_CLOCK_MODE_MASK ; +WREG32 (mmUVD_CGC_CTRL, tmp);/* disable interupt */ WREG32_P (mmUVD_MASTINT_EN,0 , ~UVD_MASTINT_EN__VCPU_EN_MASK );
@@ -964,21 +968,19 @@ static int uvd_v6_0_set_clockgating_state(void *handle, enum amd_clockgating_state state) {struct amdgpu_device *adev = (struct amdgpu_device *)handle; -bool enable = (state ==AMD_CG_STATE_GATE ) ? true : false; -static int curstate =-1 ; - -if (adev->asic_type ==CHIP_FIJI || - adev->asic_type ==CHIP_POLARIS10 ) -uvd_v6_set_bypass_mode (adev, enable);if (!(adev->cg_flags &AMD_CG_SUPPORT_UVD_MGCG ))return 0 ; -if (curstate == state) +if (adev->uvd.cg_state == state)return 0 ; - curstate = state; -if (enable) { +if (adev->asic_type ==CHIP_FIJI || + adev->asic_type ==CHIP_POLARIS10 ) +uvd_v6_set_bypass_mode (adev, state ==AMD_CG_STATE_GATE ? true : false); + + adev->uvd.cg_state = state; +if (state ==AMD_CG_STATE_GATE ) {/* disable HW gating and enable Sw gating */ uvd_v6_0_set_sw_clock_gating (adev); }else {
Signature · 6 lines
2.9.2 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 2/4 drm/amd/amdgpu: Add GFX and UVD PG for Carrizo
In reply to a message not in the archiveEnables GFX PG and UVD static PG on Carrizo class
asics.
--- drivers/gpu/drm/amd/amdgpu/vi.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/gpu/drm/amd/amdgpu/vi.c +9 -0
@@ -1578,7 +1578,16 @@ static int vi_common_early_init(void *handle)AMD_CG_SUPPORT_HDP_LS |AMD_CG_SUPPORT_SDMA_MGCG |AMD_CG_SUPPORT_SDMA_LS ; +/* rev0 hardware requires workarounds to support PG */ adev->pg_flags =0 ; +if (adev->rev_id !=0x00 ) { + adev->pg_flags |=AMD_PG_SUPPORT_GFX_PG | +AMD_PG_SUPPORT_GFX_SMG | +AMD_PG_SUPPORT_GFX_PIPELINE ; +/* powerplay UVD PG doesn't work yet */ +if (!amdgpu_powerplay) + adev->pg_flags |=AMD_PG_SUPPORT_UVD ; + } adev->external_rev_id = adev->rev_id +0x1 ;break ;case CHIP_STONEY :
Signature · 6 lines
2.9.2 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 3/4 drm/amd/amdgpu: Add GFX and UVD PG for Stoney
In reply to a message not in the archiveEnables GFX PG and UVD static PG on Stoney class
asics.
--- drivers/gpu/drm/amd/amdgpu/vi.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/gpu/drm/amd/amdgpu/vi.c +6 -0
@@ -1606,6 +1606,12 @@ static int vi_common_early_init(void *handle)AMD_CG_SUPPORT_HDP_LS |AMD_CG_SUPPORT_SDMA_MGCG |AMD_CG_SUPPORT_SDMA_LS ; + adev->pg_flags |=AMD_PG_SUPPORT_GFX_PG | +AMD_PG_SUPPORT_GFX_SMG | +AMD_PG_SUPPORT_GFX_PIPELINE ; +/* powerplay UVD PG doesn't work yet */ +if (!amdgpu_powerplay) + adev->pg_flags |=AMD_PG_SUPPORT_UVD ; adev->external_rev_id = adev->rev_id +0x1 ;break ;default :
Signature · 6 lines
2.9.2 _______________________________________________ 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): [email protected]
Re: [PATCH 3/4] drm/amd/amdgpu: Add GFX and UVD PG for Stoney
Quoted 13 lines · Tom St Denis
Enables GFX PG and UVD static PG on Stoney class
asics.Signed-off-by Tom St Denis <[email protected]>--- drivers/gpu/drm/amd/amdgpu/vi.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/gpu/drm/amd/amdgpu/vi.c +0
-0
drivers/gpu/drm/amd/amdgpu/vi.c static int vi_common_early_init(void *handle) · line 1614
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/vi.c +6
-0@@ -1606,6 +1606,12 @@ static int vi_common_early_init(void *handle)AMD_CG_SUPPORT_HDP_LS |AMD_CG_SUPPORT_SDMA_MGCG |AMD_CG_SUPPORT_SDMA_LS ; + adev->pg_flags |=AMD_PG_SUPPORT_GFX_PG | +AMD_PG_SUPPORT_GFX_SMG | +AMD_PG_SUPPORT_GFX_PIPELINE ; +/* powerplay UVD PG doesn't work yet */ +if (!amdgpu_powerplay) + adev->pg_flags |=AMD_PG_SUPPORT_UVD ;
Enable GFX PG and UVD PG in separate commits so we can more easily revert them separately if necessary.
Alex
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/vi.c +0
-1adev->external_rev_id = adev->rev_id +0x1 ;break ;default : --2.9.2
_______________________________________________
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
A message that is not in the archive (sent off-list or not yet received): CADnq5_MQ7pDaQvptUvttAdhgFkp=hJGhHB6jhqv91+7agZZCjA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: [PATCH 3/4] drm/amd/amdgpu: Add GFX and UVD PG for Stoney
Ok I'll split them up and re-send when I have the VCE content more stable.
Tom
________________________________
From: Alex Deucher <[email protected]>
Sent: Wednesday, July 27, 2016 16:16
To: Tom St Denis
Cc: amd-gfx list; StDenis, Tom
Subject: Re: [PATCH 3/4] drm/amd/amdgpu: Add GFX and UVD PG for Stoney
Quoted 13 lines · Tom St Denis
Enables GFX PG and UVD static PG on Stoney class
asics.Signed-off-by Tom St Denis <[email protected]>--- drivers/gpu/drm/amd/amdgpu/vi.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/gpu/drm/amd/amdgpu/vi.c +0
-0
drivers/gpu/drm/amd/amdgpu/vi.c static int vi_common_early_init(void *handle) · line 1614
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/vi.c +6
-0@@ -1606,6 +1606,12 @@ static int vi_common_early_init(void *handle)AMD_CG_SUPPORT_HDP_LS |AMD_CG_SUPPORT_SDMA_MGCG |AMD_CG_SUPPORT_SDMA_LS ; + adev->pg_flags |=AMD_PG_SUPPORT_GFX_PG | +AMD_PG_SUPPORT_GFX_SMG | +AMD_PG_SUPPORT_GFX_PIPELINE ; +/* powerplay UVD PG doesn't work yet */ +if (!amdgpu_powerplay) + adev->pg_flags |=AMD_PG_SUPPORT_UVD ;
Enable GFX PG and UVD PG in separate commits so we can more easily revert them separately if necessary.
Alex
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/vi.c +0
-1adev->external_rev_id = adev->rev_id +0x1 ;break ;default : --2.9.2
_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
amd-gfx Info Page - lists.freedesktop.org<https://lists.freedesktop.org/mailman/listinfo/amd-gfx>
lists.freedesktop.org
To see the collection of prior postings to the list, visit the amd-gfx Archives. Using amd-gfx: To post a message to all the list members, send email ...
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 4/4 drm/amd/powerplay: Fix PG/CG for UVD
In reply to a message not in the archiveThis patch removes the enable_clock_power_gatings_tasks task from the initialize sequence which would have powered off the UVD (and other) blocks before init.
The patch also fixes the power up order to set the clockgating after ungating power.
Finally, the patch enables UVD PG with powerplay enabled.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 5 +++++ drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | 5 ----- drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/vi.c | 12 ++++-------- .../drm/amd/powerplay/eventmgr/eventactionchains.c | 1 - .../drm/amd/powerplay/hwmgr/cz_clockpowergating.c | 22 ++++++++++++++++++---- 6 files changed, 29 insertions(+), 20 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +5 -0
@@ -2518,5 +2518,10 @@ int amdgpu_dm_display_resume(struct amdgpu_device *adev );static inline int amdgpu_dm_display_resume (struct amdgpu_device *adev) {return 0 ; }#endif +struct amdgpu_cgs_device { +struct cgs_device base; +struct amdgpu_device *adev; +}; +#include "amdgpu_object.h" #endif
drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c +0 -5
@@ -33,11 +33,6 @@#include "atom.h" #include "amdgpu_ucode.h" -struct amdgpu_cgs_device { -struct cgs_device base; -struct amdgpu_device *adev; -}; -#define CGS_FUNC_ADEV \ struct amdgpu_device *adev = \ ((struct amdgpu_cgs_device *)cgs_device)->adev
drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c +2 -2
@@ -389,9 +389,9 @@ static int uvd_v6_0_start(struct amdgpu_device *adev)uint32_t mp_swap_cntl;int i, j, r; -/* is power gated? then we can't start (TODO: re-enable power) */ +/* is power gated? then we can't start but don't return an error */ if (adev->uvd.pg_state) -return -EINVAL ; +return 0 ;/* set CG state to -1 for unset */ adev->uvd.cg_state =-1 ;
drivers/gpu/drm/amd/amdgpu/vi.c +4 -8
@@ -1583,10 +1583,8 @@ static int vi_common_early_init(void *handle)if (adev->rev_id !=0x00 ) { adev->pg_flags |=AMD_PG_SUPPORT_GFX_PG |AMD_PG_SUPPORT_GFX_SMG | -AMD_PG_SUPPORT_GFX_PIPELINE ; -/* powerplay UVD PG doesn't work yet */ -if (!amdgpu_powerplay) - adev->pg_flags |=AMD_PG_SUPPORT_UVD ; +AMD_PG_SUPPORT_GFX_PIPELINE | +AMD_PG_SUPPORT_UVD ; } adev->external_rev_id = adev->rev_id +0x1 ;break ;
@@ -1608,10 +1606,8 @@ static int vi_common_early_init(void *handle)AMD_CG_SUPPORT_SDMA_LS ; adev->pg_flags |=AMD_PG_SUPPORT_GFX_PG |AMD_PG_SUPPORT_GFX_SMG | -AMD_PG_SUPPORT_GFX_PIPELINE ; -/* powerplay UVD PG doesn't work yet */ -if (!amdgpu_powerplay) - adev->pg_flags |=AMD_PG_SUPPORT_UVD ; +AMD_PG_SUPPORT_GFX_PIPELINE | +AMD_PG_SUPPORT_UVD ; adev->external_rev_id = adev->rev_id +0x1 ;break ;default :
drivers/gpu/drm/amd/powerplay/eventmgr/eventactionchains.c +0 -1
@@ -30,7 +30,6 @@ static const pem_event_action * const initialize_event[] = { system_config_tasks, setup_asic_tasks, enable_dynamic_state_management_tasks, - enable_clock_power_gatings_tasks, get_2d_performance_state_tasks, set_performance_state_tasks, initialize_thermal_controller_tasks,
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +18 -4
@@ -21,9 +21,13 @@* */ +#include "amdgpu.h" #include "hwmgr.h" #include "cz_clockpowergating.h" #include "cz_ppsmc.h" +#include "cgs_linux.h" +#include "uvd/uvd_6_0_d.h" +#include "uvd/uvd_6_0_sh_mask.h" /* PhyID -> Status Mapping in DDI_PHY_GEN_STATUS 0 GFX0L (3:0), (27:24),
@@ -160,12 +164,21 @@ int cz_enable_disable_vce_dpm(struct pp_hwmgr *hwmgr, bool enable)int cz_dpm_powergate_uvd (struct pp_hwmgr *hwmgr,bool bgate) {struct cz_hwmgr *cz_hwmgr = (struct cz_hwmgr *)(hwmgr->backend); +struct amdgpu_cgs_device *cgs_dev = hwmgr->device; +struct amdgpu_device *adev = cgs_dev->adev; -if (cz_hwmgr->uvd_power_gated == bgate) +mutex_lock (&adev->uvd.pg_lock); + +if (cz_hwmgr->uvd_power_gated == bgate) { +mutex_unlock (&adev->uvd.pg_lock);return 0 ; + } + adev->uvd.pg_state = bgate; cz_hwmgr->uvd_power_gated = bgate; +WREG32 (mmUVD_POWER_STATUS,UVD_POWER_STATUS__UVD_PG_EN_MASK ); +if (bgate) { cgs_set_clockgating_state(hwmgr->device, AMD_IP_BLOCK_TYPE_UVD,
@@ -177,14 +190,15 @@ int cz_dpm_powergate_uvd(struct pp_hwmgr *hwmgr, bool bgate)cz_dpm_powerdown_uvd (hwmgr); }else {cz_dpm_powerup_uvd (hwmgr); -cgs_set_clockgating_state (hwmgr->device, -AMD_IP_BLOCK_TYPE_UVD , -AMD_PG_STATE_GATE );cgs_set_powergating_state (hwmgr->device,AMD_IP_BLOCK_TYPE_UVD ,AMD_CG_STATE_UNGATE ); +cgs_set_clockgating_state (hwmgr->device, +AMD_IP_BLOCK_TYPE_UVD , +AMD_PG_STATE_GATE );cz_dpm_update_uvd_dpm (hwmgr, false); } +mutex_unlock (&adev->uvd.pg_lock);return 0 ; }
Signature · 6 lines
2.9.2 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx