Skip to content

Commit d4033a9

Browse files
icklejlahtine-intel
authored andcommitted
drm/i915/gt: Move user_forcewake application to GT
We already track the debugfs user_forcewake on the GT, so it is natural to pull the suspend/resume handling under gt/ as well. Signed-off-by: Chris Wilson <[email protected]> Reviewed-by: Andi Shyti <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] (cherry picked from commit 9ab3fe2) Signed-off-by: Joonas Lahtinen <[email protected]>
1 parent 489d195 commit d4033a9

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

drivers/gpu/drm/i915/gem/i915_gem_pm.c

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,13 @@
1111

1212
#include "i915_drv.h"
1313

14-
static void user_forcewake(struct intel_gt *gt, bool suspend)
15-
{
16-
int count = atomic_read(&gt->user_wakeref);
17-
18-
/* Inside suspend/resume so single threaded, no races to worry about. */
19-
if (likely(!count))
20-
return;
21-
22-
intel_gt_pm_get(gt);
23-
if (suspend) {
24-
GEM_BUG_ON(count > atomic_read(&gt->wakeref.count));
25-
atomic_sub(count, &gt->wakeref.count);
26-
} else {
27-
atomic_add(count, &gt->wakeref.count);
28-
}
29-
intel_gt_pm_put(gt);
30-
}
31-
3214
void i915_gem_suspend(struct drm_i915_private *i915)
3315
{
3416
GEM_TRACE("\n");
3517

3618
intel_wakeref_auto(&i915->ggtt.userfault_wakeref, 0);
3719
flush_workqueue(i915->wq);
3820

39-
user_forcewake(&i915->gt, true);
40-
4121
/*
4222
* We have to flush all the executing contexts to main memory so
4323
* that they can saved in the hibernation image. To ensure the last
@@ -132,8 +112,6 @@ void i915_gem_resume(struct drm_i915_private *i915)
132112
if (intel_gt_resume(&i915->gt))
133113
goto err_wedged;
134114

135-
user_forcewake(&i915->gt, false);
136-
137115
out_unlock:
138116
intel_uncore_forcewake_put(&i915->uncore, FORCEWAKE_ALL);
139117
return;

drivers/gpu/drm/i915/gt/intel_gt_pm.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,24 @@
1818
#include "intel_rps.h"
1919
#include "intel_wakeref.h"
2020

21+
static void user_forcewake(struct intel_gt *gt, bool suspend)
22+
{
23+
int count = atomic_read(&gt->user_wakeref);
24+
25+
/* Inside suspend/resume so single threaded, no races to worry about. */
26+
if (likely(!count))
27+
return;
28+
29+
intel_gt_pm_get(gt);
30+
if (suspend) {
31+
GEM_BUG_ON(count > atomic_read(&gt->wakeref.count));
32+
atomic_sub(count, &gt->wakeref.count);
33+
} else {
34+
atomic_add(count, &gt->wakeref.count);
35+
}
36+
intel_gt_pm_put(gt);
37+
}
38+
2139
static int __gt_unpark(struct intel_wakeref *wf)
2240
{
2341
struct intel_gt *gt = container_of(wf, typeof(*gt), wakeref);
@@ -210,6 +228,8 @@ int intel_gt_resume(struct intel_gt *gt)
210228

211229
intel_uc_resume(&gt->uc);
212230

231+
user_forcewake(gt, false);
232+
213233
intel_uncore_forcewake_put(gt->uncore, FORCEWAKE_ALL);
214234
intel_gt_pm_put(gt);
215235

@@ -233,6 +253,8 @@ void intel_gt_suspend(struct intel_gt *gt)
233253
{
234254
intel_wakeref_t wakeref;
235255

256+
user_forcewake(gt, true);
257+
236258
/* We expect to be idle already; but also want to be independent */
237259
wait_for_idle(gt);
238260

0 commit comments

Comments
 (0)