Commit ae2e28b0 authored by Chris Wilson's avatar Chris Wilson

drm/i915: Teach record_defaults to operate on the intel_gt

Again we wish to operate on the engines, which are owned by the
intel_gt. As such it is easier, and much more consistent, to pass the
intel_gt parameter.

v2: Unexport i915_gem_load_power_context()
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: default avatarTvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20191022141935.15733-1-chris@chris-wilson.co.uk
parent 7867d709
...@@ -37,11 +37,6 @@ static bool switch_to_kernel_context_sync(struct intel_gt *gt) ...@@ -37,11 +37,6 @@ static bool switch_to_kernel_context_sync(struct intel_gt *gt)
return result; return result;
} }
bool i915_gem_load_power_context(struct drm_i915_private *i915)
{
return switch_to_kernel_context_sync(&i915->gt);
}
static void user_forcewake(struct intel_gt *gt, bool suspend) static void user_forcewake(struct intel_gt *gt, bool suspend)
{ {
int count = atomic_read(&gt->user_wakeref); int count = atomic_read(&gt->user_wakeref);
...@@ -171,7 +166,7 @@ void i915_gem_resume(struct drm_i915_private *i915) ...@@ -171,7 +166,7 @@ void i915_gem_resume(struct drm_i915_private *i915)
intel_uc_resume(&i915->gt.uc); intel_uc_resume(&i915->gt.uc);
/* Always reload a context for powersaving. */ /* Always reload a context for powersaving. */
if (!i915_gem_load_power_context(i915)) if (!switch_to_kernel_context_sync(&i915->gt))
goto err_wedged; goto err_wedged;
user_forcewake(&i915->gt, false); user_forcewake(&i915->gt, false);
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
struct drm_i915_private; struct drm_i915_private;
struct work_struct; struct work_struct;
bool i915_gem_load_power_context(struct drm_i915_private *i915);
void i915_gem_resume(struct drm_i915_private *i915); void i915_gem_resume(struct drm_i915_private *i915);
void i915_gem_idle_work_handler(struct work_struct *work); void i915_gem_idle_work_handler(struct work_struct *work);
......
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
#include "gt/intel_engine_user.h" #include "gt/intel_engine_user.h"
#include "gt/intel_gt.h" #include "gt/intel_gt.h"
#include "gt/intel_gt_pm.h" #include "gt/intel_gt_pm.h"
#include "gt/intel_gt_requests.h"
#include "gt/intel_mocs.h" #include "gt/intel_mocs.h"
#include "gt/intel_reset.h" #include "gt/intel_reset.h"
#include "gt/intel_renderstate.h" #include "gt/intel_renderstate.h"
...@@ -1069,7 +1070,7 @@ void i915_gem_sanitize(struct drm_i915_private *i915) ...@@ -1069,7 +1070,7 @@ void i915_gem_sanitize(struct drm_i915_private *i915)
intel_runtime_pm_put(&i915->runtime_pm, wakeref); intel_runtime_pm_put(&i915->runtime_pm, wakeref);
} }
static int __intel_engines_record_defaults(struct drm_i915_private *i915) static int __intel_engines_record_defaults(struct intel_gt *gt)
{ {
struct i915_request *requests[I915_NUM_ENGINES] = {}; struct i915_request *requests[I915_NUM_ENGINES] = {};
struct intel_engine_cs *engine; struct intel_engine_cs *engine;
...@@ -1085,7 +1086,7 @@ static int __intel_engines_record_defaults(struct drm_i915_private *i915) ...@@ -1085,7 +1086,7 @@ static int __intel_engines_record_defaults(struct drm_i915_private *i915)
* from the same default HW values. * from the same default HW values.
*/ */
for_each_engine(engine, i915, id) { for_each_engine(engine, gt, id) {
struct intel_context *ce; struct intel_context *ce;
struct i915_request *rq; struct i915_request *rq;
...@@ -1093,7 +1094,8 @@ static int __intel_engines_record_defaults(struct drm_i915_private *i915) ...@@ -1093,7 +1094,8 @@ static int __intel_engines_record_defaults(struct drm_i915_private *i915)
GEM_BUG_ON(!engine->kernel_context); GEM_BUG_ON(!engine->kernel_context);
engine->serial++; /* force the kernel context switch */ engine->serial++; /* force the kernel context switch */
ce = intel_context_create(i915->kernel_context, engine); ce = intel_context_create(engine->kernel_context->gem_context,
engine);
if (IS_ERR(ce)) { if (IS_ERR(ce)) {
err = PTR_ERR(ce); err = PTR_ERR(ce);
goto out; goto out;
...@@ -1122,7 +1124,7 @@ static int __intel_engines_record_defaults(struct drm_i915_private *i915) ...@@ -1122,7 +1124,7 @@ static int __intel_engines_record_defaults(struct drm_i915_private *i915)
} }
/* Flush the default context image to memory, and enable powersaving. */ /* Flush the default context image to memory, and enable powersaving. */
if (!i915_gem_load_power_context(i915)) { if (intel_gt_wait_for_idle(gt, I915_GEM_IDLE_TIMEOUT) == -ETIME) {
err = -EIO; err = -EIO;
goto out; goto out;
} }
...@@ -1181,7 +1183,7 @@ static int __intel_engines_record_defaults(struct drm_i915_private *i915) ...@@ -1181,7 +1183,7 @@ static int __intel_engines_record_defaults(struct drm_i915_private *i915)
* this is by declaring ourselves wedged. * this is by declaring ourselves wedged.
*/ */
if (err) if (err)
intel_gt_set_wedged(&i915->gt); intel_gt_set_wedged(gt);
for (id = 0; id < ARRAY_SIZE(requests); id++) { for (id = 0; id < ARRAY_SIZE(requests); id++) {
struct intel_context *ce; struct intel_context *ce;
...@@ -1295,7 +1297,7 @@ int i915_gem_init(struct drm_i915_private *dev_priv) ...@@ -1295,7 +1297,7 @@ int i915_gem_init(struct drm_i915_private *dev_priv)
if (ret) if (ret)
goto err_gt; goto err_gt;
ret = __intel_engines_record_defaults(dev_priv); ret = __intel_engines_record_defaults(&dev_priv->gt);
if (ret) if (ret)
goto err_gt; goto err_gt;
......
...@@ -23,8 +23,9 @@ ...@@ -23,8 +23,9 @@
#include <linux/random.h> #include <linux/random.h>
#include "../i915_drv.h" #include "gt/intel_gt_pm.h"
#include "../i915_selftest.h" #include "i915_drv.h"
#include "i915_selftest.h"
#include "igt_flush_test.h" #include "igt_flush_test.h"
...@@ -256,6 +257,10 @@ int __i915_live_setup(void *data) ...@@ -256,6 +257,10 @@ int __i915_live_setup(void *data)
{ {
struct drm_i915_private *i915 = data; struct drm_i915_private *i915 = data;
/* The selftests expect an idle system */
if (intel_gt_pm_wait_for_idle(&i915->gt))
return -EIO;
return intel_gt_terminally_wedged(&i915->gt); return intel_gt_terminally_wedged(&i915->gt);
} }
...@@ -275,6 +280,10 @@ int __intel_gt_live_setup(void *data) ...@@ -275,6 +280,10 @@ int __intel_gt_live_setup(void *data)
{ {
struct intel_gt *gt = data; struct intel_gt *gt = data;
/* The selftests expect an idle system */
if (intel_gt_pm_wait_for_idle(gt))
return -EIO;
return intel_gt_terminally_wedged(gt); return intel_gt_terminally_wedged(gt);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment