drm/i915: restore ggtt double-bind avoidance
Subsystems (2)
PATCH 1/1 drm/i915: restore ggtt double-bind avoidance
This was accidentally lost in
commit 75d04a3773ecee617847de963ae4195d6aa74c28
Author: Mika Kuoppala <[email protected]> Date: Tue Apr 28 17:56:17 2015 +0300
drm/i915/gtt: Allocate va range only if vma is not bound
While at it implement an improved version suggested by Chris which avoids the double-bind irrespective of what type of bind is done first.
--- drivers/gpu/drm/i915/i915_gem_gtt.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/i915/i915_gem_gtt.c +3 -0
@@ -2542,6 +2542,9 @@ static int ggtt_bind_vma(struct i915_vma *vma, cache_level, pte_flags); } +if (!dev_priv->mm.aliasing_ppgtt) + vma->bound |=GLOBAL_BIND |LOCAL_BIND ; +return 0 ; }
Signature · 6 lines
2.5.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 25 lines · Daniel Vetter
This was accidentally lost in
commit
75d04a3773ecee617847de963ae4195d6aa74c28Author: Mika Kuoppala <[email protected]> Date: Tue Apr 28 17:56:17 2015 +0300drm/i915/gtt: Allocate va range only if vma is not bound
While at it implement an improved version suggested by Chris which avoids the double-bind irrespective of what type of bind is done first.
Cc Chris Wilson <[email protected]>Cc Michel Thierry <[email protected]>Cc Mika Kuoppala <[email protected]>Signed-off-by Daniel Vetter <[email protected]>--- drivers/gpu/drm/i915/i915_gem_gtt.c | 3 +++ 1 file changed, 3 insertions(+)drivers/gpu/drm/i915/i915_gem_gtt.c +0
-0
drivers/gpu/drm/i915/i915_gem_gtt.c static int ggtt_bind_vma(struct i915_vma *vma, · line 2549
Quoted 8 lines
drivers/gpu/drm/i915/i915_gem_gtt.c +3
-0@@ -2542,6 +2542,9 @@ static int ggtt_bind_vma(struct i915_vma *vma, cache_level, pte_flags); } +if (!dev_priv->mm.aliasing_ppgtt) + vma->bound |=GLOBAL_BIND |LOCAL_BIND ; +return 0 ; }
Didn't we already add:
if (!dev_priv->mm.aliasing_ppgtt || flags & GLOBAL_BIND) {
vma->vm->insert_entries(vma->vm,
vma->ggtt_view.pages,
vma->node.start,
cache_level, pte_flags);
/* Note the inconsistency here is due to absence of the
* aliasing ppgtt on gen4 and earlier. Though we always
* request PIN_USER for execbuffer (translated to LOCAL_BIND),
* without the appgtt, we cannot honour that request and so
* must substitute it with a global binding. Since we do this
* behind the upper layers back, we need to explicitly set
* the bound flag ourselves.
*/
vma->bound |= GLOBAL_BIND;
}to ggtt_bind_vma() ?
-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
Quoted 55 lines · Chris Wilson
Quoted 25 lines · Daniel Vetter
This was accidentally lost in
commit
75d04a3773ecee617847de963ae4195d6aa74c28Author: Mika Kuoppala <[email protected]> Date: Tue Apr 28 17:56:17 2015 +0300drm/i915/gtt: Allocate va range only if vma is not bound
While at it implement an improved version suggested by Chris which avoids the double-bind irrespective of what type of bind is done first.
Cc Chris Wilson <[email protected]>Cc Michel Thierry <[email protected]>Cc Mika Kuoppala <[email protected]>Signed-off-by Daniel Vetter <[email protected]>--- drivers/gpu/drm/i915/i915_gem_gtt.c | 3 +++ 1 file changed, 3 insertions(+)drivers/gpu/drm/i915/i915_gem_gtt.c +0
-0drivers/gpu/drm/i915/i915_gem_gtt.c static int ggtt_bind_vma(struct i915_vma *vma, · line 2549
Quoted 8 lines
drivers/gpu/drm/i915/i915_gem_gtt.c +3
-0@@ -2542,6 +2542,9 @@ static int ggtt_bind_vma(struct i915_vma *vma, cache_level, pte_flags); } +if (!dev_priv->mm.aliasing_ppgtt) + vma->bound |=GLOBAL_BIND |LOCAL_BIND ; +return 0 ; }Didn't we already add:
if (!dev_priv->mm.aliasing_ppgtt || flags & GLOBAL_BIND) { vma->vm->insert_entries(vma->vm, vma->ggtt_view.pages, vma->node.start, cache_level, pte_flags); /* Note the inconsistency here is due to absence of the * aliasing ppgtt on gen4 and earlier. Though we always * request PIN_USER for execbuffer (translated to LOCAL_BIND), * without the appgtt, we cannot honour that request and so * must substitute it with a global binding. Since we do this * behind the upper layers back, we need to explicitly set * the bound flag ourselves. */ vma->bound |= GLOBAL_BIND; }
Quoted 1 line
to
ggtt_bind_vma()?
Yeah, my patch superseeds this one (it's an old one, cherrished for a long time) - LOCAL_BIND also implies GLOBAL_BIND if we lack a ppgtt. This is something I've missed in
commit 0875546c5318c85c13d07014af5350e9000bc9e9
Author: Daniel Vetter <[email protected]> Date: Mon Apr 20 09:04:05 2015 -0700
drm/i915: Fix up the vma aliasing ppgtt binding
I'll frob the patch a bit and ping you on irc, but first lunch. -Daniel
Quoted 4 lines
-Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 1/1 drm/i915: restore ggtt double-bind avoidance
In reply to Daniel VetterThis was accidentally lost in
commit 75d04a3773ecee617847de963ae4195d6aa74c28
Author: Mika Kuoppala <[email protected]> Date: Tue Apr 28 17:56:17 2015 +0300
drm/i915/gtt: Allocate va range only if vma is not bound
While at it implement an improved version suggested by Chris which avoids the double-bind irrespective of what type of bind is done first.
Note that this exact bug was already addressed in
commit d0e30adc42d979e4adc36b6c112b57337423b70c
Author: Chris Wilson <[email protected]> Date: Wed Jul 29 20:02:48 2015 +0100
drm/i915: Mark PIN_USER binding as GLOBAL_BIND without the aliasing ppgtt
but the problem is still that originally in
commit 0875546c5318c85c13d07014af5350e9000bc9e9
Author: Daniel Vetter <[email protected]> Date: Mon Apr 20 09:04:05 2015 -0700
drm/i915: Fix up the vma aliasing ppgtt binding
if forgotten to take into account there case where we have a GLOBAL_BIND before a LOCAL_BIND. This patch here fixes that.
v2: Pimp commit message and revert the partial fix.
v3: Split into two functions to specialize on aliasing_ppgtt y/n.
v4: WARN_ON for paranoia in the init sequence, since the ggtt probe and aliasing ppgtt setup are far apart.
--- drivers/gpu/drm/i915/i915_gem_gtt.c | 49 ++++++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 12 deletions(-)
drivers/gpu/drm/i915/i915_gem_gtt.c +37 -12
@@ -2502,6 +2502,39 @@ static int ggtt_bind_vma(struct i915_vma *vma, enum i915_cache_level cache_level, u32 flags) { +struct drm_i915_gem_object *obj = vma->obj; +struct sg_table *pages = obj->pages; +u32 pte_flags =0 ; +int ret; + + ret =i915_get_ggtt_vma_pages (vma); +if (ret) +return ret; + pages = vma->ggtt_view.pages; + +/* Currently applicable only to VLV */ +if (obj->gt_ro) + pte_flags |=PTE_READ_ONLY ; + + + vma->vm->insert_entries (vma->vm, pages, + vma->node.start, + cache_level, pte_flags); + +/* +* Without aliasing PPGTT there's no difference between +* GLOBAL/LOCAL_BIND, it's all the same ptes. Hence unconditionally +* upgrade to both bound if we bind either to avoid double-binding. +*/ + vma->bound |=GLOBAL_BIND |LOCAL_BIND ; + +return 0 ; +} + +static int aliasing_gtt_bind_vma (struct i915_vma *vma, +enum i915_cache_level cache_level, +u32 flags) +{struct drm_device *dev = vma->vm->dev;struct drm_i915_private *dev_priv = dev->dev_private;struct drm_i915_gem_object *obj = vma->obj;
@@ -2519,23 +2552,13 @@ static int ggtt_bind_vma(struct i915_vma *vma, pte_flags |=PTE_READ_ONLY ; -if (!dev_priv->mm.aliasing_ppgtt || flags &GLOBAL_BIND ) { +if (flags &GLOBAL_BIND ) { vma->vm->insert_entries (vma->vm, pages, vma->node.start, cache_level, pte_flags); - -/* Note the inconsistency here is due to absence of the -* aliasing ppgtt on gen4 and earlier. Though we always -* request PIN_USER for execbuffer (translated to LOCAL_BIND), -* without the appgtt, we cannot honour that request and so -* must substitute it with a global binding. Since we do this -* behind the upper layers back, we need to explicitly set -* the bound flag ourselves. -*/ - vma->bound |=GLOBAL_BIND ; } -if (dev_priv->mm.aliasing_ppgtt && flags &LOCAL_BIND ) { +if (flags &LOCAL_BIND ) {struct i915_hw_ppgtt *appgtt = dev_priv->mm.aliasing_ppgtt; appgtt->base.insert_entries(&appgtt->base, pages, vma->node.start,
@@ -2699,6 +2722,8 @@ static int i915_gem_setup_global_gtt(struct drm_device *dev, true); dev_priv->mm.aliasing_ppgtt = ppgtt; +WARN_ON (dev_priv->gtt.base.bind_vma != ggtt_bind_vma); + dev_priv->gtt.base.bind_vma = aliasing_gtt_bind_vma; }return 0 ;
Signature · 6 lines
2.5.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 52 lines · Daniel Vetter
This was accidentally lost in
commit
75d04a3773ecee617847de963ae4195d6aa74c28Author: Mika Kuoppala <[email protected]> Date: Tue Apr 28 17:56:17 2015 +0300drm/i915/gtt: Allocate va range only if vma is not bound
While at it implement an improved version suggested by Chris which avoids the double-bind irrespective of what type of bind is done first.
Note that this exact bug was already addressed in
commit
d0e30adc42d979e4adc36b6c112b57337423b70cAuthor: Chris Wilson <[email protected]> Date: Wed Jul 29 20:02:48 2015 +0100drm/i915: Mark
PIN_USERbinding asGLOBAL_BINDwithout the aliasing ppgttbut the problem is still that originally in
commit
0875546c5318c85c13d07014af5350e9000bc9e9Author: Daniel Vetter <[email protected]> Date: Mon Apr 20 09:04:05 2015 -0700drm/i915: Fix up the vma aliasing ppgtt binding
if forgotten to take into account there case where we have a
GLOBAL_BINDbefore aLOCAL_BIND. This patch here fixes that.v2: Pimp commit message and revert the partial fix.
v3: Split into two functions to specialize on
aliasing_ppgtty/n.v4:
WARN_ONfor paranoia in the init sequence, since the ggtt probe and aliasing ppgtt setup are far apart.Cc Chris Wilson <[email protected]>Cc Michel Thierry <[email protected]>Cc Mika Kuoppala <[email protected]>Signed-off-by Daniel Vetter <[email protected]>--- drivers/gpu/drm/i915/i915_gem_gtt.c | 49 ++++++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 12 deletions(-)drivers/gpu/drm/i915/i915_gem_gtt.c +0
-0
drivers/gpu/drm/i915/i915_gem_gtt.c static int ggtt_bind_vma(struct i915_vma *vma, · line 2506
Quoted 5 lines
drivers/gpu/drm/i915/i915_gem_gtt.c +2
-0@@ -2502,6 +2502,39 @@ static int ggtt_bind_vma(struct i915_vma *vma, enum i915_cache_level cache_level, u32 flags) { +struct drm_i915_gem_object *obj = vma->obj; +struct sg_table *pages = obj->pages;
Time to drop this as it is now correctly set later from the ggtt view. As we then only use obj in one place, lets use it directly. (Having read-only and read-write vma is a posibility to consider, too bad the read-only flag didn't come into greater use by hw.)
drivers/gpu/drm/i915/i915_gem_gtt.c static int ggtt_bind_vma(struct i915_vma *vma, · line 2519
Quoted 13 lines
drivers/gpu/drm/i915/i915_gem_gtt.c +13
-0+u32 pte_flags =0 ; +int ret; + + ret =i915_get_ggtt_vma_pages (vma); +if (ret) +return ret; + pages = vma->ggtt_view.pages; + +/* Currently applicable only to VLV */ +if (obj->gt_ro) + pte_flags |=PTE_READ_ONLY ; + +
Spare line we can trade in.
drivers/gpu/drm/i915/i915_gem_gtt.c static int ggtt_bind_vma(struct i915_vma *vma, · line 2520
Quoted 1 line
drivers/gpu/drm/i915/i915_gem_gtt.c +1
-0+ vma->vm->insert_entries(vma->vm, pages,
And since we only use pages here we can just use vma->gtt_view.pages instead.
Quoted 10 lines
drivers/gpu/drm/i915/i915_gem_gtt.c +10
-0+ vma->node.start, + cache_level, pte_flags); + +/* +* Without aliasing PPGTT there's no difference between +* GLOBAL/LOCAL_BIND, it's all the same ptes. Hence unconditionally +* upgrade to both bound if we bind either to avoid double-binding. +*/ + vma->bound |=GLOBAL_BIND |LOCAL_BIND ; +
drivers/gpu/drm/i915/i915_gem_gtt.c static int ggtt_bind_vma(struct i915_vma *vma, · line 2540
Quoted 10 lines
drivers/gpu/drm/i915/i915_gem_gtt.c +7
-0+return 0 ; +} + +static int aliasing_gtt_bind_vma (struct i915_vma *vma, +enum i915_cache_level cache_level, +u32 flags) +{struct drm_device *dev = vma->vm->dev;struct drm_i915_private *dev_priv = dev->dev_private;struct drm_i915_gem_object *obj = vma->obj;
Could make similar contractions here but meh.
Stylistic nitpicks aside,
-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