History

drm/i915/ttm: fix 32b build

Since segment_pages is no longer a compile time constant, it looks the DIV_ROUND_UP(node->size, segment_pages) breaks the 32b build. Simplest is just to use the ULL variant, but really we should need not need more than u32 for the page alignment (also we are limited by that due to the sg->length type), so also make it all u32.

Matthew Auld committed 4 years ago

Commit ced78661 parent 333991c6 files · +15 −13Browse files

Unified · Split

6 files
  1. drivers/gpu/drm/i915/gem/i915_gem_region.c +2 −0
  2. drivers/gpu/drm/i915/gem/i915_gem_ttm.c +1 −1
  3. drivers/gpu/drm/i915/i915_scatterlist.c +8 −8
  4. drivers/gpu/drm/i915/i915_scatterlist.h +2 −2
  5. drivers/gpu/drm/i915/intel_region_ttm.c +1 −1
  6. drivers/gpu/drm/i915/intel_region_ttm.h +1 −1
drivers/gpu/drm/i915/gem/i915_gem_region.c+2−0
@@ -60,6 +60,8 @@ __i915_gem_object_create_region(struct intel_memory_region *mem, · 59 unmodified lines
6060 if (page_size)
6161 default_page_size = page_size;
6262
63+ /* We should be able to fit a page within an sg entry */
64+ GEM_BUG_ON(overflows_type(default_page_size, u32));
6365 GEM_BUG_ON(!is_power_of_2_u64(default_page_size));
6466 GEM_BUG_ON(default_page_size < PAGE_SIZE);
6567
drivers/gpu/drm/i915/gem/i915_gem_ttm.c+1−1
@@ -620,7 +620,7 @@ i915_ttm_resource_get_st(struct drm_i915_gem_object *obj, · 619 unmodified lines
620620 struct ttm_resource *res)
621621 {
622622 struct ttm_buffer_object *bo = i915_gem_to_ttm(obj);
623− u64 page_alignment;
623+ u32 page_alignment;
624624
625625 if (!i915_ttm_gtt_binds_lmem(res))
626626 return i915_ttm_tt_get_st(bo->ttm);
drivers/gpu/drm/i915/i915_scatterlist.c+8−8
@@ -79,10 +79,10 @@ void i915_refct_sgt_init(struct i915_refct_sgt *rsgt, size_t size) · 78 unmodified lines
7979 */
8080 struct i915_refct_sgt *i915_rsgt_from_mm_node(const struct drm_mm_node *node,
8181 u64 region_start,
82− u64 page_alignment)
82+ u32 page_alignment)
8383 {
84− const u64 max_segment = round_down(UINT_MAX, page_alignment);
85− u64 segment_pages = max_segment >> PAGE_SHIFT;
84+ const u32 max_segment = round_down(UINT_MAX, page_alignment);
85+ const u32 segment_pages = max_segment >> PAGE_SHIFT;
8686 u64 block_size, offset, prev_end;
8787 struct i915_refct_sgt *rsgt;
8888 struct sg_table *st;
@@ -96,7 +96,7 @@ struct i915_refct_sgt *i915_rsgt_from_mm_node(const struct drm_mm_node *node, · 7 unmodified lines
9696
9797 i915_refct_sgt_init(rsgt, node->size << PAGE_SHIFT);
9898 st = &rsgt->table;
99− if (sg_alloc_table(st, DIV_ROUND_UP(node->size, segment_pages),
99+ if (sg_alloc_table(st, DIV_ROUND_UP_ULL(node->size, segment_pages),
100100 GFP_KERNEL)) {
101101 i915_refct_sgt_put(rsgt);
102102 return ERR_PTR(-ENOMEM);
@@ -123,7 +123,7 @@ struct i915_refct_sgt *i915_rsgt_from_mm_node(const struct drm_mm_node *node, · 20 unmodified lines
123123 st->nents++;
124124 }
125125
126− len = min(block_size, max_segment - sg->length);
126+ len = min_t(u64, block_size, max_segment - sg->length);
127127 sg->length += len;
128128 sg_dma_len(sg) += len;
129129
@@ -155,11 +155,11 @@ struct i915_refct_sgt *i915_rsgt_from_mm_node(const struct drm_mm_node *node, · 25 unmodified lines
155155 */
156156 struct i915_refct_sgt *i915_rsgt_from_buddy_resource(struct ttm_resource *res,
157157 u64 region_start,
158− u64 page_alignment)
158+ u32 page_alignment)
159159 {
160160 struct i915_ttm_buddy_resource *bman_res = to_ttm_buddy_resource(res);
161161 const u64 size = res->num_pages << PAGE_SHIFT;
162− const u64 max_segment = round_down(UINT_MAX, page_alignment);
162+ const u32 max_segment = round_down(UINT_MAX, page_alignment);
163163 struct drm_buddy *mm = bman_res->mm;
164164 struct list_head *blocks = &bman_res->blocks;
165165 struct drm_buddy_block *block;
@@ -207,7 +207,7 @@ struct i915_refct_sgt *i915_rsgt_from_buddy_resource(struct ttm_resource *res, · 41 unmodified lines
207207 st->nents++;
208208 }
209209
210− len = min(block_size, max_segment - sg->length);
210+ len = min_t(u64, block_size, max_segment - sg->length);
211211 sg->length += len;
212212 sg_dma_len(sg) += len;
213213
drivers/gpu/drm/i915/i915_scatterlist.h+2−2
@@ -214,10 +214,10 @@ void i915_refct_sgt_init(struct i915_refct_sgt *rsgt, size_t size); · 213 unmodified lines
214214
215215 struct i915_refct_sgt *i915_rsgt_from_mm_node(const struct drm_mm_node *node,
216216 u64 region_start,
217− u64 page_alignment);
217+ u32 page_alignment);
218218
219219 struct i915_refct_sgt *i915_rsgt_from_buddy_resource(struct ttm_resource *res,
220220 u64 region_start,
221− u64 page_alignment);
221+ u32 page_alignment);
222222
223223 #endif
drivers/gpu/drm/i915/intel_region_ttm.c+1−1
@@ -163,7 +163,7 @@ int intel_region_ttm_fini(struct intel_memory_region *mem) · 162 unmodified lines
163163 struct i915_refct_sgt *
164164 intel_region_ttm_resource_to_rsgt(struct intel_memory_region *mem,
165165 struct ttm_resource *res,
166− u64 page_alignment)
166+ u32 page_alignment)
167167 {
168168 if (mem->is_range_manager) {
169169 struct ttm_range_mgr_node *range_node =
drivers/gpu/drm/i915/intel_region_ttm.h+1−1
@@ -25,7 +25,7 @@ int intel_region_ttm_fini(struct intel_memory_region *mem); · 24 unmodified lines
2525 struct i915_refct_sgt *
2626 intel_region_ttm_resource_to_rsgt(struct intel_memory_region *mem,
2727 struct ttm_resource *res,
28− u64 page_alignment);
28+ u32 page_alignment);
2929
3030 void intel_region_ttm_resource_free(struct intel_memory_region *mem,
3131 struct ttm_resource *res);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t