drm/amdgpu/vcn5.0.1: use correct dpm helper
Subsystems (3)
Alex Deucher
maintainerPATCH 1/3 drm/amdgpu/vcn5.0.1: use correct dpm helper
The VCN and UVD helpers were split in
commit ff69bba05f08 ("drm/amd/pm: add inst to dpm_set_powergating_by_smu") However, this happened in parallel to the vcn 5.0.1 development so it was missed there.
--- drivers/gpu/drm/amd/amdgpu/vcn_v5_0_1.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/vcn_v5_0_1.c +8 -4
@@ -575,8 +575,10 @@ static int vcn_v5_0_1_start(struct amdgpu_device *adev)uint32_t tmp;int i, j, k, r, vcn_inst; -if (adev->pm.dpm_enabled) -amdgpu_dpm_enable_uvd (adev, true); +for (i =0 ; i < adev->vcn.num_vcn_inst; ++i) { +if (adev->pm.dpm_enabled) +amdgpu_dpm_enable_vcn (adev, true, i); + }for (i =0 ; i < adev->vcn.num_vcn_inst; ++i) { fw_shared = adev->vcn.inst[i].fw_shared.cpu_addr;
@@ -816,8 +818,10 @@ static int vcn_v5_0_1_stop(struct amdgpu_device *adev)WREG32_SOC15 (VCN , vcn_inst, regUVD_STATUS,0 ); } -if (adev->pm.dpm_enabled) -amdgpu_dpm_enable_uvd (adev, false); +for (i =0 ; i < adev->vcn.num_vcn_inst; ++i) { +if (adev->pm.dpm_enabled) +amdgpu_dpm_enable_vcn (adev, false, i); + }return 0 ; }
Signature · 1 line
2.48.1
Alex Deucher
maintainerPATCH 2/3 drm/amdgpu/pm: fix UVD handing in amdgpu_dpm_set_powergating_by_smu()
UVD and VCN were split into separate dpm helpers in commit ff69bba05f08 ("drm/amd/pm: add inst to dpm_set_powergating_by_smu") but the check at the top was still included UVD from an earlier version of the patch. Fix the check.
--- drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +1 -1
@@ -78,7 +78,7 @@ int amdgpu_dpm_set_powergating_by_smu(struct amdgpu_device *adev,int ret =0 ;const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;enum ip_power_state pwr_state = gate ?POWER_STATE_OFF :POWER_STATE_ON ; -bool is_vcn = (block_type ==AMD_IP_BLOCK_TYPE_UVD || block_type ==AMD_IP_BLOCK_TYPE_VCN ); +bool is_vcn = block_type ==AMD_IP_BLOCK_TYPE_VCN ;if (atomic_read (&adev->pm.pwr_state[block_type]) == pwr_state && (!is_vcn || adev->vcn.num_vcn_inst ==1 )) {
Signature · 1 line
2.48.1
Re: [PATCH 2/3] drm/amdgpu/pm: fix UVD handing in amdgpu_dpm_set_powergating_by_smu()
Ping on this series? This fixes a regression.
Alex
Quoted 31 lines · Alex Deucher
UVD and VCN were split into separate dpm helpers in commit
ff69bba05f08("drm/amd/pm: add inst todpm_set_powergating_by_smu") but the check at the top was still included UVD from an earlier version of the patch. Fix the check.Fixes ff69bba05f08 ("drm/amd/pm: add inst to dpm_set_powergating_by_smu")Signed-off-by Alex Deucher <[email protected]>Cc Boyuan Zhang <[email protected]>--- drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/pm/amdgpu_dpm.c +1
-2@@ -78,7 +78,7 @@ int amdgpu_dpm_set_powergating_by_smu(struct amdgpu_device *adev,int ret =0 ;const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;enum ip_power_state pwr_state = gate ?POWER_STATE_OFF :POWER_STATE_ON ; -bool is_vcn = (block_type ==AMD_IP_BLOCK_TYPE_UVD || block_type ==AMD_IP_BLOCK_TYPE_VCN ); +bool is_vcn = block_type ==AMD_IP_BLOCK_TYPE_VCN ;if (atomic_read (&adev->pm.pwr_state[block_type]) == pwr_state && (!is_vcn || adev->vcn.num_vcn_inst ==1 )) { --2.48.1
Re: [PATCH 2/3] drm/amdgpu/pm: fix UVD handing in amdgpu_dpm_set_powergating_by_smu()
In reply to Alex DeucherQuoted 4 lines · Alex Deucher
UVD and VCN were split into separate dpm helpers in commit
ff69bba05f08("drm/amd/pm: add inst todpm_set_powergating_by_smu") but the check at the top was still included UVD from an earlier version of the patch. Fix the check.
This description is not clear -'earlier version of the patch'. I see UVD check is introduced by the same patch.
Quoted 5 lines
Fixes ff69bba05f08 ("drm/amd/pm: add inst to dpm_set_powergating_by_smu")Signed-off-by Alex Deucher <[email protected]>
Thanks,
Lijo
Quoted 18 lines
Cc Boyuan Zhang <[email protected]>--- drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/pm/amdgpu_dpm.c +1
-1@@ -78,7 +78,7 @@ int amdgpu_dpm_set_powergating_by_smu(struct amdgpu_device *adev,int ret =0 ;const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;enum ip_power_state pwr_state = gate ?POWER_STATE_OFF :POWER_STATE_ON ; -bool is_vcn = (block_type ==AMD_IP_BLOCK_TYPE_UVD || block_type ==AMD_IP_BLOCK_TYPE_VCN ); +bool is_vcn = block_type ==AMD_IP_BLOCK_TYPE_VCN ;if (atomic_read (&adev->pm.pwr_state[block_type]) == pwr_state && (!is_vcn || adev->vcn.num_vcn_inst ==1 )) {
Alex Deucher
maintainerPATCH 3/3 drm/amdgpu/pm: store power state per instance
In reply to Alex DeucherSimplify the driver logic. We support multiple instances now so reflect that in the driver state.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 9 ++++++--- drivers/gpu/drm/amd/include/amd_shared.h | 2 ++ drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 16 ++++++++++------ drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h | 2 +- 4 files changed, 19 insertions(+), 10 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +6 -3
@@ -4184,7 +4184,7 @@ int amdgpu_device_init(struct amdgpu_device *adev, {struct drm_device *ddev =adev_to_drm (adev);struct pci_dev *pdev = adev->pdev; -int r, i; +int r, i, j;bool px = false;u32 max_MBps;int tmp;
@@ -4338,8 +4338,11 @@ int amdgpu_device_init(struct amdgpu_device *adev, adev->rmmio_size =pci_resource_len (adev->pdev,2 ); } -for (i =0 ; i <AMD_IP_BLOCK_TYPE_NUM ; i++) -atomic_set (&adev->pm.pwr_state[i],POWER_STATE_UNKNOWN ); +for (i =0 ; i <AMD_IP_BLOCK_TYPE_NUM ; i++) { +for (j =0 ; j <AMD_IP_BLOCK_MAX_INST ; j++) { +atomic_set (&adev->pm.pwr_state[i][j],POWER_STATE_UNKNOWN ); + } + } adev->rmmio =ioremap (adev->rmmio_base, adev->rmmio_size);if (!adev->rmmio)
drivers/gpu/drm/amd/include/amd_shared.h +2 -0
@@ -112,6 +112,8 @@ enum amd_ip_block_type { AMD_IP_BLOCK_TYPE_NUM, }; +#define AMD_IP_BLOCK_MAX_INST 8 +enum amd_clockgating_state {AMD_CG_STATE_GATE =0 ,AMD_CG_STATE_UNGATE ,
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +10 -6
@@ -78,12 +78,16 @@ int amdgpu_dpm_set_powergating_by_smu(struct amdgpu_device *adev,int ret =0 ;const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;enum ip_power_state pwr_state = gate ?POWER_STATE_OFF :POWER_STATE_ON ; -bool is_vcn = block_type ==AMD_IP_BLOCK_TYPE_VCN ; -if (atomic_read (&adev->pm.pwr_state[block_type]) == pwr_state && - (!is_vcn || adev->vcn.num_vcn_inst ==1 )) { -dev_dbg (adev->dev,"IP block%d already in the target %s state!" , - block_type, gate ?"gate" :"ungate" ); +if (inst >=AMD_IP_BLOCK_MAX_INST ) { +dev_err (adev->dev,"IP block %d inst %d invalid!" , + block_type, inst); +return -EINVAL ; + } + +if (atomic_read (&adev->pm.pwr_state[block_type][inst]) == pwr_state) { +dev_dbg (adev->dev,"IP block %d inst %d already in the target %s state!" , + block_type, inst, gate ?"gate" :"ungate" );return 0 ; }
@@ -112,7 +116,7 @@ int amdgpu_dpm_set_powergating_by_smu(struct amdgpu_device *adev, }if (!ret) -atomic_set (&adev->pm.pwr_state[block_type], pwr_state); +atomic_set (&adev->pm.pwr_state[block_type][inst], pwr_state);mutex_unlock (&adev->pm.mutex);
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +1 -1
@@ -370,7 +370,7 @@ struct amdgpu_pm {struct i2c_adapter *fru_eeprom_i2c_bus;struct list_head pm_attr_list; -atomic_t pwr_state[AMD_IP_BLOCK_TYPE_NUM ]; +atomic_t pwr_state[AMD_IP_BLOCK_TYPE_NUM ][AMD_IP_BLOCK_MAX_INST ];/* * 0 = disabled (default), otherwise enable corresponding debug mode
Signature · 1 line
2.48.1
Re: [PATCH 3/3] drm/amdgpu/pm: store power state per instance
Quoted 93 lines · Alex Deucher
Simplify the driver logic. We support multiple instances now so reflect that in the driver state.
Fixes ff69bba05f08 ("drm/amd/pm: add inst to dpm_set_powergating_by_smu")Signed-off-by Alex Deucher <[email protected]>Cc Boyuan Zhang <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 9 ++++++--- drivers/gpu/drm/amd/include/amd_shared.h | 2 ++ drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 16 ++++++++++------ drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h | 2 +- 4 files changed, 19 insertions(+), 10 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +6
-3@@ -4184,7 +4184,7 @@ int amdgpu_device_init(struct amdgpu_device *adev, {struct drm_device *ddev =adev_to_drm (adev);struct pci_dev *pdev = adev->pdev; -int r, i; +int r, i, j;bool px = false;u32 max_MBps;int tmp;@@ -4338,8 +4338,11 @@ int amdgpu_device_init(struct amdgpu_device *adev, adev->rmmio_size =pci_resource_len (adev->pdev,2 ); } -for (i =0 ; i <AMD_IP_BLOCK_TYPE_NUM ; i++) -atomic_set (&adev->pm.pwr_state[i],POWER_STATE_UNKNOWN ); +for (i =0 ; i <AMD_IP_BLOCK_TYPE_NUM ; i++) { +for (j =0 ; j <AMD_IP_BLOCK_MAX_INST ; j++) { +atomic_set (&adev->pm.pwr_state[i][j],POWER_STATE_UNKNOWN ); + } + } adev->rmmio =ioremap (adev->rmmio_base, adev->rmmio_size);if (!adev->rmmio)drivers/gpu/drm/amd/include/amd_shared.h +2
-0@@ -112,6 +112,8 @@ enum amd_ip_block_type { AMD_IP_BLOCK_TYPE_NUM, }; +#define AMD_IP_BLOCK_MAX_INST 8 +enum amd_clockgating_state {AMD_CG_STATE_GATE =0 ,AMD_CG_STATE_UNGATE ,drivers/gpu/drm/amd/pm/amdgpu_dpm.c +10
-6@@ -78,12 +78,16 @@ int amdgpu_dpm_set_powergating_by_smu(struct amdgpu_device *adev,int ret =0 ;const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;enum ip_power_state pwr_state = gate ?POWER_STATE_OFF :POWER_STATE_ON ; -bool is_vcn = block_type ==AMD_IP_BLOCK_TYPE_VCN ; -if (atomic_read (&adev->pm.pwr_state[block_type]) == pwr_state && - (!is_vcn || adev->vcn.num_vcn_inst ==1 )) { -dev_dbg (adev->dev,"IP block%d already in the target %s state!" , - block_type, gate ?"gate" :"ungate" ); +if (inst >=AMD_IP_BLOCK_MAX_INST ) { +dev_err (adev->dev,"IP block %d inst %d invalid!" , + block_type, inst); +return -EINVAL ; + } + +if (atomic_read (&adev->pm.pwr_state[block_type][inst]) == pwr_state) { +dev_dbg (adev->dev,"IP block %d inst %d already in the target %s state!" , + block_type, inst, gate ?"gate" :"ungate" );return 0 ; }@@ -112,7 +116,7 @@ int amdgpu_dpm_set_powergating_by_smu(struct amdgpu_device *adev, }if (!ret) -atomic_set (&adev->pm.pwr_state[block_type], pwr_state); +atomic_set (&adev->pm.pwr_state[block_type][inst], pwr_state);mutex_unlock (&adev->pm.mutex);drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +0
-0
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h struct amdgpu_pm { · line 373
Quoted 5 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +1
-1@@ -370,7 +370,7 @@ struct amdgpu_pm {struct i2c_adapter *fru_eeprom_i2c_bus;struct list_head pm_attr_list; -atomic_t pwr_state[AMD_IP_BLOCK_TYPE_NUM ]; +atomic_t pwr_state[AMD_IP_BLOCK_TYPE_NUM ][AMD_IP_BLOCK_MAX_INST ];
If it's getting refactored, it's better to keep this state in IP block than in pm.
Thanks,
Lijo
Quoted 3 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +0
-0/* * 0 = disabled (default), otherwise enable corresponding debug mode
Quoted 18 lines · Alex Deucher
The VCN and UVD helpers were split in
commitff69bba05f08("drm/amd/pm: add inst todpm_set_powergating_by_smu") However, this happened in parallel to the vcn 5.0.1 development so it was missed there.Fixes 346492f30ce3 ("drm/amdgpu: Add VCN_5_0_1 support")Signed-off-by Alex Deucher <[email protected]>Cc Sonny Jiang <[email protected]>Cc Boyuan Zhang <[email protected]>--- drivers/gpu/drm/amd/amdgpu/vcn_v5_0_1.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdgpu/vcn_v5_0_1.c +0
-0
drivers/gpu/drm/amd/amdgpu/vcn_v5_0_1.c static int vcn_v5_0_1_start(struct amdgpu_device *adev) · line 582
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/vcn_v5_0_1.c +4
-2@@ -575,8 +575,10 @@ static int vcn_v5_0_1_start(struct amdgpu_device *adev)uint32_t tmp;int i, j, k, r, vcn_inst; -if (adev->pm.dpm_enabled) -amdgpu_dpm_enable_uvd (adev, true); +for (i =0 ; i < adev->vcn.num_vcn_inst; ++i) { +if (adev->pm.dpm_enabled) +amdgpu_dpm_enable_vcn (adev, true, i); + }
This whole enable/disable vcn power gating can be dropped. This is not supported for vcn 5.0.1.
Thanks,
Lijo
Quoted 15 lines
drivers/gpu/drm/amd/amdgpu/vcn_v5_0_1.c +4
-2for (i =0 ; i < adev->vcn.num_vcn_inst; ++i) { fw_shared = adev->vcn.inst[i].fw_shared.cpu_addr;@@ -816,8 +818,10 @@ static int vcn_v5_0_1_stop(struct amdgpu_device *adev)WREG32_SOC15 (VCN , vcn_inst, regUVD_STATUS,0 ); } -if (adev->pm.dpm_enabled) -amdgpu_dpm_enable_uvd (adev, false); +for (i =0 ; i < adev->vcn.num_vcn_inst; ++i) { +if (adev->pm.dpm_enabled) +amdgpu_dpm_enable_vcn (adev, false, i); + }return 0 ; }