Skip to contentSkip to conversation

drm/amd: Check that VPE has reached DPM0 in idle handler

PATCH Superseded Mario Limonciello 2 participants 2 messages Oct 11, 2025

Subsystems (2)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 drm/amd: Check that VPE has reached DPM0 in idle handler

[Why]
Newer VPE microcode has functionality that will decrease DPM level only when a workload has run for 2 or more seconds. If VPE is turned off before this DPM decrease, the SOC can get stuck with a higher DPM level.

This can happen from amdgpu's ring buffer test because it's a short quick workload for VPE and VPE is turned off after 1s.

[How]
In idle handler besides checking fences are drained check that VPE DPM level is really is at DPM0. If not, schedule delayed work again until it is.

---
Drop unnecessary spurious dpm_level variable

 drivers/gpu/drm/amd/amdgpu/amdgpu_vpe.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vpe.c +6 -1
index 474bfe36c0c2..9065d799c2c4 100644
@@ -326,11 +326,16 @@ static void vpe_idle_work_handler(struct work_struct *work)
 {
 	struct amdgpu_device *adev =
 		container_of(work, struct amdgpu_device, vpe.idle_work.work);
+	struct amdgpu_vpe *vpe = &adev->vpe;
 	unsigned int fences = 0;
+	uint32_t dpm_level;
 
 	fences += amdgpu_fence_count_emitted(&adev->vpe.ring);
 
-	if (fences == 0)
+	dpm_level = adev->pm.dpm_enabled ?
+		    RREG32(vpe_get_reg_offset(vpe, 0, vpe->regs.dpm_request_lv)) : 0;
+
+	if (fences == 0 && dpm_level == 0)
 		amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_VPE, AMD_PG_STATE_GATE);
 	else
 		schedule_delayed_work(&adev->vpe.idle_work, VPE_IDLE_TIMEOUT);
Signature · 1 line
2.51.0
#1 lore raw

Hi Mario,

Quoted 30 lines · Mario Limonciello

[Why]
Newer VPE microcode has functionality that will decrease DPM level only when a workload has run for 2 or more seconds. If VPE is turned off before this DPM decrease, the SOC can get stuck with a higher DPM level.

This can happen from amdgpu's ring buffer test because it's a short quick workload for VPE and VPE is turned off after 1s.

[How]
In idle handler besides checking fences are drained check that VPE DPM level is really is at DPM0. If not, schedule delayed work again until it is.

---
Drop unnecessary spurious dpm_level variable

 drivers/gpu/drm/amd/amdgpu/amdgpu_vpe.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vpe.c +0 -0
index 474bfe36c0c2..9065d799c2c4 100644
@@ -326,11 +326,16 @@ static void vpe_idle_work_handler(struct work_struct *work)
 {
 	struct amdgpu_device *adev =

drivers/gpu/drm/amd/amdgpu/amdgpu_vpe.c static void vpe_idle_work_handler(struct work_struct *work) · line 336

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vpe.c +4 -1
 		container_of(work, struct amdgpu_device, vpe.idle_work.work);
+	struct amdgpu_vpe *vpe = &adev->vpe;
 	unsigned int fences = 0;
+	uint32_t dpm_level;
 
 	fences += amdgpu_fence_count_emitted(&adev->vpe.ring);
 
-	if (fences == 0)
+	dpm_level = adev->pm.dpm_enabled ?
+		    RREG32(vpe_get_reg_offset(vpe, 0, vpe->regs.dpm_request_lv)) : 0;

This register read can be skipped when fences != 0. Perhaps with a goto label?

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vpe.c +2 -0
+
+	if (fences == 0 && dpm_level == 0)
 		amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_VPE, AMD_PG_STATE_GATE);
 	else
 		schedule_delayed_work(&adev->vpe.idle_work, VPE_IDLE_TIMEOUT);
Signature · 1 line
2.51.0

Sultan