GFX/UVD PG
Subsystems (2)
This is another resend but this time re-organized from scratch so there is no revert patch in here.
These patches enable GFX and static UVD PG for Stoney and Carrizo. UVD PG support is enabled in both DPM and Powerplay. Powerplay is corrected to set the clock after ungating power as well as to not power down before the UVD core is initialized.
All tested on an AM4 Carrizo and a Gardenia Stoney.
_______________________________________________
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 doesn't 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
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH 2/4] drm/amd/amdgpu: Add GFX and UVD PG for Carrizo
Quoted 13 lines · Tom St Denis
Enables GFX PG and UVD static PG on Carrizo class
asics.Signed-off-by Tom St Denis <[email protected]>--- drivers/gpu/drm/amd/amdgpu/vi.c | 9 +++++++++ 1 file changed, 9 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 1581
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/vi.c +1
-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 doesn't support PG */
It's probably worth correcting this comment. A0 theoretically supports PG, but probably requires additional workarounds. Something like "Don't enable PG on rev0 hw due to hw issues" or something like that.
drivers/gpu/drm/amd/amdgpu/vi.c static int vi_common_early_init(void *handle) · line 1589
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/vi.c +7
-0adev->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 ;
It's probably worth testing UVD PG on rev0 hw as well so see if we can enable this on them as well. OTOH, there isn't likely much rev0 hw in the wild, so it may not matter too much.
Alex
Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/vi.c +1
-1+ } adev->external_rev_id = adev->rev_id +0x1 ;break ;case CHIP_STONEY : --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_N7U8CQtLjjfxvcJghyFRAkGfGiHGM5gGB_Y51psHW8UQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: [PATCH 2/4] drm/amd/amdgpu: Add GFX and UVD PG for Carrizo
I don't have rev0 hardware. I can edit the comment but I can't test the switch to the logic.
Is there even rev0 hardware in retail?
Tom
________________________________
From: Alex Deucher <[email protected]>
Sent: Tuesday, July 26, 2016 14:47
To: Tom St Denis
Cc: amd-gfx list; StDenis, Tom
Subject: Re: [PATCH 2/4] drm/amd/amdgpu: Add GFX and UVD PG for Carrizo
Quoted 13 lines · Tom St Denis
Enables GFX PG and UVD static PG on Carrizo class
asics.Signed-off-by Tom St Denis <[email protected]>--- drivers/gpu/drm/amd/amdgpu/vi.c | 9 +++++++++ 1 file changed, 9 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 1581
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/vi.c +1
-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 doesn't support PG */
It's probably worth correcting this comment. A0 theoretically supports PG, but probably requires additional workarounds. Something like "Don't enable PG on rev0 hw due to hw issues" or something like that.
drivers/gpu/drm/amd/amdgpu/vi.c static int vi_common_early_init(void *handle) · line 1589
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/vi.c +7
-0adev->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 ;
It's probably worth testing UVD PG on rev0 hw as well so see if we can enable this on them as well. OTOH, there isn't likely much rev0 hw in the wild, so it may not matter too much.
Alex
Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/vi.c +1
-1+ } adev->external_rev_id = adev->rev_id +0x1 ;break ;case CHIP_STONEY : --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
A message that is not in the archive (sent off-list or not yet received): DM5PR12MB1132B4CD639F3DF4015F5A60F70E0-2J9CzHegvk+UzrhdoDeimQdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org
Re: [PATCH 2/4] drm/amd/amdgpu: Add GFX and UVD PG for Carrizo
Just early engineering samples are rev0.
Alex
Quoted 69 lines · Tom
I don't have rev0 hardware. I can edit the comment but I can't test the switch to the logic.
Is there even rev0 hardware in retail?
Tom
------------------------------
*From:* Alex Deucher <[email protected]> *Sent:* Tuesday, July 26, 2016 14:47
*To:* Tom St Denis
*Cc:* amd-gfx list; StDenis, Tom
*Subject:* Re: [PATCH 2/4] drm/amd/amdgpu: Add GFX and UVD PG for CarrizoReview
Quoted 9 lines · Tom St Denis
Enables GFX PG and UVD static PG on Carrizo class
asics.Signed-off-by Tom St Denis <[email protected]>--- drivers/gpu/drm/amd/amdgpu/vi.c | 9 +++++++++ 1 file changed, 9 insertions(+)(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/vi.cdrivers/gpu/drm/amd/amdgpu/vi.c static int vi_common_early_init(void *handle) · line 1581
Quoted 8 lines
index
9ba64989f092..289a4c4ac9e7100644drivers/gpu/drm/amd/amdgpu/vi.c +1
-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 doesn't support PG */ It's probably worth correcting this comment. A0 theoretically supports PG, but probably requires additional workarounds. Something like "Don't enable PG on rev0 hw due to hw issues" or something like that.
drivers/gpu/drm/amd/amdgpu/vi.c static int vi_common_early_init(void *handle) · line 1589
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/vi.c +7
-0adev->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 ;It's probably worth testing UVD PG on rev0 hw as well so see if we can enable this on them as well. OTOH, there isn't likely much rev0 hw in the wild, so it may not matter too much.
Alex
Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/vi.c +1
-1+ } adev->external_rev_id = adev->rev_id +0x1 ;break ;case CHIP_STONEY : --2.9.2
_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 9 lines
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 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
PATCH 4/4 drm/amd/powerplay: Prevent UVD powerdown before init
In reply to a message not in the archiveBecause of the ip_blocks init order powerplay would power down the UVD block before UVD start is called. This results in a VCPU hang.
This patch prevents power down before UVD is initialized.
Also correct the power up order so clocking is set after power is ungated.
With this applied comparable clock/power behaviour to powerplay=0 with DPM is observed.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 6 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | 5 ----- drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c | 8 ++++--- drivers/gpu/drm/amd/amdgpu/vi.c | 12 ++++------- .../drm/amd/powerplay/hwmgr/cz_clockpowergating.c | 25 ++++++++++++++++++---- drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c | 7 ++++++ 6 files changed, 43 insertions(+), 20 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +6 -0
@@ -1692,6 +1692,7 @@ struct amdgpu_uvd {uint32_t srbm_soft_reset;int cg_state, pg_state;struct mutex pg_lock; +bool is_init; };/*
@@ -2518,5 +2519,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 +5 -3
@@ -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) */ -if (adev->uvd.pg_state) -return -EINVAL ; +/* is power gated? then we can't start but don't return an error */ +if (adev->uvd.is_init && adev->uvd.pg_state) +return 0 ;/* set CG state to -1 for unset */ adev->uvd.cg_state =-1 ;
@@ -662,6 +662,8 @@ static int uvd_v6_0_ring_test_ring(struct amdgpu_ring *ring) ring->idx, tmp); r = -EINVAL ; } +if (!r) + adev->uvd.is_init = true;return r; }
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/hwmgr/cz_clockpowergating.c +21 -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,24 @@ 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) +if (!adev->uvd.is_init)return 0 ; +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 +193,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 ; }
drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c +7 -0
@@ -39,6 +39,7 @@#include "power_state.h" #include "cz_clockpowergating.h" #include "pp_debug.h" +#include "amdgpu.h" #define ixSMUSVI_NB_CURRENTVID 0xD8230044#define CURRENT_NB_VID_MASK 0xff000000
@@ -1356,6 +1357,12 @@ static int cz_dpm_force_dpm_level(struct pp_hwmgr *hwmgr,int cz_dpm_powerdown_uvd (struct pp_hwmgr *hwmgr) { +struct amdgpu_cgs_device *cgs_dev = hwmgr->device; +struct amdgpu_device *adev = cgs_dev->adev; + +if (!adev->uvd.is_init) +return 0 ; +if (phm_cap_enabled (hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_UVDPowerGating)) return smum_send_msg_to_smc(hwmgr->smumgr,
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 4/4] drm/amd/powerplay: Prevent UVD powerdown before init
Quoted 6 lines · Tom St Denis
Because of the
ip_blocksinit order powerplay would power down the UVD block before UVD start is called. This results in a VCPU hang.This patch prevents power down before UVD is initialized.
Quoted 7 lines
Also correct the power up order so clocking is set after power is ungated.
With this applied comparable clock/power behaviour to powerplay=0 with DPM is observed.
Signed-off-by Tom St Denis <[email protected]>
This patch needs to be split into several patches and reworked a bit. Also, don't include amdgpu.h in powerplay. We have cgs for access to registers and data from adev, etc. The idea is to minimize the dependencies between components. We shouldn't be accessing adev directly in powerplay. A couple more comments inline.
Quoted 79 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 6 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | 5 ----- drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c | 8 ++++--- drivers/gpu/drm/amd/amdgpu/vi.c | 12 ++++------- .../drm/amd/powerplay/hwmgr/cz_clockpowergating.c | 25 ++++++++++++++++++---- drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c | 7 ++++++ 6 files changed, 43 insertions(+), 20 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +6
-0@@ -1692,6 +1692,7 @@ struct amdgpu_uvd {uint32_t srbm_soft_reset;int cg_state, pg_state;struct mutex pg_lock; +bool is_init; };/* @@ -2518,5 +2519,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)->adevdrivers/gpu/drm/amd/amdgpu/uvd_v6_0.c +5
-3@@ -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) */ -if (adev->uvd.pg_state) -return -EINVAL ; +/* is power gated? then we can't start but don't return an error */ +if (adev->uvd.is_init && adev->uvd.pg_state) +return 0 ;/* set CG state to -1 for unset */ adev->uvd.cg_state =-1 ;@@ -662,6 +662,8 @@ static int uvd_v6_0_ring_test_ring(struct amdgpu_ring *ring) ring->idx, tmp); r = -EINVAL ; } +if (!r) + adev->uvd.is_init = true;return r; }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 1587
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/vi.c +2
-4@@ -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 ;
This should be a separate patch.
drivers/gpu/drm/amd/amdgpu/vi.c static int vi_common_early_init(void *handle) · line 1610
Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/vi.c +2
-4} 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 ;
Same with this.
Quoted 34 lines
drivers/gpu/drm/amd/amdgpu/vi.c +0
-0adev->external_rev_id = adev->rev_id +0x1 ;break ;default :drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +9
-1@@ -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,24 @@ 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) +if (!adev->uvd.is_init)return 0 ; +mutex_lock (&adev->uvd.pg_lock); +
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c int cz_enable_disable_vce_dpm(struct pp_hwmgr *hwmgr, bool enable) · line 184
Quoted 10 lines
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +8
-0+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 ); +
Could this be moved to the uvd 6 module?
Quoted 6 lines
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +0
-0if (bgate) { cgs_set_clockgating_state(hwmgr->device, AMD_IP_BLOCK_TYPE_UVD,@@ -177,14 +193,15 @@ int cz_dpm_powergate_uvd(struct pp_hwmgr *hwmgr, bool bgate)cz_dpm_powerdown_uvd (hwmgr); }else {
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c int cz_dpm_powergate_uvd(struct pp_hwmgr *hwmgr, bool bgate) · line 201
Quoted 10 lines
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +3
-3cz_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 );
I think this is a standalone fix and should be split into a separate patch.
Quoted 34 lines
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +1
-0cz_dpm_update_uvd_dpm (hwmgr, false); } +mutex_unlock (&adev->uvd.pg_lock);return 0 ; }drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c +7
-1@@ -39,6 +39,7 @@#include "power_state.h" #include "cz_clockpowergating.h" #include "pp_debug.h" +#include "amdgpu.h" #define ixSMUSVI_NB_CURRENTVID 0xD8230044#define CURRENT_NB_VID_MASK 0xff000000@@ -1356,6 +1357,12 @@ static int cz_dpm_force_dpm_level(struct pp_hwmgr *hwmgr,int cz_dpm_powerdown_uvd (struct pp_hwmgr *hwmgr) { +struct amdgpu_cgs_device *cgs_dev = hwmgr->device; +struct amdgpu_device *adev = cgs_dev->adev; + +if (!adev->uvd.is_init) +return 0 ; +if (phm_cap_enabled (hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_UVDPowerGating)) return smum_send_msg_to_smc(hwmgr->smumgr, --2.9.2
Quoted 4 lines
_______________________________________________
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_P5C_Rix2wkUuzABQKtcxOYyQeL7FNBA4GJLy3Fg+o4UQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
RE: [PATCH 4/4] drm/amd/powerplay: Prevent UVD powerdown before init
From: amd-gfx [mailto:[email protected]] On Behalf Of Alex Deucher
Sent: Thursday, July 28, 2016 1:46 PM
To: Tom St Denis
Cc: StDenis, Tom; amd-gfx list
Subject: Re: [PATCH 4/4] drm/amd/powerplay: Prevent UVD powerdown before init
Quoted 5 lines · Tom St Denis
Because of the
ip_blocksinit order powerplay would power down the UVD block before UVD start is called. This results in a VCPU hang.This patch prevents power down before UVD is initialized.
Quoted 7 lines
Also correct the power up order so clocking is set after power is ungated.
With this applied comparable clock/power behaviour to powerplay=0 with DPM is observed.
Signed-off-by Tom St Denis <[email protected]>
This patch needs to be split into several patches and reworked a bit.
Also, don't include amdgpu.h in powerplay. We have cgs for access to registers and data from adev, etc. The idea is to minimize the dependencies between components. We shouldn't be accessing adev directly in powerplay. A couple more comments inline.
Rex: I also think so.
1. We can move
+ WREG32(mmUVD_POWER_STATUS,
+ UVD_POWER_STATUS__UVD_PG_EN_MASK |
+ UVD_POWER_STATUS__UVD_PG_MODE_MASK);
+ else
+ WREG32(mmUVD_POWER_STATUS,
+ UVD_POWER_STATUS__UVD_PG_EN_MASK);
to uvd_v6_0_start. no need to visit adev in powerplay and dpm. And uvd test also can pass.
2. for the lock, we can just use pm.mutex.
3. please also delete enable_clock_power_gatings_tasks in resume_action_chain in a separate patch for powerplay.
4. do we need to add cg_state, pg_state?
Best Regards
Rex
Quoted 84 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 6 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | 5 ----- drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c | 8 ++++--- drivers/gpu/drm/amd/amdgpu/vi.c | 12 ++++------- .../drm/amd/powerplay/hwmgr/cz_clockpowergating.c | 25 ++++++++++++++++++---- drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c | 7 ++++++ 6 files changed, 43 insertions(+), 20 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +1
-0@@ -1692,6 +1692,7 @@ struct amdgpu_uvd {uint32_t srbm_soft_reset;int cg_state, pg_state;struct mutex pg_lock; +bool is_init; };/* @@ -2518,5 +2519,10 @@ int amdgpu_dm_display_resume(struct
amdgpu_device*adev ); static inline intamdgpu_dm_display_resume(struct amdgpu_device *adev){ return 0; } #endifdrivers/gpu/drm/amd/amdgpu/amdgpu.h +5
-0+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
-6@@ -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 diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
index422d5300b92e..3b93327c5e25100644drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c +5
-3@@ -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) */ -if (adev->uvd.pg_state) -return -EINVAL ; +/* is power gated? then we can't start but don't return an error */ +if (adev->uvd.is_init && adev->uvd.pg_state) +return 0 ;/* set CG state to -1 for unset */ adev->uvd.cg_state =-1 ;@@ -662,6 +662,8 @@ static int uvd_v6_0_ring_test_ring(struct amdgpu_ring *ring) ring->idx, tmp); r = -EINVAL ; } +if (!r) + adev->uvd.is_init = true;return r; }(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/vi.cindex78fea940d120..f4fdde0641b0100644
drivers/gpu/drm/amd/amdgpu/vi.c static int vi_common_early_init(void *handle) · line 1587
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/vi.c +2
-4@@ -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 ;
This should be a separate patch.
drivers/gpu/drm/amd/amdgpu/vi.c static int vi_common_early_init(void *handle) · line 1610
Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/vi.c +2
-4} 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 ;
Same with this.
Quoted 36 lines
drivers/gpu/drm/amd/amdgpu/vi.c +0
-0adev->external_rev_id = adev->rev_id +0x1 ;break ;default :drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +9
-1@@ -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,24 @@ 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) +if (!adev->uvd.is_init)return 0 ; +mutex_lock (&adev->uvd.pg_lock); +
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c int cz_enable_disable_vce_dpm(struct pp_hwmgr · line 185
Quoted 10 lines
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +8
-0+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 ); +
Could this be moved to the uvd 6 module?
Quoted 6 lines
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +0
-0if (bgate) { cgs_set_clockgating_state(hwmgr->device,
AMD_IP_BLOCK_TYPE_UVD,drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +0
-0@@ -177,14 +193,15 @@ int cz_dpm_powergate_uvd(struct pp_hwmgr *hwmgr, bool bgate)cz_dpm_powerdown_uvd (hwmgr); }else {
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c int cz_dpm_powergate_uvd(struct pp_hwmgr *hwmgr, bool bgate) · line 201
Quoted 10 lines
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +3
-3cz_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 );
I think this is a standalone fix and should be split into a separate patch.
Quoted 34 lines
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +1
-0cz_dpm_update_uvd_dpm (hwmgr, false); } +mutex_unlock (&adev->uvd.pg_lock);return 0 ; }drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c +1
-0@@ -39,6 +39,7 @@#include "power_state.h" #include "cz_clockpowergating.h" #include "pp_debug.h" +#include "amdgpu.h" #define ixSMUSVI_NB_CURRENTVID 0xD8230044 #define
CURRENT_NB_VID_MASK0xff000000@@ -1356,6 +1357,12 @@ static int cz_dpm_force_dpm_level(structpp_hwmgr*hwmgr,int
cz_dpm_powerdown_uvd(struct pp_hwmgr *hwmgr){drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c +6
-1+struct amdgpu_cgs_device *cgs_dev = hwmgr->device; +struct amdgpu_device *adev = cgs_dev->adev; + +if (!adev->uvd.is_init) +return 0 ; +if (phm_cap_enabled (hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_UVDPowerGating)) return smum_send_msg_to_smc(hwmgr->smumgr, --2.9.2
Quoted 4 lines
_______________________________________________
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
_______________________________________________
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): BLUPR12MB0659D45202A93FB726C50D84FB000-7LeqcoF/[email protected]
Re: [PATCH 4/4] drm/amd/powerplay: Prevent UVD powerdown before init
I found that moving the PG_EN to start would cause problems. I'm pretty sure you have to write it just before calling the firmware otherwise bad things happen which is why I moved it there. We could probably move it into the uvd_v6_0's powergating function which is called just before the smu call.
I'll take care of comments 2/3. For 4 it was a sanity check to prevent out-of-order operations. It can probably be safely removed now.
My work tree also has a half-implemented VCE PG/CG (PG works, CG doesn't) that has some of the same issues so I'll fix them too and sort the tree out a bit and re-send the whole lot sometime today.
Tom
________________________________
From: Zhu, Rex
Sent: Thursday, July 28, 2016 03:43
To: Alex Deucher; Tom St Denis
Cc: StDenis, Tom; amd-gfx list
Subject: RE: [PATCH 4/4] drm/amd/powerplay: Prevent UVD powerdown before init
From: amd-gfx [mailto:amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org] On Behalf Of Alex Deucher
Sent: Thursday, July 28, 2016 1:46 PM
To: Tom St Denis
Cc: StDenis, Tom; amd-gfx list
Subject: Re: [PATCH 4/4] drm/amd/powerplay: Prevent UVD powerdown before init
Quoted 5 lines · Tom St Denis
Because of the
ip_blocksinit order powerplay would power down the UVD block before UVD start is called. This results in a VCPU hang.This patch prevents power down before UVD is initialized.
Quoted 7 lines
Also correct the power up order so clocking is set after power is ungated.
With this applied comparable clock/power behaviour to powerplay=0 with DPM is observed.
Signed-off-by Tom St Denis <[email protected]>
This patch needs to be split into several patches and reworked a bit.
Also, don't include amdgpu.h in powerplay. We have cgs for access to registers and data from adev, etc. The idea is to minimize the dependencies between components. We shouldn't be accessing adev directly in powerplay. A couple more comments inline.
Rex: I also think so.
1. We can move
+ WREG32(mmUVD_POWER_STATUS,
+ UVD_POWER_STATUS__UVD_PG_EN_MASK |
+ UVD_POWER_STATUS__UVD_PG_MODE_MASK);
+ else
+ WREG32(mmUVD_POWER_STATUS,
+ UVD_POWER_STATUS__UVD_PG_EN_MASK);
to uvd_v6_0_start. no need to visit adev in powerplay and dpm. And uvd test also can pass.
2. for the lock, we can just use pm.mutex.
3. please also delete enable_clock_power_gatings_tasks in resume_action_chain in a separate patch for powerplay.
4. do we need to add cg_state, pg_state?
Best Regards
Rex
Quoted 84 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 6 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | 5 ----- drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c | 8 ++++--- drivers/gpu/drm/amd/amdgpu/vi.c | 12 ++++------- .../drm/amd/powerplay/hwmgr/cz_clockpowergating.c | 25 ++++++++++++++++++---- drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c | 7 ++++++ 6 files changed, 43 insertions(+), 20 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +1
-0@@ -1692,6 +1692,7 @@ struct amdgpu_uvd {uint32_t srbm_soft_reset;int cg_state, pg_state;struct mutex pg_lock; +bool is_init; };/* @@ -2518,5 +2519,10 @@ int amdgpu_dm_display_resume(struct
amdgpu_device*adev ); static inline intamdgpu_dm_display_resume(struct amdgpu_device *adev){ return 0; } #endifdrivers/gpu/drm/amd/amdgpu/amdgpu.h +5
-0+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
-6@@ -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 diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
index422d5300b92e..3b93327c5e25100644drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c +5
-3@@ -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) */ -if (adev->uvd.pg_state) -return -EINVAL ; +/* is power gated? then we can't start but don't return an error */ +if (adev->uvd.is_init && adev->uvd.pg_state) +return 0 ;/* set CG state to -1 for unset */ adev->uvd.cg_state =-1 ;@@ -662,6 +662,8 @@ static int uvd_v6_0_ring_test_ring(struct amdgpu_ring *ring) ring->idx, tmp); r = -EINVAL ; } +if (!r) + adev->uvd.is_init = true;return r; }(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/vi.cindex78fea940d120..f4fdde0641b0100644
drivers/gpu/drm/amd/amdgpu/vi.c static int vi_common_early_init(void *handle) · line 1587
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/vi.c +2
-4@@ -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 ;
This should be a separate patch.
drivers/gpu/drm/amd/amdgpu/vi.c static int vi_common_early_init(void *handle) · line 1610
Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/vi.c +2
-4} 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 ;
Same with this.
Quoted 36 lines
drivers/gpu/drm/amd/amdgpu/vi.c +0
-0adev->external_rev_id = adev->rev_id +0x1 ;break ;default :drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +9
-1@@ -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,24 @@ 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) +if (!adev->uvd.is_init)return 0 ; +mutex_lock (&adev->uvd.pg_lock); +
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c int cz_enable_disable_vce_dpm(struct pp_hwmgr · line 185
Quoted 10 lines
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +8
-0+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 ); +
Could this be moved to the uvd 6 module?
Quoted 6 lines
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +0
-0if (bgate) { cgs_set_clockgating_state(hwmgr->device,
AMD_IP_BLOCK_TYPE_UVD,drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +0
-0@@ -177,14 +193,15 @@ int cz_dpm_powergate_uvd(struct pp_hwmgr *hwmgr, bool bgate)cz_dpm_powerdown_uvd (hwmgr); }else {
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c int cz_dpm_powergate_uvd(struct pp_hwmgr *hwmgr, bool bgate) · line 201
Quoted 10 lines
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +3
-3cz_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 );
I think this is a standalone fix and should be split into a separate patch.
Quoted 34 lines
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +1
-0cz_dpm_update_uvd_dpm (hwmgr, false); } +mutex_unlock (&adev->uvd.pg_lock);return 0 ; }drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c +1
-0@@ -39,6 +39,7 @@#include "power_state.h" #include "cz_clockpowergating.h" #include "pp_debug.h" +#include "amdgpu.h" #define ixSMUSVI_NB_CURRENTVID 0xD8230044 #define
CURRENT_NB_VID_MASK0xff000000@@ -1356,6 +1357,12 @@ static int cz_dpm_force_dpm_level(structpp_hwmgr*hwmgr,int
cz_dpm_powerdown_uvd(struct pp_hwmgr *hwmgr){drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c +6
-1+struct amdgpu_cgs_device *cgs_dev = hwmgr->device; +struct amdgpu_device *adev = cgs_dev->adev; + +if (!adev->uvd.is_init) +return 0 ; +if (phm_cap_enabled (hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_UVDPowerGating)) return smum_send_msg_to_smc(hwmgr->smumgr, --2.9.2
Quoted 4 lines
_______________________________________________
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
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH 4/4] drm/amd/powerplay: Prevent UVD powerdown before init
In reply to a message not in the archiveQuick question, how am I meant to get access to pm.mutex from powerplay?
I need a lock I can see around the SMU calls and in the amdgpu side (for userspace locking).
Tom
________________________________
From: Zhu, Rex
Sent: Thursday, July 28, 2016 03:43
To: Alex Deucher; Tom St Denis
Cc: StDenis, Tom; amd-gfx list
Subject: RE: [PATCH 4/4] drm/amd/powerplay: Prevent UVD powerdown before init
From: amd-gfx [mailto:amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org] On Behalf Of Alex Deucher
Sent: Thursday, July 28, 2016 1:46 PM
To: Tom St Denis
Cc: StDenis, Tom; amd-gfx list
Subject: Re: [PATCH 4/4] drm/amd/powerplay: Prevent UVD powerdown before init
Quoted 5 lines · Tom St Denis
Because of the
ip_blocksinit order powerplay would power down the UVD block before UVD start is called. This results in a VCPU hang.This patch prevents power down before UVD is initialized.
Quoted 7 lines
Also correct the power up order so clocking is set after power is ungated.
With this applied comparable clock/power behaviour to powerplay=0 with DPM is observed.
Signed-off-by Tom St Denis <[email protected]>
This patch needs to be split into several patches and reworked a bit.
Also, don't include amdgpu.h in powerplay. We have cgs for access to registers and data from adev, etc. The idea is to minimize the dependencies between components. We shouldn't be accessing adev directly in powerplay. A couple more comments inline.
Rex: I also think so.
1. We can move
+ WREG32(mmUVD_POWER_STATUS,
+ UVD_POWER_STATUS__UVD_PG_EN_MASK |
+ UVD_POWER_STATUS__UVD_PG_MODE_MASK);
+ else
+ WREG32(mmUVD_POWER_STATUS,
+ UVD_POWER_STATUS__UVD_PG_EN_MASK);
to uvd_v6_0_start. no need to visit adev in powerplay and dpm. And uvd test also can pass.
2. for the lock, we can just use pm.mutex.
3. please also delete enable_clock_power_gatings_tasks in resume_action_chain in a separate patch for powerplay.
4. do we need to add cg_state, pg_state?
Best Regards
Rex
Quoted 84 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 6 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | 5 ----- drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c | 8 ++++--- drivers/gpu/drm/amd/amdgpu/vi.c | 12 ++++------- .../drm/amd/powerplay/hwmgr/cz_clockpowergating.c | 25 ++++++++++++++++++---- drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c | 7 ++++++ 6 files changed, 43 insertions(+), 20 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +1
-0@@ -1692,6 +1692,7 @@ struct amdgpu_uvd {uint32_t srbm_soft_reset;int cg_state, pg_state;struct mutex pg_lock; +bool is_init; };/* @@ -2518,5 +2519,10 @@ int amdgpu_dm_display_resume(struct
amdgpu_device*adev ); static inline intamdgpu_dm_display_resume(struct amdgpu_device *adev){ return 0; } #endifdrivers/gpu/drm/amd/amdgpu/amdgpu.h +5
-0+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
-6@@ -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 diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
index422d5300b92e..3b93327c5e25100644drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c +5
-3@@ -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) */ -if (adev->uvd.pg_state) -return -EINVAL ; +/* is power gated? then we can't start but don't return an error */ +if (adev->uvd.is_init && adev->uvd.pg_state) +return 0 ;/* set CG state to -1 for unset */ adev->uvd.cg_state =-1 ;@@ -662,6 +662,8 @@ static int uvd_v6_0_ring_test_ring(struct amdgpu_ring *ring) ring->idx, tmp); r = -EINVAL ; } +if (!r) + adev->uvd.is_init = true;return r; }(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/vi.cindex78fea940d120..f4fdde0641b0100644
drivers/gpu/drm/amd/amdgpu/vi.c static int vi_common_early_init(void *handle) · line 1587
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/vi.c +2
-4@@ -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 ;
This should be a separate patch.
drivers/gpu/drm/amd/amdgpu/vi.c static int vi_common_early_init(void *handle) · line 1610
Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/vi.c +2
-4} 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 ;
Same with this.
Quoted 36 lines
drivers/gpu/drm/amd/amdgpu/vi.c +0
-0adev->external_rev_id = adev->rev_id +0x1 ;break ;default :drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +9
-1@@ -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,24 @@ 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) +if (!adev->uvd.is_init)return 0 ; +mutex_lock (&adev->uvd.pg_lock); +
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c int cz_enable_disable_vce_dpm(struct pp_hwmgr · line 185
Quoted 10 lines
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +8
-0+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 ); +
Could this be moved to the uvd 6 module?
Quoted 6 lines
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +0
-0if (bgate) { cgs_set_clockgating_state(hwmgr->device,
AMD_IP_BLOCK_TYPE_UVD,drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +0
-0@@ -177,14 +193,15 @@ int cz_dpm_powergate_uvd(struct pp_hwmgr *hwmgr, bool bgate)cz_dpm_powerdown_uvd (hwmgr); }else {
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c int cz_dpm_powergate_uvd(struct pp_hwmgr *hwmgr, bool bgate) · line 201
Quoted 10 lines
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +3
-3cz_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 );
I think this is a standalone fix and should be split into a separate patch.
Quoted 34 lines
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +1
-0cz_dpm_update_uvd_dpm (hwmgr, false); } +mutex_unlock (&adev->uvd.pg_lock);return 0 ; }drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c +1
-0@@ -39,6 +39,7 @@#include "power_state.h" #include "cz_clockpowergating.h" #include "pp_debug.h" +#include "amdgpu.h" #define ixSMUSVI_NB_CURRENTVID 0xD8230044 #define
CURRENT_NB_VID_MASK0xff000000@@ -1356,6 +1357,12 @@ static int cz_dpm_force_dpm_level(structpp_hwmgr*hwmgr,int
cz_dpm_powerdown_uvd(struct pp_hwmgr *hwmgr){drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c +6
-1+struct amdgpu_cgs_device *cgs_dev = hwmgr->device; +struct amdgpu_device *adev = cgs_dev->adev; + +if (!adev->uvd.is_init) +return 0 ; +if (phm_cap_enabled (hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_UVDPowerGating)) return smum_send_msg_to_smc(hwmgr->smumgr, --2.9.2
Quoted 4 lines
_______________________________________________
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
_______________________________________________
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): DM5PR12MB1132DA66C4E0B70497D5D121F7000-2J9CzHegvk+UzrhdoDeimQdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org
Re: [PATCH 4/4] drm/amd/powerplay: Prevent UVD powerdown before init
Nevermind I moved the locking into amdgpu_pm.c and that did the trick.
Attached is a patch that contains all the changes. If you guys want to give it a quick once-through I can then start splitting it up per Alex's comments.
Tom
________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of StDenis, Tom <[email protected]>
Sent: Thursday, July 28, 2016 07:10
To: Zhu, Rex; Alex Deucher
Cc: amd-gfx list
Subject: Re: [PATCH 4/4] drm/amd/powerplay: Prevent UVD powerdown before init
Quick question, how am I meant to get access to pm.mutex from powerplay?
I need a lock I can see around the SMU calls and in the amdgpu side (for userspace locking).
Tom
________________________________
From: Zhu, Rex
Sent: Thursday, July 28, 2016 03:43
To: Alex Deucher; Tom St Denis
Cc: StDenis, Tom; amd-gfx list
Subject: RE: [PATCH 4/4] drm/amd/powerplay: Prevent UVD powerdown before init
From: amd-gfx [mailto:amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org] On Behalf Of Alex Deucher
Sent: Thursday, July 28, 2016 1:46 PM
To: Tom St Denis
Cc: StDenis, Tom; amd-gfx list
Subject: Re: [PATCH 4/4] drm/amd/powerplay: Prevent UVD powerdown before init
Quoted 5 lines · Tom St Denis
Because of the
ip_blocksinit order powerplay would power down the UVD block before UVD start is called. This results in a VCPU hang.This patch prevents power down before UVD is initialized.
Quoted 7 lines
Also correct the power up order so clocking is set after power is ungated.
With this applied comparable clock/power behaviour to powerplay=0 with DPM is observed.
Signed-off-by Tom St Denis <[email protected]>
This patch needs to be split into several patches and reworked a bit.
Also, don't include amdgpu.h in powerplay. We have cgs for access to registers and data from adev, etc. The idea is to minimize the dependencies between components. We shouldn't be accessing adev directly in powerplay. A couple more comments inline.
Rex: I also think so.
1. We can move
+ WREG32(mmUVD_POWER_STATUS,
+ UVD_POWER_STATUS__UVD_PG_EN_MASK |
+ UVD_POWER_STATUS__UVD_PG_MODE_MASK);
+ else
+ WREG32(mmUVD_POWER_STATUS,
+ UVD_POWER_STATUS__UVD_PG_EN_MASK);
to uvd_v6_0_start. no need to visit adev in powerplay and dpm. And uvd test also can pass.
2. for the lock, we can just use pm.mutex.
3. please also delete enable_clock_power_gatings_tasks in resume_action_chain in a separate patch for powerplay.
4. do we need to add cg_state, pg_state?
Best Regards
Rex
Quoted 84 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 6 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | 5 ----- drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c | 8 ++++--- drivers/gpu/drm/amd/amdgpu/vi.c | 12 ++++------- .../drm/amd/powerplay/hwmgr/cz_clockpowergating.c | 25 ++++++++++++++++++---- drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c | 7 ++++++ 6 files changed, 43 insertions(+), 20 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +1
-0@@ -1692,6 +1692,7 @@ struct amdgpu_uvd {uint32_t srbm_soft_reset;int cg_state, pg_state;struct mutex pg_lock; +bool is_init; };/* @@ -2518,5 +2519,10 @@ int amdgpu_dm_display_resume(struct
amdgpu_device*adev ); static inline intamdgpu_dm_display_resume(struct amdgpu_device *adev){ return 0; } #endifdrivers/gpu/drm/amd/amdgpu/amdgpu.h +5
-0+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
-6@@ -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 diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
index422d5300b92e..3b93327c5e25100644drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c +5
-3@@ -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) */ -if (adev->uvd.pg_state) -return -EINVAL ; +/* is power gated? then we can't start but don't return an error */ +if (adev->uvd.is_init && adev->uvd.pg_state) +return 0 ;/* set CG state to -1 for unset */ adev->uvd.cg_state =-1 ;@@ -662,6 +662,8 @@ static int uvd_v6_0_ring_test_ring(struct amdgpu_ring *ring) ring->idx, tmp); r = -EINVAL ; } +if (!r) + adev->uvd.is_init = true;return r; }(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/vi.cindex78fea940d120..f4fdde0641b0100644
drivers/gpu/drm/amd/amdgpu/vi.c static int vi_common_early_init(void *handle) · line 1587
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/vi.c +2
-4@@ -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 ;
This should be a separate patch.
drivers/gpu/drm/amd/amdgpu/vi.c static int vi_common_early_init(void *handle) · line 1610
Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/vi.c +2
-4} 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 ;
Same with this.
Quoted 36 lines
drivers/gpu/drm/amd/amdgpu/vi.c +0
-0adev->external_rev_id = adev->rev_id +0x1 ;break ;default :drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +9
-1@@ -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,24 @@ 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) +if (!adev->uvd.is_init)return 0 ; +mutex_lock (&adev->uvd.pg_lock); +
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c int cz_enable_disable_vce_dpm(struct pp_hwmgr · line 185
Quoted 10 lines
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +8
-0+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 ); +
Could this be moved to the uvd 6 module?
Quoted 6 lines
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +0
-0if (bgate) { cgs_set_clockgating_state(hwmgr->device,
AMD_IP_BLOCK_TYPE_UVD,drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +0
-0@@ -177,14 +193,15 @@ int cz_dpm_powergate_uvd(struct pp_hwmgr *hwmgr, bool bgate)cz_dpm_powerdown_uvd (hwmgr); }else {
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c int cz_dpm_powergate_uvd(struct pp_hwmgr *hwmgr, bool bgate) · line 201
Quoted 10 lines
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +3
-3cz_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 );
I think this is a standalone fix and should be split into a separate patch.
Quoted 34 lines
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +1
-0cz_dpm_update_uvd_dpm (hwmgr, false); } +mutex_unlock (&adev->uvd.pg_lock);return 0 ; }drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c +1
-0@@ -39,6 +39,7 @@#include "power_state.h" #include "cz_clockpowergating.h" #include "pp_debug.h" +#include "amdgpu.h" #define ixSMUSVI_NB_CURRENTVID 0xD8230044 #define
CURRENT_NB_VID_MASK0xff000000@@ -1356,6 +1357,12 @@ static int cz_dpm_force_dpm_level(structpp_hwmgr*hwmgr,int
cz_dpm_powerdown_uvd(struct pp_hwmgr *hwmgr){drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c +6
-1+struct amdgpu_cgs_device *cgs_dev = hwmgr->device; +struct amdgpu_device *adev = cgs_dev->adev; + +if (!adev->uvd.is_init) +return 0 ; +if (phm_cap_enabled (hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_UVDPowerGating)) return smum_send_msg_to_smc(hwmgr->smumgr, --2.9.2
Quoted 4 lines
_______________________________________________
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
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 pm_pg_lock, use_bank;unsigned instance_bank, sh_bank, se_bank;if (size &0x3 || *pos &0x3 )return -EINVAL ; +/* are we reading registers for which a PG lock is necessary? */ + pm_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 (pm_pg_lock) +mutex_lock (&adev->pm.mutex); +while (size) {uint32_t value;
@@ -2385,6 +2392,9 @@ end:mutex_unlock (&adev->grbm_idx_mutex); } +if (pm_pg_lock) +mutex_unlock (&adev->pm.mutex); +return result; }
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +25 -33
79 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/cz_dpm.c +35 -6
64 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c +10 -19
@@ -396,15 +396,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 +959,15 @@ 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) -return 0 ; +if (adev->asic_type ==CHIP_FIJI || + adev->asic_type ==CHIP_POLARIS10 ) +uvd_v6_set_bypass_mode (adev, state ==AMD_CG_STATE_GATE ? true : false); - curstate = state; -if (enable) { +if (state ==AMD_CG_STATE_GATE ) {/* disable HW gating and enable Sw gating */ uvd_v6_0_set_sw_clock_gating (adev); }else {
@@ -1008,6 +997,8 @@ static int uvd_v6_0_set_powergating_state(void *handle,if (!(adev->pg_flags &AMD_PG_SUPPORT_UVD ))return 0 ; +WREG32 (mmUVD_POWER_STATUS,UVD_POWER_STATUS__UVD_PG_EN_MASK ); +if (state ==AMD_PG_STATE_GATE ) {uvd_v6_0_stop (adev);return 0 ;
drivers/gpu/drm/amd/amdgpu/vce_v3_0.c +1 -0
@@ -126,6 +126,7 @@ static void vce_v3_0_set_vce_sw_clock_gating(struct amdgpu_device *adev, bool gated) {u32 tmp, data; +/* Set Override to disable Clock Gating */ vce_v3_0_override_vce_clock_gating (adev, true);
drivers/gpu/drm/amd/amdgpu/vi.c +13 -0
@@ -1578,7 +1578,15 @@ 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 | +AMD_PG_SUPPORT_UVD | +AMD_PG_SUPPORT_VCE ; + } adev->external_rev_id = adev->rev_id +0x1 ;break ;case CHIP_STONEY :
@@ -1597,6 +1605,11 @@ 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 | +AMD_PG_SUPPORT_UVD | +AMD_PG_SUPPORT_VCE ; adev->external_rev_id = adev->rev_id +0x1 ;break ;default :
drivers/gpu/drm/amd/powerplay/eventmgr/eventactionchains.c +0 -2
@@ -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,
@@ -140,7 +139,6 @@ static const pem_event_action * const resume_event[] = { setup_asic_tasks, enable_stutter_mode_tasks,/*must do this in boot state and before SMC is started */ enable_dynamic_state_management_tasks, - enable_clock_power_gatings_tasks, enable_disable_bapm_tasks, initialize_thermal_controller_tasks, get_2d_performance_state_tasks,
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +9 -8
@@ -161,8 +161,9 @@ int cz_dpm_powergate_uvd(struct pp_hwmgr *hwmgr, bool bgate) {struct cz_hwmgr *cz_hwmgr = (struct cz_hwmgr *)(hwmgr->backend); -if (cz_hwmgr->uvd_power_gated == bgate) +if (cz_hwmgr->uvd_power_gated == bgate) {return 0 ; + } cz_hwmgr->uvd_power_gated = bgate;
@@ -177,12 +178,12 @@ 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); }
@@ -211,14 +212,14 @@ int cz_dpm_powergate_vce(struct pp_hwmgr *hwmgr, bool bgate) }else {cz_dpm_powerup_vce (hwmgr); cz_hwmgr->vce_power_gated = false; -cgs_set_clockgating_state ( - hwmgr->device, -AMD_IP_BLOCK_TYPE_VCE , -AMD_PG_STATE_GATE );cgs_set_powergating_state ( hwmgr->device,AMD_IP_BLOCK_TYPE_VCE ,AMD_CG_STATE_UNGATE ); +cgs_set_clockgating_state ( + hwmgr->device, +AMD_IP_BLOCK_TYPE_VCE , +AMD_PG_STATE_GATE );cz_dpm_update_vce_dpm (hwmgr);cz_enable_disable_vce_dpm (hwmgr, true);return 0 ;
_______________________________________________
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): DM5PR12MB113233C023366C58A6C3744CF7000-2J9CzHegvk+UzrhdoDeimQdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org
Re: [PATCH 4/4] drm/amd/powerplay: Prevent UVD powerdown before init
Looks good to me.
Best Regards
Rex
________________________________
From: StDenis, Tom
Sent: Thursday, July 28, 2016 8:19:52 PM
To: Zhu, Rex; Alex Deucher
Cc: amd-gfx list
Subject: Re: [PATCH 4/4] drm/amd/powerplay: Prevent UVD powerdown before init
Nevermind I moved the locking into amdgpu_pm.c and that did the trick.
Attached is a patch that contains all the changes. If you guys want to give it a quick once-through I can then start splitting it up per Alex's comments.
Tom
________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of StDenis, Tom <[email protected]>
Sent: Thursday, July 28, 2016 07:10
To: Zhu, Rex; Alex Deucher
Cc: amd-gfx list
Subject: Re: [PATCH 4/4] drm/amd/powerplay: Prevent UVD powerdown before init
Quick question, how am I meant to get access to pm.mutex from powerplay?
I need a lock I can see around the SMU calls and in the amdgpu side (for userspace locking).
Tom
________________________________
From: Zhu, Rex
Sent: Thursday, July 28, 2016 03:43
To: Alex Deucher; Tom St Denis
Cc: StDenis, Tom; amd-gfx list
Subject: RE: [PATCH 4/4] drm/amd/powerplay: Prevent UVD powerdown before init
From: amd-gfx [mailto:amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org] On Behalf Of Alex Deucher
Sent: Thursday, July 28, 2016 1:46 PM
To: Tom St Denis
Cc: StDenis, Tom; amd-gfx list
Subject: Re: [PATCH 4/4] drm/amd/powerplay: Prevent UVD powerdown before init
Quoted 5 lines · Tom St Denis
Because of the
ip_blocksinit order powerplay would power down the UVD block before UVD start is called. This results in a VCPU hang.This patch prevents power down before UVD is initialized.
Quoted 7 lines
Also correct the power up order so clocking is set after power is ungated.
With this applied comparable clock/power behaviour to powerplay=0 with DPM is observed.
Signed-off-by Tom St Denis <[email protected]>
This patch needs to be split into several patches and reworked a bit.
Also, don't include amdgpu.h in powerplay. We have cgs for access to registers and data from adev, etc. The idea is to minimize the dependencies between components. We shouldn't be accessing adev directly in powerplay. A couple more comments inline.
Rex: I also think so.
1. We can move
+ WREG32(mmUVD_POWER_STATUS,
+ UVD_POWER_STATUS__UVD_PG_EN_MASK |
+ UVD_POWER_STATUS__UVD_PG_MODE_MASK);
+ else
+ WREG32(mmUVD_POWER_STATUS,
+ UVD_POWER_STATUS__UVD_PG_EN_MASK);
to uvd_v6_0_start. no need to visit adev in powerplay and dpm. And uvd test also can pass.
2. for the lock, we can just use pm.mutex.
3. please also delete enable_clock_power_gatings_tasks in resume_action_chain in a separate patch for powerplay.
4. do we need to add cg_state, pg_state?
Best Regards
Rex
Quoted 84 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 6 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | 5 ----- drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c | 8 ++++--- drivers/gpu/drm/amd/amdgpu/vi.c | 12 ++++------- .../drm/amd/powerplay/hwmgr/cz_clockpowergating.c | 25 ++++++++++++++++++---- drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c | 7 ++++++ 6 files changed, 43 insertions(+), 20 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +1
-0@@ -1692,6 +1692,7 @@ struct amdgpu_uvd {uint32_t srbm_soft_reset;int cg_state, pg_state;struct mutex pg_lock; +bool is_init; };/* @@ -2518,5 +2519,10 @@ int amdgpu_dm_display_resume(struct
amdgpu_device*adev ); static inline intamdgpu_dm_display_resume(struct amdgpu_device *adev){ return 0; } #endifdrivers/gpu/drm/amd/amdgpu/amdgpu.h +5
-0+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
-6@@ -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 diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
index422d5300b92e..3b93327c5e25100644drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c +5
-3@@ -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) */ -if (adev->uvd.pg_state) -return -EINVAL ; +/* is power gated? then we can't start but don't return an error */ +if (adev->uvd.is_init && adev->uvd.pg_state) +return 0 ;/* set CG state to -1 for unset */ adev->uvd.cg_state =-1 ;@@ -662,6 +662,8 @@ static int uvd_v6_0_ring_test_ring(struct amdgpu_ring *ring) ring->idx, tmp); r = -EINVAL ; } +if (!r) + adev->uvd.is_init = true;return r; }(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/vi.cindex78fea940d120..f4fdde0641b0100644
drivers/gpu/drm/amd/amdgpu/vi.c static int vi_common_early_init(void *handle) · line 1587
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/vi.c +2
-4@@ -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 ;
This should be a separate patch.
drivers/gpu/drm/amd/amdgpu/vi.c static int vi_common_early_init(void *handle) · line 1610
Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/vi.c +2
-4} 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 ;
Same with this.
Quoted 36 lines
drivers/gpu/drm/amd/amdgpu/vi.c +0
-0adev->external_rev_id = adev->rev_id +0x1 ;break ;default :drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +9
-1@@ -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,24 @@ 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) +if (!adev->uvd.is_init)return 0 ; +mutex_lock (&adev->uvd.pg_lock); +
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c int cz_enable_disable_vce_dpm(struct pp_hwmgr · line 185
Quoted 10 lines
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +8
-0+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 ); +
Could this be moved to the uvd 6 module?
Quoted 6 lines
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +0
-0if (bgate) { cgs_set_clockgating_state(hwmgr->device,
AMD_IP_BLOCK_TYPE_UVD,drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +0
-0@@ -177,14 +193,15 @@ int cz_dpm_powergate_uvd(struct pp_hwmgr *hwmgr, bool bgate)cz_dpm_powerdown_uvd (hwmgr); }else {
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c int cz_dpm_powergate_uvd(struct pp_hwmgr *hwmgr, bool bgate) · line 201
Quoted 10 lines
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +3
-3cz_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 );
I think this is a standalone fix and should be split into a separate patch.
Quoted 34 lines
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +1
-0cz_dpm_update_uvd_dpm (hwmgr, false); } +mutex_unlock (&adev->uvd.pg_lock);return 0 ; }drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c +1
-0@@ -39,6 +39,7 @@#include "power_state.h" #include "cz_clockpowergating.h" #include "pp_debug.h" +#include "amdgpu.h" #define ixSMUSVI_NB_CURRENTVID 0xD8230044 #define
CURRENT_NB_VID_MASK0xff000000@@ -1356,6 +1357,12 @@ static int cz_dpm_force_dpm_level(structpp_hwmgr*hwmgr,int
cz_dpm_powerdown_uvd(struct pp_hwmgr *hwmgr){drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c +6
-1+struct amdgpu_cgs_device *cgs_dev = hwmgr->device; +struct amdgpu_device *adev = cgs_dev->adev; + +if (!adev->uvd.is_init) +return 0 ; +if (phm_cap_enabled (hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_UVDPowerGating)) return smum_send_msg_to_smc(hwmgr->smumgr, --2.9.2
Quoted 4 lines
_______________________________________________
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
_______________________________________________
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): SN1PR12MB0672CE5422D3FEF0448B5E14FB000-z7L1TMIYDg4dn98hj6UdGwdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org
Re: [PATCH 4/4] drm/amd/powerplay: Prevent UVD powerdown before init
Hi Rex,
Thanks. BTW I fixed the one liner {} in the PP code (removed the {} braces) in my worktree after I sent that in case anyone notices that :-)
Tom
________________________________
From: Zhu, Rex
Sent: Thursday, July 28, 2016 08:43
To: StDenis, Tom; Alex Deucher
Cc: amd-gfx list
Subject: Re: [PATCH 4/4] drm/amd/powerplay: Prevent UVD powerdown before init
Looks good to me.
Best Regards
Rex
________________________________
From: StDenis, Tom
Sent: Thursday, July 28, 2016 8:19:52 PM
To: Zhu, Rex; Alex Deucher
Cc: amd-gfx list
Subject: Re: [PATCH 4/4] drm/amd/powerplay: Prevent UVD powerdown before init
Nevermind I moved the locking into amdgpu_pm.c and that did the trick.
Attached is a patch that contains all the changes. If you guys want to give it a quick once-through I can then start splitting it up per Alex's comments.
Tom
________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of StDenis, Tom <[email protected]>
Sent: Thursday, July 28, 2016 07:10
To: Zhu, Rex; Alex Deucher
Cc: amd-gfx list
Subject: Re: [PATCH 4/4] drm/amd/powerplay: Prevent UVD powerdown before init
Quick question, how am I meant to get access to pm.mutex from powerplay?
I need a lock I can see around the SMU calls and in the amdgpu side (for userspace locking).
Tom
________________________________
From: Zhu, Rex
Sent: Thursday, July 28, 2016 03:43
To: Alex Deucher; Tom St Denis
Cc: StDenis, Tom; amd-gfx list
Subject: RE: [PATCH 4/4] drm/amd/powerplay: Prevent UVD powerdown before init
From: amd-gfx [mailto:amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org] On Behalf Of Alex Deucher
Sent: Thursday, July 28, 2016 1:46 PM
To: Tom St Denis
Cc: StDenis, Tom; amd-gfx list
Subject: Re: [PATCH 4/4] drm/amd/powerplay: Prevent UVD powerdown before init
Quoted 5 lines · Tom St Denis
Because of the
ip_blocksinit order powerplay would power down the UVD block before UVD start is called. This results in a VCPU hang.This patch prevents power down before UVD is initialized.
Quoted 7 lines
Also correct the power up order so clocking is set after power is ungated.
With this applied comparable clock/power behaviour to powerplay=0 with DPM is observed.
Signed-off-by Tom St Denis <[email protected]>
This patch needs to be split into several patches and reworked a bit.
Also, don't include amdgpu.h in powerplay. We have cgs for access to registers and data from adev, etc. The idea is to minimize the dependencies between components. We shouldn't be accessing adev directly in powerplay. A couple more comments inline.
Rex: I also think so.
1. We can move
+ WREG32(mmUVD_POWER_STATUS,
+ UVD_POWER_STATUS__UVD_PG_EN_MASK |
+ UVD_POWER_STATUS__UVD_PG_MODE_MASK);
+ else
+ WREG32(mmUVD_POWER_STATUS,
+ UVD_POWER_STATUS__UVD_PG_EN_MASK);
to uvd_v6_0_start. no need to visit adev in powerplay and dpm. And uvd test also can pass.
2. for the lock, we can just use pm.mutex.
3. please also delete enable_clock_power_gatings_tasks in resume_action_chain in a separate patch for powerplay.
4. do we need to add cg_state, pg_state?
Best Regards
Rex
Quoted 84 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 6 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | 5 ----- drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c | 8 ++++--- drivers/gpu/drm/amd/amdgpu/vi.c | 12 ++++------- .../drm/amd/powerplay/hwmgr/cz_clockpowergating.c | 25 ++++++++++++++++++---- drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c | 7 ++++++ 6 files changed, 43 insertions(+), 20 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +1
-0@@ -1692,6 +1692,7 @@ struct amdgpu_uvd {uint32_t srbm_soft_reset;int cg_state, pg_state;struct mutex pg_lock; +bool is_init; };/* @@ -2518,5 +2519,10 @@ int amdgpu_dm_display_resume(struct
amdgpu_device*adev ); static inline intamdgpu_dm_display_resume(struct amdgpu_device *adev){ return 0; } #endifdrivers/gpu/drm/amd/amdgpu/amdgpu.h +5
-0+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
-6@@ -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 diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
index422d5300b92e..3b93327c5e25100644drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c +5
-3@@ -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) */ -if (adev->uvd.pg_state) -return -EINVAL ; +/* is power gated? then we can't start but don't return an error */ +if (adev->uvd.is_init && adev->uvd.pg_state) +return 0 ;/* set CG state to -1 for unset */ adev->uvd.cg_state =-1 ;@@ -662,6 +662,8 @@ static int uvd_v6_0_ring_test_ring(struct amdgpu_ring *ring) ring->idx, tmp); r = -EINVAL ; } +if (!r) + adev->uvd.is_init = true;return r; }(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/vi.cindex78fea940d120..f4fdde0641b0100644
drivers/gpu/drm/amd/amdgpu/vi.c static int vi_common_early_init(void *handle) · line 1587
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/vi.c +2
-4@@ -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 ;
This should be a separate patch.
drivers/gpu/drm/amd/amdgpu/vi.c static int vi_common_early_init(void *handle) · line 1610
Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/vi.c +2
-4} 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 ;
Same with this.
Quoted 36 lines
drivers/gpu/drm/amd/amdgpu/vi.c +0
-0adev->external_rev_id = adev->rev_id +0x1 ;break ;default :drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +9
-1@@ -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,24 @@ 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) +if (!adev->uvd.is_init)return 0 ; +mutex_lock (&adev->uvd.pg_lock); +
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c int cz_enable_disable_vce_dpm(struct pp_hwmgr · line 185
Quoted 10 lines
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +8
-0+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 ); +
Could this be moved to the uvd 6 module?
Quoted 6 lines
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +0
-0if (bgate) { cgs_set_clockgating_state(hwmgr->device,
AMD_IP_BLOCK_TYPE_UVD,drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +0
-0@@ -177,14 +193,15 @@ int cz_dpm_powergate_uvd(struct pp_hwmgr *hwmgr, bool bgate)cz_dpm_powerdown_uvd (hwmgr); }else {
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c int cz_dpm_powergate_uvd(struct pp_hwmgr *hwmgr, bool bgate) · line 201
Quoted 10 lines
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +3
-3cz_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 );
I think this is a standalone fix and should be split into a separate patch.
Quoted 34 lines
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +1
-0cz_dpm_update_uvd_dpm (hwmgr, false); } +mutex_unlock (&adev->uvd.pg_lock);return 0 ; }drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c +1
-0@@ -39,6 +39,7 @@#include "power_state.h" #include "cz_clockpowergating.h" #include "pp_debug.h" +#include "amdgpu.h" #define ixSMUSVI_NB_CURRENTVID 0xD8230044 #define
CURRENT_NB_VID_MASK0xff000000@@ -1356,6 +1357,12 @@ static int cz_dpm_force_dpm_level(structpp_hwmgr*hwmgr,int
cz_dpm_powerdown_uvd(struct pp_hwmgr *hwmgr){drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c +6
-1+struct amdgpu_cgs_device *cgs_dev = hwmgr->device; +struct amdgpu_device *adev = cgs_dev->adev; + +if (!adev->uvd.is_init) +return 0 ; +if (phm_cap_enabled (hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_UVDPowerGating)) return smum_send_msg_to_smc(hwmgr->smumgr, --2.9.2
Quoted 4 lines
_______________________________________________
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
_______________________________________________
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): DM5PR12MB1132C7F6344050FD7CEDF4E8F7000-2J9CzHegvk+UzrhdoDeimQdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org
Re: [PATCH 4/4] drm/amd/powerplay: Prevent UVD powerdown before init
you mean
+ if (cz_hwmgr->uvd_power_gated == bgate) {
return 0;+ }
I didn't pay any attention at first.
Best Regards
Rex
________________________________
From: StDenis, Tom
Sent: Thursday, July 28, 2016 8:44:11 PM
To: Zhu, Rex; Alex Deucher
Cc: amd-gfx list
Subject: Re: [PATCH 4/4] drm/amd/powerplay: Prevent UVD powerdown before init
Hi Rex,
Thanks. BTW I fixed the one liner {} in the PP code (removed the {} braces) in my worktree after I sent that in case anyone notices that :-)
Tom
________________________________
From: Zhu, Rex
Sent: Thursday, July 28, 2016 08:43
To: StDenis, Tom; Alex Deucher
Cc: amd-gfx list
Subject: Re: [PATCH 4/4] drm/amd/powerplay: Prevent UVD powerdown before init
Looks good to me.
Best Regards
Rex
________________________________
From: StDenis, Tom
Sent: Thursday, July 28, 2016 8:19:52 PM
To: Zhu, Rex; Alex Deucher
Cc: amd-gfx list
Subject: Re: [PATCH 4/4] drm/amd/powerplay: Prevent UVD powerdown before init
Nevermind I moved the locking into amdgpu_pm.c and that did the trick.
Attached is a patch that contains all the changes. If you guys want to give it a quick once-through I can then start splitting it up per Alex's comments.
Tom
________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of StDenis, Tom <[email protected]>
Sent: Thursday, July 28, 2016 07:10
To: Zhu, Rex; Alex Deucher
Cc: amd-gfx list
Subject: Re: [PATCH 4/4] drm/amd/powerplay: Prevent UVD powerdown before init
Quick question, how am I meant to get access to pm.mutex from powerplay?
I need a lock I can see around the SMU calls and in the amdgpu side (for userspace locking).
Tom
________________________________
From: Zhu, Rex
Sent: Thursday, July 28, 2016 03:43
To: Alex Deucher; Tom St Denis
Cc: StDenis, Tom; amd-gfx list
Subject: RE: [PATCH 4/4] drm/amd/powerplay: Prevent UVD powerdown before init
From: amd-gfx [mailto:amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org] On Behalf Of Alex Deucher
Sent: Thursday, July 28, 2016 1:46 PM
To: Tom St Denis
Cc: StDenis, Tom; amd-gfx list
Subject: Re: [PATCH 4/4] drm/amd/powerplay: Prevent UVD powerdown before init
Quoted 5 lines · Tom St Denis
Because of the
ip_blocksinit order powerplay would power down the UVD block before UVD start is called. This results in a VCPU hang.This patch prevents power down before UVD is initialized.
Quoted 7 lines
Also correct the power up order so clocking is set after power is ungated.
With this applied comparable clock/power behaviour to powerplay=0 with DPM is observed.
Signed-off-by Tom St Denis <[email protected]>
This patch needs to be split into several patches and reworked a bit.
Also, don't include amdgpu.h in powerplay. We have cgs for access to registers and data from adev, etc. The idea is to minimize the dependencies between components. We shouldn't be accessing adev directly in powerplay. A couple more comments inline.
Rex: I also think so.
1. We can move
+ WREG32(mmUVD_POWER_STATUS,
+ UVD_POWER_STATUS__UVD_PG_EN_MASK |
+ UVD_POWER_STATUS__UVD_PG_MODE_MASK);
+ else
+ WREG32(mmUVD_POWER_STATUS,
+ UVD_POWER_STATUS__UVD_PG_EN_MASK);
to uvd_v6_0_start. no need to visit adev in powerplay and dpm. And uvd test also can pass.
2. for the lock, we can just use pm.mutex.
3. please also delete enable_clock_power_gatings_tasks in resume_action_chain in a separate patch for powerplay.
4. do we need to add cg_state, pg_state?
Best Regards
Rex
Quoted 84 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 6 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | 5 ----- drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c | 8 ++++--- drivers/gpu/drm/amd/amdgpu/vi.c | 12 ++++------- .../drm/amd/powerplay/hwmgr/cz_clockpowergating.c | 25 ++++++++++++++++++---- drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c | 7 ++++++ 6 files changed, 43 insertions(+), 20 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +1
-0@@ -1692,6 +1692,7 @@ struct amdgpu_uvd {uint32_t srbm_soft_reset;int cg_state, pg_state;struct mutex pg_lock; +bool is_init; };/* @@ -2518,5 +2519,10 @@ int amdgpu_dm_display_resume(struct
amdgpu_device*adev ); static inline intamdgpu_dm_display_resume(struct amdgpu_device *adev){ return 0; } #endifdrivers/gpu/drm/amd/amdgpu/amdgpu.h +5
-0+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
-6@@ -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 diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
index422d5300b92e..3b93327c5e25100644drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c +5
-3@@ -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) */ -if (adev->uvd.pg_state) -return -EINVAL ; +/* is power gated? then we can't start but don't return an error */ +if (adev->uvd.is_init && adev->uvd.pg_state) +return 0 ;/* set CG state to -1 for unset */ adev->uvd.cg_state =-1 ;@@ -662,6 +662,8 @@ static int uvd_v6_0_ring_test_ring(struct amdgpu_ring *ring) ring->idx, tmp); r = -EINVAL ; } +if (!r) + adev->uvd.is_init = true;return r; }(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/vi.cindex78fea940d120..f4fdde0641b0100644
drivers/gpu/drm/amd/amdgpu/vi.c static int vi_common_early_init(void *handle) · line 1587
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/vi.c +2
-4@@ -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 ;
This should be a separate patch.
drivers/gpu/drm/amd/amdgpu/vi.c static int vi_common_early_init(void *handle) · line 1610
Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/vi.c +2
-4} 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 ;
Same with this.
Quoted 36 lines
drivers/gpu/drm/amd/amdgpu/vi.c +0
-0adev->external_rev_id = adev->rev_id +0x1 ;break ;default :drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +9
-1@@ -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,24 @@ 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) +if (!adev->uvd.is_init)return 0 ; +mutex_lock (&adev->uvd.pg_lock); +
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c int cz_enable_disable_vce_dpm(struct pp_hwmgr · line 185
Quoted 10 lines
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +8
-0+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 ); +
Could this be moved to the uvd 6 module?
Quoted 6 lines
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +0
-0if (bgate) { cgs_set_clockgating_state(hwmgr->device,
AMD_IP_BLOCK_TYPE_UVD,drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +0
-0@@ -177,14 +193,15 @@ int cz_dpm_powergate_uvd(struct pp_hwmgr *hwmgr, bool bgate)cz_dpm_powerdown_uvd (hwmgr); }else {
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c int cz_dpm_powergate_uvd(struct pp_hwmgr *hwmgr, bool bgate) · line 201
Quoted 10 lines
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +3
-3cz_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 );
I think this is a standalone fix and should be split into a separate patch.
Quoted 34 lines
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +1
-0cz_dpm_update_uvd_dpm (hwmgr, false); } +mutex_unlock (&adev->uvd.pg_lock);return 0 ; }drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c +1
-0@@ -39,6 +39,7 @@#include "power_state.h" #include "cz_clockpowergating.h" #include "pp_debug.h" +#include "amdgpu.h" #define ixSMUSVI_NB_CURRENTVID 0xD8230044 #define
CURRENT_NB_VID_MASK0xff000000@@ -1356,6 +1357,12 @@ static int cz_dpm_force_dpm_level(structpp_hwmgr*hwmgr,int
cz_dpm_powerdown_uvd(struct pp_hwmgr *hwmgr){drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c +6
-1+struct amdgpu_cgs_device *cgs_dev = hwmgr->device; +struct amdgpu_device *adev = cgs_dev->adev; + +if (!adev->uvd.is_init) +return 0 ; +if (phm_cap_enabled (hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_UVDPowerGating)) return smum_send_msg_to_smc(hwmgr->smumgr, --2.9.2
Quoted 4 lines
_______________________________________________
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
_______________________________________________
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): SN1PR12MB06724EA4DE90159CF158B068FB000-z7L1TMIYDg4dn98hj6UdGwdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org
Re: [PATCH 4/4] drm/amd/powerplay: Prevent UVD powerdown before init
Yup, I fixed that in my worktree already.
Tom
________________________________
From: Zhu, Rex
Sent: Thursday, July 28, 2016 08:59
To: StDenis, Tom; Alex Deucher
Cc: amd-gfx list
Subject: Re: [PATCH 4/4] drm/amd/powerplay: Prevent UVD powerdown before init
you mean
+ if (cz_hwmgr->uvd_power_gated == bgate) {
return 0;+ }
I didn't pay any attention at first.
Best Regards
Rex
________________________________
From: StDenis, Tom
Sent: Thursday, July 28, 2016 8:44:11 PM
To: Zhu, Rex; Alex Deucher
Cc: amd-gfx list
Subject: Re: [PATCH 4/4] drm/amd/powerplay: Prevent UVD powerdown before init
Hi Rex,
Thanks. BTW I fixed the one liner {} in the PP code (removed the {} braces) in my worktree after I sent that in case anyone notices that :-)
Tom
________________________________
From: Zhu, Rex
Sent: Thursday, July 28, 2016 08:43
To: StDenis, Tom; Alex Deucher
Cc: amd-gfx list
Subject: Re: [PATCH 4/4] drm/amd/powerplay: Prevent UVD powerdown before init
Looks good to me.
Best Regards
Rex
________________________________
From: StDenis, Tom
Sent: Thursday, July 28, 2016 8:19:52 PM
To: Zhu, Rex; Alex Deucher
Cc: amd-gfx list
Subject: Re: [PATCH 4/4] drm/amd/powerplay: Prevent UVD powerdown before init
Nevermind I moved the locking into amdgpu_pm.c and that did the trick.
Attached is a patch that contains all the changes. If you guys want to give it a quick once-through I can then start splitting it up per Alex's comments.
Tom
________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of StDenis, Tom <[email protected]>
Sent: Thursday, July 28, 2016 07:10
To: Zhu, Rex; Alex Deucher
Cc: amd-gfx list
Subject: Re: [PATCH 4/4] drm/amd/powerplay: Prevent UVD powerdown before init
Quick question, how am I meant to get access to pm.mutex from powerplay?
I need a lock I can see around the SMU calls and in the amdgpu side (for userspace locking).
Tom
________________________________
From: Zhu, Rex
Sent: Thursday, July 28, 2016 03:43
To: Alex Deucher; Tom St Denis
Cc: StDenis, Tom; amd-gfx list
Subject: RE: [PATCH 4/4] drm/amd/powerplay: Prevent UVD powerdown before init
From: amd-gfx [mailto:amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org] On Behalf Of Alex Deucher
Sent: Thursday, July 28, 2016 1:46 PM
To: Tom St Denis
Cc: StDenis, Tom; amd-gfx list
Subject: Re: [PATCH 4/4] drm/amd/powerplay: Prevent UVD powerdown before init
Quoted 5 lines · Tom St Denis
Because of the
ip_blocksinit order powerplay would power down the UVD block before UVD start is called. This results in a VCPU hang.This patch prevents power down before UVD is initialized.
Quoted 7 lines
Also correct the power up order so clocking is set after power is ungated.
With this applied comparable clock/power behaviour to powerplay=0 with DPM is observed.
Signed-off-by Tom St Denis <[email protected]>
This patch needs to be split into several patches and reworked a bit.
Also, don't include amdgpu.h in powerplay. We have cgs for access to registers and data from adev, etc. The idea is to minimize the dependencies between components. We shouldn't be accessing adev directly in powerplay. A couple more comments inline.
Rex: I also think so.
1. We can move
+ WREG32(mmUVD_POWER_STATUS,
+ UVD_POWER_STATUS__UVD_PG_EN_MASK |
+ UVD_POWER_STATUS__UVD_PG_MODE_MASK);
+ else
+ WREG32(mmUVD_POWER_STATUS,
+ UVD_POWER_STATUS__UVD_PG_EN_MASK);
to uvd_v6_0_start. no need to visit adev in powerplay and dpm. And uvd test also can pass.
2. for the lock, we can just use pm.mutex.
3. please also delete enable_clock_power_gatings_tasks in resume_action_chain in a separate patch for powerplay.
4. do we need to add cg_state, pg_state?
Best Regards
Rex
Quoted 84 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 6 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | 5 ----- drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c | 8 ++++--- drivers/gpu/drm/amd/amdgpu/vi.c | 12 ++++------- .../drm/amd/powerplay/hwmgr/cz_clockpowergating.c | 25 ++++++++++++++++++---- drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c | 7 ++++++ 6 files changed, 43 insertions(+), 20 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +1
-0@@ -1692,6 +1692,7 @@ struct amdgpu_uvd {uint32_t srbm_soft_reset;int cg_state, pg_state;struct mutex pg_lock; +bool is_init; };/* @@ -2518,5 +2519,10 @@ int amdgpu_dm_display_resume(struct
amdgpu_device*adev ); static inline intamdgpu_dm_display_resume(struct amdgpu_device *adev){ return 0; } #endifdrivers/gpu/drm/amd/amdgpu/amdgpu.h +5
-0+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
-6@@ -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 diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
index422d5300b92e..3b93327c5e25100644drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c +5
-3@@ -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) */ -if (adev->uvd.pg_state) -return -EINVAL ; +/* is power gated? then we can't start but don't return an error */ +if (adev->uvd.is_init && adev->uvd.pg_state) +return 0 ;/* set CG state to -1 for unset */ adev->uvd.cg_state =-1 ;@@ -662,6 +662,8 @@ static int uvd_v6_0_ring_test_ring(struct amdgpu_ring *ring) ring->idx, tmp); r = -EINVAL ; } +if (!r) + adev->uvd.is_init = true;return r; }(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/vi.cindex78fea940d120..f4fdde0641b0100644
drivers/gpu/drm/amd/amdgpu/vi.c static int vi_common_early_init(void *handle) · line 1587
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/vi.c +2
-4@@ -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 ;
This should be a separate patch.
drivers/gpu/drm/amd/amdgpu/vi.c static int vi_common_early_init(void *handle) · line 1610
Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/vi.c +2
-4} 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 ;
Same with this.
Quoted 36 lines
drivers/gpu/drm/amd/amdgpu/vi.c +0
-0adev->external_rev_id = adev->rev_id +0x1 ;break ;default :drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +9
-1@@ -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,24 @@ 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) +if (!adev->uvd.is_init)return 0 ; +mutex_lock (&adev->uvd.pg_lock); +
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c int cz_enable_disable_vce_dpm(struct pp_hwmgr · line 185
Quoted 10 lines
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +8
-0+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 ); +
Could this be moved to the uvd 6 module?
Quoted 6 lines
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +0
-0if (bgate) { cgs_set_clockgating_state(hwmgr->device,
AMD_IP_BLOCK_TYPE_UVD,drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +0
-0@@ -177,14 +193,15 @@ int cz_dpm_powergate_uvd(struct pp_hwmgr *hwmgr, bool bgate)cz_dpm_powerdown_uvd (hwmgr); }else {
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c int cz_dpm_powergate_uvd(struct pp_hwmgr *hwmgr, bool bgate) · line 201
Quoted 10 lines
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +3
-3cz_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 );
I think this is a standalone fix and should be split into a separate patch.
Quoted 34 lines
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +1
-0cz_dpm_update_uvd_dpm (hwmgr, false); } +mutex_unlock (&adev->uvd.pg_lock);return 0 ; }drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c +1
-0@@ -39,6 +39,7 @@#include "power_state.h" #include "cz_clockpowergating.h" #include "pp_debug.h" +#include "amdgpu.h" #define ixSMUSVI_NB_CURRENTVID 0xD8230044 #define
CURRENT_NB_VID_MASK0xff000000@@ -1356,6 +1357,12 @@ static int cz_dpm_force_dpm_level(structpp_hwmgr*hwmgr,int
cz_dpm_powerdown_uvd(struct pp_hwmgr *hwmgr){drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c +6
-1+struct amdgpu_cgs_device *cgs_dev = hwmgr->device; +struct amdgpu_device *adev = cgs_dev->adev; + +if (!adev->uvd.is_init) +return 0 ; +if (phm_cap_enabled (hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_UVDPowerGating)) return smum_send_msg_to_smc(hwmgr->smumgr, --2.9.2
Quoted 4 lines
_______________________________________________
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
_______________________________________________
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): DM5PR12MB1132929B2C4F05824D7AFF94F7000-2J9CzHegvk+UzrhdoDeimQdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org
Re: [PATCH 4/4] drm/amd/powerplay: Prevent UVD powerdown before init
Quoted 1 line · Tom
Yup, I fixed that in my worktree already.
Looks good to me.
Alex
Quoted 392 lines
Tom
________________________________
From: Zhu, Rex
Sent: Thursday, July 28, 2016 08:59To: StDenis, Tom; Alex Deucher
Cc: amd-gfx list
Subject: Re: [PATCH 4/4] drm/amd/powerplay: Prevent UVD powerdown before inityou mean
(quoted diff) +2
-0+ if (cz_hwmgr->uvd_power_gated == bgate) { return 0; + }I didn't pay any attention at first.
Best Regards
Rex
________________________________
From: StDenis, Tom
Sent: Thursday, July 28, 2016 8:44:11 PM
To: Zhu, Rex; Alex Deucher
Cc: amd-gfx list
Subject: Re: [PATCH 4/4] drm/amd/powerplay: Prevent UVD powerdown before initHi Rex,
Thanks. BTW I fixed the one liner {} in the PP code (removed the {} braces) in my worktree after I sent that in case anyone notices that :-)
Tom
________________________________
From: Zhu, Rex
Sent: Thursday, July 28, 2016 08:43
To: StDenis, Tom; Alex Deucher
Cc: amd-gfx list
Subject: Re: [PATCH 4/4] drm/amd/powerplay: Prevent UVD powerdown before initLooks good to me.
Best Regards
Rex
________________________________
From: StDenis, Tom
Sent: Thursday, July 28, 2016 8:19:52 PM
To: Zhu, Rex; Alex Deucher
Cc: amd-gfx list
Subject: Re: [PATCH 4/4] drm/amd/powerplay: Prevent UVD powerdown before initNevermind I moved the locking into
amdgpu_pm.cand that did the trick.Attached is a patch that contains all the changes. If you guys want to give it a quick once-through I can then start splitting it up per Alex's comments.
Tom
________________________________
From: amd-gfx <[email protected]> on behalf of StDenis, Tom <[email protected]>
Sent: Thursday, July 28, 2016 07:10
To: Zhu, Rex; Alex Deucher
Cc: amd-gfx list
Subject: Re: [PATCH 4/4] drm/amd/powerplay: Prevent UVD powerdown before initQuick question, how am I meant to get access to pm.mutex from powerplay?
I need a lock I can see around the SMU calls and in the amdgpu side (for userspace locking).
Tom
________________________________
From: Zhu, Rex
Sent: Thursday, July 28, 2016 03:43
To: Alex Deucher; Tom St Denis
Cc: StDenis, Tom; amd-gfx list
Subject: RE: [PATCH 4/4] drm/amd/powerplay: Prevent UVD powerdown before initFrom: amd-gfx [mailto:[email protected]] On Behalf Of Alex Deucher
Sent: Thursday, July 28, 2016 1:46 PM
To: Tom St Denis
Cc: StDenis, Tom; amd-gfx list
Subject: Re: [PATCH 4/4] drm/amd/powerplay: Prevent UVD powerdown before initQuoted 5 lines · Tom St Denis
Because of the
ip_blocksinit order powerplay would power down the UVD block before UVD start is called. This results in a VCPU hang.This patch prevents power down before UVD is initialized.
Quoted 7 lines
Also correct the power up order so clocking is set after power is ungated.
With this applied comparable clock/power behaviour to powerplay=0 with DPM is observed.
Signed-off-by Tom St Denis <[email protected]>This patch needs to be split into several patches and reworked a bit. Also, don't include
amdgpu.hin powerplay. We have cgs for access to registers and data from adev, etc. The idea is to minimize the dependencies between components. We shouldn't be accessing adev directly in powerplay. A couple more comments inline.Rex: I also think so.
1. We can move(quoted diff) +6
-0+ WREG32(mmUVD_POWER_STATUS, + UVD_POWER_STATUS__UVD_PG_EN_MASK | + UVD_POWER_STATUS__UVD_PG_MODE_MASK); + else + WREG32(mmUVD_POWER_STATUS, + UVD_POWER_STATUS__UVD_PG_EN_MASK);to
uvd_v6_0_start. no need to visit adev in powerplay and dpm. And uvd test also can pass.2. for the lock, we can just use pm.mutex.
3. please also delete
enable_clock_power_gatings_tasksinresume_action_chainin a separate patch for powerplay.4. do we need to add
cg_state,pg_state?Best Regards
RexQuoted 87 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 6 ++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | 5 ----- drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c | 8 ++++--- drivers/gpu/drm/amd/amdgpu/vi.c | 12 ++++------- .../drm/amd/powerplay/hwmgr/cz_clockpowergating.c | 25 ++++++++++++++++++---- drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c | 7 ++++++ 6 files changed, 43 insertions(+), 20 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +1
-0@@ -1692,6 +1692,7 @@ struct amdgpu_uvd {uint32_t srbm_soft_reset;int cg_state, pg_state;struct mutex pg_lock; +bool is_init; };/* @@ -2518,5 +2519,10 @@ int amdgpu_dm_display_resume(struct
amdgpu_device*adev ); static inline intamdgpu_dm_display_resume(struct amdgpu_device *adev){ return 0; } #endifdrivers/gpu/drm/amd/amdgpu/amdgpu.h +5
-0+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
-6@@ -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 diff --git a/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
b/drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
index422d5300b92e..3b93327c5e25100644drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c +3
-3@@ -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) */ -if (adev->uvd.pg_state) -return -EINVAL ; +/* is power gated? then we can't start but don't return an error */ +if (adev->uvd.is_init && adev->uvd.pg_state) +return 0 ;/* set CG state to -1 for unset */ adev->uvd.cg_state = -1;drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c +2
-0@@ -662,6 +662,8 @@ static int uvd_v6_0_ring_test_ring(struct amdgpu_ring *ring) ring->idx, tmp); r = -EINVAL ; } +if (!r) + adev->uvd.is_init = true;return r; }(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/vi.cindex78fea940d120..f4fdde0641b0100644drivers/gpu/drm/amd/amdgpu/vi.c static int vi_common_early_init(void *handle) · line 1587
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/vi.c +2
-4@@ -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 ;This should be a separate patch.
drivers/gpu/drm/amd/amdgpu/vi.c static int vi_common_early_init(void *handle) · line 1610
Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/vi.c +2
-4} 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 ;Same with this.
Quoted 36 lines
drivers/gpu/drm/amd/amdgpu/vi.c +0
-0adev->external_rev_id = adev->rev_id +0x1 ;break ;default :drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +9
-1@@ -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,24 @@ 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) +if (!adev->uvd.is_init)return 0 ; +mutex_lock (&adev->uvd.pg_lock); +drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c int cz_enable_disable_vce_dpm(struct pp_hwmgr · line 185
Quoted 10 lines
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +8
-0+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 ); +Could this be moved to the uvd 6 module?
Quoted 7 lines
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +0
-0if (bgate) { cgs_set_clockgating_state(hwmgr->device,
AMD_IP_BLOCK_TYPE_UVD,drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +0
-0@@ -177,14 +193,15 @@ int cz_dpm_powergate_uvd(struct pp_hwmgr *hwmgr, bool bgate)cz_dpm_powerdown_uvd (hwmgr ); }else {drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c int cz_dpm_powergate_uvd(struct pp_hwmgr *hwmgr, · line 202
Quoted 10 lines
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +3
-3cz_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 );I think this is a standalone fix and should be split into a separate patch.
Quoted 34 lines
drivers/gpu/drm/amd/powerplay/hwmgr/cz_clockpowergating.c +1
-0cz_dpm_update_uvd_dpm (hwmgr, false); } +mutex_unlock (&adev->uvd.pg_lock);return 0 ;}
drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c +1
-0@@ -39,6 +39,7 @@#include "power_state.h" #include "cz_clockpowergating.h" #include "pp_debug.h" +#include "amdgpu.h" #define ixSMUSVI_NB_CURRENTVID 0xD8230044 #define
CURRENT_NB_VID_MASK0xff000000@@ -1356,6 +1357,12 @@ static int cz_dpm_force_dpm_level(structpp_hwmgr*hwmgr,int
cz_dpm_powerdown_uvd(struct pp_hwmgr *hwmgr){drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c +6
-1+struct amdgpu_cgs_device *cgs_dev = hwmgr->device; +struct amdgpu_device *adev = cgs_dev->adev; + +if (!adev->uvd.is_init) +return 0 ; +if (phm_cap_enabled (hwmgr->platform_descriptor.platformCaps, PHM_PlatformCaps_UVDPowerGating)) return smum_send_msg_to_smc(hwmgr->smumgr, --2.9.2
Quoted 8 lines
Quoted 4 lines
_______________________________________________
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
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx