diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2016-12-22 08:36:24 +0000 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2016-12-27 14:16:58 +0100 |
commit | 7173320758e5dfcd7a47a51d3fe2b21c43d9633c (patch) | |
tree | 60d0279dbbccea268131e4e4e72f84bfa9782d29 /drivers/gpu | |
parent | d1bac3a78111c82befc8c8fc185b2d90a64ed4b6 (diff) | |
download | linux-7173320758e5dfcd7a47a51d3fe2b21c43d9633c.tar.bz2 |
drm: Promote drm_mm alignment to u64
In places (e.g. i915.ko), the alignment is exported to userspace as u64
and there now exists hardware for which we can indeed utilize a u64
alignment. As such, we need to keep 64bit integers throughout when
handling alignment.
Testcase: igt/drm_mm/align64
Testcase: igt/gem_exec_alignment
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Christian König <christian.koenig@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161222083641.2691-22-chris@chris-wilson.co.uk
Diffstat (limited to 'drivers/gpu')
-rw-r--r-- | drivers/gpu/drm/drm_mm.c | 37 | ||||
-rw-r--r-- | drivers/gpu/drm/selftests/test-drm_mm.c | 4 |
2 files changed, 19 insertions, 22 deletions
diff --git a/drivers/gpu/drm/drm_mm.c b/drivers/gpu/drm/drm_mm.c index 9756542abe4c..fd2667052c73 100644 --- a/drivers/gpu/drm/drm_mm.c +++ b/drivers/gpu/drm/drm_mm.c @@ -93,12 +93,12 @@ static struct drm_mm_node *drm_mm_search_free_generic(const struct drm_mm *mm, u64 size, - unsigned alignment, + u64 alignment, unsigned long color, enum drm_mm_search_flags flags); static struct drm_mm_node *drm_mm_search_free_in_range_generic(const struct drm_mm *mm, u64 size, - unsigned alignment, + u64 alignment, unsigned long color, u64 start, u64 end, @@ -227,7 +227,7 @@ static void drm_mm_interval_tree_add_node(struct drm_mm_node *hole_node, static void drm_mm_insert_helper(struct drm_mm_node *hole_node, struct drm_mm_node *node, - u64 size, unsigned alignment, + u64 size, u64 alignment, unsigned long color, enum drm_mm_allocator_flags flags) { @@ -246,10 +246,9 @@ static void drm_mm_insert_helper(struct drm_mm_node *hole_node, adj_start = adj_end - size; if (alignment) { - u64 tmp = adj_start; - unsigned rem; + u64 rem; - rem = do_div(tmp, alignment); + div64_u64_rem(adj_start, alignment, &rem); if (rem) { if (flags & DRM_MM_CREATE_TOP) adj_start -= rem; @@ -376,7 +375,7 @@ EXPORT_SYMBOL(drm_mm_reserve_node); * 0 on success, -ENOSPC if there's no suitable hole. */ int drm_mm_insert_node_generic(struct drm_mm *mm, struct drm_mm_node *node, - u64 size, unsigned alignment, + u64 size, u64 alignment, unsigned long color, enum drm_mm_search_flags sflags, enum drm_mm_allocator_flags aflags) @@ -398,7 +397,7 @@ EXPORT_SYMBOL(drm_mm_insert_node_generic); static void drm_mm_insert_helper_range(struct drm_mm_node *hole_node, struct drm_mm_node *node, - u64 size, unsigned alignment, + u64 size, u64 alignment, unsigned long color, u64 start, u64 end, enum drm_mm_allocator_flags flags) @@ -423,10 +422,9 @@ static void drm_mm_insert_helper_range(struct drm_mm_node *hole_node, adj_start = adj_end - size; if (alignment) { - u64 tmp = adj_start; - unsigned rem; + u64 rem; - rem = do_div(tmp, alignment); + div64_u64_rem(adj_start, alignment, &rem); if (rem) { if (flags & DRM_MM_CREATE_TOP) adj_start -= rem; @@ -482,7 +480,7 @@ static void drm_mm_insert_helper_range(struct drm_mm_node *hole_node, * 0 on success, -ENOSPC if there's no suitable hole. */ int drm_mm_insert_node_in_range_generic(struct drm_mm *mm, struct drm_mm_node *node, - u64 size, unsigned alignment, + u64 size, u64 alignment, unsigned long color, u64 start, u64 end, enum drm_mm_search_flags sflags, @@ -548,16 +546,15 @@ void drm_mm_remove_node(struct drm_mm_node *node) } EXPORT_SYMBOL(drm_mm_remove_node); -static int check_free_hole(u64 start, u64 end, u64 size, unsigned alignment) +static int check_free_hole(u64 start, u64 end, u64 size, u64 alignment) { if (end - start < size) return 0; if (alignment) { - u64 tmp = start; - unsigned rem; + u64 rem; - rem = do_div(tmp, alignment); + div64_u64_rem(start, alignment, &rem); if (rem) start += alignment - rem; } @@ -567,7 +564,7 @@ static int check_free_hole(u64 start, u64 end, u64 size, unsigned alignment) static struct drm_mm_node *drm_mm_search_free_generic(const struct drm_mm *mm, u64 size, - unsigned alignment, + u64 alignment, unsigned long color, enum drm_mm_search_flags flags) { @@ -609,7 +606,7 @@ static struct drm_mm_node *drm_mm_search_free_generic(const struct drm_mm *mm, static struct drm_mm_node *drm_mm_search_free_in_range_generic(const struct drm_mm *mm, u64 size, - unsigned alignment, + u64 alignment, unsigned long color, u64 start, u64 end, @@ -729,7 +726,7 @@ EXPORT_SYMBOL(drm_mm_replace_node); */ void drm_mm_init_scan(struct drm_mm *mm, u64 size, - unsigned alignment, + u64 alignment, unsigned long color) { mm->scan_color = color; @@ -762,7 +759,7 @@ EXPORT_SYMBOL(drm_mm_init_scan); */ void drm_mm_init_scan_with_range(struct drm_mm *mm, u64 size, - unsigned alignment, + u64 alignment, unsigned long color, u64 start, u64 end) diff --git a/drivers/gpu/drm/selftests/test-drm_mm.c b/drivers/gpu/drm/selftests/test-drm_mm.c index fb8f7056225b..e2ed9efb361c 100644 --- a/drivers/gpu/drm/selftests/test-drm_mm.c +++ b/drivers/gpu/drm/selftests/test-drm_mm.c @@ -1116,7 +1116,7 @@ static int igt_align64(void *ignored) static void show_scan(const struct drm_mm *scan) { - pr_info("scan: hit [%llx, %llx], size=%lld, align=%d, color=%ld\n", + pr_info("scan: hit [%llx, %llx], size=%lld, align=%lld, color=%ld\n", scan->scan_hit_start, scan->scan_hit_end, scan->scan_size, scan->scan_alignment, scan->scan_color); } @@ -1178,7 +1178,7 @@ static bool evict_nodes(struct drm_mm *mm, list_del(&e->link); } if (list_empty(evict_list)) { - pr_err("Failed to find eviction: size=%lld [avail=%d], align=%d (color=%lu)\n", + pr_err("Failed to find eviction: size=%lld [avail=%d], align=%lld (color=%lu)\n", mm->scan_size, count, mm->scan_alignment, mm->scan_color); |