drm/i915/gtt: Allow >= 4GB offsets in X86_32
Subsystems (2)
PATCH 1/4 drm/i915/gtt: Allow >= 4GB offsets in X86_32
Similar to commit c44ef60e437019b8ca1dab8b4d2e8761fd4ce1e9 ("drm/i915/gtt:
Allow >= 4GB sizes for vm"), i915_gem_obj_offset and i915_gem_obj_ggtt_offset return an unsigned long, which in only 4-bytes long in 32-bit kernels.
Change return type (and other related offset variables) to u64.
Since Global GTT is always limited to 4GB, this change would not be required in i915_gem_obj_ggtt_offset, but this is done for consistency.
v2: Remove unnecessary offset variable in do_pin, as we already have
vma->node.start (Chris).
Update GGTT offset too (Tvrtko).
--- drivers/gpu/drm/i915/i915_drv.h | 12 +++++------- drivers/gpu/drm/i915/i915_gem.c | 18 +++++++----------- drivers/gpu/drm/i915/i915_gem_fence.c | 4 ++-- drivers/gpu/drm/i915/i915_gem_gtt.c | 8 ++++---- drivers/gpu/drm/i915/i915_gem_gtt.h | 2 +- drivers/gpu/drm/i915/intel_fbdev.c | 2 +- 6 files changed, 20 insertions(+), 26 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +5 -7
@@ -2968,13 +2968,11 @@ struct drm_gem_object *i915_gem_prime_import(struct drm_device *dev,struct dma_buf *i915_gem_prime_export (struct drm_device *dev,struct drm_gem_object *gem_obj,int flags); -unsigned long -i915_gem_obj_ggtt_offset_view (struct drm_i915_gem_object *o, -const struct i915_ggtt_view *view); -unsigned long -i915_gem_obj_offset (struct drm_i915_gem_object *o, -struct i915_address_space *vm); -static inline unsigned long +u64 i915_gem_obj_ggtt_offset_view (struct drm_i915_gem_object *o, +const struct i915_ggtt_view *view); +u64 i915_gem_obj_offset (struct drm_i915_gem_object *o, +struct i915_address_space *vm); +static inline u64 i915_gem_obj_ggtt_offset (struct drm_i915_gem_object *o) {return i915_gem_obj_ggtt_offset_view (o, &i915_ggtt_view_normal);
drivers/gpu/drm/i915/i915_gem.c +7 -11
@@ -4225,15 +4225,13 @@ i915_gem_object_do_pin(struct drm_i915_gem_object *obj,return -EBUSY ;if (i915_vma_misplaced (vma, alignment, flags)) { -unsigned long offset; - offset = ggtt_view ?i915_gem_obj_ggtt_offset_view (obj, ggtt_view) : -i915_gem_obj_offset (obj, vm);WARN (vma->pin_count,"bo is already pinned in %s with incorrect alignment:" -" offset=%lx, req.alignment=%x, req.map_and_fenceable=%d," +" offset=%08x %08x, req.alignment=%x, req.map_and_fenceable=%d," " obj->map_and_fenceable=%d\n" , ggtt_view ?"ggtt" :"ppgtt" , - offset, +upper_32_bits (vma->node.start), +lower_32_bits (vma->node.start), alignment, !!(flags &PIN_MAPPABLE ), obj->map_and_fenceable);
@@ -5188,9 +5186,8 @@ void i915_gem_track_fb(struct drm_i915_gem_object *old, }/* All the new VM stuff */ -unsigned long -i915_gem_obj_offset (struct drm_i915_gem_object *o, -struct i915_address_space *vm) +u64 i915_gem_obj_offset (struct drm_i915_gem_object *o, +struct i915_address_space *vm) {struct drm_i915_private *dev_priv = o->base.dev->dev_private;struct i915_vma *vma;
@@ -5210,9 +5207,8 @@ i915_gem_obj_offset(struct drm_i915_gem_object *o,return -1 ; } -unsigned long -i915_gem_obj_ggtt_offset_view (struct drm_i915_gem_object *o, -const struct i915_ggtt_view *view) +u64 i915_gem_obj_ggtt_offset_view (struct drm_i915_gem_object *o, +const struct i915_ggtt_view *view) {struct i915_address_space *ggtt =i915_obj_to_ggtt (o);struct i915_vma *vma;
drivers/gpu/drm/i915/i915_gem_fence.c +2 -2
@@ -128,7 +128,7 @@ static void i915_write_fence_reg(struct drm_device *dev, int reg,WARN ((i915_gem_obj_ggtt_offset (obj) & ~I915_FENCE_START_MASK ) || (size & -size) != size || (i915_gem_obj_ggtt_offset (obj) & (size -1 )), -"object 0x%08lx [fenceable? %d] not 1M or pot-size (0x%08x) aligned\n" , +"object 0x%08llx [fenceable? %d] not 1M or pot-size (0x%08x) aligned\n" ,i915_gem_obj_ggtt_offset (obj), obj->map_and_fenceable, size);if (obj->tiling_mode ==I915_TILING_Y &&HAS_128_BYTE_Y_TILING (dev))
@@ -171,7 +171,7 @@ static void i830_write_fence_reg(struct drm_device *dev, int reg,WARN ((i915_gem_obj_ggtt_offset (obj) & ~I830_FENCE_START_MASK ) || (size & -size) != size || (i915_gem_obj_ggtt_offset (obj) & (size -1 )), -"object 0x%08lx not 512K or pot-size 0x%08x aligned\n" , +"object 0x%08llx not 512K or pot-size 0x%08x aligned\n" ,i915_gem_obj_ggtt_offset (obj), size); pitch_val = obj->stride /128 ;
drivers/gpu/drm/i915/i915_gem_gtt.c +4 -4
@@ -2558,9 +2558,9 @@ static void i915_gtt_color_adjust(struct drm_mm_node *node, }static int i915_gem_setup_global_gtt (struct drm_device *dev, -unsigned long start, -unsigned long mappable_end, -unsigned long end) +u64 start, +u64 mappable_end, +u64 end) {/* Let GEM Manage all of the aperture. *
@@ -2599,7 +2599,7 @@ static int i915_gem_setup_global_gtt(struct drm_device *dev,list_for_each_entry (obj, &dev_priv->mm.bound_list, global_list) {struct i915_vma *vma =i915_gem_obj_to_vma (obj, ggtt_vm); -DRM_DEBUG_KMS ("reserving preallocated space: %lx + %zx\n" , +DRM_DEBUG_KMS ("reserving preallocated space: %llx + %zx\n" ,i915_gem_obj_ggtt_offset (obj), obj->base.size);WARN_ON (i915_gem_obj_ggtt_bound (obj));
drivers/gpu/drm/i915/i915_gem_gtt.h +1 -1
@@ -149,7 +149,7 @@ struct i915_ggtt_view {union {struct { -unsigned long offset; +u64 offset;unsigned int size; } partial; } params;
drivers/gpu/drm/i915/intel_fbdev.c +1 -1
@@ -263,7 +263,7 @@ static int intelfb_create(struct drm_fb_helper *helper,/* Use default scratch pixmap (info->pixmap.flags = FB_PIXMAP_SYSTEM) */ -DRM_DEBUG_KMS ("allocated %dx%d fb: 0x%08lx, bo %p\n" , +DRM_DEBUG_KMS ("allocated %dx%d fb: 0x%08llx, bo %p\n" , fb->width, fb->height,i915_gem_obj_ggtt_offset (obj), obj);
Signature · 6 lines
2.5.0 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/4 drm/i915: Use complete virtual address range on 32-bit platforms
With the offset length being taken care of in ("drm/i915/gtt: Allow >= 4GB offsets in X86_32"), the code should be finally safe in 32-bit kernels.
This reverts commit 501fd70fcaebc911b6b96a7b331e6960e5af67e7
Author: Michel Thierry <[email protected]> Date: Fri May 29 14:15:05 2015 +0100
drm/i915: limit PPGTT size to 2GB in 32-bit platforms
--- drivers/gpu/drm/i915/i915_gem_gtt.c | 8 -------- 1 file changed, 8 deletions(-)
drivers/gpu/drm/i915/i915_gem_gtt.c +0 -8
@@ -1495,14 +1495,6 @@ static int gen8_ppgtt_init(struct i915_hw_ppgtt *ppgtt) goto free_scratch; ppgtt->base.total =1ULL <<32 ; -if (IS_ENABLED (CONFIG_X86_32 )) -/* While we have a proliferation of size_t variables -* we cannot represent the full ppgtt size on 32bit, -* so limit it to the same size as the GGTT (currently -* 2GiB). -*/ - ppgtt->base.total =to_i915 (ppgtt->base.dev)->gtt.base.total; - ppgtt->switch_mm = gen8_legacy_mm_switch; trace_i915_page_directory_pointer_entry_alloc(&ppgtt->base, 0, 0,
Signature · 6 lines
2.5.0 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 2/4] drm/i915: Use complete virtual address range on 32-bit platforms
Quoted 11 lines · Michel Thierry
With the offset length being taken care of in ("drm/i915/gtt: Allow >= 4GB offsets in
X86_32"), the code should be finally safe in 32-bit kernels.This reverts commit
501fd70fcaebc911b6b96a7b331e6960e5af67e7Author: Michel Thierry <[email protected]> Date: Fri May 29 14:15:05 2015 +0100drm/i915: limit PPGTT size to 2GB in 32-bit platforms
Signed-off-by Michel Thierry <[email protected]>
I think we should be safe....
The biggest problem is that who do have testing 32bit gen8+? -Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 3/4 drm/i915: Always pass dev pointer in pdp_init
In reply to Michel ThierryAnd fix 0-DAY kernel test infrastructure warning.
--- drivers/gpu/drm/i915/i915_gem_gtt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_gem_gtt.c +1 -1
@@ -1490,7 +1490,7 @@ static int gen8_ppgtt_init(struct i915_hw_ppgtt *ppgtt) ppgtt->base.total =1ULL <<48 ; ppgtt->switch_mm = gen8_48b_mm_switch; }else { - ret =__pdp_init (false, &ppgtt->pdp); + ret =__pdp_init (ppgtt->base.dev, &ppgtt->pdp);if (ret) goto free_scratch;
Signature · 6 lines
2.5.0 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 3/4] drm/i915: Always pass dev pointer in pdp_init
Quoted 4 lines · Michel Thierry
And fix 0-DAY kernel test infrastructure warning.
Reported-by Fengguang Wu <[email protected]>Signed-off-by Michel Thierry <[email protected]>
Nah, for extra credit, pass NULL!
Not that this needs a r-b,
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 4/4 drm/i915/ppgtt: Abstract 4lvl and legacy functions
In reply to Michel ThierryCleanup, allocate, insert, clear and dump functions were already vfuncs, this patch now point them to the 4-level (48-bit) or legacy (32-bit) versions.
This removes unnecessary checks of which ppgtt is in use, as it now only happens once, in ppgtt_init.
--- drivers/gpu/drm/i915/i915_gem_gtt.c | 253 ++++++++++++++++++++++-------------- 1 file changed, 153 insertions(+), 100 deletions(-)
drivers/gpu/drm/i915/i915_gem_gtt.c +153 -100
@@ -755,28 +755,37 @@ static void gen8_ppgtt_clear_pte_range(struct i915_address_space *vm, } } -static void gen8_ppgtt_clear_range (struct i915_address_space *vm, -uint64_t start, -uint64_t length, -bool use_scratch) +static void gen8_legacy_ppgtt_clear_range (struct i915_address_space *vm, +uint64_t start, +uint64_t length, +bool use_scratch) {struct i915_hw_ppgtt *ppgtt = container_of(vm, struct i915_hw_ppgtt, base);gen8_pte_t scratch_pte =gen8_pte_encode (px_dma (vm->scratch_page),I915_CACHE_LLC , use_scratch); -if (!USES_FULL_48BIT_PPGTT (vm->dev)) { -gen8_ppgtt_clear_pte_range (vm, &ppgtt->pdp, start, length, - scratch_pte); - }else { -uint64_t templ4, pml4e; -struct i915_page_directory_pointer *pdp; +gen8_ppgtt_clear_pte_range (vm, &ppgtt->pdp, start, length, + scratch_pte); +} -gen8_for_each_pml4e (pdp, &ppgtt->pml4, start, length, templ4, pml4e) { -gen8_ppgtt_clear_pte_range (vm, pdp, start, length, - scratch_pte); - } +static void gen8_4lvl_ppgtt_clear_range (struct i915_address_space *vm, +uint64_t start, +uint64_t length, +bool use_scratch) +{ +struct i915_hw_ppgtt *ppgtt = + container_of(vm, struct i915_hw_ppgtt, base); +struct i915_page_directory_pointer *pdp; +uint64_t templ4, pml4e; +gen8_pte_t scratch_pte =gen8_pte_encode (px_dma (vm->scratch_page), +I915_CACHE_LLC , use_scratch); + +gen8_for_each_pml4e (pdp, &ppgtt->pml4, start, length, templ4, pml4e) { +gen8_ppgtt_clear_pte_range (vm, pdp, start, length, + scratch_pte); } + } static void
@@ -821,11 +830,11 @@ gen8_ppgtt_insert_pte_entries(struct i915_address_space *vm,kunmap_px (ppgtt, pt_vaddr); } -static void gen8_ppgtt_insert_entries (struct i915_address_space *vm, -struct sg_table *pages, -uint64_t start, -enum i915_cache_level cache_level, -u32 unused) +static void gen8_legacy_ppgtt_insert_entries (struct i915_address_space *vm, +struct sg_table *pages, +uint64_t start, +enum i915_cache_level cache_level, +u32 unused) {struct i915_hw_ppgtt *ppgtt = container_of(vm, struct i915_hw_ppgtt, base);
@@ -833,18 +842,28 @@ static void gen8_ppgtt_insert_entries(struct i915_address_space *vm,__sg_page_iter_start (&sg_iter, pages->sgl,sg_nents (pages->sgl),0 ); -if (!USES_FULL_48BIT_PPGTT (vm->dev)) { -gen8_ppgtt_insert_pte_entries (vm, &ppgtt->pdp, &sg_iter, start, - cache_level); - }else { -struct i915_page_directory_pointer *pdp; -uint64_t templ4, pml4e; -uint64_t length = (uint64_t )pages->orig_nents <<PAGE_SHIFT ; +gen8_ppgtt_insert_pte_entries (vm, &ppgtt->pdp, &sg_iter, start, + cache_level); +} -gen8_for_each_pml4e (pdp, &ppgtt->pml4, start, length, templ4, pml4e) { -gen8_ppgtt_insert_pte_entries (vm, pdp, &sg_iter, - start, cache_level); - } +static void gen8_4lvl_ppgtt_insert_entries (struct i915_address_space *vm, +struct sg_table *pages, +uint64_t start, +enum i915_cache_level cache_level, +u32 unused) +{ +struct i915_hw_ppgtt *ppgtt = + container_of(vm, struct i915_hw_ppgtt, base); +struct i915_page_directory_pointer *pdp; +struct sg_page_iter sg_iter; +uint64_t templ4, pml4e; +uint64_t length = (uint64_t )pages->orig_nents <<PAGE_SHIFT ; + +__sg_page_iter_start (&sg_iter, pages->sgl,sg_nents (pages->sgl),0 ); + +gen8_for_each_pml4e (pdp, &ppgtt->pml4, start, length, templ4, pml4e) { +gen8_ppgtt_insert_pte_entries (vm, pdp, &sg_iter, + start, cache_level); } }
@@ -915,7 +934,7 @@ static void gen8_free_scratch(struct i915_address_space *vm)free_scratch_page (dev, vm->scratch_page); } -static void gen8_ppgtt_cleanup_3lvl (struct drm_device *dev, +static void gen8_3lvl_ppgtt_cleanup (struct drm_device *dev,struct i915_page_directory_pointer *pdp) {int i;
@@ -931,30 +950,29 @@ static void gen8_ppgtt_cleanup_3lvl(struct drm_device *dev,free_pdp (dev, pdp); } -static void gen8_ppgtt_cleanup_4lvl (struct i915_hw_ppgtt *ppgtt) +static void gen8_legacy_ppgtt_cleanup (struct i915_address_space *vm) { +struct i915_hw_ppgtt *ppgtt = + container_of(vm, struct i915_hw_ppgtt, base); + +gen8_3lvl_ppgtt_cleanup (ppgtt->base.dev, &ppgtt->pdp); +gen8_free_scratch (vm); +} + +static void gen8_4lvl_ppgtt_cleanup (struct i915_address_space *vm) +{ +struct i915_hw_ppgtt *ppgtt = + container_of(vm, struct i915_hw_ppgtt, base);int i;for_each_set_bit (i, ppgtt->pml4.used_pml4es,GEN8_PML4ES_PER_PML4 ) {if (WARN_ON (!ppgtt->pml4.pdps[i]))continue ; -gen8_ppgtt_cleanup_3lvl (ppgtt->base.dev, ppgtt->pml4.pdps[i]); +gen8_3lvl_ppgtt_cleanup (ppgtt->base.dev, ppgtt->pml4.pdps[i]); }cleanup_px (ppgtt->base.dev, &ppgtt->pml4); -} - -static void gen8_ppgtt_cleanup (struct i915_address_space *vm) -{ -struct i915_hw_ppgtt *ppgtt = - container_of(vm, struct i915_hw_ppgtt, base); - -if (!USES_FULL_48BIT_PPGTT (ppgtt->base.dev)) -gen8_ppgtt_cleanup_3lvl (ppgtt->base.dev, &ppgtt->pdp); -else -gen8_ppgtt_cleanup_4lvl (ppgtt); -gen8_free_scratch (vm); }
@@ -1191,7 +1209,7 @@ static void mark_tlbs_dirty(struct i915_hw_ppgtt *ppgtt) ppgtt->pd_dirty_rings =INTEL_INFO (ppgtt->base.dev)->ring_mask; } -static int gen8_alloc_va_range_3lvl (struct i915_address_space *vm, +static int gen8_3lvl_alloc_va_range (struct i915_address_space *vm,struct i915_page_directory_pointer *pdp,uint64_t start,uint64_t length)
@@ -1311,14 +1329,23 @@ err_out:return ret; } -static int gen8_alloc_va_range_4lvl (struct i915_address_space *vm, -struct i915_pml4 *pml4, +static int gen8_legacy_alloc_va_range (struct i915_address_space *vm, +uint64_t start,uint64_t length) +{ +struct i915_hw_ppgtt *ppgtt = + container_of(vm, struct i915_hw_ppgtt, base); + +return gen8_3lvl_alloc_va_range (vm, &ppgtt->pdp, start, length); +} + +static int gen8_4lvl_alloc_va_range (struct i915_address_space *vm,uint64_t start,uint64_t length) {DECLARE_BITMAP (new_pdps,GEN8_PML4ES_PER_PML4 );struct i915_hw_ppgtt *ppgtt = container_of(vm, struct i915_hw_ppgtt, base); +struct i915_pml4 *pml4 = &ppgtt->pml4;struct i915_page_directory_pointer *pdp;uint64_t temp, pml4e;int ret =0 ;
@@ -1342,7 +1369,7 @@ static int gen8_alloc_va_range_4lvl(struct i915_address_space *vm,gen8_for_each_pml4e (pdp, pml4, start, length, temp, pml4e) {WARN_ON (!pdp); - ret =gen8_alloc_va_range_3lvl (vm, pdp, start, length); + ret =gen8_3lvl_alloc_va_range (vm, pdp, start, length);if (ret) goto err_out;
@@ -1356,24 +1383,12 @@ static int gen8_alloc_va_range_4lvl(struct i915_address_space *vm, err_out:for_each_set_bit (pml4e, new_pdps,GEN8_PML4ES_PER_PML4 ) -gen8_ppgtt_cleanup_3lvl (vm->dev, pml4->pdps[pml4e]); +gen8_3lvl_ppgtt_cleanup (vm->dev, pml4->pdps[pml4e]);return ret; } -static int gen8_alloc_va_range (struct i915_address_space *vm, -uint64_t start,uint64_t length) -{ -struct i915_hw_ppgtt *ppgtt = - container_of(vm, struct i915_hw_ppgtt, base); - -if (USES_FULL_48BIT_PPGTT (vm->dev)) -return gen8_alloc_va_range_4lvl (vm, &ppgtt->pml4, start, length); -else -return gen8_alloc_va_range_3lvl (vm, &ppgtt->pdp, start, length); -} - -static void gen8_dump_pdp (struct i915_page_directory_pointer *pdp, +static void gen8_pdp_dump (struct i915_page_directory_pointer *pdp,uint64_t start,uint64_t length,gen8_pte_t scratch_pte,struct seq_file *m)
@@ -1431,7 +1446,8 @@ static void gen8_dump_pdp(struct i915_page_directory_pointer *pdp, } } -static void gen8_dump_ppgtt (struct i915_hw_ppgtt *ppgtt,struct seq_file *m) +static void gen8_legacy_ppgtt_dump (struct i915_hw_ppgtt *ppgtt, +struct seq_file *m) {struct i915_address_space *vm = &ppgtt->base;uint64_t start = ppgtt->base.start;
@@ -1439,20 +1455,27 @@ static void gen8_dump_ppgtt(struct i915_hw_ppgtt *ppgtt, struct seq_file *m)gen8_pte_t scratch_pte =gen8_pte_encode (px_dma (vm->scratch_page),I915_CACHE_LLC , true); -if (!USES_FULL_48BIT_PPGTT (vm->dev)) { -gen8_dump_pdp (&ppgtt->pdp, start, length, scratch_pte, m); - }else { -uint64_t templ4, pml4e; -struct i915_pml4 *pml4 = &ppgtt->pml4; -struct i915_page_directory_pointer *pdp; +gen8_pdp_dump (&ppgtt->pdp, start, length, scratch_pte, m); +} -gen8_for_each_pml4e (pdp, pml4, start, length, templ4, pml4e) { -if (!test_bit (pml4e, pml4->used_pml4es)) -continue ; +static void gen8_4lvl_ppgtt_dump (struct i915_hw_ppgtt *ppgtt, +struct seq_file *m) +{ +struct i915_address_space *vm = &ppgtt->base; +uint64_t start = ppgtt->base.start; +uint64_t length = ppgtt->base.total; +uint64_t templ4, pml4e; +struct i915_pml4 *pml4 = &ppgtt->pml4; +struct i915_page_directory_pointer *pdp; +gen8_pte_t scratch_pte =gen8_pte_encode (px_dma (vm->scratch_page), +I915_CACHE_LLC , true); -seq_printf (m," PML4E #%llu\n" , pml4e); -gen8_dump_pdp (pdp, start, length, scratch_pte, m); - } +gen8_for_each_pml4e (pdp, pml4, start, length, templ4, pml4e) { +if (!test_bit (pml4e, pml4->used_pml4es)) +continue ; + +seq_printf (m," PML4E #%llu\n" , pml4e); +gen8_pdp_dump (pdp, start, length, scratch_pte, m); } }
@@ -1463,7 +1486,7 @@ static void gen8_dump_ppgtt(struct i915_hw_ppgtt *ppgtt, struct seq_file *m)* space. * */ -static int gen8_ppgtt_init (struct i915_hw_ppgtt *ppgtt) +static int gen8_legacy_ppgtt_init (struct i915_hw_ppgtt *ppgtt) {int ret;
@@ -1472,34 +1495,62 @@ static int gen8_ppgtt_init(struct i915_hw_ppgtt *ppgtt)return ret; ppgtt->base.start =0 ; - ppgtt->base.cleanup = gen8_ppgtt_cleanup; - ppgtt->base.allocate_va_range = gen8_alloc_va_range; - ppgtt->base.insert_entries = gen8_ppgtt_insert_entries; - ppgtt->base.clear_range = gen8_ppgtt_clear_range; + ppgtt->base.total =1ULL <<32 ; + ppgtt->switch_mm = gen8_legacy_mm_switch; + ppgtt->base.cleanup = gen8_legacy_ppgtt_cleanup; + ppgtt->base.allocate_va_range = gen8_legacy_alloc_va_range; + ppgtt->base.insert_entries = gen8_legacy_ppgtt_insert_entries; + ppgtt->base.clear_range = gen8_legacy_ppgtt_clear_range; + ppgtt->debug_dump = gen8_legacy_ppgtt_dump; ppgtt->base.unbind_vma = ppgtt_unbind_vma; ppgtt->base.bind_vma = ppgtt_bind_vma; - ppgtt->debug_dump = gen8_dump_ppgtt; -if (USES_FULL_48BIT_PPGTT (ppgtt->base.dev)) { - ret =setup_px (ppgtt->base.dev, &ppgtt->pml4); -if (ret) - goto free_scratch; + ret =__pdp_init (ppgtt->base.dev, &ppgtt->pdp); +if (ret) + goto free_scratch; -gen8_initialize_pml4 (&ppgtt->base, &ppgtt->pml4); +trace_i915_page_directory_pointer_entry_alloc (&ppgtt->base, +0 ,0 , +GEN8_PML4E_SHIFT ); - ppgtt->base.total =1ULL <<48 ; - ppgtt->switch_mm = gen8_48b_mm_switch; - }else { - ret =__pdp_init (ppgtt->base.dev, &ppgtt->pdp); -if (ret) - goto free_scratch; +return 0 ; - ppgtt->base.total =1ULL <<32 ; - ppgtt->switch_mm = gen8_legacy_mm_switch; -trace_i915_page_directory_pointer_entry_alloc (&ppgtt->base, -0 ,0 , -GEN8_PML4E_SHIFT ); - } +free_scratch: +gen8_free_scratch (&ppgtt->base); +return ret; +} + +/* +* GEN8 48-bit ppgtt programming is accomplished through 512 PDP registers +* per PML4, with a net effect resembling a 4-level page table in normal +* x86-64 terms. Each PDP represents 1GB of memory 512 * 512 * 512 * 512 * 4096 +* = 256TB 48b address space. +* +*/ +static int gen8_4lvl_ppgtt_init (struct i915_hw_ppgtt *ppgtt) +{ +int ret; + + ret =gen8_init_scratch (&ppgtt->base); +if (ret) +return ret; + + ppgtt->base.start =0 ; + ppgtt->base.total =1ULL <<48 ; + ppgtt->switch_mm = gen8_48b_mm_switch; + ppgtt->base.cleanup = gen8_4lvl_ppgtt_cleanup; + ppgtt->base.allocate_va_range = gen8_4lvl_alloc_va_range; + ppgtt->base.insert_entries = gen8_4lvl_ppgtt_insert_entries; + ppgtt->base.clear_range = gen8_4lvl_ppgtt_clear_range; + ppgtt->debug_dump = gen8_4lvl_ppgtt_dump; + ppgtt->base.unbind_vma = ppgtt_unbind_vma; + ppgtt->base.bind_vma = ppgtt_bind_vma; + + ret =setup_px (ppgtt->base.dev, &ppgtt->pml4); +if (ret) + goto free_scratch; + +gen8_initialize_pml4 (&ppgtt->base, &ppgtt->pml4);return 0 ;
@@ -2071,8 +2122,10 @@ static int __hw_ppgtt_init(struct drm_device *dev, struct i915_hw_ppgtt *ppgtt)if (INTEL_INFO (dev)->gen <8 )return gen6_ppgtt_init (ppgtt); +else if (!USES_FULL_48BIT_PPGTT (ppgtt->base.dev)) +return gen8_legacy_ppgtt_init (ppgtt);else -return gen8_ppgtt_init (ppgtt); +return gen8_4lvl_ppgtt_init (ppgtt); }int i915_ppgtt_init (struct drm_device *dev,struct i915_hw_ppgtt *ppgtt)
Signature · 6 lines
2.5.0 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 9 lines · Michel Thierry
Similar to commit
c44ef60e437019b8ca1dab8b4d2e8761fd4ce1e9("drm/i915/gtt:
Allow >= 4GB sizes for vm"),i915_gem_obj_offsetandi915_gem_obj_ggtt_offsetreturn an unsigned long, which in only 4-bytes long in 32-bit kernels.Change return type (and other related offset variables) to u64.
Since Global GTT is always limited to 4GB, this change would not be required in
i915_gem_obj_ggtt_offset, but this is done for consistency.
Quoted 8 lines
v2: Remove unnecessary offset variable in
do_pin, as we already have
vma->node.start(Chris).
Update GGTT offset too (Tvrtko).Cc Chris Wilson <[email protected]>Cc Daniel Vetter <[email protected]>Cc Tvrtko Ursulin <[email protected]>Signed-off-by Michel Thierry <[email protected]>
There are a few more places where we use ggtt_offset() and ggtt_bound() when we already have the vma, but they are only in the context of this patch and not the meat. They just make me cringe.
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx