]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
drm/amd/display: Fix unsigned underflow in SubVP vblank schedulability check v2
authorSrinivasan Shanmugam <srinivasan.shanmugam@amd.com>
Thu, 23 Apr 2026 13:32:10 +0000 (19:02 +0530)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 24 Apr 2026 14:53:17 +0000 (10:53 -0400)
commit437cbca5ea50af4d1b37dd05aa33b4e791fd6d0f
tree0e22ccd8f6f8c931e17874e1003dca8d617edf77
parent506e047aed6f66b2f8c762125f58316b82076680
drm/amd/display: Fix unsigned underflow in SubVP vblank schedulability check v2

subvp_vblank_schedulable() checks whether the SubVP active region can
fit the prefetch time, vblank frame time, and the larger of the vblank
blanking time and MALL region.

Commit 11236ac905e7 ("drm/amd/display: Fix dml2_0 narrowing boundaries")
changed the intermediate timing variables from u16 to u32. After that
change, the schedulability test:

subvp_active_us - prefetch_us - vblank_frame_us -
max_vblank_mallregion > 0

is evaluated in unsigned arithmetic. If the required time exceeds the
available active time, the subtraction can underflow and wrap, producing
a large positive value instead of a negative result.

Fix this by comparing the available time against the required time
directly, using u64 for the accumulated required duration.

v2:
- Use uint64_t instead of u64 for consistency with DC style (Dillon)
- Make all terms explicitly uint64_t in the accumulated sum & use
  single-definition form for required_us (Gaghik)

Fixes: 11236ac905e7 ("drm/amd/display: Fix dml2_0 narrowing boundaries")
Reported-by: Dan Carpenter <error27@gmail.com>
Cc: Roman Li <roman.li@amd.com>
Cc: Alex Hung <alex.hung@amd.com>
Cc: Tom Chung <chiahsuan.chung@amd.com>
Cc: Dillon Varone <dillon.varone@amd.com>
Cc: Gaghik Khachatrian <gaghik.khachatrian@amd.com>
Cc: Aurabindo Pillai <aurabindo.pillai@amd.com>
Cc: Chenyu Chen <chen-yu.chen@amd.com>
Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam@amd.com>
Reviewed-by: Dillon Varone <dillon.varone@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/dml2_0/dml2_mall_phantom.c