[PATCH] drm/i915: Exprimental resume speedup.
Thomas Hellström
thomas.hellstrom at linux.intel.com
Wed Mar 23 17:19:33 UTC 2022
Signed-off-by: Thomas Hellström <thomas.hellstrom at linux.intel.com>
---
drivers/gpu/drm/i915/gt/intel_ggtt.c | 24 +++++++++++++++++++++++-
drivers/gpu/drm/i915/gt/intel_gtt.h | 3 +++
drivers/gpu/drm/i915/i915_driver.c | 5 +++++
3 files changed, 31 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/i915/gt/intel_ggtt.c b/drivers/gpu/drm/i915/gt/intel_ggtt.c
index 04191fe2ee34..d74cb871c348 100644
--- a/drivers/gpu/drm/i915/gt/intel_ggtt.c
+++ b/drivers/gpu/drm/i915/gt/intel_ggtt.c
@@ -1180,6 +1180,8 @@ static int i915_gmch_probe(struct i915_ggtt *ggtt)
ggtt->do_idle_maps = true;
}
+ ggtt->restored = true;
+
ggtt->vm.insert_page = i915_ggtt_insert_page;
ggtt->vm.insert_entries = i915_ggtt_insert_entries;
ggtt->vm.clear_range = i915_ggtt_clear_range;
@@ -1309,11 +1311,26 @@ bool i915_ggtt_resume_vm(struct i915_address_space *vm)
{
struct i915_vma *vma;
bool write_domain_objs = false;
+ bool retained_ptes;
drm_WARN_ON(&vm->i915->drm, !vm->is_ggtt && !vm->is_dpt);
/* First fill our portion of the GTT with scratch pages */
- vm->clear_range(vm, 0, vm->total);
+ retained_ptes =
+ /* Only matters where writing PTEs is slow */
+ GRAPHICS_VER(vm->i915) >= 8 &&
+ /* LMEM never retains content on suspend */
+ !HAS_LMEM(vm->i915) &&
+ /*
+ * If this is a GGTT vm and we restored from hibernate,
+ * content is lost.
+ */
+ (vm->is_ggtt && !i915_vm_to_ggtt(vm)->restored);
+
+ if (!retained_ptes) {
+ pr_err("Retained ptes was: %d\n", (int)retained_ptes);
+ vm->clear_range(vm, 0, vm->total);
+ }
/* clflush objects bound into the GGTT and rebind them. */
list_for_each_entry(vma, &vm->bound_list, vm_link) {
@@ -1352,3 +1369,8 @@ void i915_ggtt_resume(struct i915_ggtt *ggtt)
intel_ggtt_restore_fences(ggtt);
}
+
+void i915_ggtt_mark_restored(struct drm_i915_private *i915, bool val)
+{
+ to_gt(i915)->ggtt->restored = val;
+}
diff --git a/drivers/gpu/drm/i915/gt/intel_gtt.h b/drivers/gpu/drm/i915/gt/intel_gtt.h
index 4529b5e9f6e6..d16b3aa7ecc7 100644
--- a/drivers/gpu/drm/i915/gt/intel_gtt.h
+++ b/drivers/gpu/drm/i915/gt/intel_gtt.h
@@ -345,6 +345,8 @@ struct i915_ggtt {
bool do_idle_maps;
+ bool restored;
+
int mtrr;
/** Bit 6 swizzling required for X tiling */
@@ -570,6 +572,7 @@ void i915_ggtt_suspend_vm(struct i915_address_space *vm);
bool i915_ggtt_resume_vm(struct i915_address_space *vm);
void i915_ggtt_suspend(struct i915_ggtt *gtt);
void i915_ggtt_resume(struct i915_ggtt *ggtt);
+void i915_ggtt_mark_restored(struct drm_i915_private *i915, bool val);
void
fill_page_dma(struct drm_i915_gem_object *p, const u64 val, unsigned int count);
diff --git a/drivers/gpu/drm/i915/i915_driver.c b/drivers/gpu/drm/i915/i915_driver.c
index 64e6f76861f9..d77a28d4980f 100644
--- a/drivers/gpu/drm/i915/i915_driver.c
+++ b/drivers/gpu/drm/i915/i915_driver.c
@@ -1425,6 +1425,8 @@ static int i915_pm_suspend(struct device *kdev)
return -ENODEV;
}
+ i915_ggtt_mark_restored(i915, false);
+
if (i915->drm.switch_power_state == DRM_SWITCH_POWER_OFF)
return 0;
@@ -1536,6 +1538,9 @@ static int i915_pm_restore_early(struct device *kdev)
static int i915_pm_restore(struct device *kdev)
{
+ struct drm_i915_private *i915 = kdev_to_i915(kdev);
+
+ i915_ggtt_mark_restored(i915, true);
return i915_pm_resume(kdev);
}
--
2.34.1
More information about the Intel-gfx-trybot
mailing list