scan->mm = mm;
+ if (alignment <= 1)
+ alignment = 0;
+
scan->color = color;
scan->alignment = alignment;
+ scan->remainder_mask = is_power_of_2(alignment) ? alignment - 1 : 0;
scan->size = size;
scan->flags = flags;
if (scan->alignment) {
u64 rem;
- div64_u64_rem(adj_start, scan->alignment, &rem);
+ if (likely(scan->remainder_mask))
+ rem = adj_start & scan->remainder_mask;
+ else
+ div64_u64_rem(adj_start, scan->alignment, &rem);
if (rem) {
adj_start -= rem;
if (scan->flags != DRM_MM_CREATE_TOP)
u64 size;
u64 alignment;
+ u64 remainder_mask;
u64 range_start;
u64 range_end;