Skip to content

Commit 0a87871

Browse files
committed
drm/i915: restore ggtt double-bind avoidance
This was accidentally lost in commit 75d04a3 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 d0e30ad 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 0875546 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. v5: Style nits. Cc: Chris Wilson <[email protected]> Cc: Michel Thierry <[email protected]> Cc: Mika Kuoppala <[email protected]> Signed-off-by: Daniel Vetter <[email protected]> Link: http://mid.gmane.org/[email protected] Reviewed-by: Chris Wilson <[email protected]> Signed-off-by: Daniel Vetter <[email protected]>
1 parent e12c8ce commit 0a87871

File tree

1 file changed

+34
-12
lines changed

1 file changed

+34
-12
lines changed

drivers/gpu/drm/i915/i915_gem_gtt.c

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2501,6 +2501,36 @@ static void i915_ggtt_clear_range(struct i915_address_space *vm,
25012501
static int ggtt_bind_vma(struct i915_vma *vma,
25022502
enum i915_cache_level cache_level,
25032503
u32 flags)
2504+
{
2505+
struct drm_i915_gem_object *obj = vma->obj;
2506+
u32 pte_flags = 0;
2507+
int ret;
2508+
2509+
ret = i915_get_ggtt_vma_pages(vma);
2510+
if (ret)
2511+
return ret;
2512+
2513+
/* Currently applicable only to VLV */
2514+
if (obj->gt_ro)
2515+
pte_flags |= PTE_READ_ONLY;
2516+
2517+
vma->vm->insert_entries(vma->vm, vma->ggtt_view.pages,
2518+
vma->node.start,
2519+
cache_level, pte_flags);
2520+
2521+
/*
2522+
* Without aliasing PPGTT there's no difference between
2523+
* GLOBAL/LOCAL_BIND, it's all the same ptes. Hence unconditionally
2524+
* upgrade to both bound if we bind either to avoid double-binding.
2525+
*/
2526+
vma->bound |= GLOBAL_BIND | LOCAL_BIND;
2527+
2528+
return 0;
2529+
}
2530+
2531+
static int aliasing_gtt_bind_vma(struct i915_vma *vma,
2532+
enum i915_cache_level cache_level,
2533+
u32 flags)
25042534
{
25052535
struct drm_device *dev = vma->vm->dev;
25062536
struct drm_i915_private *dev_priv = dev->dev_private;
@@ -2519,23 +2549,13 @@ static int ggtt_bind_vma(struct i915_vma *vma,
25192549
pte_flags |= PTE_READ_ONLY;
25202550

25212551

2522-
if (!dev_priv->mm.aliasing_ppgtt || flags & GLOBAL_BIND) {
2552+
if (flags & GLOBAL_BIND) {
25232553
vma->vm->insert_entries(vma->vm, pages,
25242554
vma->node.start,
25252555
cache_level, pte_flags);
2526-
2527-
/* Note the inconsistency here is due to absence of the
2528-
* aliasing ppgtt on gen4 and earlier. Though we always
2529-
* request PIN_USER for execbuffer (translated to LOCAL_BIND),
2530-
* without the appgtt, we cannot honour that request and so
2531-
* must substitute it with a global binding. Since we do this
2532-
* behind the upper layers back, we need to explicitly set
2533-
* the bound flag ourselves.
2534-
*/
2535-
vma->bound |= GLOBAL_BIND;
25362556
}
25372557

2538-
if (dev_priv->mm.aliasing_ppgtt && flags & LOCAL_BIND) {
2558+
if (flags & LOCAL_BIND) {
25392559
struct i915_hw_ppgtt *appgtt = dev_priv->mm.aliasing_ppgtt;
25402560
appgtt->base.insert_entries(&appgtt->base, pages,
25412561
vma->node.start,
@@ -2699,6 +2719,8 @@ static int i915_gem_setup_global_gtt(struct drm_device *dev,
26992719
true);
27002720

27012721
dev_priv->mm.aliasing_ppgtt = ppgtt;
2722+
WARN_ON(dev_priv->gtt.base.bind_vma != ggtt_bind_vma);
2723+
dev_priv->gtt.base.bind_vma = aliasing_gtt_bind_vma;
27022724
}
27032725

27042726
return 0;

0 commit comments

Comments
 (0)