summaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
authorMatthew Auld <matthew.auld@intel.com>2024-02-19 12:18:53 +0000
committerSasha Levin <sashal@kernel.org>2024-03-26 18:17:55 -0400
commit8d0eab76ae55ff4273695807be28f0bf829c401c (patch)
tree5c20414b63b47c5c543d7527a34fb7567750decc /drivers/gpu
parent40a56d26d5702bac309542e208c1a4e2f95b2c66 (diff)
downloadlinux-stable-8d0eab76ae55ff4273695807be28f0bf829c401c.tar.gz
linux-stable-8d0eab76ae55ff4273695807be28f0bf829c401c.tar.bz2
linux-stable-8d0eab76ae55ff4273695807be28f0bf829c401c.zip
drm/buddy: check range allocation matches alignment
[ Upstream commit 2986314aa811c8a23aeb292edd30315495d54966 ] Likely not a big deal for real users, but for consistency we should respect the min_page_size here. Main issue is that bias allocations turns into normal range allocation if the range and size matches exactly, and in the next patch we want to add some unit tests for this part of the api. Signed-off-by: Matthew Auld <matthew.auld@intel.com> Cc: Arunpravin Paneer Selvam <Arunpravin.PaneerSelvam@amd.com> Cc: Christian König <christian.koenig@amd.com> Reviewed-by: Arunpravin Paneer Selvam <Arunpravin.PaneerSelvam@amd.com> Link: https://patchwork.freedesktop.org/patch/msgid/20240219121851.25774-5-matthew.auld@intel.com Signed-off-by: Christian König <christian.koenig@amd.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/drm_buddy.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/gpu/drm/drm_buddy.c b/drivers/gpu/drm/drm_buddy.c
index f3a6ac908f81..5ebdd6f8f36e 100644
--- a/drivers/gpu/drm/drm_buddy.c
+++ b/drivers/gpu/drm/drm_buddy.c
@@ -771,8 +771,12 @@ int drm_buddy_alloc_blocks(struct drm_buddy *mm,
return -EINVAL;
/* Actual range allocation */
- if (start + size == end)
+ if (start + size == end) {
+ if (!IS_ALIGNED(start | end, min_block_size))
+ return -EINVAL;
+
return __drm_buddy_alloc_range(mm, start, size, NULL, blocks);
+ }
original_size = size;
original_min_size = min_block_size;