drm/i915: Remove livelock from "do_idle_maps" vtd w/a
authorChris Wilson <chris@chris-wilson.co.uk>
Wed, 9 Dec 2020 16:40:06 +0000 (16:40 +0000)
committerChris Wilson <chris@chris-wilson.co.uk>
Wed, 9 Dec 2020 19:32:51 +0000 (19:32 +0000)
A call to wait for the GT to idle from inside the put_pages fallback is
prone to cause an uninterruptible livelock. As it does not provide
adequate serialisation with new requests, simply fallback to a trivial
sleep.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20201209164008.5487-1-chris@chris-wilson.co.uk
drivers/gpu/drm/i915/i915_gem_gtt.c

index c5ee156..3ee2f68 100644 (file)
@@ -55,22 +55,17 @@ int i915_gem_gtt_prepare_pages(struct drm_i915_gem_object *obj,
 void i915_gem_gtt_finish_pages(struct drm_i915_gem_object *obj,
                               struct sg_table *pages)
 {
-       struct drm_i915_private *dev_priv = to_i915(obj->base.dev);
-       struct device *kdev = &dev_priv->drm.pdev->dev;
-       struct i915_ggtt *ggtt = &dev_priv->ggtt;
-
-       if (unlikely(ggtt->do_idle_maps)) {
-               /* XXX This does not prevent more requests being submitted! */
-               if (intel_gt_retire_requests_timeout(ggtt->vm.gt,
-                                                    -MAX_SCHEDULE_TIMEOUT)) {
-                       drm_err(&dev_priv->drm,
-                               "Failed to wait for idle; VT'd may hang.\n");
-                       /* Wait a bit, in hopes it avoids the hang */
-                       udelay(10);
-               }
-       }
+       struct drm_i915_private *i915 = to_i915(obj->base.dev);
+       struct i915_ggtt *ggtt = &i915->ggtt;
+
+       /* XXX This does not prevent more requests being submitted! */
+       if (unlikely(ggtt->do_idle_maps))
+               /* Wait a bit, in the hope it avoids the hang */
+               usleep_range(100, 250);
 
-       dma_unmap_sg(kdev, pages->sgl, pages->nents, PCI_DMA_BIDIRECTIONAL);
+       dma_unmap_sg(&i915->drm.pdev->dev,
+                    pages->sgl, pages->nents,
+                    PCI_DMA_BIDIRECTIONAL);
 }
 
 /**