[PATCH v2] drm/i915/gem: reschedule relocations to avoid timeouts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Platforms with greater system memory will need to relocate more entries.
It may lead to soft hangs.

Adding cond_resched() for rescheduling process to avoid timeouts.

Suggested-by: Chris Wilson <chris.p.wilson@xxxxxxxxx>
Signed-off-by: S A Muqthyar Ahmed <syed.abdul.muqthyar.ahmed@xxxxxxxxx>
---
 drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
index b7b2c14fd9e15e..25ab4b9e20049e 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
@@ -1551,6 +1551,11 @@ static int eb_relocate_vma(struct i915_execbuffer *eb, struct eb_vma *ev)
 			}
 		} while (r++, --count);
 		urelocs += ARRAY_SIZE(stack);
+
+		if (need_resched()) {
+			reloc_cache_reset(&eb->reloc_cache, eb);
+			cond_resched();
+		}
 	} while (remain);
 out:
 	reloc_cache_reset(&eb->reloc_cache, eb);
@@ -1564,18 +1569,19 @@ eb_relocate_vma_slow(struct i915_execbuffer *eb, struct eb_vma *ev)
 	struct drm_i915_gem_relocation_entry *relocs =
 		u64_to_ptr(typeof(*relocs), entry->relocs_ptr);
 	unsigned int i;
-	int err;
+	int err = 0;
 
-	for (i = 0; i < entry->relocation_count; i++) {
+	for (i = 0; !err && i < entry->relocation_count; i++) {
 		u64 offset = eb_relocate_entry(eb, ev, &relocs[i]);
 
-		if ((s64)offset < 0) {
+		if ((s64)offset < 0)
 			err = (int)offset;
-			goto err;
+
+		if (need_resched()) {
+			reloc_cache_reset(&eb->reloc_cache, eb);
+			cond_resched();
 		}
 	}
-	err = 0;
-err:
 	reloc_cache_reset(&eb->reloc_cache, eb);
 	return err;
 }
-- 
2.25.1




[Index of Archives]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux