Skip to contentSkip to conversation

drm/amd/display: fix wrong plane_count check in dm_gpureset_toggle_interrupts()

PATCH In review [email protected] 3 participants 3 messages Jul 23

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amd/display: fix wrong plane_count check in dm_gpureset_toggle_interrupts()

From: Lu Yao <[email protected]>

The else-if branch in dm_gpureset_toggle_interrupts() condition was incorrectly checking plane_count != 0, which is the same as the preceding if-branch and can never be true in the else path.

Fixes 8382cd234981 ("drm/amd/display: consolidate DCN vblank/flip handling onto vupdate_no_lock")
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -1
index 9c564cd5edee..a11c64277d1d 100644
@@ -3353,7 +3353,7 @@ static void dm_gpureset_toggle_interrupts(struct amdgpu_device *adev,
 			if (!dc_interrupt_set(adev->dm.dc, irq_source, enable))
 				drm_warn(adev_to_drm(adev), "Failed to %sable vblank interrupt\n", enable ? "en" : "dis");
 
-		} else if (acrtc && state->stream_status[i].plane_count != 0) {
+		} else if (acrtc && state->stream_status[i].plane_count == 0) {
 			/* DCN only needs to toggle VUPDATE_NO_LOCK */
 			rc = amdgpu_dm_crtc_set_vupdate_irq(&acrtc->base, enable);
 			if (rc)
Signature · 1 line
2.25.1
#1 lore raw
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] The patch introduces a critical boolean logic error in `dm_gpureset_toggle_interrupts` that breaks…

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The patch introduces a critical boolean logic error in dm_gpureset_toggle_interrupts that breaks DCN interrupt toggling during GPU reset. --

--- Patch [1]: [PATCH] drm/amd/display: fix wrong plane_count check in dm_gpureset_toggle_interrupts() --- commit 019af4e190dd8d0cacc73ad6b2cdd860d90cbb1b
Author: Lu Yao <[email protected]>
drm/amd/display: fix wrong plane_count check in dm_gpureset_toggle_interrupts()

The else-if branch in dm_gpureset_toggle_interrupts() condition was incorrectly checking plane_count != 0, which the author states is the same as the preceding if-branch and can never be true in the else path.

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static void dm_gpureset_toggle_interrupts(struct amdgpu_device *adev, · line 1590

Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -1
index f8d8132ea50ed..e3d490d27171f 100644
@@ -1587,7 +1587,7 @@ static void dm_gpureset_toggle_interrupts(struct amdgpu_device *adev,
 			if (!dc_interrupt_set(adev->dm.dc, irq_source, enable))
 				drm_warn(adev_to_drm(adev), "Failed to %sable vblank interrupt\n", enable ? "en" : "dis");
 
-		} else if (acrtc && state->stream_status[i].plane_count != 0) {
+		} else if (acrtc && state->stream_status[i].plane_count == 0) {

[Severity: High]
Does this change unintentionally break interrupt toggling for DCN hardware?

The commit message states that the preceding if-branch already checks for plane_count != 0, making it impossible to be true here. However, looking at the preceding if-condition in dm_gpureset_toggle_interrupts():

		if (acrtc && state->stream_status[i].plane_count != 0 &&
		    amdgpu_ip_version(adev, DCE_HWIP, 0) == 0) {

The if-branch also requires amdgpu_ip_version(adev, DCE_HWIP, 0) == 0. For DCN hardware, this IP version check evaluates to false, which causes the execution to fall through to this else-if branch even when plane_count != 0.

With this patch changing the check to plane_count == 0, won't DCN streams with active planes incorrectly skip toggling VUPDATE_NO_LOCK during a GPU reset?

Quoted 9 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -0
 			/* DCN only needs to toggle VUPDATE_NO_LOCK */
 			rc = amdgpu_dm_crtc_set_vupdate_irq(&acrtc->base, enable);
 			if (rc)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -0
 				drm_warn(adev_to_drm(adev), "Failed to %sable vupdate interrupt\n",
 					 enable ? "en" : "dis");
 		}
 	}
 
 }
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
maintainer
#2 lore raw
In reply to [email protected]
Quoted 17 lines · On 2026-07-22 21:55, [email protected] wrote:

From: Lu Yao <[email protected]>

The else-if branch in dm_gpureset_toggle_interrupts() condition was incorrectly checking plane_count != 0, which is the same as the preceding if-branch and can never be true in the else path.

Fixes 8382cd234981 ("drm/amd/display: consolidate DCN vblank/flip handling onto vupdate_no_lock")
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -0
index 9c564cd5edee..a11c64277d1d 100644

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static void dm_gpureset_toggle_interrupts(struct amdgpu_device *adev, · line 3356

Quoted 5 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -1
@@ -3353,7 +3353,7 @@ static void dm_gpureset_toggle_interrupts(struct amdgpu_device *adev,
 			if (!dc_interrupt_set(adev->dm.dc, irq_source, enable))
 				drm_warn(adev_to_drm(adev), "Failed to %sable vblank interrupt\n", enable ? "en" : "dis");
 
-		} else if (acrtc && state->stream_status[i].plane_count != 0) {
+		} else if (acrtc && state->stream_status[i].plane_count == 0) {

It looks like the amdgpu_ip_version(adev, DCE_HWIP, 0) == 0) { condition was lost when I rebased the tagged "Fixes" change on 7.2...
https://gitlab.freedesktop.org/agd5f/linux/-/commit/991d045abfe30cbef19b92edfb304d209fcdf7e3?file_path=drivers%2Fgpu%2Fdrm%2Famd%2Fdisplay%2Famdgpu_dm%2Famdgpu_dm.c#line_298241cee_A1561

Fix incoming.
- Leo

Quoted 3 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -0
 			/* DCN only needs to toggle VUPDATE_NO_LOCK */
 			rc = amdgpu_dm_crtc_set_vupdate_irq(&acrtc->base, enable);
 			if (rc)