Skip to content

Commit

Permalink
drm/buddy: check range allocation matches alignment
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
matt-auld authored and ChristianKoenigAMD committed Feb 28, 2024
1 parent f41900e commit 2986314
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion drivers/gpu/drm/drm_buddy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 2986314

Please sign in to comment.