[PATCH] drm/i915: suspend gem at the last part of suspend
Nirmoy Das
nirmoy.das at intel.com
Thu Feb 9 19:20:13 UTC 2023
TODO
Signed-off-by: Nirmoy Das <nirmoy.das at intel.com>
---
drivers/gpu/drm/i915/gem/i915_gem_pm.c | 33 ++++++++++++++++++++--
drivers/gpu/drm/i915/gem/i915_gem_pm.h | 1 +
drivers/gpu/drm/i915/gem/i915_gem_ttm_pm.c | 8 ++++--
drivers/gpu/drm/i915/gt/intel_gt_pm.c | 8 ++++++
drivers/gpu/drm/i915/i915_driver.c | 14 ++-------
5 files changed, 47 insertions(+), 17 deletions(-)
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_pm.c b/drivers/gpu/drm/i915/gem/i915_gem_pm.c
index 0d812f4d787d..c61af3c5890a 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_pm.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_pm.c
@@ -26,9 +26,12 @@ void i915_gem_suspend(struct drm_i915_private *i915)
unsigned int i;
GEM_TRACE("%s\n", dev_name(i915->drm.dev));
-
+
+ printk("Started i915_gem_suspend\n");
intel_wakeref_auto(&i915->runtime_pm.userfault_wakeref, 0);
+ printk("Started i915_gem_suspend\n");
flush_workqueue(i915->wq);
+ printk("Started i915_gem_suspend\n");
/*
* We have to flush all the executing contexts to main memory so
@@ -39,8 +42,11 @@ void i915_gem_suspend(struct drm_i915_private *i915)
* state. Fortunately, the kernel_context is disposable and we do
* not rely on its state.
*/
- for_each_gt(gt, i915, i)
+ for_each_gt(gt, i915, i) {
+ printk("Started i915_gem_suspend for %s\n", gt->name);
intel_gt_suspend_prepare(gt);
+ printk("Started i915_gem_suspend for %s done\n", gt->name);
+ }
i915_gem_drain_freed_objects(i915);
}
@@ -87,17 +93,33 @@ static void lmem_recover(struct drm_i915_private *i915)
i915_ttm_recover_region(mr);
}
+int i915_gem_backup_suspend_prepare(struct drm_i915_private *i915)
+{
+ int ret;
+ printk("Started i915_gem_backup_suspend_prepare\n");
+ /* Opportunistically try to evict unpinned objects */
+ ret = lmem_suspend(i915, I915_TTM_BACKUP_ALLOW_GPU|I915_TTM_BACKUP_PINNED);
+ if (ret)
+ lmem_recover(i915);
+
+ printk("Finished i915_gem_backup_suspend_prepare %d\n", ret);
+ return ret;
+}
+
int i915_gem_backup_suspend(struct drm_i915_private *i915)
{
int ret;
+ printk("Started i915_gem_backup_suspend\n");
/* Opportunistically try to evict unpinned objects */
ret = lmem_suspend(i915, I915_TTM_BACKUP_ALLOW_GPU);
if (ret)
goto out_recover;
+ printk("i915_gem_backup_suspend done 1st lmem_suspend()\n");
i915_gem_suspend(i915);
-
+ printk("i915_gem_backup_suspend done i915_gem_suspend)\n");
+
/*
* More objects may have become unpinned as requests were
* retired. Now try to evict again. The gt may be wedged here
@@ -108,6 +130,7 @@ int i915_gem_backup_suspend(struct drm_i915_private *i915)
*/
ret = lmem_suspend(i915, I915_TTM_BACKUP_ALLOW_GPU |
I915_TTM_BACKUP_PINNED);
+ printk("i915_gem_backup_suspend done 2nd lmem_suspend()\n");
if (ret)
goto out_recover;
@@ -116,14 +139,17 @@ int i915_gem_backup_suspend(struct drm_i915_private *i915)
* using the migrate context.
*/
ret = lmem_suspend(i915, I915_TTM_BACKUP_PINNED);
+ printk("i915_gem_backup_suspend done 3rd lmem_suspend()\n");
if (ret)
goto out_recover;
+ printk("Finished i915_gem_backup_suspend\n");
return 0;
out_recover:
lmem_recover(i915);
+ printk("Finished i915_gem_backup_suspend with error\n");
return ret;
}
@@ -140,6 +166,7 @@ void i915_gem_suspend_late(struct drm_i915_private *i915)
unsigned int i;
bool flush = false;
+ i915_gem_backup_suspend(i915);
/*
* Neither the BIOS, ourselves or any other kernel
* expects the system to be in execlists mode on startup,
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_pm.h b/drivers/gpu/drm/i915/gem/i915_gem_pm.h
index bedf1e95941a..65896246ff7b 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_pm.h
+++ b/drivers/gpu/drm/i915/gem/i915_gem_pm.h
@@ -19,6 +19,7 @@ void i915_gem_idle_work_handler(struct work_struct *work);
void i915_gem_suspend(struct drm_i915_private *i915);
void i915_gem_suspend_late(struct drm_i915_private *i915);
int i915_gem_backup_suspend(struct drm_i915_private *i915);
+int i915_gem_backup_suspend_prepare(struct drm_i915_private *i915);
int i915_gem_freeze(struct drm_i915_private *i915);
int i915_gem_freeze_late(struct drm_i915_private *i915);
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_ttm_pm.c b/drivers/gpu/drm/i915/gem/i915_gem_ttm_pm.c
index dfe39c8e74d8..977b6766130d 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_ttm_pm.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_ttm_pm.c
@@ -52,7 +52,7 @@ static int i915_ttm_backup(struct i915_gem_apply_to_region *apply,
struct ttm_operation_ctx ctx = {};
unsigned int flags;
int err = 0;
-
+
if (!i915_ttm_cpu_maps_iomem(bo->resource) || obj->ttm.backup)
return 0;
@@ -60,11 +60,13 @@ static int i915_ttm_backup(struct i915_gem_apply_to_region *apply,
return ttm_bo_validate(bo, i915_ttm_sys_placement(), &ctx);
if (!pm_apply->backup_pinned ||
- (pm_apply->allow_gpu && (obj->flags & I915_BO_ALLOC_PM_EARLY)))
+ (pm_apply->allow_gpu && (obj->flags & I915_BO_ALLOC_PM_EARLY))) {
return 0;
+ }
- if (obj->flags & I915_BO_ALLOC_PM_VOLATILE)
+ if (obj->flags & I915_BO_ALLOC_PM_VOLATILE) {
return 0;
+ }
/*
* It seems that we might have some framebuffers still pinned at this
diff --git a/drivers/gpu/drm/i915/gt/intel_gt_pm.c b/drivers/gpu/drm/i915/gt/intel_gt_pm.c
index cef3d6f5c34e..5b681ad01dbd 100644
--- a/drivers/gpu/drm/i915/gt/intel_gt_pm.c
+++ b/drivers/gpu/drm/i915/gt/intel_gt_pm.c
@@ -317,10 +317,13 @@ int intel_gt_resume(struct intel_gt *gt)
static void wait_for_suspend(struct intel_gt *gt)
{
+ printk("Started wait_for_suspend\n");
if (!intel_gt_pm_is_awake(gt))
return;
+ printk("wait_for_suspend waiting for idle \n");
if (intel_gt_wait_for_idle(gt, I915_GT_SUSPEND_IDLE_TIMEOUT) == -ETIME) {
+ printk("wait_for_suspend waiting failed \n");
/*
* Forcibly cancel outstanding work and leave
* the gpu quiet.
@@ -329,12 +332,17 @@ static void wait_for_suspend(struct intel_gt *gt)
intel_gt_retire_requests(gt);
}
+ printk("wait_for_suspend waiting for PM idle \n");
intel_gt_pm_wait_for_idle(gt);
+ printk("wait_for_suspend waiting done for PM idle \n");
}
void intel_gt_suspend_prepare(struct intel_gt *gt)
{
+ printk("Started i915_gt_suspend_prepare\n");
user_forcewake(gt, true);
+ printk("Started i915_gt_suspend_prepare userforce wake done\n");
+ printk("Started i915_gem_suspend waiting for suspend\n");
wait_for_suspend(gt);
}
diff --git a/drivers/gpu/drm/i915/i915_driver.c b/drivers/gpu/drm/i915/i915_driver.c
index 57305bb00dbc..a0a5fd4af8d3 100644
--- a/drivers/gpu/drm/i915/i915_driver.c
+++ b/drivers/gpu/drm/i915/i915_driver.c
@@ -1041,19 +1041,11 @@ static void i915_drm_complete(struct drm_device *dev)
intel_pxp_resume_complete(i915->pxp);
}
-static int i915_drm_prepare(struct drm_device *dev)
+static int i915_drm_prepare(struct drm_device *dev)
{
- struct drm_i915_private *i915 = to_i915(dev);
-
- intel_pxp_suspend_prepare(i915->pxp);
+ intel_pxp_suspend_prepare(to_i915(dev)->pxp);
- /*
- * NB intel_display_suspend() may issue new requests after we've
- * ostensibly marked the GPU as ready-to-sleep here. We need to
- * split out that work and pull it forward so that after point,
- * the GPU is not woken again.
- */
- return i915_gem_backup_suspend(i915);
+ return i915_gem_backup_suspend_prepare(to_i915(dev));
}
static int i915_drm_suspend(struct drm_device *dev)
--
2.39.0
More information about the Intel-gfx-trybot
mailing list