Commit 2d05fa16 authored by Rasmus Villemoes's avatar Rasmus Villemoes Committed by Daniel Vetter

drm/i915: Fix comparison bug

->stolen->start has type u64 aka unsigned long long; relying on the
difference (effectively cast to int) for sorting is wrong.

It wouldn't be a problem in practice if the values compared are always
within INT_MAX of each other (so that the difference is actually
representable in an int), but 440fd528 ("drm/mm: Support 4 GiB and
larger ranges") strongly suggests that's not the case.

Note: atm we don't support more than about 1G of stolen, so this is
impossible currenlty.
Signed-off-by: default avatarRasmus Villemoes <linux@rasmusvillemoes.dk>
[danvet: Add note that this is impossible currently.]
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent 120f5d28
......@@ -253,7 +253,11 @@ static int obj_rank_by_stolen(void *priv,
struct drm_i915_gem_object *b =
container_of(B, struct drm_i915_gem_object, obj_exec_link);
return a->stolen->start - b->stolen->start;
if (a->stolen->start < b->stolen->start)
return -1;
if (a->stolen->start > b->stolen->start)
return 1;
return 0;
}
static int i915_gem_stolen_list_info(struct seq_file *m, void *data)
......
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