aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/i915_gem_gtt.c
diff options
context:
space:
mode:
authorBen Widawsky <benjamin.widawsky@intel.com>2013-12-06 17:11:08 -0500
committerDaniel Vetter <daniel.vetter@ffwll.ch>2013-12-18 09:27:58 -0500
commite3cc19957f519dede119d6fc2fc51869bfb09e0e (patch)
tree0b51b502315475397a3443cbea05b4f454939d59 /drivers/gpu/drm/i915/i915_gem_gtt.c
parentc8d4c0d6683d9270c3f1b69b73848f6fadf0d78b (diff)
drm/i915: One hopeful eviction on PPGTT alloc
The patch before this changed the way in which we allocate space for the PPGTT PDEs. It began carving out the PPGTT PDEs (which live in the Global GTT) from the GGTT's drm_mm. Prior to that patch, the PDEs were hidden from the drm_mm, and therefore could never fail to be allocated. In unfortunate cases, the drm_mm may be full when we want to allocate the space. This can technically occur whenever we try to allocate, which happens in two places currently. Practically, it can only really ever happen at GPU reset. Later, when we allocate more PDEs for multiple PPGTTs this will potentially even more useful. Signed-off-by: Ben Widawsky <ben@bwidawsk.net> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers/gpu/drm/i915/i915_gem_gtt.c')
-rw-r--r--drivers/gpu/drm/i915/i915_gem_gtt.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index 926b2a669de1..91a76dfd6490 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -640,6 +640,7 @@ static int gen6_ppgtt_init(struct i915_hw_ppgtt *ppgtt)
640#define GEN6_PD_SIZE (GEN6_PPGTT_PD_ENTRIES * PAGE_SIZE) 640#define GEN6_PD_SIZE (GEN6_PPGTT_PD_ENTRIES * PAGE_SIZE)
641 struct drm_device *dev = ppgtt->base.dev; 641 struct drm_device *dev = ppgtt->base.dev;
642 struct drm_i915_private *dev_priv = dev->dev_private; 642 struct drm_i915_private *dev_priv = dev->dev_private;
643 bool retried = false;
643 int i, ret; 644 int i, ret;
644 645
645 /* PPGTT PDEs reside in the GGTT and consists of 512 entries. The 646 /* PPGTT PDEs reside in the GGTT and consists of 512 entries. The
@@ -647,13 +648,22 @@ static int gen6_ppgtt_init(struct i915_hw_ppgtt *ppgtt)
647 * size. We allocate at the top of the GTT to avoid fragmentation. 648 * size. We allocate at the top of the GTT to avoid fragmentation.
648 */ 649 */
649 BUG_ON(!drm_mm_initialized(&dev_priv->gtt.base.mm)); 650 BUG_ON(!drm_mm_initialized(&dev_priv->gtt.base.mm));
651alloc:
650 ret = drm_mm_insert_node_in_range_generic(&dev_priv->gtt.base.mm, 652 ret = drm_mm_insert_node_in_range_generic(&dev_priv->gtt.base.mm,
651 &ppgtt->node, GEN6_PD_SIZE, 653 &ppgtt->node, GEN6_PD_SIZE,
652 GEN6_PD_ALIGN, 0, 654 GEN6_PD_ALIGN, 0,
653 0, dev_priv->gtt.base.total, 655 0, dev_priv->gtt.base.total,
654 DRM_MM_SEARCH_DEFAULT); 656 DRM_MM_SEARCH_DEFAULT);
655 if (ret) 657 if (ret == -ENOSPC && !retried) {
656 return ret; 658 ret = i915_gem_evict_something(dev, &dev_priv->gtt.base,
659 GEN6_PD_SIZE, GEN6_PD_ALIGN,
660 I915_CACHE_NONE, false, true);
661 if (ret)
662 return ret;
663
664 retried = true;
665 goto alloc;
666 }
657 667
658 if (ppgtt->node.start < dev_priv->gtt.mappable_end) 668 if (ppgtt->node.start < dev_priv->gtt.mappable_end)
659 DRM_DEBUG("Forced to use aperture for PDEs\n"); 669 DRM_DEBUG("Forced to use aperture for PDEs\n");