Skip to content

Commit

Permalink
drm/buddy: Fix alloc_range() error handling code
Browse files Browse the repository at this point in the history
Few users have observed display corruption when they boot
the machine to KDE Plasma or playing games. We have root
caused the problem that whenever alloc_range() couldn't
find the required memory blocks the function was returning
SUCCESS in some of the corner cases.

The right approach would be if the total allocated size
is less than the required size, the function should
return -ENOSPC.

Cc: <stable@vger.kernel.org> # 6.7+
Fixes: 0a1844b ("drm/buddy: Improve contiguous memory allocation")
Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/3097
Tested-by: Mario Limonciello <mario.limonciello@amd.com>
Link: https://patchwork.kernel.org/project/dri-devel/patch/20240207174456.341121-1-Arunpravin.PaneerSelvam@amd.com/
Acked-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
Signed-off-by: Arunpravin Paneer Selvam <Arunpravin.PaneerSelvam@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240214131853.5934-1-Arunpravin.PaneerSelvam@amd.com
Signed-off-by: Christian König <christian.koenig@amd.com>
  • Loading branch information
Arunpravin Paneer Selvam authored and Christian König committed Feb 14, 2024
1 parent b6ddaa6 commit 8746c6c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/gpu/drm/drm_buddy.c
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,12 @@ static int __alloc_range(struct drm_buddy *mm,
} while (1);

list_splice_tail(&allocated, blocks);

if (total_allocated < size) {
err = -ENOSPC;
goto err_free;
}

return 0;

err_undo:
Expand Down

0 comments on commit 8746c6c

Please sign in to comment.