Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm: add a check to verify the size alignment

Add a simple check to reject any size not aligned to the
min_page_size.

when size is not aligned to min_page_size, driver module
should handle in their own way either to round_up() the
size value to min_page_size or just to enable WARN_ON().

If we dont handle the alignment properly, we may hit the
following bug, Unigine Heaven has allocation requests for
example required pages are 257 and alignment request is 256.
To allocate the left over 1 page, continues the iteration to
find the order value which is 0 and when it compares with
min_order = 8, triggers the BUG_ON(order < min_order).

v2: add more commit description
v3: remove WARN_ON()

Signed-off-by: Arunpravin Paneer Selvam <Arunpravin.PaneerSelvam@amd.com>
Suggested-by: Matthew Auld <matthew.auld@intel.com>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220411073834.15210-1-Arunpravin.PaneerSelvam@amd.com
Signed-off-by: Christian König <christian.koenig@amd.com>

authored by

Arunpravin Paneer Selvam and committed by
Christian König
5f778760 3870b54e

+3
+3
drivers/gpu/drm/drm_buddy.c
··· 665 665 if (start + size == end) 666 666 return __drm_buddy_alloc_range(mm, start, size, blocks); 667 667 668 + if (!IS_ALIGNED(size, min_page_size)) 669 + return -EINVAL; 670 + 668 671 pages = size >> ilog2(mm->chunk_size); 669 672 order = fls(pages) - 1; 670 673 min_order = ilog2(min_page_size) - ilog2(mm->chunk_size);