Commit 333991c4 authored by Andrzej Hajda's avatar Andrzej Hajda Committed by Rodrigo Vivi

drm/i915/selftests: fix subtraction overflow bug

On some machines hole_end can be small enough to cause subtraction
overflow. On the other side (addr + 2 * min_alignment) can overflow
in case of mock tests. This patch should handle both cases.

Fixes: e1c5f754 ("drm/i915: Avoid overflow in computing pot_hole loop termination")
Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/3674Signed-off-by: default avatarAndrzej Hajda <andrzej.hajda@intel.com>
Reviewed-by: default avatarAndi Shyti <andi.shyti@linux.intel.com>
Signed-off-by: default avatarAndi Shyti <andi.shyti@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220624113528.2159210-1-andrzej.hajda@intel.comSigned-off-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
(cherry picked from commit ab3edc67)
Signed-off-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
parent ad765fae
...@@ -742,7 +742,7 @@ static int pot_hole(struct i915_address_space *vm, ...@@ -742,7 +742,7 @@ static int pot_hole(struct i915_address_space *vm,
u64 addr; u64 addr;
for (addr = round_up(hole_start + min_alignment, step) - min_alignment; for (addr = round_up(hole_start + min_alignment, step) - min_alignment;
addr <= round_down(hole_end - (2 * min_alignment), step) - min_alignment; hole_end > addr && hole_end - addr >= 2 * min_alignment;
addr += step) { addr += step) {
err = i915_vma_pin(vma, 0, 0, addr | flags); err = i915_vma_pin(vma, 0, 0, addr | flags);
if (err) { if (err) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment