Commit 2920516b authored by Matthew Auld's avatar Matthew Auld Committed by Chris Wilson

drm/i915: be more solid in checking the alignment

The alignment is u64, and yet is_power_of_2() assumes unsigned long,
which might give different results between 32b and 64b kernel.
Signed-off-by: default avatarMatthew Auld <matthew.auld@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Link: https://patchwork.freedesktop.org/patch/msgid/20200305203534.210466-1-matthew.auld@intel.com
Cc: stable@vger.kernel.org
parent 64dc802a
...@@ -430,7 +430,8 @@ eb_validate_vma(struct i915_execbuffer *eb, ...@@ -430,7 +430,8 @@ eb_validate_vma(struct i915_execbuffer *eb,
if (unlikely(entry->flags & eb->invalid_flags)) if (unlikely(entry->flags & eb->invalid_flags))
return -EINVAL; return -EINVAL;
if (unlikely(entry->alignment && !is_power_of_2(entry->alignment))) if (unlikely(entry->alignment &&
!is_power_of_2_u64(entry->alignment)))
return -EINVAL; return -EINVAL;
/* /*
......
...@@ -236,6 +236,11 @@ static inline u64 ptr_to_u64(const void *ptr) ...@@ -236,6 +236,11 @@ static inline u64 ptr_to_u64(const void *ptr)
__idx; \ __idx; \
}) })
static inline bool is_power_of_2_u64(u64 n)
{
return (n != 0 && ((n & (n - 1)) == 0));
}
static inline void __list_del_many(struct list_head *head, static inline void __list_del_many(struct list_head *head,
struct list_head *first) struct list_head *first)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment