GTT cleanups, rebased
Subsystems (2)
cover GTT cleanups, rebased
This work sort of led me on the gtt vtable distraction which ended in Daniel doing his own version. I posted these originally about a month ago. I've rebased them on dinq. I'd like to see them get merged since they still help with some other work I'm doing on PPGTT.
Some of this work does conflict a bit with the gtt vtable stuff.
I did a decent amount of testing on the original post, less so on this rebased version.
Ben Widawsky (5):
drm/i915: trivial: kill-agp collateral cleanups
drm/i915: Reclaim GTT space for failed PPGTT
drm/i915: Extract gen6 aliasing ppgtt code
drm/i915: Aliased PPGTT size abstraction
drm/i915: Dynamically calculate dclv
drivers/gpu/drm/i915/i915_debugfs.c | 2 + drivers/gpu/drm/i915/i915_drv.h | 6 +-- drivers/gpu/drm/i915/i915_gem_gtt.c | 101 +++++++++++++++++++++++------------- drivers/gpu/drm/i915/i915_reg.h | 1 - 4 files changed, 71 insertions(+), 39 deletions(-)
Signature · 1 line
1.8.1.1
PATCH 1/5 drm/i915: trivial: kill-agp collateral cleanups
- i915_gem_init_aliasing_ppgtt should now be static
- move i915_gem_init_ppgtt declaration to the right place
--- drivers/gpu/drm/i915/i915_drv.h | 3 +-- drivers/gpu/drm/i915/i915_gem_gtt.c | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -2
@@ -1598,7 +1598,6 @@ int __must_check i915_gem_init(struct drm_device *dev);int __must_check i915_gem_init_hw (struct drm_device *dev);void i915_gem_l3_remap (struct drm_device *dev);void i915_gem_init_swizzling (struct drm_device *dev); -void i915_gem_init_ppgtt (struct drm_device *dev);void i915_gem_cleanup_ringbuffer (struct drm_device *dev);int __must_check i915_gpu_idle (struct drm_device *dev);int __must_check i915_gem_idle (struct drm_device *dev);
@@ -1653,7 +1652,7 @@ int i915_gem_context_destroy_ioctl(struct drm_device *dev, void *data, struct drm_file *file);/* i915_gem_gtt.c */ -int __must_check i915_gem_init_aliasing_ppgtt (struct drm_device *dev); +void i915_gem_init_ppgtt (struct drm_device *dev);void i915_gem_cleanup_aliasing_ppgtt (struct drm_device *dev); void i915_ppgtt_bind_object(struct i915_hw_ppgtt *ppgtt, struct drm_i915_gem_object *obj,
drivers/gpu/drm/i915/i915_gem_gtt.c +1 -1
@@ -108,7 +108,7 @@ static void i915_ppgtt_clear_range(struct i915_hw_ppgtt *ppgtt, } } -int i915_gem_init_aliasing_ppgtt (struct drm_device *dev) +static int i915_gem_init_aliasing_ppgtt (struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private;struct i915_hw_ppgtt *ppgtt;
Signature · 1 line
1.8.1.1
Re: [PATCH 1/5] drm/i915: trivial: kill-agp collateral cleanups
Quoted 5 lines · Ben Widawsky
-
i915_gem_init_aliasing_ppgttshould now be static
- movei915_gem_init_ppgttdeclaration to the right placeReviewed-by Chris Wilson <[email protected]>Signed-off-by Ben Widawsky <[email protected]>
I've tried to apply this patch on top of latest dinq, and there's nothing left after resolving conflicts. Have I screwed something up? -Daniel
Quoted 46 lines
--- drivers/gpu/drm/i915/i915_drv.h | 3 +-- drivers/gpu/drm/i915/i915_gem_gtt.c | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-)drivers/gpu/drm/i915/i915_drv.h +1
-2@@ -1598,7 +1598,6 @@ int __must_check i915_gem_init(struct drm_device *dev);int __must_check i915_gem_init_hw (struct drm_device *dev);void i915_gem_l3_remap (struct drm_device *dev);void i915_gem_init_swizzling (struct drm_device *dev); -void i915_gem_init_ppgtt (struct drm_device *dev);void i915_gem_cleanup_ringbuffer (struct drm_device *dev);int __must_check i915_gpu_idle (struct drm_device *dev);int __must_check i915_gem_idle (struct drm_device *dev);@@ -1653,7 +1652,7 @@ int i915_gem_context_destroy_ioctl(struct drm_device *dev, void *data, struct drm_file *file);/* i915_gem_gtt.c */ -int __must_check i915_gem_init_aliasing_ppgtt (struct drm_device *dev); +void i915_gem_init_ppgtt (struct drm_device *dev);void i915_gem_cleanup_aliasing_ppgtt (struct drm_device *dev); void i915_ppgtt_bind_object(struct i915_hw_ppgtt *ppgtt, struct drm_i915_gem_object *obj,drivers/gpu/drm/i915/i915_gem_gtt.c +1
-1@@ -108,7 +108,7 @@ static void i915_ppgtt_clear_range(struct i915_hw_ppgtt *ppgtt, } } -int i915_gem_init_aliasing_ppgtt (struct drm_device *dev) +static int i915_gem_init_aliasing_ppgtt (struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private;struct i915_hw_ppgtt *ppgtt;Signature · 6 lines
1.8.1.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [PATCH 1/5] drm/i915: trivial: kill-agp collateral cleanups
Quoted 10 lines · Daniel Vetter
Quoted 5 lines · Ben Widawsky
-
i915_gem_init_aliasing_ppgttshould now be static
- movei915_gem_init_ppgttdeclaration to the right placeReviewed-by Chris Wilson <[email protected]>Signed-off-by Ben Widawsky <[email protected]>I've tried to apply this patch on top of latest dinq, and there's nothing left after resolving conflicts. Have I screwed something up? -Daniel
No, I think you're right. I think it no longer applies.
Signature · 1 line
Ben Widawsky, Intel Open Source Technology Center
PATCH 2/5 drm/i915: Reclaim GTT space for failed PPGTT
In reply to Ben WidawskyWhen the PPGTT init fails, we may as well reuse the space that we were reserving for the PPGTT PDEs.
This also fixes an extraneous mutex_unlock.
--- drivers/gpu/drm/i915/i915_gem_gtt.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-)
drivers/gpu/drm/i915/i915_gem_gtt.c +16 -17
@@ -531,12 +531,20 @@ static void i915_gtt_color_adjust(struct drm_mm_node *node, *end -=4096 ; } } -void i915_gem_setup_global_gtt (struct drm_device *dev,unsigned long start,unsigned long mappable_end,unsigned long end) { +/* Let GEM Manage all of the aperture. +* +* However, leave one page at the end still bound to the scratch page. +* There are a number of places where the hardware apparently prefetches +* past the end of the object, and we've seen multiple hangs with the +* GPU head pointer stuck in a batchbuffer bound at the last page of the +* aperture. One page should be enough to keep any prefetching inside +* of the aperture. +*/ drm_i915_private_t *dev_priv = dev->dev_private;struct drm_mm_node *entry;struct drm_i915_gem_object *obj;
@@ -598,12 +606,12 @@ void i915_gem_init_global_gtt(struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private;unsigned long gtt_size, mappable_size; -int ret; gtt_size = dev_priv->mm.gtt->gtt_total_entries <<PAGE_SHIFT ; mappable_size = dev_priv->gtt.mappable_end;if (intel_enable_ppgtt (dev) &&HAS_ALIASING_PPGTT (dev)) { +int ret;/* PPGTT pdes are stolen from global gtt ptes, so shrink the * aperture accordingly when using aliasing ppgtt. */ gtt_size -=I915_PPGTT_PD_ENTRIES *PAGE_SIZE ;
@@ -611,23 +619,14 @@ void i915_gem_init_global_gtt(struct drm_device *dev)i915_gem_setup_global_gtt (dev,0 , mappable_size, gtt_size); ret =i915_gem_init_aliasing_ppgtt (dev); -if (ret) { -mutex_unlock (&dev->struct_mutex); +if (!ret)return ; - } - }else { -/* Let GEM Manage all of the aperture. -* -* However, leave one page at the end still bound to the scratch -* page. There are a number of places where the hardware -* apparently prefetches past the end of the object, and we've -* seen multiple hangs with the GPU head pointer stuck in a -* batchbuffer bound at the last page of the aperture. One page -* should be enough to keep any prefetching inside of the -* aperture. -*/ -i915_gem_setup_global_gtt (dev,0 , mappable_size, gtt_size); + +DRM_ERROR ("Aliased PPGTT setup failed %d\n" , ret); +drm_mm_takedown (&dev_priv->mm.gtt_space); + gtt_size +=I915_PPGTT_PD_ENTRIES *PAGE_SIZE ; } +i915_gem_setup_global_gtt (dev,0 , mappable_size, gtt_size); }static int setup_scratch_page (struct drm_device *dev)
Signature · 1 line
1.8.1.1
Daniel Vetter
AppliedRe: [PATCH 2/5] drm/i915: Reclaim GTT space for failed PPGTT
Quoted 7 lines · Ben Widawsky
When the PPGTT init fails, we may as well reuse the space that we were reserving for the PPGTT PDEs.
This also fixes an extraneous
mutex_unlock.Reviewed-by Chris Wilson <[email protected]>Signed-off-by Ben Widawsky <[email protected]>
Queued for -next, thanks for the patch.
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
PATCH 3/5 drm/i915: Extract gen6 aliasing ppgtt code
In reply to Ben WidawskyThis refactor clearly identifies the GEN specific portion of the aliased ppgtt code. Aside from some of the gen specific parts being extracted, it also preps us for an upcoming patch that pulls out the size, which has some nice benefits.
v2: Fix wonky error handling (Chris)
--- drivers/gpu/drm/i915/i915_gem_gtt.c | 42 ++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 14 deletions(-)
drivers/gpu/drm/i915/i915_gem_gtt.c +28 -14
@@ -108,10 +108,10 @@ static void i915_ppgtt_clear_range(struct i915_hw_ppgtt *ppgtt, } } -static int i915_gem_init_aliasing_ppgtt (struct drm_device *dev) +static int gen6_init_aliasing_ppgtt (struct i915_hw_ppgtt *ppgtt) { +struct drm_device *dev = ppgtt->dev;struct drm_i915_private *dev_priv = dev->dev_private; -struct i915_hw_ppgtt *ppgtt;unsigned first_pd_entry_in_global_pt;int i;int ret = -ENOMEM ;
@@ -121,16 +121,12 @@ static int i915_gem_init_aliasing_ppgtt(struct drm_device *dev)* now. */ first_pd_entry_in_global_pt = dev_priv->mm.gtt->gtt_total_entries -I915_PPGTT_PD_ENTRIES ; - ppgtt =kzalloc (sizeof (*ppgtt),GFP_KERNEL ); -if (!ppgtt) -return ret; - - ppgtt->dev = dev; ppgtt->num_pd_entries =I915_PPGTT_PD_ENTRIES ; ppgtt->pt_pages =kzalloc (sizeof (struct page *)*ppgtt->num_pd_entries,GFP_KERNEL ); +if (!ppgtt->pt_pages) - goto err_ppgtt; +return -ENOMEM ;for (i =0 ; i < ppgtt->num_pd_entries; i++) { ppgtt->pt_pages[i] =alloc_page (GFP_KERNEL );
@@ -157,15 +153,11 @@ static int i915_gem_init_aliasing_ppgtt(struct drm_device *dev) ppgtt->pt_dma_addr[i] = pt_addr; } - ppgtt->scratch_page_dma_addr = dev_priv->gtt.scratch_page_dma; -i915_ppgtt_clear_range (ppgtt,0 , ppgtt->num_pd_entries*I915_PPGTT_PT_ENTRIES ); ppgtt->pd_offset = (first_pd_entry_in_global_pt)*sizeof (gtt_pte_t); - dev_priv->mm.aliasing_ppgtt = ppgtt; -return 0 ; err_pd_pin:
@@ -180,9 +172,31 @@ err_pt_alloc:if (ppgtt->pt_pages[i])__free_page (ppgtt->pt_pages[i]); } +kfree (ppgtt->pt_pages); -err_ppgtt: -kfree (ppgtt); + +return ret; +} + + +static int i915_gem_init_aliasing_ppgtt (struct drm_device *dev) +{ +struct drm_i915_private *dev_priv = dev->dev_private; +struct i915_hw_ppgtt *ppgtt; +int ret = -ENOMEM ; + + ppgtt =kzalloc (sizeof (*ppgtt),GFP_KERNEL ); +if (!ppgtt) +return ret; + + ppgtt->dev = dev; + ppgtt->scratch_page_dma_addr = dev_priv->gtt.scratch_page_dma; + + ret =gen6_init_aliasing_ppgtt (ppgtt); +if (ret) +kfree (ppgtt); +else + dev_priv->mm.aliasing_ppgtt = ppgtt;return ret; }
Signature · 1 line
1.8.1.1
Re: [PATCH 3/5] drm/i915: Extract gen6 aliasing ppgtt code
Quoted 8 lines · Ben Widawsky
This refactor clearly identifies the GEN specific portion of the aliased ppgtt code. Aside from some of the gen specific parts being extracted, it also preps us for an upcoming patch that pulls out the size, which has some nice benefits.
v2: Fix wonky error handling (Chris)
Signed-off-by Ben Widawsky <[email protected]>
Functionally we seem to have this patch already with
commit e9ccfd7b94f1ca9b46b992a19d2e8c5af70e4c69
Author: Daniel Vetter <[email protected]> Date: Thu Jan 24 13:49:56 2013 -0800
drm/i915: extract hw ppgtt setup/cleanup code
Yeah, you're allowed to hate me with the heat of a thousand suns now ;-) -Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [PATCH 3/5] drm/i915: Extract gen6 aliasing ppgtt code
Quoted 12 lines · Daniel Vetter
Quoted 8 lines · Ben Widawsky
This refactor clearly identifies the GEN specific portion of the aliased ppgtt code. Aside from some of the gen specific parts being extracted, it also preps us for an upcoming patch that pulls out the size, which has some nice benefits.
v2: Fix wonky error handling (Chris)
Signed-off-by Ben Widawsky <[email protected]>Functionally we seem to have this patch already with
Quoted 8 lines
commit
e9ccfd7b94f1ca9b46b992a19d2e8c5af70e4c69Author: Daniel Vetter <[email protected]> Date: Thu Jan 24 13:49:56 2013 -0800drm/i915: extract hw ppgtt setup/cleanup code
Yeah, you're allowed to hate me with the heat of a thousand suns now ;-) -Daniel
I already did. I guess when I rebased the series, you hadn't merged those yet.
Signature · 1 line
Ben Widawsky, Intel Open Source Technology Center
PATCH 4/5 drm/i915: Aliased PPGTT size abstraction
In reply to Ben WidawskyAside from being a nice prep for some work I'm doing in PPGTT, this also leaves us with a more accurate size in our gtt_total_entries member. Since we can't actually use the PPGTT reserved part of the GGTT.
This will help some of the existing assertions find issues which would overwrite the PPGTT PDEs.
Another benefit is for platforms which don't use the entire 2GB GTT, this will save GTT space. For example if a platform has 1 1GB GTT, this patch should save 1MB of GTT space (512MB has an even greater savings). I don't have a platform to easily test this however.
If/when we ever move to real PPGTT, I think allocating the PDEs as objects will make the most sense.
--- drivers/gpu/drm/i915/i915_debugfs.c | 2 ++ drivers/gpu/drm/i915/i915_drv.h | 3 ++- drivers/gpu/drm/i915/i915_gem_gtt.c | 35 ++++++++++++++++++++++++++--------- 3 files changed, 30 insertions(+), 10 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +2 -0
@@ -1605,6 +1605,8 @@ static int i915_ppgtt_info(struct seq_file *m, void *data)seq_printf (m,"aliasing PPGTT:\n" );seq_printf (m,"pd gtt offset: 0x%08x\n" , ppgtt->pd_offset); +seq_printf (m,"mapped size: %lldM\n" , + ppgtt->mapped_size>>20 ); }seq_printf (m,"ECOCHK: 0x%08x\n" ,I915_READ (GAM_ECOCHK ));mutex_unlock (&dev->struct_mutex);
drivers/gpu/drm/i915/i915_drv.h +2 -1
@@ -388,10 +388,11 @@ struct i915_gtt {struct page *scratch_page; }; -#define I915_PPGTT_PD_ENTRIES 512 +#define GEN6_MAX_PD_ENTRIES 512#define I915_PPGTT_PT_ENTRIES 1024struct i915_hw_ppgtt {struct drm_device *dev; +uint64_t mapped_size;unsigned num_pd_entries;struct page **pt_pages;uint32_t pd_offset;
drivers/gpu/drm/i915/i915_gem_gtt.c +26 -9
@@ -108,7 +108,7 @@ static void i915_ppgtt_clear_range(struct i915_hw_ppgtt *ppgtt, } } -static int gen6_init_aliasing_ppgtt (struct i915_hw_ppgtt *ppgtt) +static int gen6_init_ppgtt (struct i915_hw_ppgtt *ppgtt,uint64_t size) {struct drm_device *dev = ppgtt->dev;struct drm_i915_private *dev_priv = dev->dev_private;
@@ -116,15 +116,22 @@ static int gen6_init_aliasing_ppgtt(struct i915_hw_ppgtt *ppgtt)int i;int ret = -ENOMEM ; +if (dev_priv->mm.aliasing_ppgtt) +return -EBUSY ; + +/* Each PDE maps 4MB (1k PAGE_SIZE pages)*/ + ppgtt->mapped_size =round_up (size,1 <<22 ); + ppgtt->num_pd_entries = ppgtt->mapped_size >>22 ; +BUG_ON (ppgtt->num_pd_entries >GEN6_MAX_PD_ENTRIES ); +/* ppgtt PDEs reside in the global gtt pagetable, which has 512*1024 * entries. For aliasing ppgtt support we just steal them at the end for * now. */ - first_pd_entry_in_global_pt = dev_priv->mm.gtt->gtt_total_entries -I915_PPGTT_PD_ENTRIES ; + first_pd_entry_in_global_pt = dev_priv->mm.gtt->gtt_total_entries - + ppgtt->num_pd_entries; - ppgtt->num_pd_entries =I915_PPGTT_PD_ENTRIES ; ppgtt->pt_pages =kzalloc (sizeof (struct page *)*ppgtt->num_pd_entries,GFP_KERNEL ); -if (!ppgtt->pt_pages)return -ENOMEM ;
@@ -156,7 +163,10 @@ static int gen6_init_aliasing_ppgtt(struct i915_hw_ppgtt *ppgtt)i915_ppgtt_clear_range (ppgtt,0 , ppgtt->num_pd_entries*I915_PPGTT_PT_ENTRIES ); - ppgtt->pd_offset = (first_pd_entry_in_global_pt)*sizeof (gtt_pte_t); + ppgtt->pd_offset = first_pd_entry_in_global_pt *sizeof (gtt_pte_t); + +DRM_INFO ("Allocated %d PDEs for PPGTT\n" , ppgtt->num_pd_entries); +DRM_DEBUG_DRIVER ("First PDE: %d\n" , first_pd_entry_in_global_pt);return 0 ;
@@ -192,7 +202,7 @@ static int i915_gem_init_aliasing_ppgtt(struct drm_device *dev) ppgtt->dev = dev; ppgtt->scratch_page_dma_addr = dev_priv->gtt.scratch_page_dma; - ret =gen6_init_aliasing_ppgtt (ppgtt); + ret =gen6_init_ppgtt (ppgtt, dev_priv->gtt.total);if (ret)kfree (ppgtt);else
@@ -625,20 +635,27 @@ void i915_gem_init_global_gtt(struct drm_device *dev) mappable_size = dev_priv->gtt.mappable_end;if (intel_enable_ppgtt (dev) &&HAS_ALIASING_PPGTT (dev)) { +/* Each PDE represents 1k PAGE_SIZE objects */ +const int reserve_pd_space = gtt_size >>10 ;int ret; + +BUG_ON (!reserve_pd_space); +/* PPGTT pdes are stolen from global gtt ptes, so shrink the * aperture accordingly when using aliasing ppgtt. */ - gtt_size -=I915_PPGTT_PD_ENTRIES *PAGE_SIZE ; + gtt_size -= reserve_pd_space;i915_gem_setup_global_gtt (dev,0 , mappable_size, gtt_size); ret =i915_gem_init_aliasing_ppgtt (dev); -if (!ret) +if (!ret) { + dev_priv->mm.gtt->gtt_total_entries = gtt_size >>PAGE_SHIFT ;return ; + }DRM_ERROR ("Aliased PPGTT setup failed %d\n" , ret);drm_mm_takedown (&dev_priv->mm.gtt_space); - gtt_size +=I915_PPGTT_PD_ENTRIES *PAGE_SIZE ; + gtt_size += reserve_pd_space; }i915_gem_setup_global_gtt (dev,0 , mappable_size, gtt_size); }
Signature · 1 line
1.8.1.1
Jani Nikula
maintainerRe: [PATCH 4/5] drm/i915: Aliased PPGTT size abstraction
Quoted 113 lines · Ben Widawsky
Aside from being a nice prep for some work I'm doing in PPGTT, this also leaves us with a more accurate size in our
gtt_total_entriesmember. Since we can't actually use the PPGTT reserved part of the GGTT.This will help some of the existing assertions find issues which would overwrite the PPGTT PDEs.
Another benefit is for platforms which don't use the entire 2GB GTT, this will save GTT space. For example if a platform has 1 1GB GTT, this patch should save 1MB of GTT space (512MB has an even greater savings). I don't have a platform to easily test this however.
If/when we ever move to real PPGTT, I think allocating the PDEs as objects will make the most sense.
Signed-off-by Ben Widawsky <[email protected]>--- drivers/gpu/drm/i915/i915_debugfs.c | 2 ++ drivers/gpu/drm/i915/i915_drv.h | 3 ++- drivers/gpu/drm/i915/i915_gem_gtt.c | 35 ++++++++++++++++++++++++++--------- 3 files changed, 30 insertions(+), 10 deletions(-)drivers/gpu/drm/i915/i915_debugfs.c +2
-0@@ -1605,6 +1605,8 @@ static int i915_ppgtt_info(struct seq_file *m, void *data)seq_printf (m,"aliasing PPGTT:\n" );seq_printf (m,"pd gtt offset: 0x%08x\n" , ppgtt->pd_offset); +seq_printf (m,"mapped size: %lldM\n" , + ppgtt->mapped_size>>20 ); }seq_printf (m,"ECOCHK: 0x%08x\n" ,I915_READ (GAM_ECOCHK ));mutex_unlock (&dev->struct_mutex);drivers/gpu/drm/i915/i915_drv.h +2
-1@@ -388,10 +388,11 @@ struct i915_gtt {struct page *scratch_page; }; -#define I915_PPGTT_PD_ENTRIES 512 +#define GEN6_MAX_PD_ENTRIES 512#define I915_PPGTT_PT_ENTRIES 1024struct i915_hw_ppgtt {struct drm_device *dev; +uint64_t mapped_size;unsigned num_pd_entries;struct page **pt_pages;uint32_t pd_offset;drivers/gpu/drm/i915/i915_gem_gtt.c +16
-6@@ -108,7 +108,7 @@ static void i915_ppgtt_clear_range(struct i915_hw_ppgtt *ppgtt, } } -static int gen6_init_aliasing_ppgtt (struct i915_hw_ppgtt *ppgtt) +static int gen6_init_ppgtt (struct i915_hw_ppgtt *ppgtt,uint64_t size) {struct drm_device *dev = ppgtt->dev;struct drm_i915_private *dev_priv = dev->dev_private;@@ -116,15 +116,22 @@ static int gen6_init_aliasing_ppgtt(struct i915_hw_ppgtt *ppgtt)int i;int ret = -ENOMEM ; +if (dev_priv->mm.aliasing_ppgtt) +return -EBUSY ; + +/* Each PDE maps 4MB (1k PAGE_SIZE pages)*/ + ppgtt->mapped_size =round_up (size,1 <<22 ); + ppgtt->num_pd_entries = ppgtt->mapped_size >>22 ; +BUG_ON (ppgtt->num_pd_entries >GEN6_MAX_PD_ENTRIES ); +/* ppgtt PDEs reside in the global gtt pagetable, which has 512*1024 * entries. For aliasing ppgtt support we just steal them at the end for * now. */ - first_pd_entry_in_global_pt = dev_priv->mm.gtt->gtt_total_entries -I915_PPGTT_PD_ENTRIES ; + first_pd_entry_in_global_pt = dev_priv->mm.gtt->gtt_total_entries - + ppgtt->num_pd_entries; - ppgtt->num_pd_entries =I915_PPGTT_PD_ENTRIES ; ppgtt->pt_pages =kzalloc (sizeof (struct page *)*ppgtt->num_pd_entries,GFP_KERNEL ); -if (!ppgtt->pt_pages)return -ENOMEM ;@@ -156,7 +163,10 @@ static int gen6_init_aliasing_ppgtt(struct i915_hw_ppgtt *ppgtt)i915_ppgtt_clear_range (ppgtt,0 , ppgtt->num_pd_entries*I915_PPGTT_PT_ENTRIES ); - ppgtt->pd_offset = (first_pd_entry_in_global_pt)*sizeof (gtt_pte_t); + ppgtt->pd_offset = first_pd_entry_in_global_pt *sizeof (gtt_pte_t); + +DRM_INFO ("Allocated %d PDEs for PPGTT\n" , ppgtt->num_pd_entries); +DRM_DEBUG_DRIVER ("First PDE: %d\n" , first_pd_entry_in_global_pt);return 0 ;@@ -192,7 +202,7 @@ static int i915_gem_init_aliasing_ppgtt(struct drm_device *dev) ppgtt->dev = dev; ppgtt->scratch_page_dma_addr = dev_priv->gtt.scratch_page_dma; - ret =gen6_init_aliasing_ppgtt (ppgtt); + ret =gen6_init_ppgtt (ppgtt, dev_priv->gtt.total);if (ret)kfree (ppgtt);else
drivers/gpu/drm/i915/i915_gem_gtt.c void i915_gem_init_global_gtt(struct drm_device *dev) · line 639
Quoted 5 lines
drivers/gpu/drm/i915/i915_gem_gtt.c +2
-0@@ -625,20 +635,27 @@ void i915_gem_init_global_gtt(struct drm_device *dev) mappable_size = dev_priv->gtt.mappable_end;if (intel_enable_ppgtt (dev) &&HAS_ALIASING_PPGTT (dev)) { +/* Each PDE represents 1k PAGE_SIZE objects */ +const int reserve_pd_space = gtt_size >>10 ;
Maybe (likely) I'm being dense, but care to explain this shift a bit? Should it match ppgtt->num_pd_entries * PAGE_SIZE after i915_gem_init_aliasing_ppgtt()?
BR,
Jani.
Quoted 32 lines
drivers/gpu/drm/i915/i915_gem_gtt.c +8
-3int ret; + +BUG_ON (!reserve_pd_space); +/* PPGTT pdes are stolen from global gtt ptes, so shrink the * aperture accordingly when using aliasing ppgtt. */ - gtt_size -=I915_PPGTT_PD_ENTRIES *PAGE_SIZE ; + gtt_size -= reserve_pd_space;i915_gem_setup_global_gtt (dev,0 , mappable_size, gtt_size); ret =i915_gem_init_aliasing_ppgtt (dev); -if (!ret) +if (!ret) { + dev_priv->mm.gtt->gtt_total_entries = gtt_size >>PAGE_SHIFT ;return ; + }DRM_ERROR ("Aliased PPGTT setup failed %d\n" , ret);drm_mm_takedown (&dev_priv->mm.gtt_space); - gtt_size +=I915_PPGTT_PD_ENTRIES *PAGE_SIZE ; + gtt_size += reserve_pd_space; }i915_gem_setup_global_gtt (dev,0 , mappable_size, gtt_size); }Signature · 6 lines
1.8.1.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 4/5] drm/i915: Aliased PPGTT size abstraction
Quoted 124 lines · Jani Nikula
Quoted 113 lines · Ben Widawsky
Aside from being a nice prep for some work I'm doing in PPGTT, this also leaves us with a more accurate size in our
gtt_total_entriesmember. Since we can't actually use the PPGTT reserved part of the GGTT.This will help some of the existing assertions find issues which would overwrite the PPGTT PDEs.
Another benefit is for platforms which don't use the entire 2GB GTT, this will save GTT space. For example if a platform has 1 1GB GTT, this patch should save 1MB of GTT space (512MB has an even greater savings). I don't have a platform to easily test this however.
If/when we ever move to real PPGTT, I think allocating the PDEs as objects will make the most sense.
Signed-off-by Ben Widawsky <[email protected]>--- drivers/gpu/drm/i915/i915_debugfs.c | 2 ++ drivers/gpu/drm/i915/i915_drv.h | 3 ++- drivers/gpu/drm/i915/i915_gem_gtt.c | 35 ++++++++++++++++++++++++++--------- 3 files changed, 30 insertions(+), 10 deletions(-)drivers/gpu/drm/i915/i915_debugfs.c +2
-0@@ -1605,6 +1605,8 @@ static int i915_ppgtt_info(struct seq_file *m, void *data)seq_printf (m,"aliasing PPGTT:\n" );seq_printf (m,"pd gtt offset: 0x%08x\n" , ppgtt->pd_offset); +seq_printf (m,"mapped size: %lldM\n" , + ppgtt->mapped_size>>20 ); }seq_printf (m,"ECOCHK: 0x%08x\n" ,I915_READ (GAM_ECOCHK ));mutex_unlock (&dev->struct_mutex);drivers/gpu/drm/i915/i915_drv.h +2
-1@@ -388,10 +388,11 @@ struct i915_gtt {struct page *scratch_page; }; -#define I915_PPGTT_PD_ENTRIES 512 +#define GEN6_MAX_PD_ENTRIES 512#define I915_PPGTT_PT_ENTRIES 1024struct i915_hw_ppgtt {struct drm_device *dev; +uint64_t mapped_size;unsigned num_pd_entries;struct page **pt_pages;uint32_t pd_offset;drivers/gpu/drm/i915/i915_gem_gtt.c +16
-6@@ -108,7 +108,7 @@ static void i915_ppgtt_clear_range(struct i915_hw_ppgtt *ppgtt, } } -static int gen6_init_aliasing_ppgtt (struct i915_hw_ppgtt *ppgtt) +static int gen6_init_ppgtt (struct i915_hw_ppgtt *ppgtt,uint64_t size) {struct drm_device *dev = ppgtt->dev;struct drm_i915_private *dev_priv = dev->dev_private;@@ -116,15 +116,22 @@ static int gen6_init_aliasing_ppgtt(struct i915_hw_ppgtt *ppgtt)int i;int ret = -ENOMEM ; +if (dev_priv->mm.aliasing_ppgtt) +return -EBUSY ; + +/* Each PDE maps 4MB (1k PAGE_SIZE pages)*/ + ppgtt->mapped_size =round_up (size,1 <<22 ); + ppgtt->num_pd_entries = ppgtt->mapped_size >>22 ; +BUG_ON (ppgtt->num_pd_entries >GEN6_MAX_PD_ENTRIES ); +/* ppgtt PDEs reside in the global gtt pagetable, which has 512*1024 * entries. For aliasing ppgtt support we just steal them at the end for * now. */ - first_pd_entry_in_global_pt = dev_priv->mm.gtt->gtt_total_entries -I915_PPGTT_PD_ENTRIES ; + first_pd_entry_in_global_pt = dev_priv->mm.gtt->gtt_total_entries - + ppgtt->num_pd_entries; - ppgtt->num_pd_entries =I915_PPGTT_PD_ENTRIES ; ppgtt->pt_pages =kzalloc (sizeof (struct page *)*ppgtt->num_pd_entries,GFP_KERNEL ); -if (!ppgtt->pt_pages)return -ENOMEM ;@@ -156,7 +163,10 @@ static int gen6_init_aliasing_ppgtt(struct i915_hw_ppgtt *ppgtt)i915_ppgtt_clear_range (ppgtt,0 , ppgtt->num_pd_entries*I915_PPGTT_PT_ENTRIES ); - ppgtt->pd_offset = (first_pd_entry_in_global_pt)*sizeof (gtt_pte_t); + ppgtt->pd_offset = first_pd_entry_in_global_pt *sizeof (gtt_pte_t); + +DRM_INFO ("Allocated %d PDEs for PPGTT\n" , ppgtt->num_pd_entries); +DRM_DEBUG_DRIVER ("First PDE: %d\n" , first_pd_entry_in_global_pt);return 0 ;@@ -192,7 +202,7 @@ static int i915_gem_init_aliasing_ppgtt(struct drm_device *dev) ppgtt->dev = dev; ppgtt->scratch_page_dma_addr = dev_priv->gtt.scratch_page_dma; - ret =gen6_init_aliasing_ppgtt (ppgtt); + ret =gen6_init_ppgtt (ppgtt, dev_priv->gtt.total);if (ret)kfree (ppgtt);else drivers/gpu/drm/i915/i915_gem_gtt.c void i915_gem_init_global_gtt(struct drm_device *dev) · line 639
Quoted 5 lines
drivers/gpu/drm/i915/i915_gem_gtt.c +2
-0@@ -625,20 +635,27 @@ void i915_gem_init_global_gtt(struct drm_device *dev) mappable_size = dev_priv->gtt.mappable_end;if (intel_enable_ppgtt (dev) &&HAS_ALIASING_PPGTT (dev)) { +/* Each PDE represents 1k PAGE_SIZE objects */ +const int reserve_pd_space = gtt_size >>10 ;Maybe (likely) I'm being dense, but care to explain this shift a bit? Should it match
ppgtt->num_pd_entries*PAGE_SIZEafteri915_gem_init_aliasing_ppgtt()?
Quoted 3 lines
BR,
Jani.
yeah, it's horribly confusing until you actually need to write code yourself. I actually think Daniel should have reviewed this patch, but I guess he is lazy.
In this context, gtt_size refers to the amount of GPU mappable memory. (I actually had another patch which renamed all of this stuff, but whatever).
We want to be able to map the entire space the gtt maps with the ppgtt.
Each page directory holds 1024 PTEs, which each map a 4k pfn. Therefore, each PDEs is effecitvely mapping (1 << (10 + 12)). Since the PDs are stored in the GGTT (suck), we're trying to carve out the necessary memory from the GGTT. The PDEs are special, see the DCLV stuff.
The number of PDEs required is:gtt_size >> 22
But as I said above, we really need to calculate how much PD space we need. Each PD has PAGE_SIZE of space requiredgtt_size >> 22 >> PAGE_SIZE = gtt_size >> 10
In hindsight, maybe doing that calculation in the code would have been better.
Anyway, to answer the question, I think yes, it should match ppgtt->num_pd_entries * PAGE_SIZE
Quoted 32 lines
Quoted 32 lines
drivers/gpu/drm/i915/i915_gem_gtt.c +8
-3int ret; + +BUG_ON (!reserve_pd_space); +/* PPGTT pdes are stolen from global gtt ptes, so shrink the * aperture accordingly when using aliasing ppgtt. */ - gtt_size -=I915_PPGTT_PD_ENTRIES *PAGE_SIZE ; + gtt_size -= reserve_pd_space;i915_gem_setup_global_gtt (dev,0 , mappable_size, gtt_size); ret =i915_gem_init_aliasing_ppgtt (dev); -if (!ret) +if (!ret) { + dev_priv->mm.gtt->gtt_total_entries = gtt_size >>PAGE_SHIFT ;return ; + }DRM_ERROR ("Aliased PPGTT setup failed %d\n" , ret);drm_mm_takedown (&dev_priv->mm.gtt_space); - gtt_size +=I915_PPGTT_PD_ENTRIES *PAGE_SIZE ; + gtt_size += reserve_pd_space; }i915_gem_setup_global_gtt (dev,0 , mappable_size, gtt_size); }Signature · 6 lines
1.8.1.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 1 line
Ben Widawsky, Intel Open Source Technology Center
Re: [PATCH 4/5] drm/i915: Aliased PPGTT size abstraction
Quoted 3 lines · Ben Widawsky
But as I said above, we really need to calculate how much PD space we need. Each PD has
PAGE_SIZEof space requiredgtt_size>> 22 >>PAGE_SIZE=gtt_size>> 10
gtt_size >> 22 * PAGE_SIZE
Quoted 5 lines
In hindsight, maybe doing that calculation in the code would have been better.
Anyway, to answer the question, I think yes, it should match
ppgtt->num_pd_entries*PAGE_SIZE
That looks much clearer imo and spells out what happens much better (we still a pte = full page in the address space for each ppgtt pd). Can you please apply this bikeshed to the patch?
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
PATCH v2 4/5 drm/i915: Aliased PPGTT size abstraction
In reply to Ben WidawskyAside from being a nice prep for some work I'm doing in PPGTT, this also leaves us with a more accurate size in our gtt_total_entries member. Since we can't actually use the PPGTT reserved part of the GGTT.
This will help some of the existing assertions find issues which would overwrite the PPGTT PDEs.
Another benefit is for platforms which don't use the entire 2GB GTT, this will save GTT space. For example if a platform has 1 1GB GTT, this patch should save 1MB of GTT space (512MB has an even greater savings). I don't have a platform to easily test this however.
If/when we ever move to real PPGTT, I think allocating the PDEs as objects will make the most sense.
v2: Change the size calculation for the PDs carved out of the ggtt to be more explicit. (Daniel)
--- drivers/gpu/drm/i915/i915_debugfs.c | 2 ++ drivers/gpu/drm/i915/i915_drv.h | 3 ++- drivers/gpu/drm/i915/i915_gem_gtt.c | 35 ++++++++++++++++++++++++++--------- 3 files changed, 30 insertions(+), 10 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +2 -0
@@ -1605,6 +1605,8 @@ static int i915_ppgtt_info(struct seq_file *m, void *data)seq_printf (m,"aliasing PPGTT:\n" );seq_printf (m,"pd gtt offset: 0x%08x\n" , ppgtt->pd_offset); +seq_printf (m,"mapped size: %lldM\n" , + ppgtt->mapped_size>>20 ); }seq_printf (m,"ECOCHK: 0x%08x\n" ,I915_READ (GAM_ECOCHK ));mutex_unlock (&dev->struct_mutex);
drivers/gpu/drm/i915/i915_drv.h +2 -1
@@ -388,10 +388,11 @@ struct i915_gtt {struct page *scratch_page; }; -#define I915_PPGTT_PD_ENTRIES 512 +#define GEN6_MAX_PD_ENTRIES 512#define I915_PPGTT_PT_ENTRIES 1024struct i915_hw_ppgtt {struct drm_device *dev; +uint64_t mapped_size;unsigned num_pd_entries;struct page **pt_pages;uint32_t pd_offset;
drivers/gpu/drm/i915/i915_gem_gtt.c +26 -9
@@ -108,7 +108,7 @@ static void i915_ppgtt_clear_range(struct i915_hw_ppgtt *ppgtt, } } -static int gen6_init_aliasing_ppgtt (struct i915_hw_ppgtt *ppgtt) +static int gen6_init_ppgtt (struct i915_hw_ppgtt *ppgtt,uint64_t size) {struct drm_device *dev = ppgtt->dev;struct drm_i915_private *dev_priv = dev->dev_private;
@@ -116,15 +116,22 @@ static int gen6_init_aliasing_ppgtt(struct i915_hw_ppgtt *ppgtt)int i;int ret = -ENOMEM ; +if (dev_priv->mm.aliasing_ppgtt) +return -EBUSY ; + +/* Each PDE maps 4MB (1k PAGE_SIZE pages)*/ + ppgtt->mapped_size =round_up (size,1 <<22 ); + ppgtt->num_pd_entries = ppgtt->mapped_size >>22 ; +BUG_ON (ppgtt->num_pd_entries >GEN6_MAX_PD_ENTRIES ); +/* ppgtt PDEs reside in the global gtt pagetable, which has 512*1024 * entries. For aliasing ppgtt support we just steal them at the end for * now. */ - first_pd_entry_in_global_pt = dev_priv->mm.gtt->gtt_total_entries -I915_PPGTT_PD_ENTRIES ; + first_pd_entry_in_global_pt = dev_priv->mm.gtt->gtt_total_entries - + ppgtt->num_pd_entries; - ppgtt->num_pd_entries =I915_PPGTT_PD_ENTRIES ; ppgtt->pt_pages =kzalloc (sizeof (struct page *)*ppgtt->num_pd_entries,GFP_KERNEL ); -if (!ppgtt->pt_pages)return -ENOMEM ;
@@ -156,7 +163,10 @@ static int gen6_init_aliasing_ppgtt(struct i915_hw_ppgtt *ppgtt)i915_ppgtt_clear_range (ppgtt,0 , ppgtt->num_pd_entries*I915_PPGTT_PT_ENTRIES ); - ppgtt->pd_offset = (first_pd_entry_in_global_pt)*sizeof (gtt_pte_t); + ppgtt->pd_offset = first_pd_entry_in_global_pt *sizeof (gtt_pte_t); + +DRM_INFO ("Allocated %d PDEs for PPGTT\n" , ppgtt->num_pd_entries); +DRM_DEBUG_DRIVER ("First PDE: %d\n" , first_pd_entry_in_global_pt);return 0 ;
@@ -192,7 +202,7 @@ static int i915_gem_init_aliasing_ppgtt(struct drm_device *dev) ppgtt->dev = dev; ppgtt->scratch_page_dma_addr = dev_priv->gtt.scratch_page_dma; - ret =gen6_init_aliasing_ppgtt (ppgtt); + ret =gen6_init_ppgtt (ppgtt, dev_priv->gtt.total);if (ret)kfree (ppgtt);else
@@ -625,20 +635,27 @@ void i915_gem_init_global_gtt(struct drm_device *dev) mappable_size = dev_priv->gtt.mappable_end;if (intel_enable_ppgtt (dev) &&HAS_ALIASING_PPGTT (dev)) { +/* Each PDE represents 1k PAGE_SIZE objects */ +const int reserve_pd_space = (gtt_size >>22 ) *PAGE_SIZE ;int ret; + +BUG_ON (!reserve_pd_space); +/* PPGTT pdes are stolen from global gtt ptes, so shrink the * aperture accordingly when using aliasing ppgtt. */ - gtt_size -=I915_PPGTT_PD_ENTRIES *PAGE_SIZE ; + gtt_size -= reserve_pd_space;i915_gem_setup_global_gtt (dev,0 , mappable_size, gtt_size); ret =i915_gem_init_aliasing_ppgtt (dev); -if (!ret) +if (!ret) { + dev_priv->mm.gtt->gtt_total_entries = gtt_size >>PAGE_SHIFT ;return ; + }DRM_ERROR ("Aliased PPGTT setup failed %d\n" , ret);drm_mm_takedown (&dev_priv->mm.gtt_space); - gtt_size +=I915_PPGTT_PD_ENTRIES *PAGE_SIZE ; + gtt_size += reserve_pd_space; }i915_gem_setup_global_gtt (dev,0 , mappable_size, gtt_size); }
Signature · 1 line
1.8.1.1
Re: [PATCH 4/5 v2] drm/i915: Aliased PPGTT size abstraction
Quoted 15 lines · Ben Widawsky
Aside from being a nice prep for some work I'm doing in PPGTT, this also leaves us with a more accurate size in our
gtt_total_entriesmember. Since we can't actually use the PPGTT reserved part of the GGTT.This will help some of the existing assertions find issues which would overwrite the PPGTT PDEs.
Another benefit is for platforms which don't use the entire 2GB GTT, this will save GTT space. For example if a platform has 1 1GB GTT, this patch should save 1MB of GTT space (512MB has an even greater savings). I don't have a platform to easily test this however.
If/when we ever move to real PPGTT, I think allocating the PDEs as objects will make the most sense.
Quoted 6 lines
v2: Change the size calculation for the PDs carved out of the ggtt to be more explicit. (Daniel)
Reviewed-by Jani Nikula <[email protected]>Cc Daniel Vetter <[email protected]>Signed-off-by Ben Widawsky <[email protected]>
I'm not sold yet on whether this is the interface we want. Furthermore I have some fading nightmares that maybe the pdes should be naturally aligned in the GSM. So trying to safe a few of those sounds like a risky idea. I'll punt on this one for now.
For patch 5 I'd prefer the clearer math over adding a comment (comments tend to get stale, fast), otherwise all patches of this series merged (or nothing left after resolving conflicts).
Thanks, Daniel
Quoted 130 lines
--- drivers/gpu/drm/i915/i915_debugfs.c | 2 ++ drivers/gpu/drm/i915/i915_drv.h | 3 ++- drivers/gpu/drm/i915/i915_gem_gtt.c | 35 ++++++++++++++++++++++++++--------- 3 files changed, 30 insertions(+), 10 deletions(-)drivers/gpu/drm/i915/i915_debugfs.c +2
-0@@ -1605,6 +1605,8 @@ static int i915_ppgtt_info(struct seq_file *m, void *data)seq_printf (m,"aliasing PPGTT:\n" );seq_printf (m,"pd gtt offset: 0x%08x\n" , ppgtt->pd_offset); +seq_printf (m,"mapped size: %lldM\n" , + ppgtt->mapped_size>>20 ); }seq_printf (m,"ECOCHK: 0x%08x\n" ,I915_READ (GAM_ECOCHK ));mutex_unlock (&dev->struct_mutex);drivers/gpu/drm/i915/i915_drv.h +2
-1@@ -388,10 +388,11 @@ struct i915_gtt {struct page *scratch_page; }; -#define I915_PPGTT_PD_ENTRIES 512 +#define GEN6_MAX_PD_ENTRIES 512#define I915_PPGTT_PT_ENTRIES 1024struct i915_hw_ppgtt {struct drm_device *dev; +uint64_t mapped_size;unsigned num_pd_entries;struct page **pt_pages;uint32_t pd_offset;drivers/gpu/drm/i915/i915_gem_gtt.c +26
-9@@ -108,7 +108,7 @@ static void i915_ppgtt_clear_range(struct i915_hw_ppgtt *ppgtt, } } -static int gen6_init_aliasing_ppgtt (struct i915_hw_ppgtt *ppgtt) +static int gen6_init_ppgtt (struct i915_hw_ppgtt *ppgtt,uint64_t size) {struct drm_device *dev = ppgtt->dev;struct drm_i915_private *dev_priv = dev->dev_private;@@ -116,15 +116,22 @@ static int gen6_init_aliasing_ppgtt(struct i915_hw_ppgtt *ppgtt)int i;int ret = -ENOMEM ; +if (dev_priv->mm.aliasing_ppgtt) +return -EBUSY ; + +/* Each PDE maps 4MB (1k PAGE_SIZE pages)*/ + ppgtt->mapped_size =round_up (size,1 <<22 ); + ppgtt->num_pd_entries = ppgtt->mapped_size >>22 ; +BUG_ON (ppgtt->num_pd_entries >GEN6_MAX_PD_ENTRIES ); +/* ppgtt PDEs reside in the global gtt pagetable, which has 512*1024 * entries. For aliasing ppgtt support we just steal them at the end for * now. */ - first_pd_entry_in_global_pt = dev_priv->mm.gtt->gtt_total_entries -I915_PPGTT_PD_ENTRIES ; + first_pd_entry_in_global_pt = dev_priv->mm.gtt->gtt_total_entries - + ppgtt->num_pd_entries; - ppgtt->num_pd_entries =I915_PPGTT_PD_ENTRIES ; ppgtt->pt_pages =kzalloc (sizeof (struct page *)*ppgtt->num_pd_entries,GFP_KERNEL ); -if (!ppgtt->pt_pages)return -ENOMEM ;@@ -156,7 +163,10 @@ static int gen6_init_aliasing_ppgtt(struct i915_hw_ppgtt *ppgtt)i915_ppgtt_clear_range (ppgtt,0 , ppgtt->num_pd_entries*I915_PPGTT_PT_ENTRIES ); - ppgtt->pd_offset = (first_pd_entry_in_global_pt)*sizeof (gtt_pte_t); + ppgtt->pd_offset = first_pd_entry_in_global_pt *sizeof (gtt_pte_t); + +DRM_INFO ("Allocated %d PDEs for PPGTT\n" , ppgtt->num_pd_entries); +DRM_DEBUG_DRIVER ("First PDE: %d\n" , first_pd_entry_in_global_pt);return 0 ;@@ -192,7 +202,7 @@ static int i915_gem_init_aliasing_ppgtt(struct drm_device *dev) ppgtt->dev = dev; ppgtt->scratch_page_dma_addr = dev_priv->gtt.scratch_page_dma; - ret =gen6_init_aliasing_ppgtt (ppgtt); + ret =gen6_init_ppgtt (ppgtt, dev_priv->gtt.total);if (ret)kfree (ppgtt);else @@ -625,20 +635,27 @@ void i915_gem_init_global_gtt(struct drm_device *dev) mappable_size = dev_priv->gtt.mappable_end;if (intel_enable_ppgtt (dev) &&HAS_ALIASING_PPGTT (dev)) { +/* Each PDE represents 1k PAGE_SIZE objects */ +const int reserve_pd_space = (gtt_size >>22 ) *PAGE_SIZE ;int ret; + +BUG_ON (!reserve_pd_space); +/* PPGTT pdes are stolen from global gtt ptes, so shrink the * aperture accordingly when using aliasing ppgtt. */ - gtt_size -=I915_PPGTT_PD_ENTRIES *PAGE_SIZE ; + gtt_size -= reserve_pd_space;i915_gem_setup_global_gtt (dev,0 , mappable_size, gtt_size); ret =i915_gem_init_aliasing_ppgtt (dev); -if (!ret) +if (!ret) { + dev_priv->mm.gtt->gtt_total_entries = gtt_size >>PAGE_SHIFT ;return ; + }DRM_ERROR ("Aliased PPGTT setup failed %d\n" , ret);drm_mm_takedown (&dev_priv->mm.gtt_space); - gtt_size +=I915_PPGTT_PD_ENTRIES *PAGE_SIZE ; + gtt_size += reserve_pd_space; }i915_gem_setup_global_gtt (dev,0 , mappable_size, gtt_size); }Signature · 1 line
1.8.1.1
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
PATCH 5/5 drm/i915: Dynamically calculate dclv
In reply to Ben WidawskyDirectory CacheLine Valid controls which PDEs are held in the directory cache. Each bit represents 16 PDEs (16 PDEs at 4 bytes per entry is 1 cacheline, and therefore, almost makes sense).
Since we can now have an aliasing PPGTT which isn't 2GB, theoretically, we should also modify the DCLV value to fit accordingly.
--- drivers/gpu/drm/i915/i915_gem_gtt.c | 5 +++-- drivers/gpu/drm/i915/i915_reg.h | 1 - 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_gem_gtt.c +3 -2
@@ -344,11 +344,12 @@ void i915_gem_init_ppgtt(struct drm_device *dev) }for_each_ring (ring, dev_priv, i) { +uint64_t dclv = ppgtt->mapped_size >>26 ; + dclv = (1ULL << dclv) -1 ;if (INTEL_INFO (dev)->gen >=7 )I915_WRITE (RING_MODE_GEN7 (ring),_MASKED_BIT_ENABLE (GFX_PPGTT_ENABLE )); - -I915_WRITE (RING_PP_DIR_DCLV (ring),PP_DIR_DCLV_2G ); +I915_WRITE (RING_PP_DIR_DCLV (ring), dclv);I915_WRITE (RING_PP_DIR_BASE (ring), pd_offset); } }
drivers/gpu/drm/i915/i915_reg.h +0 -1
@@ -117,7 +117,6 @@#define RING_PP_DIR_BASE (ring) ((ring)->mmio_base+0x228)#define RING_PP_DIR_BASE_READ (ring) ((ring)->mmio_base+0x518)#define RING_PP_DIR_DCLV (ring) ((ring)->mmio_base+0x220) -#define PP_DIR_DCLV_2G 0xffffffff#define GAM_ECOCHK 0x4090#define ECOCHK_SNB_BIT (1<<10)
Signature · 1 line
1.8.1.1
Jani Nikula
maintainerRe: [PATCH 5/5] drm/i915: Dynamically calculate dclv
Quoted 18 lines · Ben Widawsky
Directory CacheLine Valid controls which PDEs are held in the directory cache. Each bit represents 16 PDEs (16 PDEs at 4 bytes per entry is 1 cacheline, and therefore, almost makes sense).
Since we can now have an aliasing PPGTT which isn't 2GB, theoretically, we should also modify the DCLV value to fit accordingly.
Signed-off-by Ben Widawsky <[email protected]>--- drivers/gpu/drm/i915/i915_gem_gtt.c | 5 +++-- drivers/gpu/drm/i915/i915_reg.h | 1 - 2 files changed, 3 insertions(+), 3 deletions(-)drivers/gpu/drm/i915/i915_gem_gtt.c +0
-0
drivers/gpu/drm/i915/i915_gem_gtt.c void i915_gem_init_ppgtt(struct drm_device *dev) · line 348
Quoted 5 lines
drivers/gpu/drm/i915/i915_gem_gtt.c +2
-0@@ -344,11 +344,12 @@ void i915_gem_init_ppgtt(struct drm_device *dev) }for_each_ring (ring, dev_priv, i) { +uint64_t dclv = ppgtt->mapped_size >>26 ; + dclv = (1ULL << dclv) -1 ;
Maybe add a comment with some of the info from the commit message here?
BR,
Jani.
Quoted 28 lines
drivers/gpu/drm/i915/i915_gem_gtt.c +1
-2if (INTEL_INFO (dev)->gen >=7 )I915_WRITE (RING_MODE_GEN7 (ring),_MASKED_BIT_ENABLE (GFX_PPGTT_ENABLE )); - -I915_WRITE (RING_PP_DIR_DCLV (ring),PP_DIR_DCLV_2G ); +I915_WRITE (RING_PP_DIR_DCLV (ring), dclv);I915_WRITE (RING_PP_DIR_BASE (ring), pd_offset); } }drivers/gpu/drm/i915/i915_reg.h +0
-1@@ -117,7 +117,6 @@#define RING_PP_DIR_BASE (ring) ((ring)->mmio_base+0x228)#define RING_PP_DIR_BASE_READ (ring) ((ring)->mmio_base+0x518)#define RING_PP_DIR_DCLV (ring) ((ring)->mmio_base+0x220) -#define PP_DIR_DCLV_2G 0xffffffff#define GAM_ECOCHK 0x4090#define ECOCHK_SNB_BIT (1<<10)Signature · 6 lines
1.8.1.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 5/5 drm/i915: Dynamically calculate dclv
In reply to Ben WidawskyDirectory CacheLine Valid controls which PDEs are held in the directory cache. Each bit represents 16 PDEs (16 PDEs at 4 bytes per entry is 1 cacheline, and therefore, almost makes sense).
Since we can now have an aliasing PPGTT which isn't 2GB, theoretically, we should also modify the DCLV value to fit accordingly.
v2: Add part of this commit message to the code as a comment (Jani)
--- drivers/gpu/drm/i915/i915_gem_gtt.c | 7 +++++-- drivers/gpu/drm/i915/i915_reg.h | 1 - 2 files changed, 5 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_gem_gtt.c +5 -2
@@ -344,11 +344,14 @@ void i915_gem_init_ppgtt(struct drm_device *dev) }for_each_ring (ring, dev_priv, i) { +/* Directory CacheLine Valid controls which PDEs are held in the +* directory cache. Each bit represents 16 PDEs */ +uint64_t dclv = ppgtt->mapped_size >>26 ; + dclv = (1ULL << dclv) -1 ;if (INTEL_INFO (dev)->gen >=7 )I915_WRITE (RING_MODE_GEN7 (ring),_MASKED_BIT_ENABLE (GFX_PPGTT_ENABLE )); - -I915_WRITE (RING_PP_DIR_DCLV (ring),PP_DIR_DCLV_2G ); +I915_WRITE (RING_PP_DIR_DCLV (ring), dclv);I915_WRITE (RING_PP_DIR_BASE (ring), pd_offset); } }
drivers/gpu/drm/i915/i915_reg.h +0 -1
@@ -117,7 +117,6 @@#define RING_PP_DIR_BASE (ring) ((ring)->mmio_base+0x228)#define RING_PP_DIR_BASE_READ (ring) ((ring)->mmio_base+0x518)#define RING_PP_DIR_DCLV (ring) ((ring)->mmio_base+0x220) -#define PP_DIR_DCLV_2G 0xffffffff#define GAM_ECOCHK 0x4090#define ECOCHK_SNB_BIT (1<<10)
Signature · 1 line
1.8.1.1
Re: [PATCH 5/5] drm/i915: Dynamically calculate dclv
In reply to Ben WidawskyQuoted 18 lines · Ben Widawsky
Directory CacheLine Valid controls which PDEs are held in the directory cache. Each bit represents 16 PDEs (16 PDEs at 4 bytes per entry is 1 cacheline, and therefore, almost makes sense).
Since we can now have an aliasing PPGTT which isn't 2GB, theoretically, we should also modify the DCLV value to fit accordingly.
Signed-off-by Ben Widawsky <[email protected]>--- drivers/gpu/drm/i915/i915_gem_gtt.c | 5 +++-- drivers/gpu/drm/i915/i915_reg.h | 1 - 2 files changed, 3 insertions(+), 3 deletions(-)drivers/gpu/drm/i915/i915_gem_gtt.c +0
-0
drivers/gpu/drm/i915/i915_gem_gtt.c void i915_gem_init_ppgtt(struct drm_device *dev) · line 347
Quoted 4 lines
drivers/gpu/drm/i915/i915_gem_gtt.c +1
-0@@ -344,11 +344,12 @@ void i915_gem_init_ppgtt(struct drm_device *dev) }for_each_ring (ring, dev_priv, i) { +uint64_t dclv = ppgtt->mapped_size >>26 ;
ppgtt->num_pd_entries / 16? Would be much more self-documenting than the almost magic >> 26 ...
-Daniel
Quoted 29 lines
drivers/gpu/drm/i915/i915_gem_gtt.c +2
-2+ dclv = (1ULL << dclv) -1 ;if (INTEL_INFO (dev)->gen >=7 )I915_WRITE (RING_MODE_GEN7 (ring),_MASKED_BIT_ENABLE (GFX_PPGTT_ENABLE )); - -I915_WRITE (RING_PP_DIR_DCLV (ring),PP_DIR_DCLV_2G ); +I915_WRITE (RING_PP_DIR_DCLV (ring), dclv);I915_WRITE (RING_PP_DIR_BASE (ring), pd_offset); } }drivers/gpu/drm/i915/i915_reg.h +0
-1@@ -117,7 +117,6 @@#define RING_PP_DIR_BASE (ring) ((ring)->mmio_base+0x228)#define RING_PP_DIR_BASE_READ (ring) ((ring)->mmio_base+0x518)#define RING_PP_DIR_DCLV (ring) ((ring)->mmio_base+0x220) -#define PP_DIR_DCLV_2G 0xffffffff#define GAM_ECOCHK 0x4090#define ECOCHK_SNB_BIT (1<<10)Signature · 6 lines
1.8.1.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Quoted 9 lines · Ben Widawsky
This work sort of led me on the gtt vtable distraction which ended in Daniel doing his own version. I posted these originally about a month ago. I've rebased them on dinq. I'd like to see them get merged since they still help with some other work I'm doing on PPGTT.
Some of this work does conflict a bit with the gtt vtable stuff.
I did a decent amount of testing on the original post, less so on this rebased version.
On the series, with my limited exposure to (pp)gtt,
Quoted 21 lines
Ben Widawsky (5):
drm/i915: trivial: kill-agp collateral cleanups
drm/i915: Reclaim GTT space for failed PPGTT
drm/i915: Extract gen6 aliasing ppgtt code
drm/i915: Aliased PPGTT size abstraction
drm/i915: Dynamically calculate dclvdrivers/gpu/drm/i915/i915_debugfs.c | 2 + drivers/gpu/drm/i915/i915_drv.h | 6 +-- drivers/gpu/drm/i915/i915_gem_gtt.c | 101 +++++++++++++++++++++++------------- drivers/gpu/drm/i915/i915_reg.h | 1 - 4 files changed, 71 insertions(+), 39 deletions(-)Signature · 6 lines
1.8.1.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx