[PATCH 2/2] drm/i915: Purge loose pages if we run out of DMA remap space
Chris Wilson
chris at chris-wilson.co.uk
Sat Dec 24 14:28:23 UTC 2016
If the DMA remap fails, one cause can be that we have too many objects
pinned in a small remapping table, such as swiotlb. So try purging all
other objects (using i915_gem_shrink_all(), sparing our own pages as we
have yet to assign them to the obj->pages) and try again. If there are
no pages to reclaim (and consequently no pages to unmap), the shrinker
will report 0 and we fail with -ENOSPC as before.
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
drivers/gpu/drm/i915/i915_gem_gtt.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index 6af9311f72f5..f678c0c80cb3 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -2361,10 +2361,20 @@ void i915_gem_suspend_gtt_mappings(struct drm_i915_private *dev_priv)
int i915_gem_gtt_prepare_pages(struct drm_i915_gem_object *obj,
struct sg_table *pages)
{
- if (dma_map_sg(&obj->base.dev->pdev->dev,
- pages->sgl, pages->nents,
- PCI_DMA_BIDIRECTIONAL))
- return 0;
+ do {
+ if (dma_map_sg(&obj->base.dev->pdev->dev,
+ pages->sgl, pages->nents,
+ PCI_DMA_BIDIRECTIONAL))
+ return 0;
+
+ /* If the DMA remap fails, one cause can be that we have
+ * too many objects pinned in a small remapping table,
+ * such as swiotlb. Purging all other objects and
+ * try again - if there are no more pages to remove from
+ * the DMA remapper, i915_gem_shrink_all will return 0.
+ */
+ GEM_BUG_ON(obj->mm.pages == pages);
+ } while (i915_gem_shrink_all(to_i915(obj->base.dev)));
return -ENOSPC;
}
--
2.11.0
More information about the Intel-gfx-trybot
mailing list