Skip to content

Commit 8d208a5

Browse files
lucacoelhojnikula
authored andcommitted
drm/i915: use pointer to i915 instead of rpm in wakeref
Currently a pointer to an intel_runtime_pm structure is stored in the wake reference structures so the runtime data can be accessed. We can save the entire device information (drm_i915_private) instead, since we'll need to reference the new workqueue we'll add in subsequent patches. Reviewed-by: Tvrtko Ursulin <[email protected]> Signed-off-by: Luca Coelho <[email protected]> Signed-off-by: Jani Nikula <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/ec0eb5149120d04f3d9870d7671ef10103e6fc29.1686231190.git.jani.nikula@intel.com
1 parent 3fecd46 commit 8d208a5

File tree

5 files changed

+20
-20
lines changed

5 files changed

+20
-20
lines changed

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,9 +296,7 @@ static const struct intel_wakeref_ops wf_ops = {
296296

297297
void intel_engine_init__pm(struct intel_engine_cs *engine)
298298
{
299-
struct intel_runtime_pm *rpm = engine->uncore->rpm;
300-
301-
intel_wakeref_init(&engine->wakeref, rpm, &wf_ops);
299+
intel_wakeref_init(&engine->wakeref, engine->i915, &wf_ops);
302300
intel_engine_init_heartbeat(engine);
303301

304302
intel_gsc_idle_msg_enable(engine);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ void intel_gt_pm_init_early(struct intel_gt *gt)
137137
* runtime_pm is per-device rather than per-tile, so this is still the
138138
* correct structure.
139139
*/
140-
intel_wakeref_init(&gt->wakeref, &gt->i915->runtime_pm, &wf_ops);
140+
intel_wakeref_init(&gt->wakeref, gt->i915, &wf_ops);
141141
seqcount_mutex_init(&gt->stats.lock, &gt->wakeref.mutex);
142142
}
143143

drivers/gpu/drm/i915/intel_runtime_pm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -658,5 +658,5 @@ void intel_runtime_pm_init_early(struct intel_runtime_pm *rpm)
658658
init_intel_runtime_pm_wakeref(rpm);
659659
INIT_LIST_HEAD(&rpm->lmem_userfault_list);
660660
spin_lock_init(&rpm->lmem_userfault_lock);
661-
intel_wakeref_auto_init(&rpm->userfault_wakeref, rpm);
661+
intel_wakeref_auto_init(&rpm->userfault_wakeref, i915);
662662
}

drivers/gpu/drm/i915/intel_wakeref.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,18 @@
88

99
#include "intel_runtime_pm.h"
1010
#include "intel_wakeref.h"
11+
#include "i915_drv.h"
1112

1213
static void rpm_get(struct intel_wakeref *wf)
1314
{
14-
wf->wakeref = intel_runtime_pm_get(wf->rpm);
15+
wf->wakeref = intel_runtime_pm_get(&wf->i915->runtime_pm);
1516
}
1617

1718
static void rpm_put(struct intel_wakeref *wf)
1819
{
1920
intel_wakeref_t wakeref = fetch_and_zero(&wf->wakeref);
2021

21-
intel_runtime_pm_put(wf->rpm, wakeref);
22+
intel_runtime_pm_put(&wf->i915->runtime_pm, wakeref);
2223
INTEL_WAKEREF_BUG_ON(!wakeref);
2324
}
2425

@@ -94,11 +95,11 @@ static void __intel_wakeref_put_work(struct work_struct *wrk)
9495
}
9596

9697
void __intel_wakeref_init(struct intel_wakeref *wf,
97-
struct intel_runtime_pm *rpm,
98+
struct drm_i915_private *i915,
9899
const struct intel_wakeref_ops *ops,
99100
struct intel_wakeref_lockclass *key)
100101
{
101-
wf->rpm = rpm;
102+
wf->i915 = i915;
102103
wf->ops = ops;
103104

104105
__mutex_init(&wf->mutex, "wakeref.mutex", &key->mutex);
@@ -137,17 +138,17 @@ static void wakeref_auto_timeout(struct timer_list *t)
137138
wakeref = fetch_and_zero(&wf->wakeref);
138139
spin_unlock_irqrestore(&wf->lock, flags);
139140

140-
intel_runtime_pm_put(wf->rpm, wakeref);
141+
intel_runtime_pm_put(&wf->i915->runtime_pm, wakeref);
141142
}
142143

143144
void intel_wakeref_auto_init(struct intel_wakeref_auto *wf,
144-
struct intel_runtime_pm *rpm)
145+
struct drm_i915_private *i915)
145146
{
146147
spin_lock_init(&wf->lock);
147148
timer_setup(&wf->timer, wakeref_auto_timeout, 0);
148149
refcount_set(&wf->count, 0);
149150
wf->wakeref = 0;
150-
wf->rpm = rpm;
151+
wf->i915 = i915;
151152
}
152153

153154
void intel_wakeref_auto(struct intel_wakeref_auto *wf, unsigned long timeout)
@@ -161,13 +162,14 @@ void intel_wakeref_auto(struct intel_wakeref_auto *wf, unsigned long timeout)
161162
}
162163

163164
/* Our mission is that we only extend an already active wakeref */
164-
assert_rpm_wakelock_held(wf->rpm);
165+
assert_rpm_wakelock_held(&wf->i915->runtime_pm);
165166

166167
if (!refcount_inc_not_zero(&wf->count)) {
167168
spin_lock_irqsave(&wf->lock, flags);
168169
if (!refcount_inc_not_zero(&wf->count)) {
169170
INTEL_WAKEREF_BUG_ON(wf->wakeref);
170-
wf->wakeref = intel_runtime_pm_get_if_in_use(wf->rpm);
171+
wf->wakeref =
172+
intel_runtime_pm_get_if_in_use(&wf->i915->runtime_pm);
171173
refcount_set(&wf->count, 1);
172174
}
173175
spin_unlock_irqrestore(&wf->lock, flags);

drivers/gpu/drm/i915/intel_wakeref.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ struct intel_wakeref {
3939

4040
intel_wakeref_t wakeref;
4141

42-
struct intel_runtime_pm *rpm;
42+
struct drm_i915_private *i915;
4343
const struct intel_wakeref_ops *ops;
4444

4545
struct delayed_work work;
@@ -51,13 +51,13 @@ struct intel_wakeref_lockclass {
5151
};
5252

5353
void __intel_wakeref_init(struct intel_wakeref *wf,
54-
struct intel_runtime_pm *rpm,
54+
struct drm_i915_private *i915,
5555
const struct intel_wakeref_ops *ops,
5656
struct intel_wakeref_lockclass *key);
57-
#define intel_wakeref_init(wf, rpm, ops) do { \
57+
#define intel_wakeref_init(wf, i915, ops) do { \
5858
static struct intel_wakeref_lockclass __key; \
5959
\
60-
__intel_wakeref_init((wf), (rpm), (ops), &__key); \
60+
__intel_wakeref_init((wf), (i915), (ops), &__key); \
6161
} while (0)
6262

6363
int __intel_wakeref_get_first(struct intel_wakeref *wf);
@@ -262,7 +262,7 @@ __intel_wakeref_defer_park(struct intel_wakeref *wf)
262262
int intel_wakeref_wait_for_idle(struct intel_wakeref *wf);
263263

264264
struct intel_wakeref_auto {
265-
struct intel_runtime_pm *rpm;
265+
struct drm_i915_private *i915;
266266
struct timer_list timer;
267267
intel_wakeref_t wakeref;
268268
spinlock_t lock;
@@ -287,7 +287,7 @@ struct intel_wakeref_auto {
287287
void intel_wakeref_auto(struct intel_wakeref_auto *wf, unsigned long timeout);
288288

289289
void intel_wakeref_auto_init(struct intel_wakeref_auto *wf,
290-
struct intel_runtime_pm *rpm);
290+
struct drm_i915_private *i915);
291291
void intel_wakeref_auto_fini(struct intel_wakeref_auto *wf);
292292

293293
#endif /* INTEL_WAKEREF_H */

0 commit comments

Comments
 (0)