diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2017-01-06 10:22:39 -0500 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2017-01-06 11:54:17 -0500 |
commit | 1a292fa53d06e53000296ba76c6984a43e1e828c (patch) | |
tree | dcc3136667a08b27e222a167219390f0832925a6 | |
parent | 10466d2a59b23aa6d5ecd5310296c8cdb6458dac (diff) |
drm/i915: Purge loose pages if we run out of DMA remap space
If the DMA remap fails, one cause can be that we have too many objects
pinned in a small remapping table, such as swiotlb. (DMA remapping does
not trigger the shrinker by itself on its normal failure paths.) 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@chris-wilson.co.uk>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170106152240.5793-2-chris@chris-wilson.co.uk
-rw-r--r-- | drivers/gpu/drm/i915/i915_gem_gtt.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c index 00520f27bea6..f698006fe883 100644 --- a/drivers/gpu/drm/i915/i915_gem_gtt.c +++ b/drivers/gpu/drm/i915/i915_gem_gtt.c | |||
@@ -2361,10 +2361,24 @@ void i915_gem_suspend_gtt_mappings(struct drm_i915_private *dev_priv) | |||
2361 | int i915_gem_gtt_prepare_pages(struct drm_i915_gem_object *obj, | 2361 | int i915_gem_gtt_prepare_pages(struct drm_i915_gem_object *obj, |
2362 | struct sg_table *pages) | 2362 | struct sg_table *pages) |
2363 | { | 2363 | { |
2364 | if (dma_map_sg(&obj->base.dev->pdev->dev, | 2364 | do { |
2365 | pages->sgl, pages->nents, | 2365 | if (dma_map_sg(&obj->base.dev->pdev->dev, |
2366 | PCI_DMA_BIDIRECTIONAL)) | 2366 | pages->sgl, pages->nents, |
2367 | return 0; | 2367 | PCI_DMA_BIDIRECTIONAL)) |
2368 | return 0; | ||
2369 | |||
2370 | /* If the DMA remap fails, one cause can be that we have | ||
2371 | * too many objects pinned in a small remapping table, | ||
2372 | * such as swiotlb. Incrementally purge all other objects and | ||
2373 | * try again - if there are no more pages to remove from | ||
2374 | * the DMA remapper, i915_gem_shrink will return 0. | ||
2375 | */ | ||
2376 | GEM_BUG_ON(obj->mm.pages == pages); | ||
2377 | } while (i915_gem_shrink(to_i915(obj->base.dev), | ||
2378 | obj->base.size >> PAGE_SHIFT, | ||
2379 | I915_SHRINK_BOUND | | ||
2380 | I915_SHRINK_UNBOUND | | ||
2381 | I915_SHRINK_ACTIVE)); | ||
2368 | 2382 | ||
2369 | return -ENOSPC; | 2383 | return -ENOSPC; |
2370 | } | 2384 | } |