SI power management fixes
Subsystems (3)
cover SI power management fixes
This series fixes some power management issues on SI. Where applicable, a radeon backport is also included. I recommend backporting these commits to the stable kernel.
1. Ensure that DPM powers on the UVD for FW validation. This is necessary because SI needs to use a specific power state for UVD to work correctly, which we forgot to use for FW validation.
2. Disable ULV mode even if unsupported (+ radeon backport). Send the PPSMC_MSG_DisableULV message to the SMC even when ULV mode is not supported, to ensure that ULV mode is actually turned off. This fixes some instability on Tahiti.
3. Fix si_upload_smc_data (+ radeon backport).
The si_write_smc_soft_register return value is actually zero on success, fix checking it. This fixes an SMC hang on Tahiti.
4. Fix issues with high pixel clock displays
As we don't have something like dce_calcs for old GPUs, sadly we have to apply ad-hoc fixes. This fixes different flickering issues that I observed on Oland, Tahiti and Pitcairn.
Timur Kristóf (6):
drm/amdgpu: Power up UVD 3 for FW validation drm/amd/pm: Disable ULV even if unsupported drm/radeon: Disable ULV even if unsupported drm/amd/pm: Fix si_upload_smc_data drm/radeon: Fix si_upload_smc_data drm/amd/pm: Fix SI DPM issues with high pixel clock
drivers/gpu/drm/amd/amdgpu/uvd_v3_1.c | 9 ++- drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c | 75 ++++++++++++++++++---- drivers/gpu/drm/radeon/si_dpm.c | 38 +++++++---- 3 files changed, 91 insertions(+), 31 deletions(-)
Signature · 1 line
2.50.1
PATCH 1/6 drm/amdgpu: Power up UVD 3 for FW validation
Unlike later versions, UVD 3 has firmware validation. For this to work, the UVD should be powered up correctly.
When DPM is enabled and the display clock is off, the SMU may choose a power state which doesn't power the UVD, which can result in failure to initialize UVD.
--- drivers/gpu/drm/amd/amdgpu/uvd_v3_1.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/uvd_v3_1.c +6 -3
@@ -633,6 +633,12 @@ static int uvd_v3_1_hw_init(struct amdgpu_ip_block *ip_block)int r;uvd_v3_1_mc_resume (adev); +uvd_v3_1_enable_mgcg (adev, true); + +if (adev->pm.dpm_enabled) +amdgpu_dpm_enable_uvd (adev, true); +else +amdgpu_asic_set_uvd_clocks (adev,53300 ,40000 ); r =uvd_v3_1_fw_validate (adev);if (r) {
@@ -640,9 +646,6 @@ static int uvd_v3_1_hw_init(struct amdgpu_ip_block *ip_block)return r; } -uvd_v3_1_enable_mgcg (adev, true); -amdgpu_asic_set_uvd_clocks (adev,53300 ,40000 ); -uvd_v3_1_start (adev); r =amdgpu_ring_test_helper (ring);
Signature · 1 line
2.50.1
Re: [PATCH 1/6] drm/amdgpu: Power up UVD 3 for FW validation
Quoted 7 lines · Timur Kristóf
Unlike later versions, UVD 3 has firmware validation. For this to work, the UVD should be powered up correctly.
When DPM is enabled and the display clock is off, the SMU may choose a power state which doesn't power the UVD, which can result in failure to initialize UVD.
+ Christian, Leo
That doesn't seem right to me. IIRC, the driver always set the UVD PLL directly on SI and I don't think SI supported any kind of UVD power gating. I guess it's probably some sort of subtle sequencing difference between radeon and amdgpu. Unless Christian or Leo have any ideas, I think the patch is probably fine.
Alex
Quoted 37 lines
Fixes b38f3e80ecec ("drm amdgpu: SI UVD v3_1 (v2)")Signed-off-by Timur Kristóf <[email protected]>--- drivers/gpu/drm/amd/amdgpu/uvd_v3_1.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/uvd_v3_1.c +6
-4@@ -633,6 +633,12 @@ static int uvd_v3_1_hw_init(struct amdgpu_ip_block *ip_block)int r;uvd_v3_1_mc_resume (adev); +uvd_v3_1_enable_mgcg (adev, true); + +if (adev->pm.dpm_enabled) +amdgpu_dpm_enable_uvd (adev, true); +else +amdgpu_asic_set_uvd_clocks (adev,53300 ,40000 ); r =uvd_v3_1_fw_validate (adev);if (r) {@@ -640,9 +646,6 @@ static int uvd_v3_1_hw_init(struct amdgpu_ip_block *ip_block)return r; } -uvd_v3_1_enable_mgcg (adev, true); -amdgpu_asic_set_uvd_clocks (adev,53300 ,40000 ); -uvd_v3_1_start (adev); r =amdgpu_ring_test_helper (ring); --2.50.1
Re: [PATCH 1/6] drm/amdgpu: Power up UVD 3 for FW validation
Quoted 12 lines · Alex Deucher
Quoted 7 lines · Timur Kristóf
Unlike later versions, UVD 3 has firmware validation. For this to work, the UVD should be powered up correctly.
When DPM is enabled and the display clock is off, the SMU may choose a power state which doesn't power the UVD, which can result in failure to initialize UVD.
+ Christian, Leo
Quoted 7 lines
That doesn't seem right to me. IIRC, the driver always set the UVD PLL directly on SI and I don't think SI supported any kind of UVD power gating. I guess it's probably some sort of subtle sequencing difference between radeon and amdgpu. Unless Christian or Leo have any ideas, I think the patch is probably fine.
Alex
Hi,
These are my observations about how the UVD clock works on SI:
1. It seems that the SMC needs to know whether UVD is enabled or not, and the UVD clocks are included as part of the power states. See:si_convert_power_state_to_smc si_convert_power_level_to_smc
On SI the default power state doesn't set the UVD clocks, and SI has a specific power state to be used with UVD. Actually amdgpu_dpm_enable_uvd has a special case code path for SI, where it sets this power state. If I print the power states from si_parse_power_table, it indeed confirms that there is only one power state that has non-zero UVD clocks, and the rest of them just have the UVD clocks at zero.
It's unclear to me what happens if we try to enable UVD clocks when we selected a power state that doesn't include them (ie. when we don't tell the SMC that UVD is active).
2. When setting a power state that enables UVD, the UVD clock is enabled either before or after the engine clock by si_dpm. This is done so in both radeon and amdgpu, see:si_dpm_set_power_stateni_set_uvd_clock_before_set_eng_clock ni_set_uvd_clock_after_set_eng_clock
The specific sequence in which the UVD clock is enabled by si_dpm_set_power_state leads me to the conclusion that amdgpu_asic_set_uvd_clocks should not be directly called on SI outside of the DPM code.
Please correct me if I misunderstood the code.
Thanks,
Timur
Quoted 41 lines
Quoted 41 lines
Fixes b38f3e80ecec ("drm amdgpu: SI UVD v3_1 (v2)")Signed-off-by Timur Kristóf <[email protected]>---
drivers/gpu/drm/amd/amdgpu/uvd_v3_1.c | 9 ++++++---1 file changed, 6 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/uvd_v3_1.c +6
-0@@ -633,6 +633,12 @@ static int uvd_v3_1_hw_init(struct amdgpu_ip_block *ip_block) int r; uvd_v3_1_mc_resume(adev); + uvd_v3_1_enable_mgcg(adev, true); + + if (adev->pm.dpm_enabled) + amdgpu_dpm_enable_uvd(adev, true); + else + amdgpu_asic_set_uvd_clocks(adev, 53300, 40000); r = uvd_v3_1_fw_validate(adev);if (r) {
drivers/gpu/drm/amd/amdgpu/uvd_v3_1.c +0
-3@@ -640,9 +646,6 @@ static int uvd_v3_1_hw_init(struct amdgpu_ip_block *ip_block) return r; } - uvd_v3_1_enable_mgcg(adev, true); - amdgpu_asic_set_uvd_clocks(adev, 53300, 40000); - uvd_v3_1_start(adev);r =
amdgpu_ring_test_helper(ring);
--
2.50.1
Re: [PATCH 1/6] drm/amdgpu: Power up UVD 3 for FW validation
Quoted 50 lines · Timur Kristóf
Quoted 12 lines · Alex Deucher
Quoted 7 lines · Timur Kristóf
Unlike later versions, UVD 3 has firmware validation. For this to work, the UVD should be powered up correctly.
When DPM is enabled and the display clock is off, the SMU may choose a power state which doesn't power the UVD, which can result in failure to initialize UVD.
+ Christian, Leo
Quoted 7 lines
That doesn't seem right to me. IIRC, the driver always set the UVD PLL directly on SI and I don't think SI supported any kind of UVD power gating. I guess it's probably some sort of subtle sequencing difference between radeon and amdgpu. Unless Christian or Leo have any ideas, I think the patch is probably fine.
Alex
Hi,
These are my observations about how the UVD clock works on SI:
1. It seems that the SMC needs to know whether UVD is enabled or not, and the UVD clocks are included as part of the power states. See:
si_convert_power_state_to_smcsi_convert_power_level_to_smcOn SI the default power state doesn't set the UVD clocks, and SI has a specific power state to be used with UVD. Actually
amdgpu_dpm_enable_uvdhas a special case code path for SI, where it sets this power state. If I print the power states fromsi_parse_power_table, it indeed confirms that there is only one power state that has non-zero UVD clocks, and the rest of them just have the UVD clocks at zero.It's unclear to me what happens if we try to enable UVD clocks when we selected a power state that doesn't include them (ie. when we don't tell the SMC that UVD is active).
2. When setting a power state that enables UVD, the UVD clock is enabled either before or after the engine clock by
si_dpm. This is done so in both radeon and amdgpu, see:si_dpm_set_power_stateni_set_uvd_clock_before_set_eng_clockni_set_uvd_clock_after_set_eng_clock
Quoted 6 lines
The specific sequence in which the UVD clock is enabled by
si_dpm_set_power_stateleads me to the conclusion thatamdgpu_asic_set_uvd_clocksshould not be directly called on SI outside of the DPM code.Please correct me if I misunderstood the code.
Yeah, I don't remember the clock dependencies. I thought that you should be able to program the UVD PLLs any time you wanted and the ordering only mattered when you were also changing the sclk. Programming the PLLs directly works as is in radeon, but I guess maybe we init DPM in a different order in radeon vs amdgpu.
It would also probably be a good idea to disable the UVD clocks again after IP init to save power. E.g., something like:
if (adev->pm.dpm_enabled)
amdgpu_dpm_enable_uvd(adev, false);
else
amdgpu_asic_set_uvd_clocks(adev, 0, 0);Alex
Quoted 46 lines
Thanks,
TimurQuoted 41 lines
Quoted 41 lines
Fixes b38f3e80ecec ("drm amdgpu: SI UVD v3_1 (v2)")Signed-off-by Timur Kristóf <[email protected]>--- drivers/gpu/drm/amd/amdgpu/uvd_v3_1.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/uvd_v3_1.c +6
-0@@ -633,6 +633,12 @@ static int uvd_v3_1_hw_init(struct amdgpu_ip_block *ip_block)int r;uvd_v3_1_mc_resume (adev); +uvd_v3_1_enable_mgcg (adev, true); + +if (adev->pm.dpm_enabled) +amdgpu_dpm_enable_uvd (adev, true); +else +amdgpu_asic_set_uvd_clocks (adev,53300 ,40000 ); r =uvd_v3_1_fw_validate (adev);if (r) {drivers/gpu/drm/amd/amdgpu/uvd_v3_1.c +0
-3@@ -640,9 +646,6 @@ static int uvd_v3_1_hw_init(struct amdgpu_ip_block *ip_block)return r; } -uvd_v3_1_enable_mgcg (adev, true); -amdgpu_asic_set_uvd_clocks (adev,53300 ,40000 ); -uvd_v3_1_start (adev);r = amdgpu_ring_test_helper(ring);--
2.50.1
Re: [PATCH 1/6] drm/amdgpu: Power up UVD 3 for FW validation
Quoted 66 lines · Alex Deucher
Quoted 64 lines · Timur Kristóf
Quoted 21 lines · Alex Deucher
Quoted 7 lines · Timur Kristóf
Unlike later versions, UVD 3 has firmware validation. For this to work, the UVD should be powered up correctly.
When DPM is enabled and the display clock is off, the SMU may choose a power state which doesn't power the UVD, which can result in failure to initialize UVD.
+ Christian, Leo
That doesn't seem right to me. IIRC, the driver always set the UVD
PLL directly on SI and I don't think SI supported any kind of UVD power gating. I guess it's probably some sort of subtle sequencing
difference between radeon and amdgpu. Unless Christian or Leo have
any ideas, I think the patch is probably fine.Quoted 1 line
Alex
Hi,
These are my observations about how the UVD clock works on SI:
1. It seems that the SMC needs to know whether UVD is enabled or not,
and the UVD clocks are included as part of the power states. See:si_convert_power_state_to_smcsi_convert_power_level_to_smcOn SI the default power state doesn't set the UVD clocks, and SI has a specific power state to be used with UVD. Actually
amdgpu_dpm_enable_uvdhas a special case code path for SI, where it sets this power state. If I print the power states fromsi_parse_power_table, it indeed confirms that there is only one power
state that has non-zero UVD clocks, and the rest of them just have the
UVD clocks at zero.It's unclear to me what happens if we try to enable UVD clocks when we
selected a power state that doesn't include them (ie. when we don't tell the SMC that UVD is active).2. When setting a power state that enables UVD, the UVD clock is enabled either before or after the engine clock by
si_dpm. This is done
so in both radeon and amdgpu, see:si_dpm_set_power_stateni_set_uvd_clock_before_set_eng_clockni_set_uvd_clock_after_set_eng_clockThe specific sequence in which the UVD clock is enabled by
si_dpm_set_power_stateleads me to the conclusion thatamdgpu_asic_set_uvd_clocksshould not be directly called on SI outside
of the DPM code.
Quoted 5 lines
Quoted 1 line
Please correct me if I misunderstood the code.
Yeah, I don't remember the clock dependencies. I thought that you should be able to program the UVD PLLs any time you wanted and the ordering only mattered when you were also changing the sclk.
In that case, wouldn't it cause issues that the SMC is not aware that the UVD is running?
As far as I see from si_convert_power_*_to_smc there are some flags in the power states which are set differently depending on whether UVD is active or not.
A secondary issue is that the VBIOS seems to have different clock values for the UVD compared to what is hardcoded in the driver. This doesn't mean the driver is incorrect, but si_dpm does use the values from the VBIOS.
Quoted 3 lines
Programming the PLLs directly works as is in radeon, but I guess maybe
we init DPM in a different order in radeon vs amdgpu.
The order is the same.
Looking at radeon's si.c, in si_init:
It calls radeon_pm_init (which eventually calls si_dpm_init) before calling si_uvd_init.
Looking at amdgpu's si.c, in si_set_ip_blocks:
The si_smu_ip_block is added before uvd_v3_1_ip_block.
I think the main difference between radeon and amdgpu as far as I see:
- radeon doesn't do the FW validation
- radeon doesn't do a ring test
Hence, radeon doesn't actually need to enable the UVD clocks at initialization.
Quoted 10 lines
It would also probably be a good idea to disable the UVD clocks again after IP init to save power. E.g., something like:
if (
adev->pm.dpm_enabled)amdgpu_dpm_enable_uvd(adev, false); else
amdgpu_asic_set_uvd_clocks(adev, 0, 0);Alex
Note that the UVD clocks were already enabled by uvd_v3_1_hw_init, when it creates the ring test, that calls amdgpu_uvd_ring_begin_use which enables the clock by calling amdgpu_dpm_enable_uvd. The only difference that my patch makes is that it now enables the UVD clock just a little bit earlier.
I think we can't disable the UVD clocks directly in uvd_v3_1_hw_init, because the ring test would fail. However, as far as I understand, the UVD clocks are already disabled automatically anyway after the ring test is done: amdgpu_ring_commit calls amdgpu_uvd_ring_end_use. This launches the UVD idle work handler, which automatically disables the UV clock when all pending fences are signalled.
Please correct me if I misunderstood this.
Thanks,
Timur
Quoted 48 lines
Quoted 48 lines
Thanks,
TimurQuoted 41 lines
Quoted 41 lines
Fixes b38f3e80ecec ("drm amdgpu: SI UVD v3_1 (v2)")Signed-off-by Timur Kristóf <[email protected]>---
drivers/gpu/drm/amd/amdgpu/uvd_v3_1.c | 9 ++++++---1 file changed, 6 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/uvd_v3_1.c +6
-0@@ -633,6 +633,12 @@ static int uvd_v3_1_hw_init(struct amdgpu_ip_block *ip_block) int r; uvd_v3_1_mc_resume(adev); + uvd_v3_1_enable_mgcg(adev, true); + + if (adev->pm.dpm_enabled) + amdgpu_dpm_enable_uvd(adev, true); + else + amdgpu_asic_set_uvd_clocks(adev, 53300, 40000); r = uvd_v3_1_fw_validate(adev);if (r) {
drivers/gpu/drm/amd/amdgpu/uvd_v3_1.c +0
-3@@ -640,9 +646,6 @@ static int uvd_v3_1_hw_init(struct amdgpu_ip_block *ip_block) return r; } - uvd_v3_1_enable_mgcg(adev, true); - amdgpu_asic_set_uvd_clocks(adev, 53300, 40000); - uvd_v3_1_start(adev);r =
amdgpu_ring_test_helper(ring);
--
2.50.1
Christian König
maintainerRe: [PATCH 1/6] drm/amdgpu: Power up UVD 3 for FW validation
In reply to Alex DeucherQuoted 13 lines · Alex Deucher
Quoted 12 lines · Timur Kristóf
Quoted 10 lines · Alex Deucher
Quoted 7 lines · Timur Kristóf
Unlike later versions, UVD 3 has firmware validation. For this to work, the UVD should be powered up correctly.
When DPM is enabled and the display clock is off, the SMU may choose a power state which doesn't power the UVD, which can result in failure to initialize UVD.
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
+ Christian, Leo
That doesn't seem right to me. IIRC, the driver always set the UVD PLL directly on SI and I don't think SI supported any kind of UVD power gating. I guess it's probably some sort of subtle sequencing difference between radeon and amdgpu. Unless Christian or Leo have any ideas, I think the patch is probably fine.
Oh my, that stuff was last at the front of my head a long long time ago.
Quoted 11 lines
Quoted 11 lines
Quoted 2 lines
Alex
Hi,
These are my observations about how the UVD clock works on SI:
1. It seems that the SMC needs to know whether UVD is enabled or not, and the UVD clocks are included as part of the power states. See:
si_convert_power_state_to_smcsi_convert_power_level_to_smc
Correct, yes. The design was that either the KMD or the SMC could program the PLLs.
Quoted 9 lines
Quoted 9 lines
On SI the default power state doesn't set the UVD clocks, and SI has a specific power state to be used with UVD. Actually
amdgpu_dpm_enable_uvdhas a special case code path for SI, where it sets this power state. If I print the power states fromsi_parse_power_table, it indeed confirms that there is only one power state that has non-zero UVD clocks, and the rest of them just have the UVD clocks at zero.
Quoted 3 lines
Quoted 3 lines
It's unclear to me what happens if we try to enable UVD clocks when we selected a power state that doesn't include them (ie. when we don't tell the SMC that UVD is active).
IIRC there were two possibilities.
Either you let the SMC handle the clocks in which case it would lower the GFX clock in favor of stable UVD clocks.
Or the KMD would lock the SMC to the highest level and then program the UVD clocks manually.
The later was not really validated but requested by a lot of people because otherwise you got a GFX performance reduction whenever you used UVD.
Quoted 8 lines
Quoted 8 lines
2. When setting a power state that enables UVD, the UVD clock is enabled either before or after the engine clock by
si_dpm. This is done so in both radeon and amdgpu, see:si_dpm_set_power_stateni_set_uvd_clock_before_set_eng_clockni_set_uvd_clock_after_set_eng_clock
Quoted 6 lines
Quoted 6 lines
The specific sequence in which the UVD clock is enabled by
si_dpm_set_power_stateleads me to the conclusion thatamdgpu_asic_set_uvd_clocksshould not be directly called on SI outside of the DPM code.Please correct me if I misunderstood the code.
That sounds correct to me.
Quoted 7 lines
Yeah, I don't remember the clock dependencies. I thought that you should be able to program the UVD PLLs any time you wanted and the ordering only mattered when you were also changing the sclk. Programming the PLLs directly works as is in radeon, but I guess maybe we init DPM in a different order in radeon vs amdgpu.
Quoted 7 lines
It would also probably be a good idea to disable the UVD clocks again after IP init to save power. E.g., something like:
if (adev->pm.dpm_enabled) amdgpu_dpm_enable_uvd(adev, false); else amdgpu_asic_set_uvd_clocks(adev, 0, 0);
IIRC we always disabled the PLL manually when UVD was unused because the SMC sometimes failed to do this.
Regards,
Christian.
Quoted 50 lines
Alex
Quoted 46 lines
Thanks,
TimurQuoted 41 lines
Quoted 41 lines
Fixes b38f3e80ecec ("drm amdgpu: SI UVD v3_1 (v2)")Signed-off-by Timur Kristóf <[email protected]>--- drivers/gpu/drm/amd/amdgpu/uvd_v3_1.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/uvd_v3_1.c +6
-0@@ -633,6 +633,12 @@ static int uvd_v3_1_hw_init(struct amdgpu_ip_block *ip_block)int r;uvd_v3_1_mc_resume (adev); +uvd_v3_1_enable_mgcg (adev, true); + +if (adev->pm.dpm_enabled) +amdgpu_dpm_enable_uvd (adev, true); +else +amdgpu_asic_set_uvd_clocks (adev,53300 ,40000 ); r =uvd_v3_1_fw_validate (adev);if (r) {drivers/gpu/drm/amd/amdgpu/uvd_v3_1.c +0
-3@@ -640,9 +646,6 @@ static int uvd_v3_1_hw_init(struct amdgpu_ip_block *ip_block)return r; } -uvd_v3_1_enable_mgcg (adev, true); -amdgpu_asic_set_uvd_clocks (adev,53300 ,40000 ); -uvd_v3_1_start (adev);r = amdgpu_ring_test_helper(ring);--
2.50.1
Re: [PATCH 1/6] drm/amdgpu: Power up UVD 3 for FW validation
Quoted 27 lines · Christian König
Quoted 16 lines · Alex Deucher
Quoted 14 lines · Timur Kristóf
Quoted 12 lines · Alex Deucher
Quoted 7 lines · Timur Kristóf
Unlike later versions, UVD 3 has firmware validation. For this to work, the UVD should be powered up correctly.
When DPM is enabled and the display clock is off, the SMU may choose a power state which doesn't power the UVD, which can result in failure to initialize UVD.
+ Christian, Leo
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
That doesn't seem right to me. IIRC, the driver always set the UVD
PLL directly on SI and I don't think SI supported any kind of UVD
power gating. I guess it's probably some sort of subtle sequencing
difference between radeon and amdgpu. Unless Christian or Leo have
any ideas, I think the patch is probably fine.
Quoted 2 lines
Oh my, that stuff was last at the front of my head a long long time ago.
Thanks for taking the time to reply anyway!
Quoted 35 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Alex
Hi,
Quoted 7 lines
Quoted 7 lines
These are my observations about how the UVD clock works on SI:
1. It seems that the SMC needs to know whether UVD is enabled or not,
and the UVD clocks are included as part of the power states. See:si_convert_power_state_to_smcsi_convert_power_level_to_smcCorrect, yes. The design was that either the KMD or the SMC could program the PLLs.
Quoted 12 lines
Quoted 12 lines
On SI the default power state doesn't set the UVD clocks, and SI has a specific power state to be used with UVD. Actually
amdgpu_dpm_enable_uvdhas a special case code path for SI, where it
sets this power state. If I print the power states fromsi_parse_power_table, it indeed confirms that there is only one power
state that has non-zero UVD clocks, and the rest of them just have the
UVD clocks at zero.Quoted 5 lines
Quoted 5 lines
It's unclear to me what happens if we try to enable UVD clocks when we
selected a power state that doesn't include them (ie. when we don't
tell the SMC that UVD is active).
Quoted 7 lines
IIRC there were two possibilities.
Either you let the SMC handle the clocks in which case it would lower the GFX clock in favor of stable UVD clocks.
Or the KMD would lock the SMC to the highest level and then program the UVD clocks manually.
As far as I see the si_dpm code does a mixture of the above two. When UVD is enabled, it selects the VBIOS-provided UVD power state and then it manually enables the UVD clocks to the value provided by the VBIOS.
When the UVD ring is not used anymore, it then shuts the UVD clock down manually.
(I assume then it goes back to a normal power state but I haven't actually verified that.)
Quoted 4 lines
The later was not really validated but requested by a lot of people because otherwise you got a GFX performance reduction whenever you used UVD.
Yes, the UVD power state from the VBIOS indeed has lower shader clocks compared to the normal power state.
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
2. When setting a power state that enables UVD, the UVD clock is enabled either before or after the engine clock by
si_dpm. This is done
so in both radeon and amdgpu, see:si_dpm_set_power_stateni_set_uvd_clock_before_set_eng_clockni_set_uvd_clock_after_set_eng_clockThe specific sequence in which the UVD clock is enabled by
si_dpm_set_power_stateleads me to the conclusion thatamdgpu_asic_set_uvd_clocksshould not be directly called on SI outside
of the DPM code.
Quoted 3 lines
Quoted 1 line
Quoted 1 line
Please correct me if I misunderstood the code.
That sounds correct to me.
Thanks!
Sounds like the patch is correct, then.
Quoted 13 lines
Quoted 13 lines
Yeah, I don't remember the clock dependencies. I thought that you should be able to program the UVD PLLs any time you wanted and the ordering only mattered when you were also changing the sclk. Programming the PLLs directly works as is in radeon, but I guess maybe
we init DPM in a different order in radeon vs amdgpu.It would also probably be a good idea to disable the UVD clocks again
after IP init to save power. E.g., something like:
Quoted 7 lines
Quoted 4 lines
if (
adev->pm.dpm_enabled)amdgpu_dpm_enable_uvd(adev, false); else
amdgpu_asic_set_uvd_clocks(adev, 0, 0);IIRC we always disabled the PLL manually when UVD was unused because the SMC sometimes failed to do this.
Yes, as I mentioned in my previous mail the PM code does that already when the UVD ring is not in use anymore. So it's not necessary to add any code to shut it down.
Maybe I should edit the commit to explain that in a comment?
Thanks,
Timur
Quoted 55 lines
Regards,
Christian.Quoted 51 lines
Alex
Quoted 47 lines
Thanks,
TimurQuoted 42 lines
Quoted 42 lines
Fixes b38f3e80ecec ("drm amdgpu: SI UVD v3_1 (v2)")Signed-off-by Timur Kristóf <[email protected]>---
drivers/gpu/drm/amd/amdgpu/uvd_v3_1.c | 9 ++++++---1 file changed, 6 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/uvd_v3_1.c +6
-0@@ -633,6 +633,12 @@ static int uvd_v3_1_hw_init(struct amdgpu_ip_block *ip_block) int r; uvd_v3_1_mc_resume(adev); + uvd_v3_1_enable_mgcg(adev, true); + + if (adev->pm.dpm_enabled) + amdgpu_dpm_enable_uvd(adev, true); + else + amdgpu_asic_set_uvd_clocks(adev, 53300,40000 );r =
uvd_v3_1_fw_validate(adev);
if (r) {drivers/gpu/drm/amd/amdgpu/uvd_v3_1.c +0
-3@@ -640,9 +646,6 @@ static int uvd_v3_1_hw_init(struct amdgpu_ip_block *ip_block) return r; } - uvd_v3_1_enable_mgcg(adev, true); - amdgpu_asic_set_uvd_clocks(adev, 53300, 40000); - uvd_v3_1_start(adev);r =
amdgpu_ring_test_helper(ring);
--
2.50.1
Christian König
maintainerRe: [PATCH 1/6] drm/amdgpu: Power up UVD 3 for FW validation
Quoted 78 lines · Timur Kristóf
Quoted 35 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Alex
Hi,
Quoted 7 lines
Quoted 7 lines
These are my observations about how the UVD clock works on SI:
1. It seems that the SMC needs to know whether UVD is enabled or not,
and the UVD clocks are included as part of the power states. See:si_convert_power_state_to_smcsi_convert_power_level_to_smcCorrect, yes. The design was that either the KMD or the SMC could program the PLLs.
Quoted 12 lines
Quoted 12 lines
On SI the default power state doesn't set the UVD clocks, and SI has a specific power state to be used with UVD. Actually
amdgpu_dpm_enable_uvdhas a special case code path for SI, where it
sets this power state. If I print the power states fromsi_parse_power_table, it indeed confirms that there is only one power
state that has non-zero UVD clocks, and the rest of them just have the
UVD clocks at zero.Quoted 5 lines
Quoted 5 lines
It's unclear to me what happens if we try to enable UVD clocks when we
selected a power state that doesn't include them (ie. when we don't
tell the SMC that UVD is active).Quoted 7 lines
IIRC there were two possibilities.
Either you let the SMC handle the clocks in which case it would lower the GFX clock in favor of stable UVD clocks.
Or the KMD would lock the SMC to the highest level and then program the UVD clocks manually.
As far as I see the
si_dpmcode does a mixture of the above two. When UVD is enabled, it selects the VBIOS-provided UVD power state and then it manually enables the UVD clocks to the value provided by the VBIOS.When the UVD ring is not used anymore, it then shuts the UVD clock down manually.
(I assume then it goes back to a normal power state but I haven't actually verified that.)
Quoted 4 lines
The later was not really validated but requested by a lot of people because otherwise you got a GFX performance reduction whenever you used UVD.
Yes, the UVD power state from the VBIOS indeed has lower shader clocks compared to the normal power state.
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
2. When setting a power state that enables UVD, the UVD clock is enabled either before or after the engine clock by
si_dpm. This is done
so in both radeon and amdgpu, see:si_dpm_set_power_stateni_set_uvd_clock_before_set_eng_clockni_set_uvd_clock_after_set_eng_clockThe specific sequence in which the UVD clock is enabled by
si_dpm_set_power_stateleads me to the conclusion thatamdgpu_asic_set_uvd_clocksshould not be directly called on SI outside
of the DPM code.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
Please correct me if I misunderstood the code.
That sounds correct to me.
Thanks!
Sounds like the patch is correct, then.
Most likely yes.
Quoted 23 lines
Quoted 14 lines
Quoted 14 lines
Yeah, I don't remember the clock dependencies. I thought that you should be able to program the UVD PLLs any time you wanted and the ordering only mattered when you were also changing the sclk. Programming the PLLs directly works as is in radeon, but I guess maybe
we init DPM in a different order in radeon vs amdgpu.It would also probably be a good idea to disable the UVD clocks again
after IP init to save power. E.g., something like:Quoted 7 lines
Quoted 4 lines
if (
adev->pm.dpm_enabled)amdgpu_dpm_enable_uvd(adev, false); else
amdgpu_asic_set_uvd_clocks(adev, 0, 0);IIRC we always disabled the PLL manually when UVD was unused because the SMC sometimes failed to do this.
Quoted 5 lines
Yes, as I mentioned in my previous mail the PM code does that already when the UVD ring is not in use anymore. So it's not necessary to add any code to shut it down.
Maybe I should edit the commit to explain that in a comment?
Code comment please!
That's basically the only chance we have to keep the knowledge why we did something the way we do it for the old HW generations around.
Regards,
Christian.
Quoted 4 lines
Thanks,
Timur
Re: [PATCH 1/6] drm/amdgpu: Power up UVD 3 for FW validation
Quoted 142 lines · Christian König
Quoted 96 lines · Timur Kristóf
Quoted 44 lines
Quoted 9 lines
Quoted 9 lines
Quoted 3 lines
Alex
Hi,
These are my observations about how the UVD clock works on SI:
Quoted 7 lines
Quoted 7 lines
1. It seems that the SMC needs to know whether UVD is enabled or
not,
and the UVD clocks are included as part of the power states. See:si_convert_power_state_to_smcsi_convert_power_level_to_smcCorrect, yes. The design was that either the KMD or the SMC could program the PLLs.
Quoted 15 lines
Quoted 15 lines
On SI the default power state doesn't set the UVD clocks, and SI has a specific power state to be used with UVD. Actually
amdgpu_dpm_enable_uvdhas a special case code path for SI, where
it
sets this power state. If I print the power states fromsi_parse_power_table, it indeed confirms that there is only one
power
state that has non-zero UVD clocks, and the rest of them just have the
UVD clocks at zero.Quoted 6 lines
Quoted 6 lines
It's unclear to me what happens if we try to enable UVD clocks
when we
selected a power state that doesn't include them (ie. when we don't
tell the SMC that UVD is active).IIRC there were two possibilities.
Quoted 7 lines
Either you let the SMC handle the clocks in which case it would lower
the GFX clock in favor of stable UVD clocks.Or the KMD would lock the SMC to the highest level and then program
the UVD clocks manually.As far as I see the
si_dpmcode does a mixture of the above two. When UVD is enabled, it selects the VBIOS-provided UVD power state and
then it manually enables the UVD clocks to the value provided by the
VBIOS.When the UVD ring is not used anymore, it then shuts the UVD clock down
manually.(I assume then it goes back to a normal power state but I haven't actually verified that.)
Quoted 6 lines
The later was not really validated but requested by a lot of people
because otherwise you got a GFX performance reduction whenever you
used UVD.Yes, the UVD power state from the VBIOS indeed has lower shader clocks
compared to the normal power state.Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
2. When setting a power state that enables UVD, the UVD clock is
enabled either before or after the engine clock bysi_dpm. This
is done
so in both radeon and amdgpu, see:si_dpm_set_power_stateni_set_uvd_clock_before_set_eng_clockni_set_uvd_clock_after_set_eng_clockThe specific sequence in which the UVD clock is enabled by
si_dpm_set_power_stateleads me to the conclusion thatamdgpu_asic_set_uvd_clocksshould not be directly called on SI
outside
of the DPM code.Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
Please correct me if I misunderstood the code.
That sounds correct to me.
Thanks!
Sounds like the patch is correct, then.
Most likely yes.
Quoted 27 lines
Quoted 17 lines
Quoted 17 lines
Yeah, I don't remember the clock dependencies. I thought that you
should be able to program the UVD PLLs any time you wanted and the
ordering only mattered when you were also changing the sclk. Programming the PLLs directly works as is in radeon, but I guess
maybe
we init DPM in a different order in radeon vs amdgpu.It would also probably be a good idea to disable the UVD clocks again
after IP init to save power. E.g., something like:Quoted 8 lines
Quoted 4 lines
if (
adev->pm.dpm_enabled)amdgpu_dpm_enable_uvd(adev, false); else
amdgpu_asic_set_uvd_clocks(adev, 0, 0);IIRC we always disabled the PLL manually when UVD was unused because
the SMC sometimes failed to do this.Quoted 7 lines
Yes, as I mentioned in my previous mail the PM code does that already
when the UVD ring is not in use anymore. So it's not necessary to add
any code to shut it down.Maybe I should edit the commit to explain that in a comment?
Quoted 7 lines
Code comment please!
That's basically the only chance we have to keep the knowledge why we did something the way we do it for the old HW generations around.
Regards,
Christian.
Hi Christian,
Sounds good. I will add a comment when I submit a next version of this series.
Quoted 4 lines
Quoted 4 lines
Thanks,
Timur
PATCH 2/6 drm/amd/pm: Disable ULV even if unsupported
In reply to Timur KristófThis commit fixes some instability on Tahiti.
Sometimes UVD initialization would fail when using DC. I suspect this is because DC doesn't immediately turn on the display clock, so it changes how DPM behaves.
--- drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +5 -2
@@ -5639,10 +5639,13 @@ static int si_disable_ulv(struct amdgpu_device *adev) {struct si_power_info *si_pi =si_get_pi (adev);struct si_ulv_param *ulv = &si_pi->ulv; +PPSMC_Result r; + r =amdgpu_si_send_msg_to_smc (adev, PPSMC_MSG_DisableULV); + +/* Only care about SMC reply when ULV is supported. */ if (ulv->supported) -return (amdgpu_si_send_msg_to_smc (adev, PPSMC_MSG_DisableULV) == PPSMC_Result_OK) ? -0 : -EINVAL ; +return (r == PPSMC_Result_OK) ?0 : -EINVAL ;return 0 ; }
Signature · 1 line
2.50.1
Re: [PATCH 2/6] drm/amd/pm: Disable ULV even if unsupported
Quoted 6 lines · Timur Kristóf
This commit fixes some instability on Tahiti.
Sometimes UVD initialization would fail when using DC. I suspect this is because DC doesn't immediately turn on the display clock, so it changes how DPM behaves.
Is this the right description for this patch? I thought you had said this fixed something else.
Alex
Quoted 30 lines
Fixes 841686df9f7d ("drm/amdgpu: add SI DPM support (v4)")Signed-off-by Timur Kristóf <[email protected]>--- drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +5
-3@@ -5639,10 +5639,13 @@ static int si_disable_ulv(struct amdgpu_device *adev) {struct si_power_info *si_pi =si_get_pi (adev);struct si_ulv_param *ulv = &si_pi->ulv; +PPSMC_Result r; + r =amdgpu_si_send_msg_to_smc (adev, PPSMC_MSG_DisableULV); + +/* Only care about SMC reply when ULV is supported. */ if (ulv->supported) -return (amdgpu_si_send_msg_to_smc (adev, PPSMC_MSG_DisableULV) == PPSMC_Result_OK) ? -0 : -EINVAL ; +return (r == PPSMC_Result_OK) ?0 : -EINVAL ;return 0 ; } --2.50.1
Re: [PATCH 2/6] drm/amd/pm: Disable ULV even if unsupported
Quoted 5 lines · Alex Deucher
Quoted 3 lines · Timur Kristóf
This commit fixes some instability on Tahiti.
Quoted 8 lines
Quoted 3 lines
Sometimes UVD initialization would fail when using DC. I suspect this is because DC doesn't immediately turn on the display clock, so it changes how DPM behaves.
Is this the right description for this patch? I thought you had said this fixed something else.
Alex
Yes, this patch together with the previous one fixes the "amdgpu: UVD Firmware validate fail" when I enable DC on Tahiti.
Last week I thought this also fixed the "si_set_sw_state failed", but that turned out to be wrong. For that one, I sent a separate patch which involves a different fix.
Timur
Quoted 34 lines
Quoted 34 lines
Fixes 841686df9f7d ("drm/amdgpu: add SI DPM support (v4)")Signed-off-by Timur Kristóf <[email protected]>---
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c | 7 +++++--1 file changed, 5 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +4
-1@@ -5639,10 +5639,13 @@ static int si_disable_ulv(struct amdgpu_device *adev) { struct si_power_info *si_pi = si_get_pi(adev); struct si_ulv_param *ulv = &si_pi->ulv; + PPSMC_Result r; + r = amdgpu_si_send_msg_to_smc(adev, PPSMC_MSG_DisableULV); + + /* Only care about SMC reply when ULV is supported. */ if (ulv->supported) - return (amdgpu_si_send_msg_to_smc(adev,
PPSMC_MSG_DisableULV) ==PPSMC_Result_OK) ?
- 0 :-EINVAL;
+ return (r ==PPSMC_Result_OK) ? 0 :-EINVAL;return 0;
}
--
2.50.1
Alex Deucher
Acked-byRe: [PATCH 2/6] drm/amd/pm: Disable ULV even if unsupported
Quoted 14 lines · Timur Kristóf
Quoted 12 lines · Alex Deucher
Quoted 6 lines · Timur Kristóf
This commit fixes some instability on Tahiti.
Sometimes UVD initialization would fail when using DC. I suspect this is because DC doesn't immediately turn on the display clock, so it changes how DPM behaves.
Is this the right description for this patch? I thought you had said this fixed something else.
Quoted 8 lines
Quoted 1 line
Alex
Yes, this patch together with the previous one fixes the "amdgpu: UVD Firmware validate fail" when I enable DC on Tahiti.
Last week I thought this also fixed the "
si_set_sw_statefailed", but that turned out to be wrong. For that one, I sent a separate patch which involves a different fix.
Thanks for clarifying.
Quoted 37 lines
Timur
Quoted 34 lines
Quoted 34 lines
Fixes 841686df9f7d ("drm/amdgpu: add SI DPM support (v4)")Signed-off-by Timur Kristóf <[email protected]>--- drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +4
-1@@ -5639,10 +5639,13 @@ static int si_disable_ulv(struct amdgpu_device *adev) {struct si_power_info *si_pi =si_get_pi (adev);struct si_ulv_param *ulv = &si_pi->ulv; +PPSMC_Result r; + r =amdgpu_si_send_msg_to_smc (adev, PPSMC_MSG_DisableULV); + +/* Only care about SMC reply when ULV is supported. */ if (ulv->supported) - return (amdgpu_si_send_msg_to_smc(adev,
PPSMC_MSG_DisableULV) ==PPSMC_Result_OK) ?drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +1
-2- 0 : -EINVAL; +return (r == PPSMC_Result_OK) ?0 : -EINVAL ;return 0 ; } --2.50.1
PATCH 3/6 drm/radeon: Disable ULV even if unsupported
In reply to Timur KristófBackport of the same commit to amdgpu.
This commit fixes some instability on Tahiti.
--- drivers/gpu/drm/radeon/si_dpm.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/radeon/si_dpm.c +5 -2
@@ -5073,10 +5073,13 @@ static int si_disable_ulv(struct radeon_device *rdev) {struct si_power_info *si_pi =si_get_pi (rdev);struct si_ulv_param *ulv = &si_pi->ulv; +PPSMC_Result r; + r =si_send_msg_to_smc (rdev, PPSMC_MSG_DisableULV); + +/* Only care about SMC reply when ULV is supported. */ if (ulv->supported) -return (si_send_msg_to_smc (rdev, PPSMC_MSG_DisableULV) == PPSMC_Result_OK) ? -0 : -EINVAL ; +return (r == PPSMC_Result_OK) ?0 : -EINVAL ;return 0 ; }
Signature · 1 line
2.50.1
Re: [PATCH 3/6] drm/radeon: Disable ULV even if unsupported
Quoted 3 lines · Timur Kristóf
Backport of the same commit to amdgpu.
This commit fixes some instability on Tahiti.
Have you tested this with radeon?
Alex
Quoted 30 lines
Fixes a9e61410921b ("drm/radeon/kms: add dpm support for SI (v7)")Signed-off-by Timur Kristóf <[email protected]>--- drivers/gpu/drm/radeon/si_dpm.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)drivers/gpu/drm/radeon/si_dpm.c +5
-3@@ -5073,10 +5073,13 @@ static int si_disable_ulv(struct radeon_device *rdev) {struct si_power_info *si_pi =si_get_pi (rdev);struct si_ulv_param *ulv = &si_pi->ulv; +PPSMC_Result r; + r =si_send_msg_to_smc (rdev, PPSMC_MSG_DisableULV); + +/* Only care about SMC reply when ULV is supported. */ if (ulv->supported) -return (si_send_msg_to_smc (rdev, PPSMC_MSG_DisableULV) == PPSMC_Result_OK) ? -0 : -EINVAL ; +return (r == PPSMC_Result_OK) ?0 : -EINVAL ;return 0 ; } --2.50.1
Re: [PATCH 3/6] drm/radeon: Disable ULV even if unsupported
Quoted 9 lines · Alex Deucher
Quoted 3 lines · Timur Kristóf
Backport of the same commit to amdgpu.
This commit fixes some instability on Tahiti.Have you tested this with radeon?
Alex
Considering that ULV is currently always marked as unsupported by both radeon and amdgpu, and that the same patch fixes a real issue on amdgpu, I assume it would improve stability on radeon too.
I leave it up to your judgement whether it's a good idea to apply this to radeon or not.
That said, I haven't got a specific issue which this fixes on radeon. I only tested that Tahiti can boot with radeon with this patch included, but didn't do detailed testing other than that. Do you have something specific in mind that I should try?
Timur
Quoted 34 lines
Quoted 34 lines
Fixes a9e61410921b ("drm/radeon/kms: add dpm support for SI (v7)")Signed-off-by Timur Kristóf <[email protected]>---
drivers/gpu/drm/radeon/si_dpm.c | 7 +++++--1 file changed, 5 insertions(+), 2 deletions(-)drivers/gpu/drm/radeon/si_dpm.c +4
-1@@ -5073,10 +5073,13 @@ static int si_disable_ulv(struct radeon_device *rdev) { struct si_power_info *si_pi = si_get_pi(rdev); struct si_ulv_param *ulv = &si_pi->ulv; + PPSMC_Result r; + r = si_send_msg_to_smc(rdev, PPSMC_MSG_DisableULV); + + /* Only care about SMC reply when ULV is supported. */ if (ulv->supported) - return (si_send_msg_to_smc(rdev,
PPSMC_MSG_DisableULV) ==PPSMC_Result_OK) ?
- 0 :-EINVAL;
+ return (r ==PPSMC_Result_OK) ? 0 :-EINVAL;return 0;
}
--
2.50.1
Alex Deucher
Acked-byRe: [PATCH 3/6] drm/radeon: Disable ULV even if unsupported
Quoted 16 lines · Timur Kristóf
Quoted 9 lines · Alex Deucher
Quoted 3 lines · Timur Kristóf
Backport of the same commit to amdgpu.
This commit fixes some instability on Tahiti.Have you tested this with radeon?
Alex
Considering that ULV is currently always marked as unsupported by both radeon and amdgpu, and that the same patch fixes a real issue on amdgpu, I assume it would improve stability on radeon too.
Quoted 7 lines
I leave it up to your judgement whether it's a good idea to apply this to radeon or not.
That said, I haven't got a specific issue which this fixes on radeon. I only tested that Tahiti can boot with radeon with this patch included, but didn't do detailed testing other than that. Do you have something specific in mind that I should try?
That's fine. I was thinking this contributed to the other issue you were debugging, but you clarified that in the other patch.
Alex
Quoted 37 lines
Timur
Quoted 34 lines
Quoted 34 lines
Fixes a9e61410921b ("drm/radeon/kms: add dpm support for SI (v7)")Signed-off-by Timur Kristóf <[email protected]>--- drivers/gpu/drm/radeon/si_dpm.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)drivers/gpu/drm/radeon/si_dpm.c +4
-1@@ -5073,10 +5073,13 @@ static int si_disable_ulv(struct radeon_device *rdev) {struct si_power_info *si_pi =si_get_pi (rdev);struct si_ulv_param *ulv = &si_pi->ulv; +PPSMC_Result r; + r =si_send_msg_to_smc (rdev, PPSMC_MSG_DisableULV); + +/* Only care about SMC reply when ULV is supported. */ if (ulv->supported) - return (si_send_msg_to_smc(rdev,
PPSMC_MSG_DisableULV) ==PPSMC_Result_OK) ?drivers/gpu/drm/radeon/si_dpm.c +1
-2- 0 : -EINVAL; +return (r == PPSMC_Result_OK) ?0 : -EINVAL ;return 0 ; } --2.50.1
PATCH 4/6 drm/amd/pm: Fix si_upload_smc_data
In reply to Timur KristófThe si_upload_smc_data function uses si_write_smc_soft_register to set some register values in the SMC, and expects the result to be PPSMC_Result_OK which is 1.
The PPSMC_Result_OK / PPSMC_Result_Failed values are used for checking the result of a command sent to the SMC.
However, the si_write_smc_soft_register actually doesn't send any commands to the SMC and returns zero on success, so this check was incorrect.
Fix that by correctly interpreting zero as success. This seems to fix an SMC hang that happens in si_set_sw_state.
--- drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c | 31 +++++++++++++--------- 1 file changed, 19 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +19 -12
@@ -5820,6 +5820,7 @@ static int si_upload_smc_data(struct amdgpu_device *adev) {struct amdgpu_crtc *amdgpu_crtc =NULL ;int i; +int ret;if (adev->pm.dpm.new_active_crtc_count ==0 )return 0 ;
@@ -5837,20 +5838,26 @@ static int si_upload_smc_data(struct amdgpu_device *adev)if (amdgpu_crtc->line_time <=0 )return 0 ; -if (si_write_smc_soft_register (adev, - SI_SMC_SOFT_REGISTER_crtc_index, - amdgpu_crtc->crtc_id) != PPSMC_Result_OK) -return 0 ; + ret =si_write_smc_soft_register ( + adev, + SI_SMC_SOFT_REGISTER_crtc_index, + amdgpu_crtc->crtc_id); +if (ret) +return ret; -if (si_write_smc_soft_register (adev, - SI_SMC_SOFT_REGISTER_mclk_change_block_cp_min, - amdgpu_crtc->wm_high / amdgpu_crtc->line_time) != PPSMC_Result_OK) -return 0 ; + ret =si_write_smc_soft_register ( + adev, + SI_SMC_SOFT_REGISTER_mclk_change_block_cp_min, + amdgpu_crtc->wm_high / amdgpu_crtc->line_time); +if (ret) +return ret; -if (si_write_smc_soft_register (adev, - SI_SMC_SOFT_REGISTER_mclk_change_block_cp_max, - amdgpu_crtc->wm_low / amdgpu_crtc->line_time) != PPSMC_Result_OK) -return 0 ; + ret =si_write_smc_soft_register ( + adev, + SI_SMC_SOFT_REGISTER_mclk_change_block_cp_max, + amdgpu_crtc->wm_low / amdgpu_crtc->line_time); +if (ret) +return ret;return 0 ; }
Signature · 1 line
2.50.1
Re: [PATCH 4/6] drm/amd/pm: Fix si_upload_smc_data
Quoted 59 lines · Timur Kristóf
The
si_upload_smc_datafunction usessi_write_smc_soft_registerto set some register values in the SMC, and expects the result to bePPSMC_Result_OKwhich is 1.The
PPSMC_Result_OK/PPSMC_Result_Failedvalues are used for checking the result of a command sent to the SMC.However, the
si_write_smc_soft_registeractually doesn't send any commands to the SMC and returns zero on success, so this check was incorrect.Fix that by correctly interpreting zero as success. This seems to fix an SMC hang that happens in
si_set_sw_state.Fixes 841686df9f7d ("drm/amdgpu: add SI DPM support (v4)")Signed-off-by Timur Kristóf <[email protected]>--- drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c | 31 +++++++++++++--------- 1 file changed, 19 insertions(+), 12 deletions(-)drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +13
-8@@ -5820,6 +5820,7 @@ static int si_upload_smc_data(struct amdgpu_device *adev) {struct amdgpu_crtc *amdgpu_crtc =NULL ;int i; +int ret;if (adev->pm.dpm.new_active_crtc_count ==0 )return 0 ;@@ -5837,20 +5838,26 @@ static int si_upload_smc_data(struct amdgpu_device *adev)if (amdgpu_crtc->line_time <=0 )return 0 ; -if (si_write_smc_soft_register (adev, - SI_SMC_SOFT_REGISTER_crtc_index, - amdgpu_crtc->crtc_id) != PPSMC_Result_OK) -return 0 ; + ret =si_write_smc_soft_register ( + adev, + SI_SMC_SOFT_REGISTER_crtc_index, + amdgpu_crtc->crtc_id); +if (ret) +return ret; -if (si_write_smc_soft_register (adev, - SI_SMC_SOFT_REGISTER_mclk_change_block_cp_min, - amdgpu_crtc->wm_high / amdgpu_crtc->line_time) != PPSMC_Result_OK) -return 0 ; + ret =si_write_smc_soft_register ( + adev, + SI_SMC_SOFT_REGISTER_mclk_change_block_cp_min, + amdgpu_crtc->wm_high / amdgpu_crtc->line_time); +if (ret) +return ret;
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c static int si_upload_smc_data(struct amdgpu_device *adev) · line 5860
Quoted 10 lines
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +6
-4-if (si_write_smc_soft_register (adev, - SI_SMC_SOFT_REGISTER_mclk_change_block_cp_max, - amdgpu_crtc->wm_low / amdgpu_crtc->line_time) != PPSMC_Result_OK) -return 0 ; + ret =si_write_smc_soft_register ( + adev, + SI_SMC_SOFT_REGISTER_mclk_change_block_cp_max, + amdgpu_crtc->wm_low / amdgpu_crtc->line_time); +if (ret) +return ret;
This patch changes the behavior of this function (i.e., it always returns 0 before this patch). Not sure if that matters or not. I think this could be simplified to something like the following to retain the current behavior.
(quoted diff) +0 -0
b/drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c
index 52e732be59e36..3dd0115aa15f8 100644
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +0 -0
@@ -5836,17 +5836,17 @@ static int si_upload_smc_data(struct
amdgpu_device *adev)
if (si_write_smc_soft_register(adev,
SI_SMC_SOFT_REGISTER_crtc_index,
- amdgpu_crtc->crtc_id) != PPSMC_Result_OK)
+ amdgpu_crtc->crtc_id))
return 0;
if (si_write_smc_soft_register(adev,SI_SMC_SOFT_REGISTER_mclk_change_block_cp_min,
- amdgpu_crtc->wm_high /amdgpu_crtc->line_time) != PPSMC_Result_OK)
+ amdgpu_crtc->wm_high /amdgpu_crtc->line_time))
return 0;
if (si_write_smc_soft_register(adev,SI_SMC_SOFT_REGISTER_mclk_change_block_cp_max,
- amdgpu_crtc->wm_low /amdgpu_crtc->line_time) != PPSMC_Result_OK)
+ amdgpu_crtc->wm_low /amdgpu_crtc->line_time))
return 0;
return 0;Quoted 6 lines
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +0
-1return 0 ; } --2.50.1
Re: [PATCH 4/6] drm/amd/pm: Fix si_upload_smc_data
Quoted 78 lines · Alex Deucher
Quoted 76 lines · Timur Kristóf
The
si_upload_smc_datafunction usessi_write_smc_soft_registerto set some register values in the SMC, and expects the result to bePPSMC_Result_OKwhich is 1.The
PPSMC_Result_OK/PPSMC_Result_Failedvalues are used for checking the result of a command sent to the SMC.However, the
si_write_smc_soft_registeractually doesn't send any commands to the SMC and returns zero on success, so this check was incorrect.Fix that by correctly interpreting zero as success. This seems to fix an SMC hang that happens in
si_set_sw_state.Fixes 841686df9f7d ("drm/amdgpu: add SI DPM support (v4)")Signed-off-by Timur Kristóf <[email protected]>---
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c | 31 +++++++++++++-----
----1 file changed, 19 insertions(+), 12 deletions(-)drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +1
-0@@ -5820,6 +5820,7 @@ static int si_upload_smc_data(struct amdgpu_device *adev) { struct amdgpu_crtc *amdgpu_crtc = NULL; int i; + int ret; if (adev->pm.dpm.new_active_crtc_count == 0)return 0;
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +12
-10@@ -5837,20 +5838,26 @@ static int si_upload_smc_data(struct amdgpu_device *adev) if (amdgpu_crtc->line_time <= 0) return 0; - if (si_write_smc_soft_register(adev, - SI_SMC_SOFT_REGISTER_crtc_index, - amdgpu_crtc->crtc_id) != PPSMC_Result_OK) - return 0; + ret = si_write_smc_soft_register( + adev, + SI_SMC_SOFT_REGISTER_crtc_index, + amdgpu_crtc->crtc_id); + if (ret) + return ret; - if (si_write_smc_soft_register(adev, - SI_SMC_SOFT_REGISTER_mclk_change_block_cp_min, - amdgpu_crtc->wm_high / amdgpu_crtc->line_time) != PPSMC_Result_OK) - return 0; + ret = si_write_smc_soft_register( + adev, + SI_SMC_SOFT_REGISTER_mclk_change_block_cp_min, + amdgpu_crtc->wm_high / amdgpu_crtc->line_time); + if (ret) + return ret; - if (si_write_smc_soft_register(adev, -
SI_SMC_SOFT_REGISTER_mclk_change_block_cp_max,
-amdgpu_crtc->wm_low/amdgpu_crtc->line_time) !=PPSMC_Result_OK)
- return 0;
+ ret = si_write_smc_soft_register(
+ adev,
+SI_SMC_SOFT_REGISTER_mclk_change_block_cp_max,
Quoted 8 lines
Quoted 3 lines
+
amdgpu_crtc->wm_low/amdgpu_crtc->line_time); + if (ret)
+ return ret;This patch changes the behavior of this function (i.e., it always returns 0 before this patch). Not sure if that matters or not. I think this could be simplified to something like the following to retain the current behavior.
Actually now that I think of it more, I think it may be entirely unnecessary to check the return value.
si_upload_smc_data calls:si_write_smc_soft_registeramdgpu_si_write_smc_sram_dwordsi_set_smc_sram_address
This last one, si_set_smc_sram_address returns -EINVAL when its smc_address parameter is not dword-aligned or out of bounds. Otherwise all of the above functions return 0 (success). Considering that all of the addresses passed by si_upload_smc_data are compile time constants, we know they are correct so there is no reason why any of those functions would return an error.
Looking at other callers of si_write_smc_soft_register, I see that they don't check the return value at all.
So, I'd actually simplify this even more and just not check the return values. What do you think about that?
Quoted 44 lines
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +0
-0@@ -5836,17 +5836,17 @@ static int si_upload_smc_data(struct amdgpu_device *adev) if (si_write_smc_soft_register(adev,
SI_SMC_SOFT_REGISTER_crtc_index,
-amdgpu_crtc->crtc_id) !=PPSMC_Result_OK)
+amdgpu_crtc->crtc_id)) return 0;if (si_write_smc_soft_register(adev,
SI_SMC_SOFT_REGISTER_mclk_change_block_cp_min,
-amdgpu_crtc->wm_high/amdgpu_crtc->line_time) !=PPSMC_Result_OK)
+amdgpu_crtc->wm_high/amdgpu_crtc->line_time))
return 0;if (si_write_smc_soft_register(adev,
SI_SMC_SOFT_REGISTER_mclk_change_block_cp_max,
-amdgpu_crtc->wm_low/amdgpu_crtc->line_time) !=PPSMC_Result_OK)
+amdgpu_crtc->wm_low/amdgpu_crtc->line_time))
return 0;return 0;
Quoted 6 lines
return 0;
}
--
2.50.1
Re: [PATCH 4/6] drm/amd/pm: Fix si_upload_smc_data
Quoted 104 lines · Timur Kristóf
Quoted 78 lines · Alex Deucher
Quoted 76 lines · Timur Kristóf
The
si_upload_smc_datafunction usessi_write_smc_soft_registerto set some register values in the SMC, and expects the result to bePPSMC_Result_OKwhich is 1.The
PPSMC_Result_OK/PPSMC_Result_Failedvalues are used for checking the result of a command sent to the SMC.However, the
si_write_smc_soft_registeractually doesn't send any commands to the SMC and returns zero on success, so this check was incorrect.Fix that by correctly interpreting zero as success. This seems to fix an SMC hang that happens in
si_set_sw_state.Fixes 841686df9f7d ("drm/amdgpu: add SI DPM support (v4)")Signed-off-by Timur Kristóf <[email protected]>--- drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c | 31 +++++++++++++----- ---- 1 file changed, 19 insertions(+), 12 deletions(-)drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +1
-0@@ -5820,6 +5820,7 @@ static int si_upload_smc_data(struct amdgpu_device *adev) {struct amdgpu_crtc *amdgpu_crtc =NULL ;int i; +int ret;if (adev->pm.dpm.new_active_crtc_count ==0 )return 0;drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +12
-10@@ -5837,20 +5838,26 @@ static int si_upload_smc_data(struct amdgpu_device *adev)if (amdgpu_crtc->line_time <=0 )return 0 ; -if (si_write_smc_soft_register (adev, - SI_SMC_SOFT_REGISTER_crtc_index, - amdgpu_crtc->crtc_id) != PPSMC_Result_OK) -return 0 ; + ret =si_write_smc_soft_register ( + adev, + SI_SMC_SOFT_REGISTER_crtc_index, + amdgpu_crtc->crtc_id); +if (ret) +return ret; -if (si_write_smc_soft_register (adev, - SI_SMC_SOFT_REGISTER_mclk_change_block_cp_min, - amdgpu_crtc->wm_high / amdgpu_crtc->line_time) != PPSMC_Result_OK) -return 0 ; + ret =si_write_smc_soft_register ( + adev, + SI_SMC_SOFT_REGISTER_mclk_change_block_cp_min, + amdgpu_crtc->wm_high / amdgpu_crtc->line_time); +if (ret) +return ret; - if (si_write_smc_soft_register(adev, -
SI_SMC_SOFT_REGISTER_mclk_change_block_cp_max,
-amdgpu_crtc->wm_low/amdgpu_crtc->line_time) !=PPSMC_Result_OK)drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +3
-1-return 0 ; + ret = si_write_smc_soft_register( + adev, + SI_SMC_SOFT_REGISTER_mclk_change_block_cp_max,Quoted 8 lines
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c
Quoted 3 lines
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +3
-0+ amdgpu_crtc->wm_low / amdgpu_crtc->line_time); +if (ret) +return ret;This patch changes the behavior of this function (i.e., it always returns 0 before this patch). Not sure if that matters or not. I think this could be simplified to something like the following to retain the current behavior.
Actually now that I think of it more, I think it may be entirely unnecessary to check the return value.
si_upload_smc_datacalls:si_write_smc_soft_registeramdgpu_si_write_smc_sram_dwordsi_set_smc_sram_addressThis last one,
si_set_smc_sram_addressreturns-EINVALwhen itssmc_addressparameter is not dword-aligned or out of bounds. Otherwise all of the above functions return 0 (success). Considering that all of the addresses passed bysi_upload_smc_dataare compile time constants, we know they are correct so there is no reason why any of those functions would return an error.
Quoted 5 lines
Looking at other callers of
si_write_smc_soft_register, I see that they don't check the return value at all.So, I'd actually simplify this even more and just not check the return values. What do you think about that?
Sure. Works for me.
Alex
Quoted 46 lines
Quoted 46 lines
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +2
-2@@ -5836,17 +5836,17 @@ static int si_upload_smc_data(struct amdgpu_device *adev) if (si_write_smc_soft_register(adev,SI_SMC_SOFT_REGISTER_crtc_index , - amdgpu_crtc->crtc_id) !=PPSMC_Result_OK ) + amdgpu_crtc->crtc_id)) return 0;if (si_write_smc_soft_register (adev, SI_SMC_SOFT_REGISTER_mclk_change_block_cp_min, - amdgpu_crtc->wm_high / amdgpu_crtc->line_time) != PPSMC_Result_OK) + amdgpu_crtc->wm_high / amdgpu_crtc->line_time))return 0 ;if (si_write_smc_soft_register(adev,
SI_SMC_SOFT_REGISTER_mclk_change_block_cp_max,
-amdgpu_crtc->wm_low/amdgpu_crtc->line_time) !=PPSMC_Result_OK)
+amdgpu_crtc->wm_low/amdgpu_crtc->line_time))return 0; return 0;Quoted 6 lines
return 0;}
--
2.50.1
Re: [PATCH 4/6] drm/amd/pm: Fix si_upload_smc_data
Quoted 115 lines · Alex Deucher
Quoted 113 lines · Timur Kristóf
Quoted 80 lines · Alex Deucher
Quoted 78 lines · Timur Kristóf
The
si_upload_smc_datafunction usessi_write_smc_soft_registerto set some register values in the SMC, and expects the result to bePPSMC_Result_OKwhich is 1.The
PPSMC_Result_OK/PPSMC_Result_Failedvalues are used for checking the result of a command sent to the SMC.However, the
si_write_smc_soft_registeractually doesn't send any commands to the SMC and returns zero on success, so this check was incorrect.Fix that by correctly interpreting zero as success. This seems to fix an SMC hang that happens in
si_set_sw_state.Fixes 841686df9f7d ("drm/amdgpu: add SI DPM support (v4)")Signed-off-by Timur Kristóf <[email protected]>---
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c | 31 +++++++++++++-
----
----1 file changed, 19 insertions(+), 12 deletions(-)drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +1
-0@@ -5820,6 +5820,7 @@ static int si_upload_smc_data(struct amdgpu_device *adev) { struct amdgpu_crtc *amdgpu_crtc = NULL; int i; + int ret; if (adev->pm.dpm.new_active_crtc_count == 0)return 0;
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +12
-10@@ -5837,20 +5838,26 @@ static int si_upload_smc_data(struct amdgpu_device *adev) if (amdgpu_crtc->line_time <= 0) return 0; - if (si_write_smc_soft_register(adev, - SI_SMC_SOFT_REGISTER_crtc_index, - amdgpu_crtc->crtc_id) != PPSMC_Result_OK) - return 0; + ret = si_write_smc_soft_register( + adev, + SI_SMC_SOFT_REGISTER_crtc_index, + amdgpu_crtc->crtc_id); + if (ret) + return ret; - if (si_write_smc_soft_register(adev, - SI_SMC_SOFT_REGISTER_mclk_change_block_cp_min, - amdgpu_crtc->wm_high / amdgpu_crtc->line_time) != PPSMC_Result_OK) - return 0; + ret = si_write_smc_soft_register( + adev, + SI_SMC_SOFT_REGISTER_mclk_change_block_cp_min, + amdgpu_crtc->wm_high / amdgpu_crtc->line_time); + if (ret) + return ret; - if (si_write_smc_soft_register(adev, -
SI_SMC_SOFT_REGISTER_mclk_change_block_cp_max,
-amdgpu_crtc->wm_low/amdgpu_crtc->line_time) !=PPSMC_Result_OK)
- return 0;
+ ret = si_write_smc_soft_register(
+ adev,
+SI_SMC_SOFT_REGISTER_mclk_change_block_cp_max, +amdgpu_crtc->wm_low/amdgpu_crtc->line_time);Quoted 8 lines
Quoted 2 lines
+ if (ret)
+ return ret;This patch changes the behavior of this function (i.e., it always returns 0 before this patch). Not sure if that matters or not. I
think this could be simplified to something like the following to retain the current behavior.Actually now that I think of it more, I think it may be entirely unnecessary to check the return value.
si_upload_smc_datacalls:si_write_smc_soft_registeramdgpu_si_write_smc_sram_dwordsi_set_smc_sram_addressThis last one,
si_set_smc_sram_addressreturns-EINVALwhen itssmc_addressparameter is not dword-aligned or out of bounds. Otherwise
all of the above functions return 0 (success). Considering that all of
the addresses passed bysi_upload_smc_dataare compile time constants,
we know they are correct so there is no reason why any of those functions would return an error.Looking at other callers of
si_write_smc_soft_register, I see that they
don't check the return value at all.
Quoted 7 lines
Quoted 3 lines
So, I'd actually simplify this even more and just not check the return
values. What do you think about that?Sure. Works for me.
Alex
Alex, before I send a new version of this series, can you please clarify what these registers are and verify that the actual programming of these SMC registers is correct?
The reason I ask is because due the the bug being fixed by these patch, these registers were never actually written, which makes me wonder if the value we program them to is actually correct.
I mean the values that we program these registers to:
SI_SMC_SOFT_REGISTER_crtc_index - we just program the index of the first active CRTC, seems straightforward enough, but it's unclear what the SMC uses this for. Why does the SMC care which crtc we use?
SI_SMC_SOFT_REGISTER_mclk_change_block_cp_min - programmed to the high display watermark divided by the line time. But I can't find any information about what this information represents or what the SMC uses it for. Judging by the name it has to do with mclk switching?
SI_SMC_SOFT_REGISTER_mclk_change_block_cp_max - same concern as _min.
Thanks,
Timur
Quoted 47 lines
Quoted 47 lines
Quoted 47 lines
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +2
-2@@ -5836,17 +5836,17 @@ static int si_upload_smc_data(struct amdgpu_device *adev) if (si_write_smc_soft_register(adev,SI_SMC_SOFT_REGISTER_crtc_index , - amdgpu_crtc->crtc_id) !=PPSMC_Result_OK ) + amdgpu_crtc->crtc_id)) return 0; if (si_write_smc_soft_register(adev, SI_SMC_SOFT_REGISTER_mclk_change_block_cp_min, - amdgpu_crtc->wm_high / amdgpu_crtc->line_time) != PPSMC_Result_OK) + amdgpu_crtc->wm_high / amdgpu_crtc->line_time)) return 0;if (si_write_smc_soft_register(adev,
SI_SMC_SOFT_REGISTER_mclk_change_block_cp_max,
-amdgpu_crtc->wm_low/amdgpu_crtc->line_time) !=PPSMC_Result_OK)
+amdgpu_crtc->wm_low/amdgpu_crtc->line_time))
return 0;return 0;
Quoted 6 lines
return 0;
}
--
2.50.1
Re: [PATCH 4/6] drm/amd/pm: Fix si_upload_smc_data
Quoted 121 lines · Timur Kristóf
Quoted 119 lines · Alex Deucher
Quoted 116 lines · Timur Kristóf
Quoted 80 lines · Alex Deucher
Quoted 78 lines · Timur Kristóf
The
si_upload_smc_datafunction usessi_write_smc_soft_registerto set some register values in the SMC, and expects the result to bePPSMC_Result_OKwhich is 1.The
PPSMC_Result_OK/PPSMC_Result_Failedvalues are used for checking the result of a command sent to the SMC.However, the
si_write_smc_soft_registeractually doesn't send any commands to the SMC and returns zero on success, so this check was incorrect.Fix that by correctly interpreting zero as success. This seems to fix an SMC hang that happens in
si_set_sw_state.Fixes 841686df9f7d ("drm/amdgpu: add SI DPM support (v4)")Signed-off-by Timur Kristóf <[email protected]>--- drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c | 31 +++++++++++++- ---- ---- 1 file changed, 19 insertions(+), 12 deletions(-)drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +1
-0@@ -5820,6 +5820,7 @@ static int si_upload_smc_data(struct amdgpu_device *adev) {struct amdgpu_crtc *amdgpu_crtc =NULL ;int i; +int ret;if (adev->pm.dpm.new_active_crtc_count ==0 )return 0;drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +12
-10@@ -5837,20 +5838,26 @@ static int si_upload_smc_data(struct amdgpu_device *adev)if (amdgpu_crtc->line_time <=0 )return 0 ; -if (si_write_smc_soft_register (adev, - SI_SMC_SOFT_REGISTER_crtc_index, - amdgpu_crtc->crtc_id) != PPSMC_Result_OK) -return 0 ; + ret =si_write_smc_soft_register ( + adev, + SI_SMC_SOFT_REGISTER_crtc_index, + amdgpu_crtc->crtc_id); +if (ret) +return ret; -if (si_write_smc_soft_register (adev, - SI_SMC_SOFT_REGISTER_mclk_change_block_cp_min, - amdgpu_crtc->wm_high / amdgpu_crtc->line_time) != PPSMC_Result_OK) -return 0 ; + ret =si_write_smc_soft_register ( + adev, + SI_SMC_SOFT_REGISTER_mclk_change_block_cp_min, + amdgpu_crtc->wm_high / amdgpu_crtc->line_time); +if (ret) +return ret; - if (si_write_smc_soft_register(adev, -
SI_SMC_SOFT_REGISTER_mclk_change_block_cp_max,
-amdgpu_crtc->wm_low/amdgpu_crtc->line_time) !=PPSMC_Result_OK)drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +4
-1-return 0 ; + ret =si_write_smc_soft_register ( + adev, + SI_SMC_SOFT_REGISTER_mclk_change_block_cp_max, + amdgpu_crtc->wm_low / amdgpu_crtc->line_time);Quoted 8 lines
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c
Quoted 2 lines
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +2
-0+if (ret) +return ret;This patch changes the behavior of this function (i.e., it always returns 0 before this patch). Not sure if that matters or not. I
think this could be simplified to something like the following to retain the current behavior.Actually now that I think of it more, I think it may be entirely unnecessary to check the return value.
si_upload_smc_datacalls:si_write_smc_soft_registeramdgpu_si_write_smc_sram_dwordsi_set_smc_sram_addressThis last one,
si_set_smc_sram_addressreturns-EINVALwhen itssmc_addressparameter is not dword-aligned or out of bounds. Otherwise
all of the above functions return 0 (success). Considering that all of
the addresses passed bysi_upload_smc_dataare compile time constants,
we know they are correct so there is no reason why any of those functions would return an error.Looking at other callers of
si_write_smc_soft_register, I see that they
don't check the return value at all.So, I'd actually simplify this even more and just not check the return
values. What do you think about that?
Quoted 7 lines
Quoted 3 lines
Sure. Works for me.
Alex
Alex, before I send a new version of this series, can you please clarify what these registers are and verify that the actual programming of these SMC registers is correct?
This code was based on what the windows code did.
Quoted 11 lines
The reason I ask is because due the the bug being fixed by these patch, these registers were never actually written, which makes me wonder if the value we program them to is actually correct.
I mean the values that we program these registers to:
SI_SMC_SOFT_REGISTER_crtc_index- we just program the index of the first active CRTC, seems straightforward enough, but it's unclear what the SMC uses this for. Why does the SMC care which crtc we use?
Quoted 6 lines
SI_SMC_SOFT_REGISTER_mclk_change_block_cp_min- programmed to the high display watermark divided by the line time. But I can't find any information about what this information represents or what the SMC uses it for. Judging by the name it has to do with mclk switching?
SI_SMC_SOFT_REGISTER_mclk_change_block_cp_max- same concern as_min.
For mclk switching, the mclk has to be changed during the display blanking period to avoid display artifacts. This is presumably part of that, but I don't remember exactly what all of these do anymore.
Alex
Quoted 52 lines
Thanks,
TimurQuoted 47 lines
Quoted 47 lines
Quoted 47 lines
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +2
-2@@ -5836,17 +5836,17 @@ static int si_upload_smc_data(struct amdgpu_device *adev) if (si_write_smc_soft_register(adev,SI_SMC_SOFT_REGISTER_crtc_index , - amdgpu_crtc->crtc_id) !=PPSMC_Result_OK ) + amdgpu_crtc->crtc_id)) return 0;if (si_write_smc_soft_register (adev, SI_SMC_SOFT_REGISTER_mclk_change_block_cp_min, - amdgpu_crtc->wm_high / amdgpu_crtc->line_time) != PPSMC_Result_OK) + amdgpu_crtc->wm_high / amdgpu_crtc->line_time))return 0 ;if (si_write_smc_soft_register(adev,
SI_SMC_SOFT_REGISTER_mclk_change_block_cp_max,
-amdgpu_crtc->wm_low/amdgpu_crtc->line_time) !=PPSMC_Result_OK)
+amdgpu_crtc->wm_low/amdgpu_crtc->line_time))return 0; return 0;Quoted 6 lines
return 0;}
--
2.50.1
Re: [PATCH 4/6] drm/amd/pm: Fix si_upload_smc_data
Quoted 145 lines · Alex Deucher
Quoted 143 lines · Timur Kristóf
Quoted 141 lines · Alex Deucher
Quoted 128 lines · Timur Kristóf
Quoted 97 lines · Alex Deucher
Quoted 91 lines · Timur Kristóf
The
si_upload_smc_datafunction usessi_write_smc_soft_register
to set some register values in the SMC, and expects the result
to bePPSMC_Result_OKwhich is 1.The
PPSMC_Result_OK/PPSMC_Result_Failedvalues are used for
checking the result of a command sent to the SMC.However, the
si_write_smc_soft_registeractually doesn't send
any commands to the SMC and returns zero on success, so this check was incorrect.Fix that by correctly interpreting zero as success. This seems to fix an SMC hang that happens in
si_set_sw_state.Fixes 841686df9f7d ("drm/amdgpu: add SI DPM support (v4)")Signed-off-by Timur Kristóf <[email protected]>---
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c | 31
+++++++++++++-
----
----1 file changed, 19 insertions(+), 12 deletions(-)drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +1
-0@@ -5820,6 +5820,7 @@ static int si_upload_smc_data(struct amdgpu_device *adev) { struct amdgpu_crtc *amdgpu_crtc = NULL; int i; + int ret; if (adev->pm.dpm.new_active_crtc_count == 0)return 0;
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +0
-0@@ -5837,20 +5838,26 @@ static intsi_upload_smc_data(struct
amdgpu_device*adev)
if (amdgpu_crtc->line_time<= 0)
return 0;- if (si_write_smc_soft_register(adev, -
SI_SMC_SOFT_REGISTER_crtc_index,
- amdgpu_crtc-Quoted 1 line
crtc_id) !=
PPSMC_Result_OK)
- return 0;
+ ret = si_write_smc_soft_register(
+ adev,
+SI_SMC_SOFT_REGISTER_crtc_index,
+amdgpu_crtc->crtc_id);
+ if (ret)
+ return ret;- if (si_write_smc_soft_register(adev,
-SI_SMC_SOFT_REGISTER_mclk_change_block_cp_min,
-amdgpu_crtc->wm_high/amdgpu_crtc->line_time) !=PPSMC_Result_OK)
- return 0;
+ ret = si_write_smc_soft_register(
+ adev,
+SI_SMC_SOFT_REGISTER_mclk_change_block_cp_min,
+amdgpu_crtc->wm_high/ amdgpu_crtc-Quoted 1 line
line_time);+ if (ret)
+ return ret;- if (si_write_smc_soft_register(adev,
-SI_SMC_SOFT_REGISTER_mclk_change_block_cp_max,
-amdgpu_crtc->wm_low/amdgpu_crtc->line_time) !=PPSMC_Result_OK)
- return 0;
+ ret = si_write_smc_soft_register(
+ adev,
+SI_SMC_SOFT_REGISTER_mclk_change_block_cp_max,
+amdgpu_crtc->wm_low/ amdgpu_crtc-Quoted 3 lines
Quoted 1 line
line_time);+ if (ret)
+ return ret;Quoted 8 lines
This patch changes the behavior of this function (i.e., it always
returns 0 before this patch). Not sure if that matters or not.
I
think this could be simplified to something like the following to
retain the current behavior.Actually now that I think of it more, I think it may be entirely
unnecessary to check the return value.
si_upload_smc_datacalls:si_write_smc_soft_registeramdgpu_si_write_smc_sram_dwordsi_set_smc_sram_addressThis last one,
si_set_smc_sram_addressreturns-EINVALwhen itssmc_addressparameter is not dword-aligned or out of bounds. Otherwise
all of the above functions return 0 (success). Considering that all
of
the addresses passed bysi_upload_smc_dataare compile time constants,
we know they are correct so there is no reason why any of those functions would return an error.Quoted 8 lines
Looking at other callers of
si_write_smc_soft_register, I see that
they
don't check the return value at all.So, I'd actually simplify this even more and just not check the return
values. What do you think about that?Sure. Works for me.
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Alex
Alex, before I send a new version of this series, can you please clarify what these registers are and verify that the actual programming
of these SMC registers is correct?This code was based on what the windows code did.
Makes sense. Let's assume that it's correct then.
Quoted 22 lines
Quoted 22 lines
The reason I ask is because due the the bug being fixed by these patch,
these registers were never actually written, which makes me wonder if
the value we program them to is actually correct.I mean the values that we program these registers to:
SI_SMC_SOFT_REGISTER_crtc_index- we just program the index of the first active CRTC, seems straightforward enough, but it's unclear what
the SMC uses this for. Why does the SMC care which crtc we use?
SI_SMC_SOFT_REGISTER_mclk_change_block_cp_min- programmed to the high
display watermark divided by the line time. But I can't find any information about what this information represents or what the SMC uses
it for. Judging by the name it has to do with mclk switching?
Quoted 8 lines
Quoted 2 lines
SI_SMC_SOFT_REGISTER_mclk_change_block_cp_max- same concern as_min.For mclk switching, the mclk has to be changed during the display blanking period to avoid display artifacts. This is presumably part of that, but I don't remember exactly what all of these do anymore.
Alex
Thank you. I will make the changes that we discussed above and send a second version of this series next week.
Quoted 54 lines
Quoted 54 lines
Thanks,
TimurQuoted 48 lines
Quoted 48 lines
Quoted 48 lines
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +0
-1@@ -5836,17 +5836,17 @@ static int si_upload_smc_data(struct amdgpu_device *adev) if (si_write_smc_soft_register(adev, SI_SMC_SOFT_REGISTER_crtc_index, - amdgpu_crtc->crtc_id)!=
PPSMC_Result_OK)
+amdgpu_crtc->crtc_id)) return 0;if (si_write_smc_soft_register(adev,
SI_SMC_SOFT_REGISTER_mclk_change_block_cp_min,
-amdgpu_crtc->wm_high/amdgpu_crtc->line_time) !=PPSMC_Result_OK)
+amdgpu_crtc->wm_high/amdgpu_crtc->line_time))
return 0;if (si_write_smc_soft_register(adev,
SI_SMC_SOFT_REGISTER_mclk_change_block_cp_max,
-amdgpu_crtc->wm_low/amdgpu_crtc->line_time) !=PPSMC_Result_OK)
+amdgpu_crtc->wm_low/amdgpu_crtc->line_time))
return 0;return 0;
Quoted 6 lines
return 0;
}
--
2.50.1
PATCH 5/6 drm/radeon: Fix si_upload_smc_data
In reply to Timur KristófBackport of the fix to the same amdgpu issue.
The si_upload_smc_data function uses si_write_smc_soft_register to set some register values in the SMC, and expects the result to be PPSMC_Result_OK which is 1.
The PPSMC_Result_OK / PPSMC_Result_Failed values are used for checking the result of a command sent to the SMC.
However, the si_write_smc_soft_register actually doesn't send any commands to the SMC and returns zero on success, so this check was incorrect.
Fix that by correctly interpreting zero as success. This seems to fix an SMC hang that happens in si_set_sw_state.
--- drivers/gpu/drm/radeon/si_dpm.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-)
drivers/gpu/drm/radeon/si_dpm.c +19 -12
@@ -5257,6 +5257,7 @@ static int si_upload_smc_data(struct radeon_device *rdev) {struct radeon_crtc *radeon_crtc =NULL ;int i; +int ret;if (rdev->pm.dpm.new_active_crtc_count ==0 )return 0 ;
@@ -5274,20 +5275,26 @@ static int si_upload_smc_data(struct radeon_device *rdev)if (radeon_crtc->line_time <=0 )return 0 ; -if (si_write_smc_soft_register (rdev, - SI_SMC_SOFT_REGISTER_crtc_index, - radeon_crtc->crtc_id) != PPSMC_Result_OK) -return 0 ; + ret =si_write_smc_soft_register ( + rdev, + SI_SMC_SOFT_REGISTER_crtc_index, + radeon_crtc->crtc_id); +if (ret) +return ret; -if (si_write_smc_soft_register (rdev, - SI_SMC_SOFT_REGISTER_mclk_change_block_cp_min, - radeon_crtc->wm_high / radeon_crtc->line_time) != PPSMC_Result_OK) -return 0 ; + ret =si_write_smc_soft_register ( + rdev, + SI_SMC_SOFT_REGISTER_mclk_change_block_cp_min, + radeon_crtc->wm_high / radeon_crtc->line_time); +if (ret) +return ret; -if (si_write_smc_soft_register (rdev, - SI_SMC_SOFT_REGISTER_mclk_change_block_cp_max, - radeon_crtc->wm_low / radeon_crtc->line_time) != PPSMC_Result_OK) -return 0 ; + ret =si_write_smc_soft_register ( + rdev, + SI_SMC_SOFT_REGISTER_mclk_change_block_cp_max, + radeon_crtc->wm_low / radeon_crtc->line_time); +if (ret) +return ret;return 0 ; }
Signature · 1 line
2.50.1
Re: [PATCH 5/6] drm/radeon: Fix si_upload_smc_data
Quoted 14 lines · Timur Kristóf
Backport of the fix to the same amdgpu issue.
The
si_upload_smc_datafunction usessi_write_smc_soft_registerto set some register values in the SMC, and expects the result to bePPSMC_Result_OKwhich is 1.The
PPSMC_Result_OK/PPSMC_Result_Failedvalues are used for checking the result of a command sent to the SMC.However, the
si_write_smc_soft_registeractually doesn't send any commands to the SMC and returns zero on success, so this check was incorrect.
Quoted 5 lines
Fix that by correctly interpreting zero as success. This seems to fix an SMC hang that happens in
si_set_sw_state.Fixes a9e61410921b ("drm/radeon/kms: add dpm support for SI (v7)")Signed-off-by Timur Kristóf <[email protected]>
Same comment here as the previous patch.
Alex
Quoted 58 lines
--- drivers/gpu/drm/radeon/si_dpm.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-)drivers/gpu/drm/radeon/si_dpm.c +19
-13@@ -5257,6 +5257,7 @@ static int si_upload_smc_data(struct radeon_device *rdev) {struct radeon_crtc *radeon_crtc =NULL ;int i; +int ret;if (rdev->pm.dpm.new_active_crtc_count ==0 )return 0 ;@@ -5274,20 +5275,26 @@ static int si_upload_smc_data(struct radeon_device *rdev)if (radeon_crtc->line_time <=0 )return 0 ; -if (si_write_smc_soft_register (rdev, - SI_SMC_SOFT_REGISTER_crtc_index, - radeon_crtc->crtc_id) != PPSMC_Result_OK) -return 0 ; + ret =si_write_smc_soft_register ( + rdev, + SI_SMC_SOFT_REGISTER_crtc_index, + radeon_crtc->crtc_id); +if (ret) +return ret; -if (si_write_smc_soft_register (rdev, - SI_SMC_SOFT_REGISTER_mclk_change_block_cp_min, - radeon_crtc->wm_high / radeon_crtc->line_time) != PPSMC_Result_OK) -return 0 ; + ret =si_write_smc_soft_register ( + rdev, + SI_SMC_SOFT_REGISTER_mclk_change_block_cp_min, + radeon_crtc->wm_high / radeon_crtc->line_time); +if (ret) +return ret; -if (si_write_smc_soft_register (rdev, - SI_SMC_SOFT_REGISTER_mclk_change_block_cp_max, - radeon_crtc->wm_low / radeon_crtc->line_time) != PPSMC_Result_OK) -return 0 ; + ret =si_write_smc_soft_register ( + rdev, + SI_SMC_SOFT_REGISTER_mclk_change_block_cp_max, + radeon_crtc->wm_low / radeon_crtc->line_time); +if (ret) +return ret;return 0 ; } --2.50.1
PATCH 6/6 drm/amd/pm: Fix SI DPM issues with high pixel clock
In reply to Timur KristófWe define "high pixelclock" for SI as higher than necessary for 4K 30Hz. For example, 4K 60Hz and 1080p 144Hz fall into this category.
When a high pixel clock display is connected, always disable memory clock switching to solve some flickering that can be observed on Tahiti and Pitcairn on 4K 60Hz displays.
When two high pixel clock displays are connected to Oland, additionally disable shader clock switching, which results in a higher voltage, thereby addressing some visible flickering.
Ideally, these issues would be solved by introducing something like dce_calcs, but we don't have that for old GPUs, so ad-hoc fixes become necessary.
--- drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+)
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +37 -0
@@ -3443,12 +3443,14 @@ static void si_apply_state_adjust_rules(struct amdgpu_device *adev, {struct si_ps *ps =si_get_ps (rps);struct amdgpu_clock_and_voltage_limits *max_limits; +struct amdgpu_connector *conn;bool disable_mclk_switching = false;bool disable_sclk_switching = false;u32 mclk, sclk;u16 vddc, vddci, min_vce_voltage =0 ;u32 max_sclk_vddc, max_mclk_vddci, max_mclk_vddc;u32 max_sclk =0 , max_mclk =0 ; +u32 high_pixelclock_count =0 ;int i;if (adev->asic_type ==CHIP_HAINAN ) {
@@ -3476,6 +3478,41 @@ static void si_apply_state_adjust_rules(struct amdgpu_device *adev, } } +/* We define "high pixelclock" for SI as higher than necessary for 4K 30Hz. +* For example, 4K 60Hz and 1080p 144Hz fall into this category. +* Find number of such displays connected. +*/ +for (i =0 ; i < adev->mode_info.num_crtc; i++) { +if (!(adev->pm.dpm.new_active_crtcs & (1 << i)) || + !adev->mode_info.crtcs[i]->enabled) +continue ; + + conn =to_amdgpu_connector (adev->mode_info.crtcs[i]->connector); + +if (conn->pixelclock_for_modeset >297000 ) + high_pixelclock_count++; + } + +/* These are some ad-hoc fixes to some issues observed with SI GPUs. +* They are necessary because we don't have something like dce_calcs +* for these GPUs. +*/ +if (high_pixelclock_count) { +/* High pixelclock displays need higher memory bandwidth. +* Disable memory clock switching in order to: +* - Solve visible display flickering +* - Avoid starving other clients of the memory controller +*/ + disable_mclk_switching = true; + +/* On Oland, we observe some flickering when two 4K 60Hz +* displays are connected, possibly because voltage is too low. +* Raise the voltage by requiring a higher SCLK. +*/ +if (high_pixelclock_count >1 && adev->asic_type ==CHIP_OLAND ) + disable_sclk_switching = true; + } +if (rps->vce_active) { rps->evclk = adev->pm.dpm.vce_states[adev->pm.dpm.vce_level].evclk; rps->ecclk = adev->pm.dpm.vce_states[adev->pm.dpm.vce_level].ecclk;
Signature · 1 line
2.50.1