Skip to content

Commit 2986314

Browse files
matt-auldChristianKoenigAMD
authored andcommitted
drm/buddy: check range allocation matches alignment
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>
1 parent f41900e commit 2986314

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

drivers/gpu/drm/drm_buddy.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -771,8 +771,12 @@ int drm_buddy_alloc_blocks(struct drm_buddy *mm,
771771
return -EINVAL;
772772

773773
/* Actual range allocation */
774-
if (start + size == end)
774+
if (start + size == end) {
775+
if (!IS_ALIGNED(start | end, min_block_size))
776+
return -EINVAL;
777+
775778
return __drm_buddy_alloc_range(mm, start, size, NULL, blocks);
779+
}
776780

777781
original_size = size;
778782
original_min_size = min_block_size;

0 commit comments

Comments
 (0)