Skip to contentSkip to conversation

Runtime PM encapsulation

RFC Superseded Daniele Ceraolo Spurio 4 participants 20 messages May 16, 2019 – Jun 3, 2019

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover Runtime PM encapsulation

While reworking other parts of the code to rely less on i915 and use the new uncore logic for register access, I've noticed that, after the conversion, in a few places the i915 structure is required only for the rpm_get/put calls. We do have a reference to the rpm structure in the uncore one, so, since we're relying on the latter more, having the rpm code work directly on its own sub-structure will allow us to ditch dev_priv in a few more places. Also, having a section of the code work on its own logic sub-structure instead getting it out of dev_priv every time makes the flow generally cleaner IMO.

This series grows the code slightly due to flipping all the get/put call points derive the rpm structure from dev_priv, but we should recoup that over time while we complete the rework.

While applying the changes I noticed that there is also a lot of potential for refactoring/encapsuliation around the display power functions. I experimented a bit with splitting these functions to their own file and moving most of the logic to work on i915_power_domains since we keep getting that structure out of i915, but the code is not as easy to update due to frequent calls to other areas in the display domain, so I gave up for now.

Series very lightly tested.

Cc Imre Deak <[email protected]>
Cc Chris Wilson <[email protected]>

Daniele Ceraolo Spurio (7):
drm/i915: prefer i915_runtime_pm in intel_runtime function drm/i915: Remove rpm asserts that use i915
drm/i915: make enable/disable rpm assert function use the rpm
structure
drm/i915: move and rename i915_runtime_pm
drm/i915: move a few more functions to accept the rpm structure drm/i915: update rpm_get/put to use the rpm structure drm/i915: update with_intel_runtime_pm to use the rpm structure

 drivers/gpu/drm/i915/gt/intel_context.c       |   2 +-
 drivers/gpu/drm/i915/gt/intel_engine_cs.c     |   8 +-
 drivers/gpu/drm/i915/gt/intel_hangcheck.c     |   4 +-
 drivers/gpu/drm/i915/gt/intel_reset.c         |   6 +-
 drivers/gpu/drm/i915/gt/selftest_hangcheck.c  |  20 +-
 drivers/gpu/drm/i915/gt/selftest_lrc.c        |  36 +--
 .../gpu/drm/i915/gt/selftest_workarounds.c    |  16 +-
 drivers/gpu/drm/i915/gvt/aperture_gm.c        |  17 +-
 drivers/gpu/drm/i915/gvt/gvt.h                |   4 +-
 drivers/gpu/drm/i915/gvt/sched_policy.c       |   4 +-
 drivers/gpu/drm/i915/gvt/scheduler.c          |   4 +-
 drivers/gpu/drm/i915/i915_debugfs.c           |  79 +++----
 drivers/gpu/drm/i915/i915_drv.c               |  57 ++---
 drivers/gpu/drm/i915/i915_drv.h               |  50 +----
 drivers/gpu/drm/i915/i915_gem.c               |  30 +--
 drivers/gpu/drm/i915/i915_gem_fence_reg.c     |   6 +-
 drivers/gpu/drm/i915/i915_gem_gtt.c           |   8 +-
 drivers/gpu/drm/i915/i915_gem_shrinker.c      |  12 +-
 drivers/gpu/drm/i915/i915_irq.c               |  38 ++--
 drivers/gpu/drm/i915/i915_perf.c              |   6 +-
 drivers/gpu/drm/i915/i915_pmu.c               |  11 +-
 drivers/gpu/drm/i915/i915_sysfs.c             |  14 +-
 drivers/gpu/drm/i915/i915_vma.c               |   2 +-
 drivers/gpu/drm/i915/intel_csr.c              |   2 +-
 drivers/gpu/drm/i915/intel_display.c          |   4 +-
 drivers/gpu/drm/i915/intel_drv.h              | 105 ---------
 drivers/gpu/drm/i915/intel_fbdev.c            |   6 +-
 drivers/gpu/drm/i915/intel_guc.c              |   4 +-
 drivers/gpu/drm/i915/intel_guc_log.c          |   6 +-
 drivers/gpu/drm/i915/intel_hotplug.c          |   4 +-
 drivers/gpu/drm/i915/intel_huc.c              |   2 +-
 drivers/gpu/drm/i915/intel_panel.c            |   2 +-
 drivers/gpu/drm/i915/intel_pm.c               |   8 +-
 drivers/gpu/drm/i915/intel_runtime_pm.c       | 205 ++++++++----------
 drivers/gpu/drm/i915/intel_runtime_pm.h       | 185 ++++++++++++++--
 drivers/gpu/drm/i915/intel_uc.c               |   2 +-
 drivers/gpu/drm/i915/intel_uncore.c           |  26 +--
 drivers/gpu/drm/i915/intel_uncore.h           |   4 +-
 drivers/gpu/drm/i915/intel_wakeref.c          |   4 +-
 drivers/gpu/drm/i915/selftests/huge_pages.c   |   4 +-
 drivers/gpu/drm/i915/selftests/i915_active.c  |   8 +-
 drivers/gpu/drm/i915/selftests/i915_gem.c     |  10 +-
 .../drm/i915/selftests/i915_gem_coherency.c   |   4 +-
 .../gpu/drm/i915/selftests/i915_gem_context.c |  18 +-
 .../gpu/drm/i915/selftests/i915_gem_evict.c   |   6 +-
 drivers/gpu/drm/i915/selftests/i915_gem_gtt.c |   8 +-
 .../gpu/drm/i915/selftests/i915_gem_object.c  |   6 +-
 drivers/gpu/drm/i915/selftests/i915_request.c |  22 +-
 .../gpu/drm/i915/selftests/i915_timeline.c    |  16 +-
 drivers/gpu/drm/i915/selftests/intel_guc.c    |   8 +-
 drivers/gpu/drm/i915/selftests/intel_uncore.c |   4 +-
 .../gpu/drm/i915/selftests/mock_gem_device.c  |   2 +-
 52 files changed, 553 insertions(+), 566 deletions(-)
Signature · 6 lines
2.20.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

RFC 1/7 drm/i915: prefer i915_runtime_pm in intel_runtime function

As a first step towards updating the code to work on the runtime_pm structure instead of i915, rework all the internals to use and pass around that.

---
 drivers/gpu/drm/i915/i915_drv.h         |   2 +
 drivers/gpu/drm/i915/intel_drv.h        |  10 +-
 drivers/gpu/drm/i915/intel_runtime_pm.c | 152 ++++++++++++------------
 3 files changed, 82 insertions(+), 82 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +2 -0
index 5801f5407589..474074c7f395 100644
@@ -1177,6 +1177,8 @@ struct skl_wm_params {
  */
 struct i915_runtime_pm {
 	atomic_t wakeref_count;
+	struct device *kdev;
+	bool available;
 	bool suspended;
 	bool irqs_enabled;
 
drivers/gpu/drm/i915/intel_drv.h +7 -3
index 30b2d6ed2d53..bd04f394fbd3 100644
@@ -1662,13 +1662,17 @@ ____assert_rpm_wakelock_held(struct i915_runtime_pm *rpm, int wakeref_count)
 }
 
 static inline void
-assert_rpm_raw_wakeref_held(struct drm_i915_private *i915)
+__assert_rpm_raw_wakeref_held(struct i915_runtime_pm *rpm)
 {
-	struct i915_runtime_pm *rpm = &i915->runtime_pm;
-
 	____assert_rpm_raw_wakeref_held(rpm, atomic_read(&rpm->wakeref_count));
 }
 
+static inline void
+assert_rpm_raw_wakeref_held(struct drm_i915_private *i915)
+{
+	__assert_rpm_raw_wakeref_held(&i915->runtime_pm);
+}
+
 static inline void
 __assert_rpm_wakelock_held(struct i915_runtime_pm *rpm)
 {
drivers/gpu/drm/i915/intel_runtime_pm.c +73 -79

390 lines not on this page · raw message

Signature · 6 lines
2.20.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
maintainer
#2 lore raw

Re: [RFC 1/7] drm/i915: prefer i915_runtime_pm in intel_runtime function

Quoted 16 lines · Daniele Ceraolo Spurio

As a first step towards updating the code to work on the runtime_pm structure instead of i915, rework all the internals to use and pass around that.

---
 drivers/gpu/drm/i915/i915_drv.h         |   2 +
 drivers/gpu/drm/i915/intel_drv.h        |  10 +-
 drivers/gpu/drm/i915/intel_runtime_pm.c | 152 ++++++++++++------------
 3 files changed, 82 insertions(+), 82 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +0 -0
index 5801f5407589..474074c7f395 100644

drivers/gpu/drm/i915/i915_drv.h struct skl_wm_params { · line 1180

Quoted 4 lines
drivers/gpu/drm/i915/i915_drv.h +1 -0
@@ -1177,6 +1177,8 @@ struct skl_wm_params {
  */
 struct i915_runtime_pm {
 	atomic_t wakeref_count;
+	struct device *kdev;

This could use a small comment to say what device this is.

BR,
Jani.

Quoted 447 lines
drivers/gpu/drm/i915/i915_drv.h +1 -0
+	bool available;
 	bool suspended;
 	bool irqs_enabled;
 
drivers/gpu/drm/i915/intel_drv.h +7 -3
index 30b2d6ed2d53..bd04f394fbd3 100644
@@ -1662,13 +1662,17 @@ ____assert_rpm_wakelock_held(struct i915_runtime_pm *rpm, int wakeref_count)
 }
 
 static inline void
-assert_rpm_raw_wakeref_held(struct drm_i915_private *i915)
+__assert_rpm_raw_wakeref_held(struct i915_runtime_pm *rpm)
 {
-	struct i915_runtime_pm *rpm = &i915->runtime_pm;
-
 	____assert_rpm_raw_wakeref_held(rpm, atomic_read(&rpm->wakeref_count));
 }
 
+static inline void
+assert_rpm_raw_wakeref_held(struct drm_i915_private *i915)
+{
+	__assert_rpm_raw_wakeref_held(&i915->runtime_pm);
+}
+
 static inline void
 __assert_rpm_wakelock_held(struct i915_runtime_pm *rpm)
 {
drivers/gpu/drm/i915/intel_runtime_pm.c +73 -79
index b4abababdf6c..2e21f562df44 100644
@@ -60,19 +60,19 @@
  * present for a given platform.
  */
 
-static intel_wakeref_t intel_runtime_pm_get_raw(struct drm_i915_private *i915);
+static intel_wakeref_t intel_runtime_pm_get_raw(struct i915_runtime_pm *rpm);
 static void
-__intel_runtime_pm_put(struct drm_i915_private *i915, intel_wakeref_t wref,
+__intel_runtime_pm_put(struct i915_runtime_pm *rpm, intel_wakeref_t wref,
 		       bool wakelock);
 
 #if IS_ENABLED(CONFIG_DRM_I915_DEBUG_RUNTIME_PM)
 static void
-intel_runtime_pm_put_raw(struct drm_i915_private *i915, intel_wakeref_t wref);
+intel_runtime_pm_put_raw(struct i915_runtime_pm *rpm, intel_wakeref_t wref);
 #else
-static inline void intel_runtime_pm_put_raw(struct drm_i915_private *i915,
+static inline void intel_runtime_pm_put_raw(struct i915_runtime_pm *rpm,
 					    intel_wakeref_t wref)
 {
-	__intel_runtime_pm_put(i915, -1, false);
+	__intel_runtime_pm_put(rpm, -1, false);
 }
 #endif
 
@@ -112,21 +112,18 @@ static void __print_depot_stack(depot_stack_handle_t stack,
 	snprint_stack_trace(buf, sz, &trace, indent);
 }
 
-static void init_intel_runtime_pm_wakeref(struct drm_i915_private *i915)
+static void init_intel_runtime_pm_wakeref(struct i915_runtime_pm *rpm)
 {
-	struct i915_runtime_pm *rpm = &i915->runtime_pm;
-
 	spin_lock_init(&rpm->debug.lock);
 }
 
 static noinline depot_stack_handle_t
-track_intel_runtime_pm_wakeref(struct drm_i915_private *i915)
+track_intel_runtime_pm_wakeref(struct i915_runtime_pm *rpm)
 {
-	struct i915_runtime_pm *rpm = &i915->runtime_pm;
 	depot_stack_handle_t stack, *stacks;
 	unsigned long flags;
 
-	if (!HAS_RUNTIME_PM(i915))
+	if (!rpm->available)
 		return -1;
 
 	stack = __save_depot_stack();
@@ -153,10 +150,9 @@ track_intel_runtime_pm_wakeref(struct drm_i915_private *i915)
 	return stack;
 }
 
-static void untrack_intel_runtime_pm_wakeref(struct drm_i915_private *i915,
+static void untrack_intel_runtime_pm_wakeref(struct i915_runtime_pm *rpm,
 					     depot_stack_handle_t stack)
 {
-	struct i915_runtime_pm *rpm = &i915->runtime_pm;
 	unsigned long flags, n;
 	bool found = false;
 
@@ -274,9 +270,8 @@ dump_and_free_wakeref_tracking(struct intel_runtime_pm_debug *debug)
 }
 
 static noinline void
-__intel_wakeref_dec_and_check_tracking(struct drm_i915_private *i915)
+__intel_wakeref_dec_and_check_tracking(struct i915_runtime_pm *rpm)
 {
-	struct i915_runtime_pm *rpm = &i915->runtime_pm;
 	struct intel_runtime_pm_debug dbg = {};
 	unsigned long flags;
 
@@ -292,9 +287,8 @@ __intel_wakeref_dec_and_check_tracking(struct drm_i915_private *i915)
 }
 
 static noinline void
-untrack_all_intel_runtime_pm_wakerefs(struct drm_i915_private *i915)
+untrack_all_intel_runtime_pm_wakerefs(struct i915_runtime_pm *rpm)
 {
-	struct i915_runtime_pm *rpm = &i915->runtime_pm;
 	struct intel_runtime_pm_debug dbg = {};
 	unsigned long flags;
 
@@ -345,61 +339,57 @@ void print_intel_runtime_pm_wakeref(struct drm_i915_private *i915,
 
 #else
 
-static void init_intel_runtime_pm_wakeref(struct drm_i915_private *i915)
+static void init_intel_runtime_pm_wakeref(struct i915_runtime_pm *rpm)
 {
 }
 
 static depot_stack_handle_t
-track_intel_runtime_pm_wakeref(struct drm_i915_private *i915)
+track_intel_runtime_pm_wakeref(struct i915_runtime_pm *rpm)
 {
 	return -1;
 }
 
-static void untrack_intel_runtime_pm_wakeref(struct drm_i915_private *i915,
+static void untrack_intel_runtime_pm_wakeref(struct i915_runtime_pm *rpm,
 					     intel_wakeref_t wref)
 {
 }
 
 static void
-__intel_wakeref_dec_and_check_tracking(struct drm_i915_private *i915)
+__intel_wakeref_dec_and_check_tracking(struct i915_runtime_pm *rpm)
 {
-	atomic_dec(&i915->runtime_pm.wakeref_count);
+	atomic_dec(&rpm->wakeref_count);
 }
 
 static void
-untrack_all_intel_runtime_pm_wakerefs(struct drm_i915_private *i915)
+untrack_all_intel_runtime_pm_wakerefs(struct i915_runtime_pm *rpm)
 {
 }
 
 #endif
 
 static void
-intel_runtime_pm_acquire(struct drm_i915_private *i915, bool wakelock)
+intel_runtime_pm_acquire(struct i915_runtime_pm *rpm, bool wakelock)
 {
-	struct i915_runtime_pm *rpm = &i915->runtime_pm;
-
 	if (wakelock) {
 		atomic_add(1 + INTEL_RPM_WAKELOCK_BIAS, &rpm->wakeref_count);
-		assert_rpm_wakelock_held(i915);
+		__assert_rpm_wakelock_held(rpm);
 	} else {
 		atomic_inc(&rpm->wakeref_count);
-		assert_rpm_raw_wakeref_held(i915);
+		__assert_rpm_raw_wakeref_held(rpm);
 	}
 }
 
 static void
-intel_runtime_pm_release(struct drm_i915_private *i915, int wakelock)
+intel_runtime_pm_release(struct i915_runtime_pm *rpm, int wakelock)
 {
-	struct i915_runtime_pm *rpm = &i915->runtime_pm;
-
 	if (wakelock) {
-		assert_rpm_wakelock_held(i915);
+		__assert_rpm_wakelock_held(rpm);
 		atomic_sub(INTEL_RPM_WAKELOCK_BIAS, &rpm->wakeref_count);
 	} else {
-		assert_rpm_raw_wakeref_held(i915);
+		__assert_rpm_raw_wakeref_held(rpm);
 	}
 
-	__intel_wakeref_dec_and_check_tracking(i915);
+	__intel_wakeref_dec_and_check_tracking(rpm);
 }
 
 bool intel_display_power_well_is_enabled(struct drm_i915_private *dev_priv,
@@ -2030,7 +2020,7 @@ intel_display_power_grab_async_put_ref(struct drm_i915_private *dev_priv,
 		goto out_verify;
 
 	cancel_delayed_work(&power_domains->async_put_work);
-	intel_runtime_pm_put_raw(dev_priv,
+	intel_runtime_pm_put_raw(&dev_priv->runtime_pm,
 				 fetch_and_zero(&power_domains->async_put_wakeref));
 out_verify:
 	verify_async_put_domains_state(power_domains);
@@ -2219,7 +2209,8 @@ intel_display_power_put_async_work(struct work_struct *work)
 		container_of(work, struct drm_i915_private,
 			     power_domains.async_put_work.work);
 	struct i915_power_domains *power_domains = &dev_priv->power_domains;
-	intel_wakeref_t new_work_wakeref = intel_runtime_pm_get_raw(dev_priv);
+	struct i915_runtime_pm *rpm = &dev_priv->runtime_pm;
+	intel_wakeref_t new_work_wakeref = intel_runtime_pm_get_raw(rpm);
 	intel_wakeref_t old_work_wakeref = 0;
 
 	mutex_lock(&power_domains->lock);
@@ -2249,9 +2240,9 @@ intel_display_power_put_async_work(struct work_struct *work)
 	mutex_unlock(&power_domains->lock);
 
 	if (old_work_wakeref)
-		intel_runtime_pm_put_raw(dev_priv, old_work_wakeref);
+		intel_runtime_pm_put_raw(rpm, old_work_wakeref);
 	if (new_work_wakeref)
-		intel_runtime_pm_put_raw(dev_priv, new_work_wakeref);
+		intel_runtime_pm_put_raw(rpm, new_work_wakeref);
 }
 
 /**
@@ -2269,7 +2260,8 @@ void __intel_display_power_put_async(struct drm_i915_private *i915,
 				     intel_wakeref_t wakeref)
 {
 	struct i915_power_domains *power_domains = &i915->power_domains;
-	intel_wakeref_t work_wakeref = intel_runtime_pm_get_raw(i915);
+	struct i915_runtime_pm *rpm = &i915->runtime_pm;
+	intel_wakeref_t work_wakeref = intel_runtime_pm_get_raw(rpm);
 
 	mutex_lock(&power_domains->lock);
 
@@ -2296,7 +2288,7 @@ void __intel_display_power_put_async(struct drm_i915_private *i915,
 	mutex_unlock(&power_domains->lock);
 
 	if (work_wakeref)
-		intel_runtime_pm_put_raw(i915, work_wakeref);
+		intel_runtime_pm_put_raw(rpm, work_wakeref);
 
 	intel_runtime_pm_put(i915, wakeref);
 }
@@ -2334,7 +2326,7 @@ void intel_display_power_flush_work(struct drm_i915_private *i915)
 	mutex_unlock(&power_domains->lock);
 
 	if (work_wakeref)
-		intel_runtime_pm_put_raw(i915, work_wakeref);
+		intel_runtime_pm_put_raw(&i915->runtime_pm, work_wakeref);
 }
 
 /**
@@ -4996,24 +4988,22 @@ static void intel_power_domains_verify_state(struct drm_i915_private *i915)
 
 #endif
 
-static intel_wakeref_t __intel_runtime_pm_get(struct drm_i915_private *i915,
+static intel_wakeref_t __intel_runtime_pm_get(struct i915_runtime_pm *rpm,
 					      bool wakelock)
 {
-	struct pci_dev *pdev = i915->drm.pdev;
-	struct device *kdev = &pdev->dev;
 	int ret;
 
-	ret = pm_runtime_get_sync(kdev);
+	ret = pm_runtime_get_sync(rpm->kdev);
 	WARN_ONCE(ret < 0, "pm_runtime_get_sync() failed: %d\n", ret);
 
-	intel_runtime_pm_acquire(i915, wakelock);
+	intel_runtime_pm_acquire(rpm, wakelock);
 
-	return track_intel_runtime_pm_wakeref(i915);
+	return track_intel_runtime_pm_wakeref(rpm);
 }
 
-static intel_wakeref_t intel_runtime_pm_get_raw(struct drm_i915_private *i915)
+static intel_wakeref_t intel_runtime_pm_get_raw(struct i915_runtime_pm *rpm)
 {
-	return __intel_runtime_pm_get(i915, false);
+	return __intel_runtime_pm_get(rpm, false);
 }
 
 /**
@@ -5030,7 +5020,7 @@ static intel_wakeref_t intel_runtime_pm_get_raw(struct drm_i915_private *i915)
  */
 intel_wakeref_t intel_runtime_pm_get(struct drm_i915_private *i915)
 {
-	return __intel_runtime_pm_get(i915, true);
+	return __intel_runtime_pm_get(&i915->runtime_pm, true);
 }
 
 /**
@@ -5049,23 +5039,22 @@ intel_wakeref_t intel_runtime_pm_get(struct drm_i915_private *i915)
  */
 intel_wakeref_t intel_runtime_pm_get_if_in_use(struct drm_i915_private *i915)
 {
-	if (IS_ENABLED(CONFIG_PM)) {
-		struct pci_dev *pdev = i915->drm.pdev;
-		struct device *kdev = &pdev->dev;
+	struct i915_runtime_pm *rpm = &i915->runtime_pm;
 
+	if (IS_ENABLED(CONFIG_PM)) {
 		/*
 		 * In cases runtime PM is disabled by the RPM core and we get
 		 * an -EINVAL return value we are not supposed to call this
 		 * function, since the power state is undefined. This applies
 		 * atm to the late/early system suspend/resume handlers.
 		 */
-		if (pm_runtime_get_if_in_use(kdev) <= 0)
+		if (pm_runtime_get_if_in_use(rpm->kdev) <= 0)
 			return 0;
 	}
 
-	intel_runtime_pm_acquire(i915, true);
+	intel_runtime_pm_acquire(rpm, true);
 
-	return track_intel_runtime_pm_wakeref(i915);
+	return track_intel_runtime_pm_wakeref(rpm);
 }
 
 /**
@@ -5089,27 +5078,25 @@ intel_wakeref_t intel_runtime_pm_get_if_in_use(struct drm_i915_private *i915)
  */
 intel_wakeref_t intel_runtime_pm_get_noresume(struct drm_i915_private *i915)
 {
-	struct pci_dev *pdev = i915->drm.pdev;
-	struct device *kdev = &pdev->dev;
+	struct i915_runtime_pm *rpm = &i915->runtime_pm;
 
-	assert_rpm_wakelock_held(i915);
-	pm_runtime_get_noresume(kdev);
+	__assert_rpm_wakelock_held(rpm);
+	pm_runtime_get_noresume(rpm->kdev);
 
-	intel_runtime_pm_acquire(i915, true);
+	intel_runtime_pm_acquire(rpm, true);
 
-	return track_intel_runtime_pm_wakeref(i915);
+	return track_intel_runtime_pm_wakeref(rpm);
 }
 
-static void __intel_runtime_pm_put(struct drm_i915_private *i915,
+static void __intel_runtime_pm_put(struct i915_runtime_pm *rpm,
 				   intel_wakeref_t wref,
 				   bool wakelock)
 {
-	struct pci_dev *pdev = i915->drm.pdev;
-	struct device *kdev = &pdev->dev;
+	struct device *kdev = rpm->kdev;
 
-	untrack_intel_runtime_pm_wakeref(i915, wref);
+	untrack_intel_runtime_pm_wakeref(rpm, wref);
 
-	intel_runtime_pm_release(i915, wakelock);
+	intel_runtime_pm_release(rpm, wakelock);
 
 	pm_runtime_mark_last_busy(kdev);
 	pm_runtime_put_autosuspend(kdev);
@@ -5117,9 +5104,9 @@ static void __intel_runtime_pm_put(struct drm_i915_private *i915,
 
 #if IS_ENABLED(CONFIG_DRM_I915_DEBUG_RUNTIME_PM)
 static void
-intel_runtime_pm_put_raw(struct drm_i915_private *i915, intel_wakeref_t wref)
+intel_runtime_pm_put_raw(struct i915_runtime_pm *rpm, intel_wakeref_t wref)
 {
-	__intel_runtime_pm_put(i915, wref, false);
+	__intel_runtime_pm_put(rpm, wref, false);
 }
 #endif
 
@@ -5137,7 +5124,7 @@ intel_runtime_pm_put_raw(struct drm_i915_private *i915, intel_wakeref_t wref)
  */
 void intel_runtime_pm_put_unchecked(struct drm_i915_private *i915)
 {
-	__intel_runtime_pm_put(i915, -1, true);
+	__intel_runtime_pm_put(&i915->runtime_pm, -1, true);
 }
 
 #if IS_ENABLED(CONFIG_DRM_I915_DEBUG_RUNTIME_PM)
@@ -5152,7 +5139,7 @@ void intel_runtime_pm_put_unchecked(struct drm_i915_private *i915)
  */
 void intel_runtime_pm_put(struct drm_i915_private *i915, intel_wakeref_t wref)
 {
-	__intel_runtime_pm_put(i915, wref, true);
+	__intel_runtime_pm_put(&i915->runtime_pm, wref, true);
 }
 #endif
 
@@ -5168,8 +5155,8 @@ void intel_runtime_pm_put(struct drm_i915_private *i915, intel_wakeref_t wref)
  */
 void intel_runtime_pm_enable(struct drm_i915_private *i915)
 {
-	struct pci_dev *pdev = i915->drm.pdev;
-	struct device *kdev = &pdev->dev;
+	struct i915_runtime_pm *rpm = &i915->runtime_pm;
+	struct device *kdev = rpm->kdev;
 
 	/*
 	 * Disable the system suspend direct complete optimization, which can
@@ -5190,7 +5177,7 @@ void intel_runtime_pm_enable(struct drm_i915_private *i915)
 	 * so the driver's own RPM reference tracking asserts also work on
 	 * platforms without RPM support.
 	 */
-	if (!HAS_RUNTIME_PM(i915)) {
+	if (!rpm->available) {
 		int ret;
 
 		pm_runtime_dont_use_autosuspend(kdev);
@@ -5210,8 +5197,8 @@ void intel_runtime_pm_enable(struct drm_i915_private *i915)
 
 void intel_runtime_pm_disable(struct drm_i915_private *i915)
 {
-	struct pci_dev *pdev = i915->drm.pdev;
-	struct device *kdev = &pdev->dev;
+	struct i915_runtime_pm *rpm = &i915->runtime_pm;
+	struct device *kdev = rpm->kdev;
 
 	/* Transfer rpm ownership back to core */
 	WARN(pm_runtime_get_sync(kdev) < 0,
@@ -5219,7 +5206,7 @@ void intel_runtime_pm_disable(struct drm_i915_private *i915)
 
 	pm_runtime_dont_use_autosuspend(kdev);
 
-	if (!HAS_RUNTIME_PM(i915))
+	if (!rpm->available)
 		pm_runtime_put(kdev);
 }
 
@@ -5233,10 +5220,17 @@ void intel_runtime_pm_cleanup(struct drm_i915_private *i915)
 	     intel_rpm_raw_wakeref_count(count),
 	     intel_rpm_wakelock_count(count));
 
-	untrack_all_intel_runtime_pm_wakerefs(i915);
+	untrack_all_intel_runtime_pm_wakerefs(rpm);
 }
 
 void intel_runtime_pm_init_early(struct drm_i915_private *i915)
 {
-	init_intel_runtime_pm_wakeref(i915);
+	struct i915_runtime_pm *rpm = &i915->runtime_pm;
+	struct pci_dev *pdev = i915->drm.pdev;
+	struct device *kdev = &pdev->dev;
+
+	rpm->kdev = kdev;
+	rpm->available = HAS_RUNTIME_PM(i915);
+
+	init_intel_runtime_pm_wakeref(rpm);
 }
Signature · 5 lines
Jani Nikula, Intel Open Source Graphics Center
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#3 lore raw

Re: [RFC 1/7] drm/i915: prefer i915_runtime_pm in intel_runtime function

Quoted 12 lines · Jani Nikula
Quoted 11 lines · Daniele Ceraolo Spurio

As a first step towards updating the code to work on the runtime_pm structure instead of i915, rework all the internals to use and pass around that.

---
  drivers/gpu/drm/i915/i915_drv.h         |   2 +
  drivers/gpu/drm/i915/intel_drv.h        |  10 +-
  drivers/gpu/drm/i915/intel_runtime_pm.c | 152 ++++++++++++------------
  3 files changed, 82 insertions(+), 82 deletions(-)
Quoted 12 lines

drivers/gpu/drm/i915/i915_drv.h struct skl_wm_params { · line 1180

Quoted 9 lines
drivers/gpu/drm/i915/i915_drv.h +1 -0
index 5801f5407589..474074c7f395 100644
@@ -1177,6 +1177,8 @@ struct skl_wm_params {
   */
  struct i915_runtime_pm {
  	atomic_t wakeref_count;
+	struct device *kdev;

This could use a small comment to say what device this is.

Would something like:

	/* the intel gpu we're loaded on */

work? Or should I just rename it to i915_kdev like we use in other parts of the driver?

Thanks,
Daniele

Quoted 438 lines

BR,
Jani.

Quoted 435 lines
drivers/gpu/drm/i915/i915_drv.h +1 -0
+	bool available;
  	bool suspended;
  	bool irqs_enabled;
 
drivers/gpu/drm/i915/intel_drv.h +7 -3
index 30b2d6ed2d53..bd04f394fbd3 100644
@@ -1662,13 +1662,17 @@ ____assert_rpm_wakelock_held(struct i915_runtime_pm *rpm, int wakeref_count)
  }
 
  static inline void
-assert_rpm_raw_wakeref_held(struct drm_i915_private *i915)
+__assert_rpm_raw_wakeref_held(struct i915_runtime_pm *rpm)
  {
-	struct i915_runtime_pm *rpm = &i915->runtime_pm;
-
  	____assert_rpm_raw_wakeref_held(rpm, atomic_read(&rpm->wakeref_count));
  }
 
+static inline void
+assert_rpm_raw_wakeref_held(struct drm_i915_private *i915)
+{
+	__assert_rpm_raw_wakeref_held(&i915->runtime_pm);
+}
+
  static inline void
  __assert_rpm_wakelock_held(struct i915_runtime_pm *rpm)
  {
drivers/gpu/drm/i915/intel_runtime_pm.c +65 -78
index b4abababdf6c..2e21f562df44 100644
@@ -60,19 +60,19 @@
   * present for a given platform.
   */
 
-static intel_wakeref_t intel_runtime_pm_get_raw(struct drm_i915_private *i915);
+static intel_wakeref_t intel_runtime_pm_get_raw(struct i915_runtime_pm *rpm);
  static void
-__intel_runtime_pm_put(struct drm_i915_private *i915, intel_wakeref_t wref,
+__intel_runtime_pm_put(struct i915_runtime_pm *rpm, intel_wakeref_t wref,
  		       bool wakelock);
 
  #if IS_ENABLED(CONFIG_DRM_I915_DEBUG_RUNTIME_PM)
  static void
-intel_runtime_pm_put_raw(struct drm_i915_private *i915, intel_wakeref_t wref);
+intel_runtime_pm_put_raw(struct i915_runtime_pm *rpm, intel_wakeref_t wref);
  #else
-static inline void intel_runtime_pm_put_raw(struct drm_i915_private *i915,
+static inline void intel_runtime_pm_put_raw(struct i915_runtime_pm *rpm,
  					    intel_wakeref_t wref)
  {
-	__intel_runtime_pm_put(i915, -1, false);
+	__intel_runtime_pm_put(rpm, -1, false);
  }
  #endif
 
@@ -112,21 +112,18 @@ static void __print_depot_stack(depot_stack_handle_t stack,
  	snprint_stack_trace(buf, sz, &trace, indent);
  }
 
-static void init_intel_runtime_pm_wakeref(struct drm_i915_private *i915)
+static void init_intel_runtime_pm_wakeref(struct i915_runtime_pm *rpm)
  {
-	struct i915_runtime_pm *rpm = &i915->runtime_pm;
-
  	spin_lock_init(&rpm->debug.lock);
  }
 
  static noinline depot_stack_handle_t
-track_intel_runtime_pm_wakeref(struct drm_i915_private *i915)
+track_intel_runtime_pm_wakeref(struct i915_runtime_pm *rpm)
  {
-	struct i915_runtime_pm *rpm = &i915->runtime_pm;
  	depot_stack_handle_t stack, *stacks;
  	unsigned long flags;
 
-	if (!HAS_RUNTIME_PM(i915))
+	if (!rpm->available)
  		return -1;
 
  	stack = __save_depot_stack();
@@ -153,10 +150,9 @@ track_intel_runtime_pm_wakeref(struct drm_i915_private *i915)
  	return stack;
  }
 
-static void untrack_intel_runtime_pm_wakeref(struct drm_i915_private *i915,
+static void untrack_intel_runtime_pm_wakeref(struct i915_runtime_pm *rpm,
  					     depot_stack_handle_t stack)
  {
-	struct i915_runtime_pm *rpm = &i915->runtime_pm;
  	unsigned long flags, n;
  	bool found = false;
 
@@ -274,9 +270,8 @@ dump_and_free_wakeref_tracking(struct intel_runtime_pm_debug *debug)
  }
 
  static noinline void
-__intel_wakeref_dec_and_check_tracking(struct drm_i915_private *i915)
+__intel_wakeref_dec_and_check_tracking(struct i915_runtime_pm *rpm)
  {
-	struct i915_runtime_pm *rpm = &i915->runtime_pm;
  	struct intel_runtime_pm_debug dbg = {};
  	unsigned long flags;
 
@@ -292,9 +287,8 @@ __intel_wakeref_dec_and_check_tracking(struct drm_i915_private *i915)
  }
 
  static noinline void
-untrack_all_intel_runtime_pm_wakerefs(struct drm_i915_private *i915)
+untrack_all_intel_runtime_pm_wakerefs(struct i915_runtime_pm *rpm)
  {
-	struct i915_runtime_pm *rpm = &i915->runtime_pm;
  	struct intel_runtime_pm_debug dbg = {};
  	unsigned long flags;
 
@@ -345,61 +339,57 @@ void print_intel_runtime_pm_wakeref(struct drm_i915_private *i915,
 
  #else
 
-static void init_intel_runtime_pm_wakeref(struct drm_i915_private *i915)
+static void init_intel_runtime_pm_wakeref(struct i915_runtime_pm *rpm)
  {
  }
 
  static depot_stack_handle_t
-track_intel_runtime_pm_wakeref(struct drm_i915_private *i915)
+track_intel_runtime_pm_wakeref(struct i915_runtime_pm *rpm)
  {
  	return -1;
  }
 
-static void untrack_intel_runtime_pm_wakeref(struct drm_i915_private *i915,
+static void untrack_intel_runtime_pm_wakeref(struct i915_runtime_pm *rpm,
  					     intel_wakeref_t wref)
  {
  }
 
  static void
-__intel_wakeref_dec_and_check_tracking(struct drm_i915_private *i915)
+__intel_wakeref_dec_and_check_tracking(struct i915_runtime_pm *rpm)
  {
-	atomic_dec(&i915->runtime_pm.wakeref_count);
+	atomic_dec(&rpm->wakeref_count);
  }
 
  static void
-untrack_all_intel_runtime_pm_wakerefs(struct drm_i915_private *i915)
+untrack_all_intel_runtime_pm_wakerefs(struct i915_runtime_pm *rpm)
  {
  }
 
  #endif
 
  static void
-intel_runtime_pm_acquire(struct drm_i915_private *i915, bool wakelock)
+intel_runtime_pm_acquire(struct i915_runtime_pm *rpm, bool wakelock)
  {
-	struct i915_runtime_pm *rpm = &i915->runtime_pm;
-
  	if (wakelock) {
  		atomic_add(1 + INTEL_RPM_WAKELOCK_BIAS, &rpm->wakeref_count);
-		assert_rpm_wakelock_held(i915);
+		__assert_rpm_wakelock_held(rpm);
  	} else {
  		atomic_inc(&rpm->wakeref_count);
-		assert_rpm_raw_wakeref_held(i915);
+		__assert_rpm_raw_wakeref_held(rpm);
  	}
  }
 
  static void
-intel_runtime_pm_release(struct drm_i915_private *i915, int wakelock)
+intel_runtime_pm_release(struct i915_runtime_pm *rpm, int wakelock)
  {
-	struct i915_runtime_pm *rpm = &i915->runtime_pm;
-
  	if (wakelock) {
-		assert_rpm_wakelock_held(i915);
+		__assert_rpm_wakelock_held(rpm);
  		atomic_sub(INTEL_RPM_WAKELOCK_BIAS, &rpm->wakeref_count);
  	} else {
-		assert_rpm_raw_wakeref_held(i915);
+		__assert_rpm_raw_wakeref_held(rpm);
  	}
 
-	__intel_wakeref_dec_and_check_tracking(i915);
+	__intel_wakeref_dec_and_check_tracking(rpm);
  }
 
  bool intel_display_power_well_is_enabled(struct drm_i915_private *dev_priv,
@@ -2030,7 +2020,7 @@ intel_display_power_grab_async_put_ref(struct drm_i915_private *dev_priv,
  		goto out_verify;
 
  	cancel_delayed_work(&power_domains->async_put_work);
-	intel_runtime_pm_put_raw(dev_priv,
+	intel_runtime_pm_put_raw(&dev_priv->runtime_pm,
  				 fetch_and_zero(&power_domains->async_put_wakeref));
  out_verify:
  	verify_async_put_domains_state(power_domains);
@@ -2219,7 +2209,8 @@ intel_display_power_put_async_work(struct work_struct *work)
  		container_of(work, struct drm_i915_private,
  			     power_domains.async_put_work.work);
  	struct i915_power_domains *power_domains = &dev_priv->power_domains;
-	intel_wakeref_t new_work_wakeref = intel_runtime_pm_get_raw(dev_priv);
+	struct i915_runtime_pm *rpm = &dev_priv->runtime_pm;
+	intel_wakeref_t new_work_wakeref = intel_runtime_pm_get_raw(rpm);
  	intel_wakeref_t old_work_wakeref = 0;
 
  	mutex_lock(&power_domains->lock);
@@ -2249,9 +2240,9 @@ intel_display_power_put_async_work(struct work_struct *work)
  	mutex_unlock(&power_domains->lock);
 
  	if (old_work_wakeref)
-		intel_runtime_pm_put_raw(dev_priv, old_work_wakeref);
+		intel_runtime_pm_put_raw(rpm, old_work_wakeref);
  	if (new_work_wakeref)
-		intel_runtime_pm_put_raw(dev_priv, new_work_wakeref);
+		intel_runtime_pm_put_raw(rpm, new_work_wakeref);
  }
 
  /**
@@ -2269,7 +2260,8 @@ void __intel_display_power_put_async(struct drm_i915_private *i915,
  				     intel_wakeref_t wakeref)
  {
  	struct i915_power_domains *power_domains = &i915->power_domains;
-	intel_wakeref_t work_wakeref = intel_runtime_pm_get_raw(i915);
+	struct i915_runtime_pm *rpm = &i915->runtime_pm;
+	intel_wakeref_t work_wakeref = intel_runtime_pm_get_raw(rpm);
 
  	mutex_lock(&power_domains->lock);
 
@@ -2296,7 +2288,7 @@ void __intel_display_power_put_async(struct drm_i915_private *i915,
  	mutex_unlock(&power_domains->lock);
 
  	if (work_wakeref)
-		intel_runtime_pm_put_raw(i915, work_wakeref);
+		intel_runtime_pm_put_raw(rpm, work_wakeref);
 
  	intel_runtime_pm_put(i915, wakeref);
  }
@@ -2334,7 +2326,7 @@ void intel_display_power_flush_work(struct drm_i915_private *i915)
  	mutex_unlock(&power_domains->lock);
 
  	if (work_wakeref)
-		intel_runtime_pm_put_raw(i915, work_wakeref);
+		intel_runtime_pm_put_raw(&i915->runtime_pm, work_wakeref);
  }
 
  /**
@@ -4996,24 +4988,22 @@ static void intel_power_domains_verify_state(struct drm_i915_private *i915)
 
  #endif
 
-static intel_wakeref_t __intel_runtime_pm_get(struct drm_i915_private *i915,
+static intel_wakeref_t __intel_runtime_pm_get(struct i915_runtime_pm *rpm,
  					      bool wakelock)
  {
-	struct pci_dev *pdev = i915->drm.pdev;
-	struct device *kdev = &pdev->dev;
  	int ret;
 
-	ret = pm_runtime_get_sync(kdev);
+	ret = pm_runtime_get_sync(rpm->kdev);
  	WARN_ONCE(ret < 0, "pm_runtime_get_sync() failed: %d\n", ret);
 
-	intel_runtime_pm_acquire(i915, wakelock);
+	intel_runtime_pm_acquire(rpm, wakelock);
 
-	return track_intel_runtime_pm_wakeref(i915);
+	return track_intel_runtime_pm_wakeref(rpm);
  }
 
-static intel_wakeref_t intel_runtime_pm_get_raw(struct drm_i915_private *i915)
+static intel_wakeref_t intel_runtime_pm_get_raw(struct i915_runtime_pm *rpm)
  {
-	return __intel_runtime_pm_get(i915, false);
+	return __intel_runtime_pm_get(rpm, false);
  }
 
  /**
@@ -5030,7 +5020,7 @@ static intel_wakeref_t intel_runtime_pm_get_raw(struct drm_i915_private *i915)
   */
  intel_wakeref_t intel_runtime_pm_get(struct drm_i915_private *i915)
  {
-	return __intel_runtime_pm_get(i915, true);
+	return __intel_runtime_pm_get(&i915->runtime_pm, true);
  }
 
  /**
@@ -5049,23 +5039,22 @@ intel_wakeref_t intel_runtime_pm_get(struct drm_i915_private *i915)
   */
  intel_wakeref_t intel_runtime_pm_get_if_in_use(struct drm_i915_private *i915)
  {
-	if (IS_ENABLED(CONFIG_PM)) {
-		struct pci_dev *pdev = i915->drm.pdev;
-		struct device *kdev = &pdev->dev;
+	struct i915_runtime_pm *rpm = &i915->runtime_pm;
 
+	if (IS_ENABLED(CONFIG_PM)) {
  		/*
  		 * In cases runtime PM is disabled by the RPM core and we get
  		 * an -EINVAL return value we are not supposed to call this
  		 * function, since the power state is undefined. This applies
  		 * atm to the late/early system suspend/resume handlers.
  		 */
-		if (pm_runtime_get_if_in_use(kdev) <= 0)
+		if (pm_runtime_get_if_in_use(rpm->kdev) <= 0)
  			return 0;
  	}
 
-	intel_runtime_pm_acquire(i915, true);
+	intel_runtime_pm_acquire(rpm, true);
 
-	return track_intel_runtime_pm_wakeref(i915);
+	return track_intel_runtime_pm_wakeref(rpm);
  }
 
  /**
@@ -5089,27 +5078,25 @@ intel_wakeref_t intel_runtime_pm_get_if_in_use(struct drm_i915_private *i915)
   */
  intel_wakeref_t intel_runtime_pm_get_noresume(struct drm_i915_private *i915)
  {
-	struct pci_dev *pdev = i915->drm.pdev;
-	struct device *kdev = &pdev->dev;
+	struct i915_runtime_pm *rpm = &i915->runtime_pm;
 
-	assert_rpm_wakelock_held(i915);
-	pm_runtime_get_noresume(kdev);
+	__assert_rpm_wakelock_held(rpm);
+	pm_runtime_get_noresume(rpm->kdev);
 
-	intel_runtime_pm_acquire(i915, true);
+	intel_runtime_pm_acquire(rpm, true);
 
-	return track_intel_runtime_pm_wakeref(i915);
+	return track_intel_runtime_pm_wakeref(rpm);
  }
 
-static void __intel_runtime_pm_put(struct drm_i915_private *i915,
+static void __intel_runtime_pm_put(struct i915_runtime_pm *rpm,
  				   intel_wakeref_t wref,
  				   bool wakelock)
  {
-	struct pci_dev *pdev = i915->drm.pdev;
-	struct device *kdev = &pdev->dev;
+	struct device *kdev = rpm->kdev;
 
-	untrack_intel_runtime_pm_wakeref(i915, wref);
+	untrack_intel_runtime_pm_wakeref(rpm, wref);
 
-	intel_runtime_pm_release(i915, wakelock);
+	intel_runtime_pm_release(rpm, wakelock);
 
  	pm_runtime_mark_last_busy(kdev);
  	pm_runtime_put_autosuspend(kdev);
@@ -5117,9 +5104,9 @@ static void __intel_runtime_pm_put(struct drm_i915_private *i915,
 
  #if IS_ENABLED(CONFIG_DRM_I915_DEBUG_RUNTIME_PM)
  static void
-intel_runtime_pm_put_raw(struct drm_i915_private *i915, intel_wakeref_t wref)
+intel_runtime_pm_put_raw(struct i915_runtime_pm *rpm, intel_wakeref_t wref)
  {
-	__intel_runtime_pm_put(i915, wref, false);
+	__intel_runtime_pm_put(rpm, wref, false);
  }
  #endif
 
@@ -5137,7 +5124,7 @@ intel_runtime_pm_put_raw(struct drm_i915_private *i915, intel_wakeref_t wref)
   */
  void intel_runtime_pm_put_unchecked(struct drm_i915_private *i915)
  {
-	__intel_runtime_pm_put(i915, -1, true);
+	__intel_runtime_pm_put(&i915->runtime_pm, -1, true);
  }
 
  #if IS_ENABLED(CONFIG_DRM_I915_DEBUG_RUNTIME_PM)
@@ -5152,7 +5139,7 @@ void intel_runtime_pm_put_unchecked(struct drm_i915_private *i915)
   */
  void intel_runtime_pm_put(struct drm_i915_private *i915, intel_wakeref_t wref)
  {
-	__intel_runtime_pm_put(i915, wref, true);
+	__intel_runtime_pm_put(&i915->runtime_pm, wref, true);
  }
  #endif
 
@@ -5168,8 +5155,8 @@ void intel_runtime_pm_put(struct drm_i915_private *i915, intel_wakeref_t wref)
   */
  void intel_runtime_pm_enable(struct drm_i915_private *i915)
  {
-	struct pci_dev *pdev = i915->drm.pdev;
-	struct device *kdev = &pdev->dev;
+	struct i915_runtime_pm *rpm = &i915->runtime_pm;
+	struct device *kdev = rpm->kdev;
 
  	/*
  	 * Disable the system suspend direct complete optimization, which can
@@ -5190,7 +5177,7 @@ void intel_runtime_pm_enable(struct drm_i915_private *i915)
  	 * so the driver's own RPM reference tracking asserts also work on
  	 * platforms without RPM support.
  	 */
-	if (!HAS_RUNTIME_PM(i915)) {
+	if (!rpm->available) {
  		int ret;
 
  		pm_runtime_dont_use_autosuspend(kdev);
@@ -5210,8 +5197,8 @@ void intel_runtime_pm_enable(struct drm_i915_private *i915)
 
  void intel_runtime_pm_disable(struct drm_i915_private *i915)
  {
-	struct pci_dev *pdev = i915->drm.pdev;
-	struct device *kdev = &pdev->dev;
+	struct i915_runtime_pm *rpm = &i915->runtime_pm;
+	struct device *kdev = rpm->kdev;
 
  	/* Transfer rpm ownership back to core */
  	WARN(pm_runtime_get_sync(kdev) < 0,
@@ -5219,7 +5206,7 @@ void intel_runtime_pm_disable(struct drm_i915_private *i915)
 
  	pm_runtime_dont_use_autosuspend(kdev);
 
-	if (!HAS_RUNTIME_PM(i915))
+	if (!rpm->available)
  		pm_runtime_put(kdev);
  }
 
@@ -5233,10 +5220,17 @@ void intel_runtime_pm_cleanup(struct drm_i915_private *i915)
  	     intel_rpm_raw_wakeref_count(count),
  	     intel_rpm_wakelock_count(count));
 
-	untrack_all_intel_runtime_pm_wakerefs(i915);
+	untrack_all_intel_runtime_pm_wakerefs(rpm);
  }
 
Quoted 13 lines

drivers/gpu/drm/i915/intel_runtime_pm.c void intel_runtime_pm_cleanup(struct drm_i915_private *i915) · line 5236

Quoted 12 lines
drivers/gpu/drm/i915/intel_runtime_pm.c +8 -1
  void intel_runtime_pm_init_early(struct drm_i915_private *i915)
  {
-	init_intel_runtime_pm_wakeref(i915);
+	struct i915_runtime_pm *rpm = &i915->runtime_pm;
+	struct pci_dev *pdev = i915->drm.pdev;
+	struct device *kdev = &pdev->dev;
+
+	rpm->kdev = kdev;
+	rpm->available = HAS_RUNTIME_PM(i915);
+
+	init_intel_runtime_pm_wakeref(rpm);
  }

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

maintainer
#4 lore raw

Re: [RFC 1/7] drm/i915: prefer i915_runtime_pm in intel_runtime function

Quoted 26 lines · Daniele Ceraolo Spurio
Quoted 12 lines · Jani Nikula
Quoted 11 lines · Daniele Ceraolo Spurio

As a first step towards updating the code to work on the runtime_pm structure instead of i915, rework all the internals to use and pass around that.

---
  drivers/gpu/drm/i915/i915_drv.h         |   2 +
  drivers/gpu/drm/i915/intel_drv.h        |  10 +-
  drivers/gpu/drm/i915/intel_runtime_pm.c | 152 ++++++++++++------------
  3 files changed, 82 insertions(+), 82 deletions(-)
Quoted 12 lines

drivers/gpu/drm/i915/i915_drv.h struct skl_wm_params { · line 1180

Quoted 9 lines
drivers/gpu/drm/i915/i915_drv.h +1 -0
index 5801f5407589..474074c7f395 100644
@@ -1177,6 +1177,8 @@ struct skl_wm_params {
   */
  struct i915_runtime_pm {
  	atomic_t wakeref_count;
+	struct device *kdev;

This could use a small comment to say what device this is.

Quoted 3 lines

Would something like:

	/* the intel gpu we're loaded on */

I meant more literally something like "set to i915->drm->pdev->dev". (With . instead of -> in some places...)

BR,
Jani.

Quoted 457 lines

work? Or should I just rename it to i915_kdev like we use in other parts of the driver?

Thanks,
Daniele

Quoted 451 lines

BR,
Jani.

Quoted 447 lines
drivers/gpu/drm/i915/i915_drv.h +1 -0
+	bool available;
  	bool suspended;
  	bool irqs_enabled;
 
drivers/gpu/drm/i915/intel_drv.h +7 -3
index 30b2d6ed2d53..bd04f394fbd3 100644
@@ -1662,13 +1662,17 @@ ____assert_rpm_wakelock_held(struct i915_runtime_pm *rpm, int wakeref_count)
  }
 
  static inline void
-assert_rpm_raw_wakeref_held(struct drm_i915_private *i915)
+__assert_rpm_raw_wakeref_held(struct i915_runtime_pm *rpm)
  {
-	struct i915_runtime_pm *rpm = &i915->runtime_pm;
-
  	____assert_rpm_raw_wakeref_held(rpm, atomic_read(&rpm->wakeref_count));
  }
 
+static inline void
+assert_rpm_raw_wakeref_held(struct drm_i915_private *i915)
+{
+	__assert_rpm_raw_wakeref_held(&i915->runtime_pm);
+}
+
  static inline void
  __assert_rpm_wakelock_held(struct i915_runtime_pm *rpm)
  {
drivers/gpu/drm/i915/intel_runtime_pm.c +73 -79
index b4abababdf6c..2e21f562df44 100644
@@ -60,19 +60,19 @@
   * present for a given platform.
   */
 
-static intel_wakeref_t intel_runtime_pm_get_raw(struct drm_i915_private *i915);
+static intel_wakeref_t intel_runtime_pm_get_raw(struct i915_runtime_pm *rpm);
  static void
-__intel_runtime_pm_put(struct drm_i915_private *i915, intel_wakeref_t wref,
+__intel_runtime_pm_put(struct i915_runtime_pm *rpm, intel_wakeref_t wref,
  		       bool wakelock);
 
  #if IS_ENABLED(CONFIG_DRM_I915_DEBUG_RUNTIME_PM)
  static void
-intel_runtime_pm_put_raw(struct drm_i915_private *i915, intel_wakeref_t wref);
+intel_runtime_pm_put_raw(struct i915_runtime_pm *rpm, intel_wakeref_t wref);
  #else
-static inline void intel_runtime_pm_put_raw(struct drm_i915_private *i915,
+static inline void intel_runtime_pm_put_raw(struct i915_runtime_pm *rpm,
  					    intel_wakeref_t wref)
  {
-	__intel_runtime_pm_put(i915, -1, false);
+	__intel_runtime_pm_put(rpm, -1, false);
  }
  #endif
 
@@ -112,21 +112,18 @@ static void __print_depot_stack(depot_stack_handle_t stack,
  	snprint_stack_trace(buf, sz, &trace, indent);
  }
 
-static void init_intel_runtime_pm_wakeref(struct drm_i915_private *i915)
+static void init_intel_runtime_pm_wakeref(struct i915_runtime_pm *rpm)
  {
-	struct i915_runtime_pm *rpm = &i915->runtime_pm;
-
  	spin_lock_init(&rpm->debug.lock);
  }
 
  static noinline depot_stack_handle_t
-track_intel_runtime_pm_wakeref(struct drm_i915_private *i915)
+track_intel_runtime_pm_wakeref(struct i915_runtime_pm *rpm)
  {
-	struct i915_runtime_pm *rpm = &i915->runtime_pm;
  	depot_stack_handle_t stack, *stacks;
  	unsigned long flags;
 
-	if (!HAS_RUNTIME_PM(i915))
+	if (!rpm->available)
  		return -1;
 
  	stack = __save_depot_stack();
@@ -153,10 +150,9 @@ track_intel_runtime_pm_wakeref(struct drm_i915_private *i915)
  	return stack;
  }
 
-static void untrack_intel_runtime_pm_wakeref(struct drm_i915_private *i915,
+static void untrack_intel_runtime_pm_wakeref(struct i915_runtime_pm *rpm,
  					     depot_stack_handle_t stack)
  {
-	struct i915_runtime_pm *rpm = &i915->runtime_pm;
  	unsigned long flags, n;
  	bool found = false;
 
@@ -274,9 +270,8 @@ dump_and_free_wakeref_tracking(struct intel_runtime_pm_debug *debug)
  }
 
  static noinline void
-__intel_wakeref_dec_and_check_tracking(struct drm_i915_private *i915)
+__intel_wakeref_dec_and_check_tracking(struct i915_runtime_pm *rpm)
  {
-	struct i915_runtime_pm *rpm = &i915->runtime_pm;
  	struct intel_runtime_pm_debug dbg = {};
  	unsigned long flags;
 
@@ -292,9 +287,8 @@ __intel_wakeref_dec_and_check_tracking(struct drm_i915_private *i915)
  }
 
  static noinline void
-untrack_all_intel_runtime_pm_wakerefs(struct drm_i915_private *i915)
+untrack_all_intel_runtime_pm_wakerefs(struct i915_runtime_pm *rpm)
  {
-	struct i915_runtime_pm *rpm = &i915->runtime_pm;
  	struct intel_runtime_pm_debug dbg = {};
  	unsigned long flags;
 
@@ -345,61 +339,57 @@ void print_intel_runtime_pm_wakeref(struct drm_i915_private *i915,
 
  #else
 
-static void init_intel_runtime_pm_wakeref(struct drm_i915_private *i915)
+static void init_intel_runtime_pm_wakeref(struct i915_runtime_pm *rpm)
  {
  }
 
  static depot_stack_handle_t
-track_intel_runtime_pm_wakeref(struct drm_i915_private *i915)
+track_intel_runtime_pm_wakeref(struct i915_runtime_pm *rpm)
  {
  	return -1;
  }
 
-static void untrack_intel_runtime_pm_wakeref(struct drm_i915_private *i915,
+static void untrack_intel_runtime_pm_wakeref(struct i915_runtime_pm *rpm,
  					     intel_wakeref_t wref)
  {
  }
 
  static void
-__intel_wakeref_dec_and_check_tracking(struct drm_i915_private *i915)
+__intel_wakeref_dec_and_check_tracking(struct i915_runtime_pm *rpm)
  {
-	atomic_dec(&i915->runtime_pm.wakeref_count);
+	atomic_dec(&rpm->wakeref_count);
  }
 
  static void
-untrack_all_intel_runtime_pm_wakerefs(struct drm_i915_private *i915)
+untrack_all_intel_runtime_pm_wakerefs(struct i915_runtime_pm *rpm)
  {
  }
 
  #endif
 
  static void
-intel_runtime_pm_acquire(struct drm_i915_private *i915, bool wakelock)
+intel_runtime_pm_acquire(struct i915_runtime_pm *rpm, bool wakelock)
  {
-	struct i915_runtime_pm *rpm = &i915->runtime_pm;
-
  	if (wakelock) {
  		atomic_add(1 + INTEL_RPM_WAKELOCK_BIAS, &rpm->wakeref_count);
-		assert_rpm_wakelock_held(i915);
+		__assert_rpm_wakelock_held(rpm);
  	} else {
  		atomic_inc(&rpm->wakeref_count);
-		assert_rpm_raw_wakeref_held(i915);
+		__assert_rpm_raw_wakeref_held(rpm);
  	}
  }
 
  static void
-intel_runtime_pm_release(struct drm_i915_private *i915, int wakelock)
+intel_runtime_pm_release(struct i915_runtime_pm *rpm, int wakelock)
  {
-	struct i915_runtime_pm *rpm = &i915->runtime_pm;
-
  	if (wakelock) {
-		assert_rpm_wakelock_held(i915);
+		__assert_rpm_wakelock_held(rpm);
  		atomic_sub(INTEL_RPM_WAKELOCK_BIAS, &rpm->wakeref_count);
  	} else {
-		assert_rpm_raw_wakeref_held(i915);
+		__assert_rpm_raw_wakeref_held(rpm);
  	}
 
-	__intel_wakeref_dec_and_check_tracking(i915);
+	__intel_wakeref_dec_and_check_tracking(rpm);
  }
 
  bool intel_display_power_well_is_enabled(struct drm_i915_private *dev_priv,
@@ -2030,7 +2020,7 @@ intel_display_power_grab_async_put_ref(struct drm_i915_private *dev_priv,
  		goto out_verify;
 
  	cancel_delayed_work(&power_domains->async_put_work);
-	intel_runtime_pm_put_raw(dev_priv,
+	intel_runtime_pm_put_raw(&dev_priv->runtime_pm,
  				 fetch_and_zero(&power_domains->async_put_wakeref));
  out_verify:
  	verify_async_put_domains_state(power_domains);
@@ -2219,7 +2209,8 @@ intel_display_power_put_async_work(struct work_struct *work)
  		container_of(work, struct drm_i915_private,
  			     power_domains.async_put_work.work);
  	struct i915_power_domains *power_domains = &dev_priv->power_domains;
-	intel_wakeref_t new_work_wakeref = intel_runtime_pm_get_raw(dev_priv);
+	struct i915_runtime_pm *rpm = &dev_priv->runtime_pm;
+	intel_wakeref_t new_work_wakeref = intel_runtime_pm_get_raw(rpm);
  	intel_wakeref_t old_work_wakeref = 0;
 
  	mutex_lock(&power_domains->lock);
@@ -2249,9 +2240,9 @@ intel_display_power_put_async_work(struct work_struct *work)
  	mutex_unlock(&power_domains->lock);
 
  	if (old_work_wakeref)
-		intel_runtime_pm_put_raw(dev_priv, old_work_wakeref);
+		intel_runtime_pm_put_raw(rpm, old_work_wakeref);
  	if (new_work_wakeref)
-		intel_runtime_pm_put_raw(dev_priv, new_work_wakeref);
+		intel_runtime_pm_put_raw(rpm, new_work_wakeref);
  }
 
  /**
@@ -2269,7 +2260,8 @@ void __intel_display_power_put_async(struct drm_i915_private *i915,
  				     intel_wakeref_t wakeref)
  {
  	struct i915_power_domains *power_domains = &i915->power_domains;
-	intel_wakeref_t work_wakeref = intel_runtime_pm_get_raw(i915);
+	struct i915_runtime_pm *rpm = &i915->runtime_pm;
+	intel_wakeref_t work_wakeref = intel_runtime_pm_get_raw(rpm);
 
  	mutex_lock(&power_domains->lock);
 
@@ -2296,7 +2288,7 @@ void __intel_display_power_put_async(struct drm_i915_private *i915,
  	mutex_unlock(&power_domains->lock);
 
  	if (work_wakeref)
-		intel_runtime_pm_put_raw(i915, work_wakeref);
+		intel_runtime_pm_put_raw(rpm, work_wakeref);
 
  	intel_runtime_pm_put(i915, wakeref);
  }
@@ -2334,7 +2326,7 @@ void intel_display_power_flush_work(struct drm_i915_private *i915)
  	mutex_unlock(&power_domains->lock);
 
  	if (work_wakeref)
-		intel_runtime_pm_put_raw(i915, work_wakeref);
+		intel_runtime_pm_put_raw(&i915->runtime_pm, work_wakeref);
  }
 
  /**
@@ -4996,24 +4988,22 @@ static void intel_power_domains_verify_state(struct drm_i915_private *i915)
 
  #endif
 
-static intel_wakeref_t __intel_runtime_pm_get(struct drm_i915_private *i915,
+static intel_wakeref_t __intel_runtime_pm_get(struct i915_runtime_pm *rpm,
  					      bool wakelock)
  {
-	struct pci_dev *pdev = i915->drm.pdev;
-	struct device *kdev = &pdev->dev;
  	int ret;
 
-	ret = pm_runtime_get_sync(kdev);
+	ret = pm_runtime_get_sync(rpm->kdev);
  	WARN_ONCE(ret < 0, "pm_runtime_get_sync() failed: %d\n", ret);
 
-	intel_runtime_pm_acquire(i915, wakelock);
+	intel_runtime_pm_acquire(rpm, wakelock);
 
-	return track_intel_runtime_pm_wakeref(i915);
+	return track_intel_runtime_pm_wakeref(rpm);
  }
 
-static intel_wakeref_t intel_runtime_pm_get_raw(struct drm_i915_private *i915)
+static intel_wakeref_t intel_runtime_pm_get_raw(struct i915_runtime_pm *rpm)
  {
-	return __intel_runtime_pm_get(i915, false);
+	return __intel_runtime_pm_get(rpm, false);
  }
 
  /**
@@ -5030,7 +5020,7 @@ static intel_wakeref_t intel_runtime_pm_get_raw(struct drm_i915_private *i915)
   */
  intel_wakeref_t intel_runtime_pm_get(struct drm_i915_private *i915)
  {
-	return __intel_runtime_pm_get(i915, true);
+	return __intel_runtime_pm_get(&i915->runtime_pm, true);
  }
 
  /**
@@ -5049,23 +5039,22 @@ intel_wakeref_t intel_runtime_pm_get(struct drm_i915_private *i915)
   */
  intel_wakeref_t intel_runtime_pm_get_if_in_use(struct drm_i915_private *i915)
  {
-	if (IS_ENABLED(CONFIG_PM)) {
-		struct pci_dev *pdev = i915->drm.pdev;
-		struct device *kdev = &pdev->dev;
+	struct i915_runtime_pm *rpm = &i915->runtime_pm;
 
+	if (IS_ENABLED(CONFIG_PM)) {
  		/*
  		 * In cases runtime PM is disabled by the RPM core and we get
  		 * an -EINVAL return value we are not supposed to call this
  		 * function, since the power state is undefined. This applies
  		 * atm to the late/early system suspend/resume handlers.
  		 */
-		if (pm_runtime_get_if_in_use(kdev) <= 0)
+		if (pm_runtime_get_if_in_use(rpm->kdev) <= 0)
  			return 0;
  	}
 
-	intel_runtime_pm_acquire(i915, true);
+	intel_runtime_pm_acquire(rpm, true);
 
-	return track_intel_runtime_pm_wakeref(i915);
+	return track_intel_runtime_pm_wakeref(rpm);
  }
 
  /**
@@ -5089,27 +5078,25 @@ intel_wakeref_t intel_runtime_pm_get_if_in_use(struct drm_i915_private *i915)
   */
  intel_wakeref_t intel_runtime_pm_get_noresume(struct drm_i915_private *i915)
  {
-	struct pci_dev *pdev = i915->drm.pdev;
-	struct device *kdev = &pdev->dev;
+	struct i915_runtime_pm *rpm = &i915->runtime_pm;
 
-	assert_rpm_wakelock_held(i915);
-	pm_runtime_get_noresume(kdev);
+	__assert_rpm_wakelock_held(rpm);
+	pm_runtime_get_noresume(rpm->kdev);
 
-	intel_runtime_pm_acquire(i915, true);
+	intel_runtime_pm_acquire(rpm, true);
 
-	return track_intel_runtime_pm_wakeref(i915);
+	return track_intel_runtime_pm_wakeref(rpm);
  }
 
-static void __intel_runtime_pm_put(struct drm_i915_private *i915,
+static void __intel_runtime_pm_put(struct i915_runtime_pm *rpm,
  				   intel_wakeref_t wref,
  				   bool wakelock)
  {
-	struct pci_dev *pdev = i915->drm.pdev;
-	struct device *kdev = &pdev->dev;
+	struct device *kdev = rpm->kdev;
 
-	untrack_intel_runtime_pm_wakeref(i915, wref);
+	untrack_intel_runtime_pm_wakeref(rpm, wref);
 
-	intel_runtime_pm_release(i915, wakelock);
+	intel_runtime_pm_release(rpm, wakelock);
 
  	pm_runtime_mark_last_busy(kdev);
  	pm_runtime_put_autosuspend(kdev);
@@ -5117,9 +5104,9 @@ static void __intel_runtime_pm_put(struct drm_i915_private *i915,
 
  #if IS_ENABLED(CONFIG_DRM_I915_DEBUG_RUNTIME_PM)
  static void
-intel_runtime_pm_put_raw(struct drm_i915_private *i915, intel_wakeref_t wref)
+intel_runtime_pm_put_raw(struct i915_runtime_pm *rpm, intel_wakeref_t wref)
  {
-	__intel_runtime_pm_put(i915, wref, false);
+	__intel_runtime_pm_put(rpm, wref, false);
  }
  #endif
 
@@ -5137,7 +5124,7 @@ intel_runtime_pm_put_raw(struct drm_i915_private *i915, intel_wakeref_t wref)
   */
  void intel_runtime_pm_put_unchecked(struct drm_i915_private *i915)
  {
-	__intel_runtime_pm_put(i915, -1, true);
+	__intel_runtime_pm_put(&i915->runtime_pm, -1, true);
  }
 
  #if IS_ENABLED(CONFIG_DRM_I915_DEBUG_RUNTIME_PM)
@@ -5152,7 +5139,7 @@ void intel_runtime_pm_put_unchecked(struct drm_i915_private *i915)
   */
  void intel_runtime_pm_put(struct drm_i915_private *i915, intel_wakeref_t wref)
  {
-	__intel_runtime_pm_put(i915, wref, true);
+	__intel_runtime_pm_put(&i915->runtime_pm, wref, true);
  }
  #endif
 
@@ -5168,8 +5155,8 @@ void intel_runtime_pm_put(struct drm_i915_private *i915, intel_wakeref_t wref)
   */
  void intel_runtime_pm_enable(struct drm_i915_private *i915)
  {
-	struct pci_dev *pdev = i915->drm.pdev;
-	struct device *kdev = &pdev->dev;
+	struct i915_runtime_pm *rpm = &i915->runtime_pm;
+	struct device *kdev = rpm->kdev;
 
  	/*
  	 * Disable the system suspend direct complete optimization, which can
@@ -5190,7 +5177,7 @@ void intel_runtime_pm_enable(struct drm_i915_private *i915)
  	 * so the driver's own RPM reference tracking asserts also work on
  	 * platforms without RPM support.
  	 */
-	if (!HAS_RUNTIME_PM(i915)) {
+	if (!rpm->available) {
  		int ret;
 
  		pm_runtime_dont_use_autosuspend(kdev);
@@ -5210,8 +5197,8 @@ void intel_runtime_pm_enable(struct drm_i915_private *i915)
 
  void intel_runtime_pm_disable(struct drm_i915_private *i915)
  {
-	struct pci_dev *pdev = i915->drm.pdev;
-	struct device *kdev = &pdev->dev;
+	struct i915_runtime_pm *rpm = &i915->runtime_pm;
+	struct device *kdev = rpm->kdev;
 
  	/* Transfer rpm ownership back to core */
  	WARN(pm_runtime_get_sync(kdev) < 0,
@@ -5219,7 +5206,7 @@ void intel_runtime_pm_disable(struct drm_i915_private *i915)
 
  	pm_runtime_dont_use_autosuspend(kdev);
 
-	if (!HAS_RUNTIME_PM(i915))
+	if (!rpm->available)
  		pm_runtime_put(kdev);
  }
 
@@ -5233,10 +5220,17 @@ void intel_runtime_pm_cleanup(struct drm_i915_private *i915)
  	     intel_rpm_raw_wakeref_count(count),
  	     intel_rpm_wakelock_count(count));
 
-	untrack_all_intel_runtime_pm_wakerefs(i915);
+	untrack_all_intel_runtime_pm_wakerefs(rpm);
  }
 
  void intel_runtime_pm_init_early(struct drm_i915_private *i915)
  {
-	init_intel_runtime_pm_wakeref(i915);
+	struct i915_runtime_pm *rpm = &i915->runtime_pm;
+	struct pci_dev *pdev = i915->drm.pdev;
+	struct device *kdev = &pdev->dev;
+
+	rpm->kdev = kdev;
+	rpm->available = HAS_RUNTIME_PM(i915);
+
+	init_intel_runtime_pm_wakeref(rpm);
  }
Signature · 5 lines
Jani Nikula, Intel Open Source Graphics Center
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#5 lore raw

RFC 2/7 drm/i915: Remove rpm asserts that use i915

In reply to Daniele Ceraolo Spurio

Quite a few of the call points have already switched to the version working directly on the runtime_pm structure, so let's switch over the rest and kill the i915-based asserts.

---
 drivers/gpu/drm/i915/gvt/aperture_gm.c    |  2 +-
 drivers/gpu/drm/i915/i915_gem.c           |  2 +-
 drivers/gpu/drm/i915/i915_gem_fence_reg.c |  2 +-
 drivers/gpu/drm/i915/i915_irq.c           |  6 +++---
 drivers/gpu/drm/i915/i915_vma.c           |  2 +-
 drivers/gpu/drm/i915/intel_csr.c          |  2 +-
 drivers/gpu/drm/i915/intel_drv.h          | 26 ++++++-----------------
 drivers/gpu/drm/i915/intel_runtime_pm.c   | 14 ++++++------
 drivers/gpu/drm/i915/intel_uncore.c       | 12 +++++------
 9 files changed, 28 insertions(+), 40 deletions(-)
drivers/gpu/drm/i915/gvt/aperture_gm.c +1 -1
index 1fa2f65c3cd1..7f4e3456ce11 100644
@@ -131,7 +131,7 @@ void intel_vgpu_write_fence(struct intel_vgpu *vgpu,
 	struct drm_i915_fence_reg *reg;
 	i915_reg_t fence_reg_lo, fence_reg_hi;
 
-	assert_rpm_wakelock_held(dev_priv);
+	assert_rpm_wakelock_held(&dev_priv->runtime_pm);
 
 	if (WARN_ON(fence >= vgpu_fence_sz(vgpu)))
 		return;
drivers/gpu/drm/i915/i915_gem.c +1 -1
index 2fcec1bfb038..5bccf7955285 100644
@@ -1807,7 +1807,7 @@ vm_fault_t i915_gem_fault(struct vm_fault *vmf)
 		goto err_fence;
 
 	/* Mark as being mmapped into userspace for later revocation */
-	assert_rpm_wakelock_held(dev_priv);
+	assert_rpm_wakelock_held(&dev_priv->runtime_pm);
 	if (!i915_vma_set_userfault(vma) && !obj->userfault_count++)
 		list_add(&obj->userfault_link, &dev_priv->mm.userfault_list);
 	GEM_BUG_ON(!obj->userfault_count);
drivers/gpu/drm/i915/i915_gem_fence_reg.c +1 -1
index 3084f52e3372..50f52264b163 100644
@@ -354,7 +354,7 @@ i915_vma_pin_fence(struct i915_vma *vma)
 	/* Note that we revoke fences on runtime suspend. Therefore the user
 	 * must keep the device awake whilst using the fence.
 	 */
-	assert_rpm_wakelock_held(vma->vm->i915);
+	assert_rpm_wakelock_held(&vma->vm->i915->runtime_pm);
 
 	/* Just update our place in the LRU if our fence is getting reused. */
 	if (vma->fence) {
drivers/gpu/drm/i915/i915_irq.c +3 -3
index 233211fde0ea..32f56dd68ac9 100644
@@ -588,7 +588,7 @@ void gen6_disable_rps_interrupts(struct drm_i915_private *dev_priv)
 
 void gen9_reset_guc_interrupts(struct drm_i915_private *dev_priv)
 {
-	assert_rpm_wakelock_held(dev_priv);
+	assert_rpm_wakelock_held(&dev_priv->runtime_pm);
 
 	spin_lock_irq(&dev_priv->irq_lock);
 	gen6_reset_pm_iir(dev_priv, dev_priv->pm_guc_events);
@@ -597,7 +597,7 @@ void gen9_reset_guc_interrupts(struct drm_i915_private *dev_priv)
 
 void gen9_enable_guc_interrupts(struct drm_i915_private *dev_priv)
 {
-	assert_rpm_wakelock_held(dev_priv);
+	assert_rpm_wakelock_held(&dev_priv->runtime_pm);
 
 	spin_lock_irq(&dev_priv->irq_lock);
 	if (!dev_priv->guc.interrupts_enabled) {
@@ -611,7 +611,7 @@ void gen9_enable_guc_interrupts(struct drm_i915_private *dev_priv)
 
 void gen9_disable_guc_interrupts(struct drm_i915_private *dev_priv)
 {
-	assert_rpm_wakelock_held(dev_priv);
+	assert_rpm_wakelock_held(&dev_priv->runtime_pm);
 
 	spin_lock_irq(&dev_priv->irq_lock);
 	dev_priv->guc.interrupts_enabled = false;
drivers/gpu/drm/i915/i915_vma.c +1 -1
index d4d308b6d1d8..07c84b8e2560 100644
@@ -364,7 +364,7 @@ void __iomem *i915_vma_pin_iomap(struct i915_vma *vma)
 	int err;
 
 	/* Access through the GTT requires the device to be awake. */
-	assert_rpm_wakelock_held(vma->vm->i915);
+	assert_rpm_wakelock_held(&vma->vm->i915->runtime_pm);
 
 	lockdep_assert_held(&vma->vm->i915->drm.struct_mutex);
 	if (WARN_ON(!i915_vma_is_map_and_fenceable(vma))) {
drivers/gpu/drm/i915/intel_csr.c +1 -1
index 4527b9662330..ade1a3bd75bc 100644
@@ -273,7 +273,7 @@ void intel_csr_load_program(struct drm_i915_private *dev_priv)
 	}
 
 	fw_size = dev_priv->csr.dmc_fw_size;
-	assert_rpm_wakelock_held(dev_priv);
+	assert_rpm_wakelock_held(&dev_priv->runtime_pm);
 
 	preempt_disable();
 
drivers/gpu/drm/i915/intel_drv.h +7 -19
index bd04f394fbd3..13fcb5d59d9d 100644
@@ -1646,7 +1646,7 @@ assert_rpm_device_not_suspended(struct i915_runtime_pm *rpm)
 }
 
 static inline void
-____assert_rpm_raw_wakeref_held(struct i915_runtime_pm *rpm, int wakeref_count)
+__assert_rpm_raw_wakeref_held(struct i915_runtime_pm *rpm, int wakeref_count)
 {
 	assert_rpm_device_not_suspended(rpm);
 	WARN_ONCE(!intel_rpm_raw_wakeref_count(wakeref_count),
@@ -1654,35 +1654,23 @@ ____assert_rpm_raw_wakeref_held(struct i915_runtime_pm *rpm, int wakeref_count)
 }
 
 static inline void
-____assert_rpm_wakelock_held(struct i915_runtime_pm *rpm, int wakeref_count)
+__assert_rpm_wakelock_held(struct i915_runtime_pm *rpm, int wakeref_count)
 {
-	____assert_rpm_raw_wakeref_held(rpm, wakeref_count);
+	__assert_rpm_raw_wakeref_held(rpm, wakeref_count);
 	WARN_ONCE(!intel_rpm_wakelock_count(wakeref_count),
 		  "RPM wakelock ref not held during HW access\n");
 }
 
 static inline void
-__assert_rpm_raw_wakeref_held(struct i915_runtime_pm *rpm)
+assert_rpm_raw_wakeref_held(struct i915_runtime_pm *rpm)
 {
-	____assert_rpm_raw_wakeref_held(rpm, atomic_read(&rpm->wakeref_count));
+	__assert_rpm_raw_wakeref_held(rpm, atomic_read(&rpm->wakeref_count));
 }
 
 static inline void
-assert_rpm_raw_wakeref_held(struct drm_i915_private *i915)
+assert_rpm_wakelock_held(struct i915_runtime_pm *rpm)
 {
-	__assert_rpm_raw_wakeref_held(&i915->runtime_pm);
-}
-
-static inline void
-__assert_rpm_wakelock_held(struct i915_runtime_pm *rpm)
-{
-	____assert_rpm_wakelock_held(rpm, atomic_read(&rpm->wakeref_count));
-}
-
-static inline void
-assert_rpm_wakelock_held(struct drm_i915_private *i915)
-{
-	__assert_rpm_wakelock_held(&i915->runtime_pm);
+	__assert_rpm_wakelock_held(rpm, atomic_read(&rpm->wakeref_count));
 }
 
 /**
drivers/gpu/drm/i915/intel_runtime_pm.c +7 -7
index 2e21f562df44..271153fd3a33 100644
@@ -372,10 +372,10 @@ intel_runtime_pm_acquire(struct i915_runtime_pm *rpm, bool wakelock)
 {
 	if (wakelock) {
 		atomic_add(1 + INTEL_RPM_WAKELOCK_BIAS, &rpm->wakeref_count);
-		__assert_rpm_wakelock_held(rpm);
+		assert_rpm_wakelock_held(rpm);
 	} else {
 		atomic_inc(&rpm->wakeref_count);
-		__assert_rpm_raw_wakeref_held(rpm);
+		assert_rpm_raw_wakeref_held(rpm);
 	}
 }
 
@@ -383,10 +383,10 @@ static void
 intel_runtime_pm_release(struct i915_runtime_pm *rpm, int wakelock)
 {
 	if (wakelock) {
-		__assert_rpm_wakelock_held(rpm);
+		assert_rpm_wakelock_held(rpm);
 		atomic_sub(INTEL_RPM_WAKELOCK_BIAS, &rpm->wakeref_count);
 	} else {
-		__assert_rpm_raw_wakeref_held(rpm);
+		assert_rpm_raw_wakeref_held(rpm);
 	}
 
 	__intel_wakeref_dec_and_check_tracking(rpm);
@@ -1072,7 +1072,7 @@ static void assert_can_enable_dc5(struct drm_i915_private *dev_priv)
 
 	WARN_ONCE((I915_READ(DC_STATE_EN) & DC_STATE_EN_UPTO_DC5),
 		  "DC5 already programmed to be enabled.\n");
-	assert_rpm_wakelock_held(dev_priv);
+	assert_rpm_wakelock_held(&dev_priv->runtime_pm);
 
 	assert_csr_loaded(dev_priv);
 }
@@ -2190,7 +2190,7 @@ release_async_put_domains(struct i915_power_domains *power_domains, u64 mask)
 	 * wakeref to make the state checker happy about the HW access during
 	 * power well disabling.
 	 */
-	assert_rpm_raw_wakeref_held(dev_priv);
+	assert_rpm_raw_wakeref_held(&dev_priv->runtime_pm);
 	wakeref = intel_runtime_pm_get(dev_priv);
 
 	for_each_power_domain(domain, mask) {
@@ -5080,7 +5080,7 @@ intel_wakeref_t intel_runtime_pm_get_noresume(struct drm_i915_private *i915)
 {
 	struct i915_runtime_pm *rpm = &i915->runtime_pm;
 
-	__assert_rpm_wakelock_held(rpm);
+	assert_rpm_wakelock_held(rpm);
 	pm_runtime_get_noresume(rpm->kdev);
 
 	intel_runtime_pm_acquire(rpm, true);
drivers/gpu/drm/i915/intel_uncore.c +6 -6
index f78668123f02..3002872b4a88 100644
@@ -583,7 +583,7 @@ void intel_uncore_forcewake_get(struct intel_uncore *uncore,
 	if (!uncore->funcs.force_wake_get)
 		return;
 
-	__assert_rpm_wakelock_held(uncore->rpm);
+	assert_rpm_wakelock_held(uncore->rpm);
 
 	spin_lock_irqsave(&uncore->lock, irqflags);
 	__intel_uncore_forcewake_get(uncore, fw_domains);
@@ -737,7 +737,7 @@ void assert_forcewakes_active(struct intel_uncore *uncore,
 	if (!uncore->funcs.force_wake_get)
 		return;
 
-	__assert_rpm_wakelock_held(uncore->rpm);
+	assert_rpm_wakelock_held(uncore->rpm);
 
 	fw_domains &= uncore->fw_domains;
 	WARN(fw_domains & ~uncore->fw_domains_active,
@@ -1054,7 +1054,7 @@ unclaimed_reg_debug(struct intel_uncore *uncore,
 
 #define GEN2_READ_HEADER(x) \
 	u##x val = 0; \
-	__assert_rpm_wakelock_held(uncore->rpm);
+	assert_rpm_wakelock_held(uncore->rpm);
 
 #define GEN2_READ_FOOTER \
 	trace_i915_reg_rw(false, reg, val, sizeof(val), trace); \
@@ -1096,7 +1096,7 @@ __gen2_read(64)
 	u32 offset = i915_mmio_reg_offset(reg); \
 	unsigned long irqflags; \
 	u##x val = 0; \
-	__assert_rpm_wakelock_held(uncore->rpm); \
+	assert_rpm_wakelock_held(uncore->rpm); \
 	spin_lock_irqsave(&uncore->lock, irqflags); \
 	unclaimed_reg_debug(uncore, reg, true, true)
 
@@ -1170,7 +1170,7 @@ __gen6_read(64)
 
 #define GEN2_WRITE_HEADER \
 	trace_i915_reg_rw(true, reg, val, sizeof(val), trace); \
-	__assert_rpm_wakelock_held(uncore->rpm); \
+	assert_rpm_wakelock_held(uncore->rpm); \
 
 #define GEN2_WRITE_FOOTER
 
@@ -1208,7 +1208,7 @@ __gen2_write(32)
 	u32 offset = i915_mmio_reg_offset(reg); \
 	unsigned long irqflags; \
 	trace_i915_reg_rw(true, reg, val, sizeof(val), trace); \
-	__assert_rpm_wakelock_held(uncore->rpm); \
+	assert_rpm_wakelock_held(uncore->rpm); \
 	spin_lock_irqsave(&uncore->lock, irqflags); \
 	unclaimed_reg_debug(uncore, reg, false, true)
 
Signature · 6 lines
2.20.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#6 lore raw

RFC 3/7 drm/i915: make enable/disable rpm assert function use the rpm structure

In reply to Daniele Ceraolo Spurio

With this all the rpm assert-related functions consistently work on the i915_runtime_pm structure

---
 drivers/gpu/drm/i915/i915_drv.c     | 44 +++++++++++++++--------------
 drivers/gpu/drm/i915/i915_irq.c     | 32 ++++++++++-----------
 drivers/gpu/drm/i915/intel_drv.h    | 12 ++++----
 drivers/gpu/drm/i915/intel_guc.c    |  4 +--
 drivers/gpu/drm/i915/intel_uncore.c | 12 ++++----
 5 files changed, 53 insertions(+), 51 deletions(-)
drivers/gpu/drm/i915/i915_drv.c +23 -21
index 2c7a4318d13c..8b9e5b042e70 100644
@@ -1884,7 +1884,7 @@ int i915_driver_load(struct pci_dev *pdev, const struct pci_device_id *ent)
 	if (ret < 0)
 		goto out_pci_disable;
 
-	disable_rpm_wakeref_asserts(dev_priv);
+	disable_rpm_wakeref_asserts(&dev_priv->runtime_pm);
 
 	ret = i915_driver_init_mmio(dev_priv);
 	if (ret < 0)
@@ -1900,7 +1900,7 @@ int i915_driver_load(struct pci_dev *pdev, const struct pci_device_id *ent)
 
 	i915_driver_register(dev_priv);
 
-	enable_rpm_wakeref_asserts(dev_priv);
+	enable_rpm_wakeref_asserts(&dev_priv->runtime_pm);
 
 	i915_welcome_messages(dev_priv);
 
@@ -1911,7 +1911,7 @@ int i915_driver_load(struct pci_dev *pdev, const struct pci_device_id *ent)
 out_cleanup_mmio:
 	i915_driver_cleanup_mmio(dev_priv);
 out_runtime_pm_put:
-	enable_rpm_wakeref_asserts(dev_priv);
+	enable_rpm_wakeref_asserts(&dev_priv->runtime_pm);
 	i915_driver_cleanup_early(dev_priv);
 out_pci_disable:
 	pci_disable_device(pdev);
@@ -1926,7 +1926,7 @@ void i915_driver_unload(struct drm_device *dev)
 	struct drm_i915_private *dev_priv = to_i915(dev);
 	struct pci_dev *pdev = dev_priv->drm.pdev;
 
-	disable_rpm_wakeref_asserts(dev_priv);
+	disable_rpm_wakeref_asserts(&dev_priv->runtime_pm);
 
 	i915_driver_unregister(dev_priv);
 
@@ -1966,7 +1966,7 @@ void i915_driver_unload(struct drm_device *dev)
 	i915_driver_cleanup_hw(dev_priv);
 	i915_driver_cleanup_mmio(dev_priv);
 
-	enable_rpm_wakeref_asserts(dev_priv);
+	enable_rpm_wakeref_asserts(&dev_priv->runtime_pm);
 	intel_runtime_pm_cleanup(dev_priv);
 }
 
@@ -2066,7 +2066,7 @@ static int i915_drm_suspend(struct drm_device *dev)
 	struct pci_dev *pdev = dev_priv->drm.pdev;
 	pci_power_t opregion_target_state;
 
-	disable_rpm_wakeref_asserts(dev_priv);
+	disable_rpm_wakeref_asserts(&dev_priv->runtime_pm);
 
 	/* We do a lot of poking in a lot of registers, make sure they work
 	 * properly. */
@@ -2100,7 +2100,7 @@ static int i915_drm_suspend(struct drm_device *dev)
 
 	intel_csr_ucode_suspend(dev_priv);
 
-	enable_rpm_wakeref_asserts(dev_priv);
+	enable_rpm_wakeref_asserts(&dev_priv->runtime_pm);
 
 	return 0;
 }
@@ -2123,7 +2123,7 @@ static int i915_drm_suspend_late(struct drm_device *dev, bool hibernation)
 	struct pci_dev *pdev = dev_priv->drm.pdev;
 	int ret;
 
-	disable_rpm_wakeref_asserts(dev_priv);
+	disable_rpm_wakeref_asserts(&dev_priv->runtime_pm);
 
 	i915_gem_suspend_late(dev_priv);
 
@@ -2164,7 +2164,7 @@ static int i915_drm_suspend_late(struct drm_device *dev, bool hibernation)
 		pci_set_power_state(pdev, PCI_D3hot);
 
 out:
-	enable_rpm_wakeref_asserts(dev_priv);
+	enable_rpm_wakeref_asserts(&dev_priv->runtime_pm);
 	if (!dev_priv->uncore.user_forcewake.count)
 		intel_runtime_pm_cleanup(dev_priv);
 
@@ -2200,7 +2200,7 @@ static int i915_drm_resume(struct drm_device *dev)
 	struct drm_i915_private *dev_priv = to_i915(dev);
 	int ret;
 
-	disable_rpm_wakeref_asserts(dev_priv);
+	disable_rpm_wakeref_asserts(&dev_priv->runtime_pm);
 	intel_sanitize_gt_powersave(dev_priv);
 
 	i915_gem_sanitize(dev_priv);
@@ -2260,7 +2260,7 @@ static int i915_drm_resume(struct drm_device *dev)
 
 	intel_power_domains_enable(dev_priv);
 
-	enable_rpm_wakeref_asserts(dev_priv);
+	enable_rpm_wakeref_asserts(&dev_priv->runtime_pm);
 
 	return 0;
 }
@@ -2315,7 +2315,7 @@ static int i915_drm_resume_early(struct drm_device *dev)
 
 	pci_set_master(pdev);
 
-	disable_rpm_wakeref_asserts(dev_priv);
+	disable_rpm_wakeref_asserts(&dev_priv->runtime_pm);
 
 	if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv))
 		ret = vlv_resume_prepare(dev_priv, false);
@@ -2340,7 +2340,7 @@ static int i915_drm_resume_early(struct drm_device *dev)
 
 	intel_gt_sanitize(dev_priv, true);
 
-	enable_rpm_wakeref_asserts(dev_priv);
+	enable_rpm_wakeref_asserts(&dev_priv->runtime_pm);
 
 	return ret;
 }
@@ -2873,6 +2873,7 @@ static int intel_runtime_suspend(struct device *kdev)
 	struct pci_dev *pdev = to_pci_dev(kdev);
 	struct drm_device *dev = pci_get_drvdata(pdev);
 	struct drm_i915_private *dev_priv = to_i915(dev);
+	struct i915_runtime_pm *rpm = &dev_priv->runtime_pm;
 	int ret;
 
 	if (WARN_ON_ONCE(!(dev_priv->gt_pm.rc6.enabled && HAS_RC6(dev_priv))))
@@ -2883,7 +2884,7 @@ static int intel_runtime_suspend(struct device *kdev)
 
 	DRM_DEBUG_KMS("Suspending device\n");
 
-	disable_rpm_wakeref_asserts(dev_priv);
+	disable_rpm_wakeref_asserts(rpm);
 
 	/*
 	 * We are safe here against re-faults, since the fault handler takes
@@ -2921,18 +2922,18 @@ static int intel_runtime_suspend(struct device *kdev)
 		i915_gem_init_swizzling(dev_priv);
 		i915_gem_restore_fences(dev_priv);
 
-		enable_rpm_wakeref_asserts(dev_priv);
+		enable_rpm_wakeref_asserts(rpm);
 
 		return ret;
 	}
 
-	enable_rpm_wakeref_asserts(dev_priv);
+	enable_rpm_wakeref_asserts(rpm);
 	intel_runtime_pm_cleanup(dev_priv);
 
 	if (intel_uncore_arm_unclaimed_mmio_detection(&dev_priv->uncore))
 		DRM_ERROR("Unclaimed access detected prior to suspending\n");
 
-	dev_priv->runtime_pm.suspended = true;
+	rpm->suspended = true;
 
 	/*
 	 * FIXME: We really should find a document that references the arguments
@@ -2971,6 +2972,7 @@ static int intel_runtime_resume(struct device *kdev)
 	struct pci_dev *pdev = to_pci_dev(kdev);
 	struct drm_device *dev = pci_get_drvdata(pdev);
 	struct drm_i915_private *dev_priv = to_i915(dev);
+	struct i915_runtime_pm *rpm = &dev_priv->runtime_pm;
 	int ret = 0;
 
 	if (WARN_ON_ONCE(!HAS_RUNTIME_PM(dev_priv)))
@@ -2978,11 +2980,11 @@ static int intel_runtime_resume(struct device *kdev)
 
 	DRM_DEBUG_KMS("Resuming device\n");
 
-	WARN_ON_ONCE(atomic_read(&dev_priv->runtime_pm.wakeref_count));
-	disable_rpm_wakeref_asserts(dev_priv);
+	WARN_ON_ONCE(atomic_read(&rpm->wakeref_count));
+	disable_rpm_wakeref_asserts(rpm);
 
 	intel_opregion_notify_adapter(dev_priv, PCI_D0);
-	dev_priv->runtime_pm.suspended = false;
+	rpm->suspended = false;
 	if (intel_uncore_unclaimed_mmio(&dev_priv->uncore))
 		DRM_DEBUG_DRIVER("Unclaimed access during suspend, bios?\n");
 
@@ -3032,7 +3034,7 @@ static int intel_runtime_resume(struct device *kdev)
 
 	intel_enable_ipc(dev_priv);
 
-	enable_rpm_wakeref_asserts(dev_priv);
+	enable_rpm_wakeref_asserts(rpm);
 
 	if (ret)
 		DRM_ERROR("Runtime resume failed, disabling it (%d)\n", ret);
drivers/gpu/drm/i915/i915_irq.c +16 -16
index 32f56dd68ac9..008cd5202026 100644
@@ -2140,7 +2140,7 @@ static irqreturn_t valleyview_irq_handler(int irq, void *arg)
 		return IRQ_NONE;
 
 	/* IRQs are synced during runtime_suspend, we don't require a wakeref */
-	disable_rpm_wakeref_asserts(dev_priv);
+	disable_rpm_wakeref_asserts(&dev_priv->runtime_pm);
 
 	do {
 		u32 iir, gt_iir, pm_iir;
@@ -2211,7 +2211,7 @@ static irqreturn_t valleyview_irq_handler(int irq, void *arg)
 		valleyview_pipestat_irq_handler(dev_priv, pipe_stats);
 	} while (0);
 
-	enable_rpm_wakeref_asserts(dev_priv);
+	enable_rpm_wakeref_asserts(&dev_priv->runtime_pm);
 
 	return ret;
 }
@@ -2226,7 +2226,7 @@ static irqreturn_t cherryview_irq_handler(int irq, void *arg)
 		return IRQ_NONE;
 
 	/* IRQs are synced during runtime_suspend, we don't require a wakeref */
-	disable_rpm_wakeref_asserts(dev_priv);
+	disable_rpm_wakeref_asserts(&dev_priv->runtime_pm);
 
 	do {
 		u32 master_ctl, iir;
@@ -2292,7 +2292,7 @@ static irqreturn_t cherryview_irq_handler(int irq, void *arg)
 		valleyview_pipestat_irq_handler(dev_priv, pipe_stats);
 	} while (0);
 
-	enable_rpm_wakeref_asserts(dev_priv);
+	enable_rpm_wakeref_asserts(&dev_priv->runtime_pm);
 
 	return ret;
 }
@@ -2646,7 +2646,7 @@ static irqreturn_t ironlake_irq_handler(int irq, void *arg)
 		return IRQ_NONE;
 
 	/* IRQs are synced during runtime_suspend, we don't require a wakeref */
-	disable_rpm_wakeref_asserts(dev_priv);
+	disable_rpm_wakeref_asserts(&dev_priv->runtime_pm);
 
 	/* disable master interrupt before clearing iir  */
 	de_ier = I915_READ(DEIER);
@@ -2698,7 +2698,7 @@ static irqreturn_t ironlake_irq_handler(int irq, void *arg)
 		I915_WRITE(SDEIER, sde_ier);
 
 	/* IRQs are synced during runtime_suspend, we don't require a wakeref */
-	enable_rpm_wakeref_asserts(dev_priv);
+	enable_rpm_wakeref_asserts(&dev_priv->runtime_pm);
 
 	return ret;
 }
@@ -2965,9 +2965,9 @@ static irqreturn_t gen8_irq_handler(int irq, void *arg)
 
 	/* IRQs are synced during runtime_suspend, we don't require a wakeref */
 	if (master_ctl & ~GEN8_GT_IRQS) {
-		disable_rpm_wakeref_asserts(dev_priv);
+		disable_rpm_wakeref_asserts(&dev_priv->runtime_pm);
 		gen8_de_irq_handler(dev_priv, master_ctl);
-		enable_rpm_wakeref_asserts(dev_priv);
+		enable_rpm_wakeref_asserts(&dev_priv->runtime_pm);
 	}
 
 	gen8_master_intr_enable(regs);
@@ -3163,13 +3163,13 @@ static irqreturn_t gen11_irq_handler(int irq, void *arg)
 	if (master_ctl & GEN11_DISPLAY_IRQ) {
 		const u32 disp_ctl = raw_reg_read(regs, GEN11_DISPLAY_INT_CTL);
 
-		disable_rpm_wakeref_asserts(i915);
+		disable_rpm_wakeref_asserts(&i915->runtime_pm);
 		/*
 		 * GEN11_DISPLAY_INT_CTL has same format as GEN8_MASTER_IRQ
 		 * for the display related bits.
 		 */
 		gen8_de_irq_handler(i915, disp_ctl);
-		enable_rpm_wakeref_asserts(i915);
+		enable_rpm_wakeref_asserts(&i915->runtime_pm);
 	}
 
 	gu_misc_iir = gen11_gu_misc_irq_ack(i915, master_ctl);
@@ -4384,7 +4384,7 @@ static irqreturn_t i8xx_irq_handler(int irq, void *arg)
 		return IRQ_NONE;
 
 	/* IRQs are synced during runtime_suspend, we don't require a wakeref */
-	disable_rpm_wakeref_asserts(dev_priv);
+	disable_rpm_wakeref_asserts(&dev_priv->runtime_pm);
 
 	do {
 		u32 pipe_stats[I915_MAX_PIPES] = {};
@@ -4415,7 +4415,7 @@ static irqreturn_t i8xx_irq_handler(int irq, void *arg)
 		i8xx_pipestat_irq_handler(dev_priv, iir, pipe_stats);
 	} while (0);
 
-	enable_rpm_wakeref_asserts(dev_priv);
+	enable_rpm_wakeref_asserts(&dev_priv->runtime_pm);
 
 	return ret;
 }
@@ -4489,7 +4489,7 @@ static irqreturn_t i915_irq_handler(int irq, void *arg)
 		return IRQ_NONE;
 
 	/* IRQs are synced during runtime_suspend, we don't require a wakeref */
-	disable_rpm_wakeref_asserts(dev_priv);
+	disable_rpm_wakeref_asserts(&dev_priv->runtime_pm);
 
 	do {
 		u32 pipe_stats[I915_MAX_PIPES] = {};
@@ -4528,7 +4528,7 @@ static irqreturn_t i915_irq_handler(int irq, void *arg)
 		i915_pipestat_irq_handler(dev_priv, iir, pipe_stats);
 	} while (0);
 
-	enable_rpm_wakeref_asserts(dev_priv);
+	enable_rpm_wakeref_asserts(&dev_priv->runtime_pm);
 
 	return ret;
 }
@@ -4637,7 +4637,7 @@ static irqreturn_t i965_irq_handler(int irq, void *arg)
 		return IRQ_NONE;
 
 	/* IRQs are synced during runtime_suspend, we don't require a wakeref */
-	disable_rpm_wakeref_asserts(dev_priv);
+	disable_rpm_wakeref_asserts(&dev_priv->runtime_pm);
 
 	do {
 		u32 pipe_stats[I915_MAX_PIPES] = {};
@@ -4678,7 +4678,7 @@ static irqreturn_t i965_irq_handler(int irq, void *arg)
 		i965_pipestat_irq_handler(dev_priv, iir, pipe_stats);
 	} while (0);
 
-	enable_rpm_wakeref_asserts(dev_priv);
+	enable_rpm_wakeref_asserts(&dev_priv->runtime_pm);
 
 	return ret;
 }
drivers/gpu/drm/i915/intel_drv.h +6 -6
index 13fcb5d59d9d..6976d92b0bd8 100644
@@ -1675,7 +1675,7 @@ assert_rpm_wakelock_held(struct i915_runtime_pm *rpm)
 
 /**
  * disable_rpm_wakeref_asserts - disable the RPM assert checks
- * @i915: i915 device instance
+ * @rpm: the i915_runtime_pm structure
  *
  * This function disable asserts that check if we hold an RPM wakelock
  * reference, while keeping the device-not-suspended checks still enabled.
@@ -1692,15 +1692,15 @@ assert_rpm_wakelock_held(struct i915_runtime_pm *rpm)
  * enable_rpm_wakeref_asserts().
  */
 static inline void
-disable_rpm_wakeref_asserts(struct drm_i915_private *i915)
+disable_rpm_wakeref_asserts(struct i915_runtime_pm *rpm)
 {
 	atomic_add(INTEL_RPM_WAKELOCK_BIAS + 1,
-		   &i915->runtime_pm.wakeref_count);
+		   &rpm->wakeref_count);
 }
 
 /**
  * enable_rpm_wakeref_asserts - re-enable the RPM assert checks
- * @i915: i915 device instance
+ * @rpm: the i915_runtime_pm structure
  *
  * This function re-enables the RPM assert checks after disabling them with
  * disable_rpm_wakeref_asserts. It's meant to be used only in special
@@ -1710,10 +1710,10 @@ disable_rpm_wakeref_asserts(struct drm_i915_private *i915)
  * disable_rpm_wakeref_asserts().
  */
 static inline void
-enable_rpm_wakeref_asserts(struct drm_i915_private *i915)
+enable_rpm_wakeref_asserts(struct i915_runtime_pm *rpm)
 {
 	atomic_sub(INTEL_RPM_WAKELOCK_BIAS + 1,
-		   &i915->runtime_pm.wakeref_count);
+		   &rpm->wakeref_count);
 }
 
 #endif /* __INTEL_DRV_H__ */
drivers/gpu/drm/i915/intel_guc.c +2 -2
index c4ac29309fcc..849863a675ca 100644
@@ -484,13 +484,13 @@ void intel_guc_to_host_event_handler_mmio(struct intel_guc *guc)
 	 * could happen that GuC sets the bit for 2nd interrupt but Host
 	 * clears out the bit on handling the 1st interrupt.
 	 */
-	disable_rpm_wakeref_asserts(dev_priv);
+	disable_rpm_wakeref_asserts(&dev_priv->runtime_pm);
 	spin_lock(&guc->irq_lock);
 	val = I915_READ(SOFT_SCRATCH(15));
 	msg = val & guc->msg_enabled_mask;
 	I915_WRITE(SOFT_SCRATCH(15), val & ~msg);
 	spin_unlock(&guc->irq_lock);
-	enable_rpm_wakeref_asserts(dev_priv);
+	enable_rpm_wakeref_asserts(&dev_priv->runtime_pm);
 
 	intel_guc_to_host_process_recv_msg(guc, &msg, 1);
 }
drivers/gpu/drm/i915/intel_uncore.c +6 -6
index 3002872b4a88..a5b7e99eb5e1 100644
@@ -1461,8 +1461,8 @@ static void intel_uncore_fw_domains_init(struct intel_uncore *uncore)
 static int i915_pmic_bus_access_notifier(struct notifier_block *nb,
 					 unsigned long action, void *data)
 {
-	struct drm_i915_private *dev_priv = container_of(nb,
-			struct drm_i915_private, uncore.pmic_bus_access_nb);
+	struct intel_uncore *uncore = container_of(nb,
+			struct intel_uncore, pmic_bus_access_nb);
 
 	switch (action) {
 	case MBI_PMIC_BUS_ACCESS_BEGIN:
@@ -1479,12 +1479,12 @@ static int i915_pmic_bus_access_notifier(struct notifier_block *nb,
 		 * wake reference -> disable wakeref asserts for the time of
 		 * the access.
 		 */
-		disable_rpm_wakeref_asserts(dev_priv);
-		intel_uncore_forcewake_get(&dev_priv->uncore, FORCEWAKE_ALL);
-		enable_rpm_wakeref_asserts(dev_priv);
+		disable_rpm_wakeref_asserts(uncore->rpm);
+		intel_uncore_forcewake_get(uncore, FORCEWAKE_ALL);
+		enable_rpm_wakeref_asserts(uncore->rpm);
 		break;
 	case MBI_PMIC_BUS_ACCESS_END:
-		intel_uncore_forcewake_put(&dev_priv->uncore, FORCEWAKE_ALL);
+		intel_uncore_forcewake_put(uncore, FORCEWAKE_ALL);
 		break;
 	}
 
Signature · 6 lines
2.20.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#7 lore raw

RFC 4/7 drm/i915: move and rename i915_runtime_pm

In reply to Daniele Ceraolo Spurio

Asserts aside, all the code working on this structure is in intel_runtime_pm.c and uses the intel_ prefix, so move the structure to intel_runtime_pm.h and adopt the same prefix.

Since all the asserts are now working on the runtime_pm structure, bring them across as well.

---
 drivers/gpu/drm/i915/i915_debugfs.c     |   4 +-
 drivers/gpu/drm/i915/i915_drv.c         |   4 +-
 drivers/gpu/drm/i915/i915_drv.h         |  52 +--------
 drivers/gpu/drm/i915/intel_drv.h        |  97 ----------------
 drivers/gpu/drm/i915/intel_runtime_pm.c |  58 +++++-----
 drivers/gpu/drm/i915/intel_runtime_pm.h | 147 ++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_uncore.h     |   4 +-
 7 files changed, 183 insertions(+), 183 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +2 -2
index 072464a18050..227a1cdf4f02 100644
@@ -2636,7 +2636,7 @@ static int i915_energy_uJ(struct seq_file *m, void *data)
 	return 0;
 }
 
-static int i915_runtime_pm_status(struct seq_file *m, void *unused)
+static int intel_runtime_pm_status(struct seq_file *m, void *unused)
 {
 	struct drm_i915_private *dev_priv = node_to_i915(m->private);
 	struct pci_dev *pdev = dev_priv->drm.pdev;
@@ -4600,7 +4600,7 @@ static const struct drm_info_list i915_debugfs_list[] = {
 	{"i915_llc", i915_llc, 0},
 	{"i915_edp_psr_status", i915_edp_psr_status, 0},
 	{"i915_energy_uJ", i915_energy_uJ, 0},
-	{"i915_runtime_pm_status", i915_runtime_pm_status, 0},
+	{"intel_runtime_pm_status", intel_runtime_pm_status, 0},
 	{"i915_power_domain_info", i915_power_domain_info, 0},
 	{"i915_dmc_info", i915_dmc_info, 0},
 	{"i915_display_info", i915_display_info, 0},
drivers/gpu/drm/i915/i915_drv.c +2 -2
index 8b9e5b042e70..7938906f5b1d 100644
@@ -2873,7 +2873,7 @@ static int intel_runtime_suspend(struct device *kdev)
 	struct pci_dev *pdev = to_pci_dev(kdev);
 	struct drm_device *dev = pci_get_drvdata(pdev);
 	struct drm_i915_private *dev_priv = to_i915(dev);
-	struct i915_runtime_pm *rpm = &dev_priv->runtime_pm;
+	struct intel_runtime_pm *rpm = &dev_priv->runtime_pm;
 	int ret;
 
 	if (WARN_ON_ONCE(!(dev_priv->gt_pm.rc6.enabled && HAS_RC6(dev_priv))))
@@ -2972,7 +2972,7 @@ static int intel_runtime_resume(struct device *kdev)
 	struct pci_dev *pdev = to_pci_dev(kdev);
 	struct drm_device *dev = pci_get_drvdata(pdev);
 	struct drm_i915_private *dev_priv = to_i915(dev);
-	struct i915_runtime_pm *rpm = &dev_priv->runtime_pm;
+	struct intel_runtime_pm *rpm = &dev_priv->runtime_pm;
 	int ret = 0;
 
 	if (WARN_ON_ONCE(!HAS_RUNTIME_PM(dev_priv)))
drivers/gpu/drm/i915/i915_drv.h +1 -51

64 lines not on this page · raw message

drivers/gpu/drm/i915/intel_drv.h +0 -97

101 lines not on this page · raw message

drivers/gpu/drm/i915/intel_runtime_pm.c +29 -29

213 lines not on this page · raw message

drivers/gpu/drm/i915/intel_runtime_pm.h +147 -0

159 lines not on this page · raw message

drivers/gpu/drm/i915/intel_uncore.h +2 -2
index d6af3de70121..804a0faacc91 100644
@@ -33,7 +33,7 @@
 #include "i915_reg.h"
 
 struct drm_i915_private;
-struct i915_runtime_pm;
+struct intel_runtime_pm;
 struct intel_uncore;
 
 enum forcewake_domain_id {
@@ -97,7 +97,7 @@ struct intel_forcewake_range {
 struct intel_uncore {
 	void __iomem *regs;
 
-	struct i915_runtime_pm *rpm;
+	struct intel_runtime_pm *rpm;
 
 	spinlock_t lock; /** lock is also taken in irq contexts. */
 
Signature · 6 lines
2.20.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#8 lore raw

Re: [RFC 4/7] drm/i915: move and rename i915_runtime_pm

Quoting Daniele Ceraolo Spurio (2019-05-16 22:56:31)

drivers/gpu/drm/i915/intel_runtime_pm.h line 9

Quoted 9 lines
drivers/gpu/drm/i915/intel_runtime_pm.h +1 -0
index b964ca7af9c8..0e3817f9785e 100644
@@ -6,6 +6,7 @@
 #ifndef __INTEL_RUNTIME_PM_H__
 #define __INTEL_RUNTIME_PM_H__
 
+#include <linux/device.h>

There doesn't seem to be any peeking into struct device, so do we not just need the struct device forward decl here?

drivers/gpu/drm/i915/intel_runtime_pm.h line 11

Quoted 2 lines
drivers/gpu/drm/i915/intel_runtime_pm.h +0 -0
 #include <linux/stackdepot.h>
 #include <linux/types.h>

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#9 lore raw

Re: [RFC 4/7] drm/i915: move and rename i915_runtime_pm

Quoting Chris Wilson (2019-05-16 23:07:43)

Quoted 9 lines

Quoting Daniele Ceraolo Spurio (2019-05-16 22:56:31)

Quoted 8 lines
drivers/gpu/drm/i915/intel_runtime_pm.h +0 -0
index b964ca7af9c8..0e3817f9785e 100644
@@ -6,6 +6,7 @@
 #ifndef __INTEL_RUNTIME_PM_H__
 #define __INTEL_RUNTIME_PM_H__
 
Quoted 4 lines

drivers/gpu/drm/i915/intel_runtime_pm.h line 9

Quoted 1 line
drivers/gpu/drm/i915/intel_runtime_pm.h +1 -0
+#include <linux/device.h>

There doesn't seem to be any peeking into struct device, so do we not just need the struct device forward decl here?

And add it to Makefile.headers_test
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#10 lore raw

Re: [RFC 4/7] drm/i915: move and rename i915_runtime_pm

Quoting Chris Wilson (2019-05-16 23:10:10)

Quoted 10 lines

Quoting Chris Wilson (2019-05-16 23:07:43)

Quoted 9 lines

Quoting Daniele Ceraolo Spurio (2019-05-16 22:56:31)

Quoted 8 lines
drivers/gpu/drm/i915/intel_runtime_pm.h +0 -0
index b964ca7af9c8..0e3817f9785e 100644
@@ -6,6 +6,7 @@
 #ifndef __INTEL_RUNTIME_PM_H__
 #define __INTEL_RUNTIME_PM_H__
 
Quoted 6 lines
Quoted 4 lines

drivers/gpu/drm/i915/intel_runtime_pm.h line 9

Quoted 1 line
drivers/gpu/drm/i915/intel_runtime_pm.h +1 -0
+#include <linux/device.h>

There doesn't seem to be any peeking into struct device, so do we not just need the struct device forward decl here?

And add it to Makefile.headers_test

Hint: we may need to split out intel_display_power.[ch] -Chris
_______________________________________________
Intel-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#11 lore raw

Re: [RFC 4/7] drm/i915: move and rename i915_runtime_pm

Quoted 15 lines · Chris Wilson

Quoting Chris Wilson (2019-05-16 23:10:10)

Quoted 14 lines

Quoting Chris Wilson (2019-05-16 23:07:43)

Quoted 13 lines

Quoting Daniele Ceraolo Spurio (2019-05-16 22:56:31)

drivers/gpu/drm/i915/intel_runtime_pm.h line 9

Quoted 9 lines
drivers/gpu/drm/i915/intel_runtime_pm.h +1 -0
index b964ca7af9c8..0e3817f9785e 100644
@@ -6,6 +6,7 @@
  #ifndef __INTEL_RUNTIME_PM_H__
  #define __INTEL_RUNTIME_PM_H__
 
+#include <linux/device.h>

There doesn't seem to be any peeking into struct device, so do we not just need the struct device forward decl here?

True, will fix.

Quoted 6 lines
Quoted 2 lines

And add it to Makefile.headers_test

Hint: we may need to split out intel_display_power.[ch] -Chris

Should I add intel_display_power.h to Makefile.headers_test as well? It does compile on its own, but it'll have to include intel_display.h, which isn't on the list.

Daniele
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#12 lore raw

Re: [RFC 4/7] drm/i915: move and rename i915_runtime_pm

Quoting Daniele Ceraolo Spurio (2019-05-17 16:27:26)

Quoted 22 lines · Chris Wilson
Quoted 15 lines

Quoting Chris Wilson (2019-05-16 23:10:10)

Quoted 14 lines

Quoting Chris Wilson (2019-05-16 23:07:43)

Quoted 13 lines

Quoting Daniele Ceraolo Spurio (2019-05-16 22:56:31)

drivers/gpu/drm/i915/intel_runtime_pm.h line 9

Quoted 9 lines
drivers/gpu/drm/i915/intel_runtime_pm.h +1 -0
index b964ca7af9c8..0e3817f9785e 100644
@@ -6,6 +6,7 @@
  #ifndef __INTEL_RUNTIME_PM_H__
  #define __INTEL_RUNTIME_PM_H__
 
+#include <linux/device.h>

There doesn't seem to be any peeking into struct device, so do we not just need the struct device forward decl here?

True, will fix.

Quoted 1 line
Quoted 1 line
Quoted 8 lines
Quoted 4 lines
Quoted 1 line

And add it to Makefile.headers_test

Hint: we may need to split out intel_display_power.[ch]

Should I add intel_display_power.h to Makefile.headers_test as well? It does compile on its own, but it'll have to include intel_display.h, which isn't on the list.

Yes. If we have to include intel_display.h, that means whenever we get around to splitting intel_display.h, we will remember to update intel_display_power.h. Rainy day tasks will be to delete #include at random and see which are still required in headers.
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

maintainer
#13 lore raw

Re: [RFC 4/7] drm/i915: move and rename i915_runtime_pm

Quoted 21 lines · Chris Wilson

Quoting Daniele Ceraolo Spurio (2019-05-17 16:27:26)

Quoted 20 lines · Chris Wilson
Quoted 15 lines

Quoting Chris Wilson (2019-05-16 23:10:10)

Quoted 14 lines

Quoting Chris Wilson (2019-05-16 23:07:43)

Quoted 13 lines

Quoting Daniele Ceraolo Spurio (2019-05-16 22:56:31)

drivers/gpu/drm/i915/intel_runtime_pm.h line 9

Quoted 9 lines
drivers/gpu/drm/i915/intel_runtime_pm.h +1 -0
index b964ca7af9c8..0e3817f9785e 100644
@@ -6,6 +6,7 @@
  #ifndef __INTEL_RUNTIME_PM_H__
  #define __INTEL_RUNTIME_PM_H__
 
+#include <linux/device.h>

There doesn't seem to be any peeking into struct device, so do we not just need the struct device forward decl here?

True, will fix.

At some point we had the idea of adding separate _types.h headers for types. The more we add structs in the headers, the more they'll need to include to be self-contained, while the interface users in many cases don't need to look at the internals at all. They just need the forward decls for the pointers.

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines

And add it to Makefile.headers_test

Hint: we may need to split out intel_display_power.[ch]

Quoted 8 lines
Quoted 3 lines

Should I add intel_display_power.h to Makefile.headers_test as well? It does compile on its own, but it'll have to include intel_display.h, which isn't on the list.

Yes. If we have to include intel_display.h, that means whenever we get around to splitting intel_display.h, we will remember to update intel_display_power.h. Rainy day tasks will be to delete #include at random and see which are still required in headers.

Storm day task will be to bang iwyu [1] to work nicely with the kernel build.

BR,
Jani.

[1] https://include-what-you-use.org/

Signature · 5 lines
Jani Nikula, Intel Open Source Graphics Center
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#14 lore raw

RFC 5/7 drm/i915: move a few more functions to accept the rpm structure

In reply to Daniele Ceraolo Spurio

Focusing on the functions called in few places.

---
 drivers/gpu/drm/i915/i915_debugfs.c           |  2 +-
 drivers/gpu/drm/i915/i915_drv.c               | 17 +++++++++--------
 drivers/gpu/drm/i915/intel_runtime_pm.c       | 19 ++++++++-----------
 drivers/gpu/drm/i915/intel_runtime_pm.h       | 12 ++++++------
 .../gpu/drm/i915/selftests/mock_gem_device.c  |  2 +-
 5 files changed, 25 insertions(+), 27 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +1 -1
index 227a1cdf4f02..011537632c4f 100644
@@ -2663,7 +2663,7 @@ static int intel_runtime_pm_status(struct seq_file *m, void *unused)
 	if (IS_ENABLED(CONFIG_DRM_I915_DEBUG_RUNTIME_PM)) {
 		struct drm_printer p = drm_seq_file_printer(m);
 
-		print_intel_runtime_pm_wakeref(dev_priv, &p);
+		print_intel_runtime_pm_wakeref(&dev_priv->runtime_pm, &p);
 	}
 
 	return 0;
drivers/gpu/drm/i915/i915_drv.c +9 -8
index 7938906f5b1d..4ce41083313b 100644
@@ -903,7 +903,7 @@ static int i915_driver_init_early(struct drm_i915_private *dev_priv)
 	mutex_init(&dev_priv->hdcp_comp_mutex);
 
 	i915_memcpy_init_early(dev_priv);
-	intel_runtime_pm_init_early(dev_priv);
+	intel_runtime_pm_init_early(&dev_priv->runtime_pm);
 
 	ret = i915_workqueues_init(dev_priv);
 	if (ret < 0)
@@ -1746,7 +1746,7 @@ static void i915_driver_register(struct drm_i915_private *dev_priv)
 		drm_kms_helper_poll_init(dev);
 
 	intel_power_domains_enable(dev_priv);
-	intel_runtime_pm_enable(dev_priv);
+	intel_runtime_pm_enable(&dev_priv->runtime_pm);
 }
 
 /**
@@ -1755,7 +1755,7 @@ static void i915_driver_register(struct drm_i915_private *dev_priv)
  */
 static void i915_driver_unregister(struct drm_i915_private *dev_priv)
 {
-	intel_runtime_pm_disable(dev_priv);
+	intel_runtime_pm_disable(&dev_priv->runtime_pm);
 	intel_power_domains_disable(dev_priv);
 
 	intel_fbdev_unregister(dev_priv);
@@ -1967,7 +1967,7 @@ void i915_driver_unload(struct drm_device *dev)
 	i915_driver_cleanup_mmio(dev_priv);
 
 	enable_rpm_wakeref_asserts(&dev_priv->runtime_pm);
-	intel_runtime_pm_cleanup(dev_priv);
+	intel_runtime_pm_cleanup(&dev_priv->runtime_pm);
 }
 
 static void i915_driver_release(struct drm_device *dev)
@@ -2121,9 +2121,10 @@ static int i915_drm_suspend_late(struct drm_device *dev, bool hibernation)
 {
 	struct drm_i915_private *dev_priv = to_i915(dev);
 	struct pci_dev *pdev = dev_priv->drm.pdev;
+	struct intel_runtime_pm *rpm = &dev_priv->runtime_pm;
 	int ret;
 
-	disable_rpm_wakeref_asserts(&dev_priv->runtime_pm);
+	disable_rpm_wakeref_asserts(rpm);
 
 	i915_gem_suspend_late(dev_priv);
 
@@ -2164,9 +2165,9 @@ static int i915_drm_suspend_late(struct drm_device *dev, bool hibernation)
 		pci_set_power_state(pdev, PCI_D3hot);
 
 out:
-	enable_rpm_wakeref_asserts(&dev_priv->runtime_pm);
+	enable_rpm_wakeref_asserts(rpm);
 	if (!dev_priv->uncore.user_forcewake.count)
-		intel_runtime_pm_cleanup(dev_priv);
+		intel_runtime_pm_cleanup(rpm);
 
 	return ret;
 }
@@ -2928,7 +2929,7 @@ static int intel_runtime_suspend(struct device *kdev)
 	}
 
 	enable_rpm_wakeref_asserts(rpm);
-	intel_runtime_pm_cleanup(dev_priv);
+	intel_runtime_pm_cleanup(rpm);
 
 	if (intel_uncore_arm_unclaimed_mmio_detection(&dev_priv->uncore))
 		DRM_ERROR("Unclaimed access detected prior to suspending\n");
drivers/gpu/drm/i915/intel_runtime_pm.c +8 -11
index f669688c32c9..3150dbe4d1c3 100644
@@ -299,13 +299,12 @@ untrack_all_intel_runtime_pm_wakerefs(struct intel_runtime_pm *rpm)
 	dump_and_free_wakeref_tracking(&dbg);
 }
 
-void print_intel_runtime_pm_wakeref(struct drm_i915_private *i915,
+void print_intel_runtime_pm_wakeref(struct intel_runtime_pm *rpm,
 				    struct drm_printer *p)
 {
 	struct intel_runtime_pm_debug dbg = {};
 
 	do {
-		struct intel_runtime_pm *rpm = &i915->runtime_pm;
 		unsigned long alloc = dbg.count;
 		depot_stack_handle_t *s;
 
@@ -5145,7 +5144,7 @@ void intel_runtime_pm_put(struct drm_i915_private *i915, intel_wakeref_t wref)
 
 /**
  * intel_runtime_pm_enable - enable runtime pm
- * @i915: i915 device instance
+ * @rpm: the intel_runtime_pm structure
  *
  * This function enables runtime pm at the end of the driver load sequence.
  *
@@ -5153,9 +5152,8 @@ void intel_runtime_pm_put(struct drm_i915_private *i915, intel_wakeref_t wref)
  * subordinate display power domains. That is done by
  * intel_power_domains_enable().
  */
-void intel_runtime_pm_enable(struct drm_i915_private *i915)
+void intel_runtime_pm_enable(struct intel_runtime_pm *rpm)
 {
-	struct intel_runtime_pm *rpm = &i915->runtime_pm;
 	struct device *kdev = rpm->kdev;
 
 	/*
@@ -5195,9 +5193,8 @@ void intel_runtime_pm_enable(struct drm_i915_private *i915)
 	pm_runtime_put_autosuspend(kdev);
 }
 
-void intel_runtime_pm_disable(struct drm_i915_private *i915)
+void intel_runtime_pm_disable(struct intel_runtime_pm *rpm)
 {
-	struct intel_runtime_pm *rpm = &i915->runtime_pm;
 	struct device *kdev = rpm->kdev;
 
 	/* Transfer rpm ownership back to core */
@@ -5210,9 +5207,8 @@ void intel_runtime_pm_disable(struct drm_i915_private *i915)
 		pm_runtime_put(kdev);
 }
 
-void intel_runtime_pm_cleanup(struct drm_i915_private *i915)
+void intel_runtime_pm_cleanup(struct intel_runtime_pm *rpm)
 {
-	struct intel_runtime_pm *rpm = &i915->runtime_pm;
 	int count = atomic_read(&rpm->wakeref_count);
 
 	WARN(count,
@@ -5223,9 +5219,10 @@ void intel_runtime_pm_cleanup(struct drm_i915_private *i915)
 	untrack_all_intel_runtime_pm_wakerefs(rpm);
 }
 
-void intel_runtime_pm_init_early(struct drm_i915_private *i915)
+void intel_runtime_pm_init_early(struct intel_runtime_pm *rpm)
 {
-	struct intel_runtime_pm *rpm = &i915->runtime_pm;
+	struct drm_i915_private *i915 =
+			container_of(rpm, struct drm_i915_private, runtime_pm);
 	struct pci_dev *pdev = i915->drm.pdev;
 	struct device *kdev = &pdev->dev;
 
drivers/gpu/drm/i915/intel_runtime_pm.h +6 -6
index 0e3817f9785e..3cec3b90274a 100644
@@ -172,7 +172,7 @@ void bxt_enable_dc9(struct drm_i915_private *dev_priv);
 void bxt_disable_dc9(struct drm_i915_private *dev_priv);
 void gen9_enable_dc5(struct drm_i915_private *dev_priv);
 
-void intel_runtime_pm_init_early(struct drm_i915_private *dev_priv);
+void intel_runtime_pm_init_early(struct intel_runtime_pm *rpm);
 int intel_power_domains_init(struct drm_i915_private *);
 void intel_power_domains_cleanup(struct drm_i915_private *dev_priv);
 void intel_power_domains_init_hw(struct drm_i915_private *dev_priv, bool resume);
@@ -188,9 +188,9 @@ void hsw_enable_pc8(struct drm_i915_private *dev_priv);
 void hsw_disable_pc8(struct drm_i915_private *dev_priv);
 void bxt_display_core_init(struct drm_i915_private *dev_priv, bool resume);
 void bxt_display_core_uninit(struct drm_i915_private *dev_priv);
-void intel_runtime_pm_enable(struct drm_i915_private *dev_priv);
-void intel_runtime_pm_disable(struct drm_i915_private *dev_priv);
-void intel_runtime_pm_cleanup(struct drm_i915_private *dev_priv);
+void intel_runtime_pm_enable(struct intel_runtime_pm *rpm);
+void intel_runtime_pm_disable(struct intel_runtime_pm *rpm);
+void intel_runtime_pm_cleanup(struct intel_runtime_pm *rpm);
 
 const char *
 intel_display_power_domain_str(enum intel_display_power_domain domain);
@@ -270,10 +270,10 @@ intel_runtime_pm_put(struct drm_i915_private *i915, intel_wakeref_t wref)
 #endif
 
 #if IS_ENABLED(CONFIG_DRM_I915_DEBUG_RUNTIME_PM)
-void print_intel_runtime_pm_wakeref(struct drm_i915_private *i915,
+void print_intel_runtime_pm_wakeref(struct intel_runtime_pm *rpm,
 				    struct drm_printer *p);
 #else
-static inline void print_intel_runtime_pm_wakeref(struct drm_i915_private *i915,
+static inline void print_intel_runtime_pm_wakeref(struct intel_runtime_pm *rpm,
 						  struct drm_printer *p)
 {
 }
drivers/gpu/drm/i915/selftests/mock_gem_device.c +1 -1
index 9fd02025d382..b3ed2b907b83 100644
@@ -151,7 +151,7 @@ struct drm_i915_private *mock_gem_device(void)
 	i915 = (struct drm_i915_private *)(pdev + 1);
 	pci_set_drvdata(pdev, i915);
 
-	intel_runtime_pm_init_early(i915);
+	intel_runtime_pm_init_early(&i915->runtime_pm);
 
 	dev_pm_domain_set(&pdev->dev, &pm_domain);
 	pm_runtime_enable(&pdev->dev);
Signature · 6 lines
2.20.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#15 lore raw

RFC 6/7 drm/i915: update rpm_get/put to use the rpm structure

In reply to Daniele Ceraolo Spurio

The functions are internally already only using the structure, so we need to just flip the interface.

---
 drivers/gpu/drm/i915/gt/intel_engine_cs.c     |  8 +--
 drivers/gpu/drm/i915/gt/intel_hangcheck.c     |  4 +-
 drivers/gpu/drm/i915/gt/intel_reset.c         |  4 +-
 drivers/gpu/drm/i915/gt/selftest_hangcheck.c  | 20 ++++----
 drivers/gpu/drm/i915/gt/selftest_lrc.c        | 36 +++++++-------
 .../gpu/drm/i915/gt/selftest_workarounds.c    | 12 ++---
 drivers/gpu/drm/i915/gvt/aperture_gm.c        | 15 +++---
 drivers/gpu/drm/i915/gvt/gvt.h                |  4 +-
 drivers/gpu/drm/i915/gvt/sched_policy.c       |  4 +-
 drivers/gpu/drm/i915/gvt/scheduler.c          |  4 +-
 drivers/gpu/drm/i915/i915_debugfs.c           | 49 ++++++++++---------
 drivers/gpu/drm/i915/i915_gem.c               | 26 +++++-----
 drivers/gpu/drm/i915/i915_gem_fence_reg.c     |  4 +-
 drivers/gpu/drm/i915/i915_gem_shrinker.c      |  4 +-
 drivers/gpu/drm/i915/i915_perf.c              |  6 +--
 drivers/gpu/drm/i915/i915_pmu.c               |  8 +--
 drivers/gpu/drm/i915/i915_sysfs.c             | 12 ++---
 drivers/gpu/drm/i915/intel_display.c          |  4 +-
 drivers/gpu/drm/i915/intel_fbdev.c            |  6 +--
 drivers/gpu/drm/i915/intel_hotplug.c          |  4 +-
 drivers/gpu/drm/i915/intel_runtime_pm.c       | 48 +++++++++---------
 drivers/gpu/drm/i915/intel_runtime_pm.h       | 22 ++++-----
 drivers/gpu/drm/i915/intel_wakeref.c          |  4 +-
 drivers/gpu/drm/i915/selftests/huge_pages.c   |  4 +-
 drivers/gpu/drm/i915/selftests/i915_active.c  |  8 +--
 drivers/gpu/drm/i915/selftests/i915_gem.c     |  4 +-
 .../drm/i915/selftests/i915_gem_coherency.c   |  4 +-
 .../gpu/drm/i915/selftests/i915_gem_context.c | 12 ++---
 .../gpu/drm/i915/selftests/i915_gem_evict.c   |  4 +-
 drivers/gpu/drm/i915/selftests/i915_gem_gtt.c |  8 +--
 .../gpu/drm/i915/selftests/i915_gem_object.c  |  4 +-
 drivers/gpu/drm/i915/selftests/i915_request.c | 20 ++++----
 .../gpu/drm/i915/selftests/i915_timeline.c    | 16 +++---
 drivers/gpu/drm/i915/selftests/intel_guc.c    |  8 +--
 drivers/gpu/drm/i915/selftests/intel_uncore.c |  4 +-
 35 files changed, 201 insertions(+), 203 deletions(-)
drivers/gpu/drm/i915/gt/intel_engine_cs.c +4 -4
index 4c3753c1b573..26f3b68ab7d6 100644
@@ -1059,7 +1059,7 @@ static bool ring_is_idle(struct intel_engine_cs *engine)
 		return true;
 
 	/* If the whole device is asleep, the engine must be idle */
-	wakeref = intel_runtime_pm_get_if_in_use(dev_priv);
+	wakeref = intel_runtime_pm_get_if_in_use(&dev_priv->runtime_pm);
 	if (!wakeref)
 		return true;
 
@@ -1073,7 +1073,7 @@ static bool ring_is_idle(struct intel_engine_cs *engine)
 	    !(ENGINE_READ(engine, RING_MI_MODE) & MODE_IDLE))
 		idle = false;
 
-	intel_runtime_pm_put(dev_priv, wakeref);
+	intel_runtime_pm_put(&dev_priv->runtime_pm, wakeref);
 
 	return idle;
 }
@@ -1487,10 +1487,10 @@ void intel_engine_dump(struct intel_engine_cs *engine,
 
 	rcu_read_unlock();
 
-	wakeref = intel_runtime_pm_get_if_in_use(engine->i915);
+	wakeref = intel_runtime_pm_get_if_in_use(&engine->i915->runtime_pm);
 	if (wakeref) {
 		intel_engine_print_registers(engine, m);
-		intel_runtime_pm_put(engine->i915, wakeref);
+		intel_runtime_pm_put(&engine->i915->runtime_pm, wakeref);
 	} else {
 		drm_printf(m, "\tDevice is asleep; skipping register dump\n");
 	}
drivers/gpu/drm/i915/gt/intel_hangcheck.c +2 -2
index 3a4d09b80fa0..d5a76b66b91b 100644
@@ -273,7 +273,7 @@ static void i915_hangcheck_elapsed(struct work_struct *work)
 	if (i915_terminally_wedged(dev_priv))
 		return;
 
-	wakeref = intel_runtime_pm_get_if_in_use(dev_priv);
+	wakeref = intel_runtime_pm_get_if_in_use(&dev_priv->runtime_pm);
 	if (!wakeref)
 		return;
 
@@ -324,7 +324,7 @@ static void i915_hangcheck_elapsed(struct work_struct *work)
 	if (hung)
 		hangcheck_declare_hang(dev_priv, hung, stuck);
 
-	intel_runtime_pm_put(dev_priv, wakeref);
+	intel_runtime_pm_put(&dev_priv->runtime_pm, wakeref);
 
 	/* Reset timer in case GPU hangs without another request being added */
 	i915_queue_hangcheck(dev_priv);
drivers/gpu/drm/i915/gt/intel_reset.c +2 -2
index 464369bc55ad..ad943810eded 100644
@@ -1242,7 +1242,7 @@ void i915_handle_error(struct drm_i915_private *i915,
 	 * isn't the case at least when we get here by doing a
 	 * simulated reset via debugfs, so get an RPM reference.
 	 */
-	wakeref = intel_runtime_pm_get(i915);
+	wakeref = intel_runtime_pm_get(&i915->runtime_pm);
 
 	engine_mask &= INTEL_INFO(i915)->engine_mask;
 
@@ -1305,7 +1305,7 @@ void i915_handle_error(struct drm_i915_private *i915,
 	wake_up_all(&error->reset_queue);
 
 out:
-	intel_runtime_pm_put(i915, wakeref);
+	intel_runtime_pm_put(&i915->runtime_pm, wakeref);
 }
 
 int i915_reset_trylock(struct drm_i915_private *i915)
drivers/gpu/drm/i915/gt/selftest_hangcheck.c +10 -10
index dab3d30c9c73..39bcce32175b 100644
@@ -400,14 +400,14 @@ static int igt_wedged_reset(void *arg)
 	/* Check that we can recover a wedged device with a GPU reset */
 
 	igt_global_reset_lock(i915);
-	wakeref = intel_runtime_pm_get(i915);
+	wakeref = intel_runtime_pm_get(&i915->runtime_pm);
 
 	i915_gem_set_wedged(i915);
 
 	GEM_BUG_ON(!i915_reset_failed(i915));
 	i915_reset(i915, ALL_ENGINES, NULL);
 
-	intel_runtime_pm_put(i915, wakeref);
+	intel_runtime_pm_put(&i915->runtime_pm, wakeref);
 	igt_global_reset_unlock(i915);
 
 	return i915_reset_failed(i915) ? -EIO : 0;
@@ -445,7 +445,7 @@ static int igt_reset_nop(void *arg)
 	}
 
 	i915_gem_context_clear_bannable(ctx);
-	wakeref = intel_runtime_pm_get(i915);
+	wakeref = intel_runtime_pm_get(&i915->runtime_pm);
 	reset_count = i915_reset_count(&i915->gpu_error);
 	count = 0;
 	do {
@@ -492,7 +492,7 @@ static int igt_reset_nop(void *arg)
 	err = igt_flush_test(i915, I915_WAIT_LOCKED);
 	mutex_unlock(&i915->drm.struct_mutex);
 
-	intel_runtime_pm_put(i915, wakeref);
+	intel_runtime_pm_put(&i915->runtime_pm, wakeref);
 
 out:
 	mock_file_free(i915, file);
@@ -529,7 +529,7 @@ static int igt_reset_nop_engine(void *arg)
 	}
 
 	i915_gem_context_clear_bannable(ctx);
-	wakeref = intel_runtime_pm_get(i915);
+	wakeref = intel_runtime_pm_get(&i915->runtime_pm);
 	for_each_engine(engine, i915, id) {
 		unsigned int reset_count, reset_engine_count;
 		unsigned int count;
@@ -600,7 +600,7 @@ static int igt_reset_nop_engine(void *arg)
 	err = igt_flush_test(i915, I915_WAIT_LOCKED);
 	mutex_unlock(&i915->drm.struct_mutex);
 
-	intel_runtime_pm_put(i915, wakeref);
+	intel_runtime_pm_put(&i915->runtime_pm, wakeref);
 out:
 	mock_file_free(i915, file);
 	if (i915_reset_failed(i915))
@@ -1786,7 +1786,7 @@ static int igt_atomic_reset(void *arg)
 
 	igt_global_reset_lock(i915);
 	mutex_lock(&i915->drm.struct_mutex);
-	wakeref = intel_runtime_pm_get(i915);
+	wakeref = intel_runtime_pm_get(&i915->runtime_pm);
 
 	/* Flush any requests before we get started and check basics */
 	force_reset(i915);
@@ -1836,7 +1836,7 @@ static int igt_atomic_reset(void *arg)
 	force_reset(i915);
 
 unlock:
-	intel_runtime_pm_put(i915, wakeref);
+	intel_runtime_pm_put(&i915->runtime_pm, wakeref);
 	mutex_unlock(&i915->drm.struct_mutex);
 	igt_global_reset_unlock(i915);
 
@@ -1872,7 +1872,7 @@ int intel_hangcheck_live_selftests(struct drm_i915_private *i915)
 	if (i915_terminally_wedged(i915))
 		return -EIO; /* we're long past hope of a successful reset */
 
-	wakeref = intel_runtime_pm_get(i915);
+	wakeref = intel_runtime_pm_get(&i915->runtime_pm);
 	saved_hangcheck = fetch_and_zero(&i915_modparams.enable_hangcheck);
 	drain_delayed_work(&i915->gpu_error.hangcheck_work); /* flush param */
 
@@ -1883,7 +1883,7 @@ int intel_hangcheck_live_selftests(struct drm_i915_private *i915)
 	mutex_unlock(&i915->drm.struct_mutex);
 
 	i915_modparams.enable_hangcheck = saved_hangcheck;
-	intel_runtime_pm_put(i915, wakeref);
+	intel_runtime_pm_put(&i915->runtime_pm, wakeref);
 
 	return err;
 }
drivers/gpu/drm/i915/gt/selftest_lrc.c +18 -18
index 4b042893dc0e..e536cc6b5622 100644
@@ -29,7 +29,7 @@ static int live_sanitycheck(void *arg)
 		return 0;
 
 	mutex_lock(&i915->drm.struct_mutex);
-	wakeref = intel_runtime_pm_get(i915);
+	wakeref = intel_runtime_pm_get(&i915->runtime_pm);
 
 	if (igt_spinner_init(&spin, i915))
 		goto err_unlock;
@@ -70,7 +70,7 @@ static int live_sanitycheck(void *arg)
 	igt_spinner_fini(&spin);
 err_unlock:
 	igt_flush_test(i915, I915_WAIT_LOCKED);
-	intel_runtime_pm_put(i915, wakeref);
+	intel_runtime_pm_put(&i915->runtime_pm, wakeref);
 	mutex_unlock(&i915->drm.struct_mutex);
 	return err;
 }
@@ -93,7 +93,7 @@ static int live_busywait_preempt(void *arg)
 	 */
 
 	mutex_lock(&i915->drm.struct_mutex);
-	wakeref = intel_runtime_pm_get(i915);
+	wakeref = intel_runtime_pm_get(&i915->runtime_pm);
 
 	ctx_hi = kernel_context(i915);
 	if (!ctx_hi)
@@ -249,7 +249,7 @@ static int live_busywait_preempt(void *arg)
 err_unlock:
 	if (igt_flush_test(i915, I915_WAIT_LOCKED))
 		err = -EIO;
-	intel_runtime_pm_put(i915, wakeref);
+	intel_runtime_pm_put(&i915->runtime_pm, wakeref);
 	mutex_unlock(&i915->drm.struct_mutex);
 	return err;
 }
@@ -271,7 +271,7 @@ static int live_preempt(void *arg)
 		pr_err("Logical preemption supported, but not exposed\n");
 
 	mutex_lock(&i915->drm.struct_mutex);
-	wakeref = intel_runtime_pm_get(i915);
+	wakeref = intel_runtime_pm_get(&i915->runtime_pm);
 
 	if (igt_spinner_init(&spin_hi, i915))
 		goto err_unlock;
@@ -356,7 +356,7 @@ static int live_preempt(void *arg)
 	igt_spinner_fini(&spin_hi);
 err_unlock:
 	igt_flush_test(i915, I915_WAIT_LOCKED);
-	intel_runtime_pm_put(i915, wakeref);
+	intel_runtime_pm_put(&i915->runtime_pm, wakeref);
 	mutex_unlock(&i915->drm.struct_mutex);
 	return err;
 }
@@ -376,7 +376,7 @@ static int live_late_preempt(void *arg)
 		return 0;
 
 	mutex_lock(&i915->drm.struct_mutex);
-	wakeref = intel_runtime_pm_get(i915);
+	wakeref = intel_runtime_pm_get(&i915->runtime_pm);
 
 	if (igt_spinner_init(&spin_hi, i915))
 		goto err_unlock;
@@ -460,7 +460,7 @@ static int live_late_preempt(void *arg)
 	igt_spinner_fini(&spin_hi);
 err_unlock:
 	igt_flush_test(i915, I915_WAIT_LOCKED);
-	intel_runtime_pm_put(i915, wakeref);
+	intel_runtime_pm_put(&i915->runtime_pm, wakeref);
 	mutex_unlock(&i915->drm.struct_mutex);
 	return err;
 
@@ -526,7 +526,7 @@ static int live_suppress_self_preempt(void *arg)
 		return 0; /* presume black blox */
 
 	mutex_lock(&i915->drm.struct_mutex);
-	wakeref = intel_runtime_pm_get(i915);
+	wakeref = intel_runtime_pm_get(&i915->runtime_pm);
 
 	if (preempt_client_init(i915, &a))
 		goto err_unlock;
@@ -600,7 +600,7 @@ static int live_suppress_self_preempt(void *arg)
 err_unlock:
 	if (igt_flush_test(i915, I915_WAIT_LOCKED))
 		err = -EIO;
-	intel_runtime_pm_put(i915, wakeref);
+	intel_runtime_pm_put(&i915->runtime_pm, wakeref);
 	mutex_unlock(&i915->drm.struct_mutex);
 	return err;
 
@@ -677,7 +677,7 @@ static int live_suppress_wait_preempt(void *arg)
 		return 0;
 
 	mutex_lock(&i915->drm.struct_mutex);
-	wakeref = intel_runtime_pm_get(i915);
+	wakeref = intel_runtime_pm_get(&i915->runtime_pm);
 
 	if (preempt_client_init(i915, &client[0])) /* ELSP[0] */
 		goto err_unlock;
@@ -770,7 +770,7 @@ static int live_suppress_wait_preempt(void *arg)
 err_unlock:
 	if (igt_flush_test(i915, I915_WAIT_LOCKED))
 		err = -EIO;
-	intel_runtime_pm_put(i915, wakeref);
+	intel_runtime_pm_put(&i915->runtime_pm, wakeref);
 	mutex_unlock(&i915->drm.struct_mutex);
 	return err;
 
@@ -801,7 +801,7 @@ static int live_chain_preempt(void *arg)
 		return 0;
 
 	mutex_lock(&i915->drm.struct_mutex);
-	wakeref = intel_runtime_pm_get(i915);
+	wakeref = intel_runtime_pm_get(&i915->runtime_pm);
 
 	if (preempt_client_init(i915, &hi))
 		goto err_unlock;
@@ -918,7 +918,7 @@ static int live_chain_preempt(void *arg)
 err_unlock:
 	if (igt_flush_test(i915, I915_WAIT_LOCKED))
 		err = -EIO;
-	intel_runtime_pm_put(i915, wakeref);
+	intel_runtime_pm_put(&i915->runtime_pm, wakeref);
 	mutex_unlock(&i915->drm.struct_mutex);
 	return err;
 
@@ -947,7 +947,7 @@ static int live_preempt_hang(void *arg)
 		return 0;
 
 	mutex_lock(&i915->drm.struct_mutex);
-	wakeref = intel_runtime_pm_get(i915);
+	wakeref = intel_runtime_pm_get(&i915->runtime_pm);
 
 	if (igt_spinner_init(&spin_hi, i915))
 		goto err_unlock;
@@ -1042,7 +1042,7 @@ static int live_preempt_hang(void *arg)
 	igt_spinner_fini(&spin_hi);
 err_unlock:
 	igt_flush_test(i915, I915_WAIT_LOCKED);
-	intel_runtime_pm_put(i915, wakeref);
+	intel_runtime_pm_put(&i915->runtime_pm, wakeref);
 	mutex_unlock(&i915->drm.struct_mutex);
 	return err;
 }
@@ -1246,7 +1246,7 @@ static int live_preempt_smoke(void *arg)
 		return -ENOMEM;
 
 	mutex_lock(&smoke.i915->drm.struct_mutex);
-	wakeref = intel_runtime_pm_get(smoke.i915);
+	wakeref = intel_runtime_pm_get(&smoke.i915->runtime_pm);
 
 	smoke.batch = i915_gem_object_create_internal(smoke.i915, PAGE_SIZE);
 	if (IS_ERR(smoke.batch)) {
@@ -1299,7 +1299,7 @@ static int live_preempt_smoke(void *arg)
 err_batch:
 	i915_gem_object_put(smoke.batch);
 err_unlock:
-	intel_runtime_pm_put(smoke.i915, wakeref);
+	intel_runtime_pm_put(&smoke.i915->runtime_pm, wakeref);
 	mutex_unlock(&smoke.i915->drm.struct_mutex);
 	kfree(smoke.contexts);
 
drivers/gpu/drm/i915/gt/selftest_workarounds.c +6 -6
index 9f7680b9984b..6c1db2e403ba 100644
@@ -630,7 +630,7 @@ static int live_dirty_whitelist(void *arg)
 	if (INTEL_GEN(i915) < 7) /* minimum requirement for LRI, SRM, LRM */
 		return 0;
 
-	wakeref = intel_runtime_pm_get(i915);
+	wakeref = intel_runtime_pm_get(&i915->runtime_pm);
 
 	mutex_unlock(&i915->drm.struct_mutex);
 	file = mock_file(i915);
@@ -660,7 +660,7 @@ static int live_dirty_whitelist(void *arg)
 	mock_file_free(i915, file);
 	mutex_lock(&i915->drm.struct_mutex);
 out_rpm:
-	intel_runtime_pm_put(i915, wakeref);
+	intel_runtime_pm_put(&i915->runtime_pm, wakeref);
 	return err;
 }
 
@@ -1035,7 +1035,7 @@ live_gpu_reset_gt_engine_workarounds(void *arg)
 	pr_info("Verifying after GPU reset...\n");
 
 	igt_global_reset_lock(i915);
-	wakeref = intel_runtime_pm_get(i915);
+	wakeref = intel_runtime_pm_get(&i915->runtime_pm);
 
 	reference_lists_init(i915, &lists);
 
@@ -1049,7 +1049,7 @@ live_gpu_reset_gt_engine_workarounds(void *arg)
 
 out:
 	reference_lists_fini(i915, &lists);
-	intel_runtime_pm_put(i915, wakeref);
+	intel_runtime_pm_put(&i915->runtime_pm, wakeref);
 	igt_global_reset_unlock(i915);
 
 	return ok ? 0 : -ESRCH;
@@ -1076,7 +1076,7 @@ live_engine_reset_gt_engine_workarounds(void *arg)
 		return PTR_ERR(ctx);
 
 	igt_global_reset_lock(i915);
-	wakeref = intel_runtime_pm_get(i915);
+	wakeref = intel_runtime_pm_get(&i915->runtime_pm);
 
 	reference_lists_init(i915, &lists);
 
@@ -1133,7 +1133,7 @@ live_engine_reset_gt_engine_workarounds(void *arg)
 
 err:
 	reference_lists_fini(i915, &lists);
-	intel_runtime_pm_put(i915, wakeref);
+	intel_runtime_pm_put(&i915->runtime_pm, wakeref);
 	igt_global_reset_unlock(i915);
 	kernel_context_close(ctx);
 
drivers/gpu/drm/i915/gvt/aperture_gm.c +8 -7
index 7f4e3456ce11..b2080a99c5c2 100644
@@ -169,7 +169,7 @@ static void free_vgpu_fence(struct intel_vgpu *vgpu)
 	if (WARN_ON(!vgpu_fence_sz(vgpu)))
 		return;
 
-	intel_runtime_pm_get(dev_priv);
+	intel_runtime_pm_get(&dev_priv->runtime_pm);
 
 	mutex_lock(&dev_priv->drm.struct_mutex);
 	_clear_vgpu_fence(vgpu);
@@ -180,17 +180,18 @@ static void free_vgpu_fence(struct intel_vgpu *vgpu)
 	}
 	mutex_unlock(&dev_priv->drm.struct_mutex);
 
-	intel_runtime_pm_put_unchecked(dev_priv);
+	intel_runtime_pm_put_unchecked(&dev_priv->runtime_pm);
 }
 
 static int alloc_vgpu_fence(struct intel_vgpu *vgpu)
 {
 	struct intel_gvt *gvt = vgpu->gvt;
 	struct drm_i915_private *dev_priv = gvt->dev_priv;
+	struct intel_runtime_pm *rpm = &dev_priv->runtime_pm;
 	struct drm_i915_fence_reg *reg;
 	int i;
 
-	intel_runtime_pm_get(dev_priv);
+	intel_runtime_pm_get(rpm);
 
 	/* Request fences from host */
 	mutex_lock(&dev_priv->drm.struct_mutex);
@@ -206,7 +207,7 @@ static int alloc_vgpu_fence(struct intel_vgpu *vgpu)
 	_clear_vgpu_fence(vgpu);
 
 	mutex_unlock(&dev_priv->drm.struct_mutex);
-	intel_runtime_pm_put_unchecked(dev_priv);
+	intel_runtime_pm_put_unchecked(rpm);
 	return 0;
 out_free_fence:
 	gvt_vgpu_err("Failed to alloc fences\n");
@@ -219,7 +220,7 @@ static int alloc_vgpu_fence(struct intel_vgpu *vgpu)
 		vgpu->fence.regs[i] = NULL;
 	}
 	mutex_unlock(&dev_priv->drm.struct_mutex);
-	intel_runtime_pm_put_unchecked(dev_priv);
+	intel_runtime_pm_put_unchecked(rpm);
 	return -ENOSPC;
 }
 
@@ -315,9 +316,9 @@ void intel_vgpu_reset_resource(struct intel_vgpu *vgpu)
 {
 	struct drm_i915_private *dev_priv = vgpu->gvt->dev_priv;
 
-	intel_runtime_pm_get(dev_priv);
+	intel_runtime_pm_get(&dev_priv->runtime_pm);
 	_clear_vgpu_fence(vgpu);
-	intel_runtime_pm_put_unchecked(dev_priv);
+	intel_runtime_pm_put_unchecked(&dev_priv->runtime_pm);
 }
 
 /**
drivers/gpu/drm/i915/gvt/gvt.h +2 -2
index b54f2bdc13a4..5fee2e112c55 100644
@@ -584,12 +584,12 @@ enum {
 
 static inline void mmio_hw_access_pre(struct drm_i915_private *dev_priv)
 {
-	intel_runtime_pm_get(dev_priv);
+	intel_runtime_pm_get(&dev_priv->runtime_pm);
 }
 
 static inline void mmio_hw_access_post(struct drm_i915_private *dev_priv)
 {
-	intel_runtime_pm_put_unchecked(dev_priv);
+	intel_runtime_pm_put_unchecked(&dev_priv->runtime_pm);
 }
 
 /**
drivers/gpu/drm/i915/gvt/sched_policy.c +2 -2
index 1c763a27a412..2369d4a9af94 100644
@@ -465,7 +465,7 @@ void intel_vgpu_stop_schedule(struct intel_vgpu *vgpu)
 		scheduler->current_vgpu = NULL;
 	}
 
-	intel_runtime_pm_get(dev_priv);
+	intel_runtime_pm_get(&dev_priv->runtime_pm);
 	spin_lock_bh(&scheduler->mmio_context_lock);
 	for (ring_id = 0; ring_id < I915_NUM_ENGINES; ring_id++) {
 		if (scheduler->engine_owner[ring_id] == vgpu) {
@@ -474,6 +474,6 @@ void intel_vgpu_stop_schedule(struct intel_vgpu *vgpu)
 		}
 	}
 	spin_unlock_bh(&scheduler->mmio_context_lock);
-	intel_runtime_pm_put_unchecked(dev_priv);
+	intel_runtime_pm_put_unchecked(&dev_priv->runtime_pm);
 	mutex_unlock(&vgpu->gvt->sched_lock);
 }
drivers/gpu/drm/i915/gvt/scheduler.c +2 -2
index d97d9355bf15..78812d0ce31d 100644
@@ -1481,11 +1481,11 @@ intel_vgpu_create_workload(struct intel_vgpu *vgpu, int ring_id,
 	 * as there is only one pre-allocated buf-obj for shadow.
 	 */
 	if (list_empty(workload_q_head(vgpu, ring_id))) {
-		intel_runtime_pm_get(dev_priv);
+		intel_runtime_pm_get(&dev_priv->runtime_pm);
 		mutex_lock(&dev_priv->drm.struct_mutex);
 		ret = intel_gvt_scan_and_shadow_workload(workload);
 		mutex_unlock(&dev_priv->drm.struct_mutex);
-		intel_runtime_pm_put_unchecked(dev_priv);
+		intel_runtime_pm_put_unchecked(&dev_priv->runtime_pm);
 	}
 
 	if (ret) {
drivers/gpu/drm/i915/i915_debugfs.c +25 -24

190 lines not on this page · raw message

drivers/gpu/drm/i915/i915_gem.c +13 -13
index 5bccf7955285..631fef6e4b7a 100644
@@ -896,7 +896,7 @@ i915_gem_gtt_pread(struct drm_i915_gem_object *obj,
 	if (ret)
 		return ret;
 
-	wakeref = intel_runtime_pm_get(i915);
+	wakeref = intel_runtime_pm_get(&i915->runtime_pm);
 	vma = i915_gem_object_ggtt_pin(obj, NULL, 0, 0,
 				       PIN_MAPPABLE |
 				       PIN_NONFAULT |
@@ -969,7 +969,7 @@ i915_gem_gtt_pread(struct drm_i915_gem_object *obj,
 		i915_vma_unpin(vma);
 	}
 out_unlock:
-	intel_runtime_pm_put(i915, wakeref);
+	intel_runtime_pm_put(&i915->runtime_pm, wakeref);
 	mutex_unlock(&i915->drm.struct_mutex);
 
 	return ret;
@@ -1088,14 +1088,14 @@ i915_gem_gtt_pwrite_fast(struct drm_i915_gem_object *obj,
 		 * This easily dwarfs any performance advantage from
 		 * using the cache bypass of indirect GGTT access.
 		 */
-		wakeref = intel_runtime_pm_get_if_in_use(i915);
+		wakeref = intel_runtime_pm_get_if_in_use(&i915->runtime_pm);
 		if (!wakeref) {
 			ret = -EFAULT;
 			goto out_unlock;
 		}
 	} else {
 		/* No backing pages, no fallback, we must force GGTT access */
-		wakeref = intel_runtime_pm_get(i915);
+		wakeref = intel_runtime_pm_get(&i915->runtime_pm);
 	}
 
 	vma = i915_gem_object_ggtt_pin(obj, NULL, 0, 0,
@@ -1177,7 +1177,7 @@ i915_gem_gtt_pwrite_fast(struct drm_i915_gem_object *obj,
 		i915_vma_unpin(vma);
 	}
 out_rpm:
-	intel_runtime_pm_put(i915, wakeref);
+	intel_runtime_pm_put(&i915->runtime_pm, wakeref);
 out_unlock:
 	mutex_unlock(&i915->drm.struct_mutex);
 	return ret;
@@ -1742,7 +1742,7 @@ vm_fault_t i915_gem_fault(struct vm_fault *vmf)
 	if (ret)
 		goto err;
 
-	wakeref = intel_runtime_pm_get(dev_priv);
+	wakeref = intel_runtime_pm_get(&dev_priv->runtime_pm);
 
 	srcu = i915_reset_trylock(dev_priv);
 	if (srcu < 0) {
@@ -1823,7 +1823,7 @@ vm_fault_t i915_gem_fault(struct vm_fault *vmf)
 err_reset:
 	i915_reset_unlock(dev_priv, srcu);
 err_rpm:
-	intel_runtime_pm_put(dev_priv, wakeref);
+	intel_runtime_pm_put(&dev_priv->runtime_pm, wakeref);
 	i915_gem_object_unpin_pages(obj);
 err:
 	switch (ret) {
@@ -1907,7 +1907,7 @@ i915_gem_release_mmap(struct drm_i915_gem_object *obj)
 	 * wakeref.
 	 */
 	lockdep_assert_held(&i915->drm.struct_mutex);
-	wakeref = intel_runtime_pm_get(i915);
+	wakeref = intel_runtime_pm_get(&i915->runtime_pm);
 
 	if (!obj->userfault_count)
 		goto out;
@@ -1924,7 +1924,7 @@ i915_gem_release_mmap(struct drm_i915_gem_object *obj)
 	wmb();
 
 out:
-	intel_runtime_pm_put(i915, wakeref);
+	intel_runtime_pm_put(&i915->runtime_pm, wakeref);
 }
 
 void i915_gem_runtime_suspend(struct drm_i915_private *dev_priv)
@@ -3961,7 +3961,7 @@ static void __i915_gem_free_objects(struct drm_i915_private *i915,
 	struct drm_i915_gem_object *obj, *on;
 	intel_wakeref_t wakeref;
 
-	wakeref = intel_runtime_pm_get(i915);
+	wakeref = intel_runtime_pm_get(&i915->runtime_pm);
 	llist_for_each_entry_safe(obj, on, freed, freed) {
 		struct i915_vma *vma, *vn;
 
@@ -4021,7 +4021,7 @@ static void __i915_gem_free_objects(struct drm_i915_private *i915,
 		if (on)
 			cond_resched();
 	}
-	intel_runtime_pm_put(i915, wakeref);
+	intel_runtime_pm_put(&i915->runtime_pm, wakeref);
 }
 
 static void i915_gem_flush_free_objects(struct drm_i915_private *i915)
@@ -4134,7 +4134,7 @@ void i915_gem_sanitize(struct drm_i915_private *i915)
 
 	GEM_TRACE("\n");
 
-	wakeref = intel_runtime_pm_get(i915);
+	wakeref = intel_runtime_pm_get(&i915->runtime_pm);
 	intel_uncore_forcewake_get(&i915->uncore, FORCEWAKE_ALL);
 
 	/*
@@ -4157,7 +4157,7 @@ void i915_gem_sanitize(struct drm_i915_private *i915)
 	intel_gt_sanitize(i915, false);
 
 	intel_uncore_forcewake_put(&i915->uncore, FORCEWAKE_ALL);
-	intel_runtime_pm_put(i915, wakeref);
+	intel_runtime_pm_put(&i915->runtime_pm, wakeref);
 
 	mutex_lock(&i915->drm.struct_mutex);
 	i915_gem_contexts_lost(i915);
drivers/gpu/drm/i915/i915_gem_fence_reg.c +2 -2
index 50f52264b163..fa5f92ebae4f 100644
@@ -264,7 +264,7 @@ static int fence_update(struct drm_i915_fence_reg *fence,
 	 * be cleared before we can use any other fences to ensure that
 	 * the new fences do not overlap the elided clears, confusing HW.
 	 */
-	wakeref = intel_runtime_pm_get_if_in_use(fence->i915);
+	wakeref = intel_runtime_pm_get_if_in_use(&fence->i915->runtime_pm);
 	if (!wakeref) {
 		GEM_BUG_ON(vma);
 		return 0;
@@ -278,7 +278,7 @@ static int fence_update(struct drm_i915_fence_reg *fence,
 		list_move_tail(&fence->link, &fence->i915->mm.fence_list);
 	}
 
-	intel_runtime_pm_put(fence->i915, wakeref);
+	intel_runtime_pm_put(&fence->i915->runtime_pm, wakeref);
 	return 0;
 }
 
drivers/gpu/drm/i915/i915_gem_shrinker.c +2 -2
index 588e3898b120..05b75a42dd1c 100644
@@ -245,7 +245,7 @@ i915_gem_shrink(struct drm_i915_private *i915,
 	 * we will force the wake during oom-notifier.
 	 */
 	if (flags & I915_SHRINK_BOUND) {
-		wakeref = intel_runtime_pm_get_if_in_use(i915);
+		wakeref = intel_runtime_pm_get_if_in_use(&i915->runtime_pm);
 		if (!wakeref)
 			flags &= ~I915_SHRINK_BOUND;
 	}
@@ -329,7 +329,7 @@ i915_gem_shrink(struct drm_i915_private *i915,
 	}
 
 	if (flags & I915_SHRINK_BOUND)
-		intel_runtime_pm_put(i915, wakeref);
+		intel_runtime_pm_put(&i915->runtime_pm, wakeref);
 
 	i915_retire_requests(i915);
 
drivers/gpu/drm/i915/i915_perf.c +3 -3
index c4995d5a16d2..7d1a23c6af2e 100644
@@ -1373,7 +1373,7 @@ static void i915_oa_stream_destroy(struct i915_perf_stream *stream)
 	free_oa_buffer(dev_priv);
 
 	intel_uncore_forcewake_put(&dev_priv->uncore, FORCEWAKE_ALL);
-	intel_runtime_pm_put(dev_priv, stream->wakeref);
+	intel_runtime_pm_put(&dev_priv->runtime_pm, stream->wakeref);
 
 	if (stream->ctx)
 		oa_put_render_ctx_id(stream);
@@ -2110,7 +2110,7 @@ static int i915_oa_stream_init(struct i915_perf_stream *stream,
 	 *   In our case we are expecting that taking pm + FORCEWAKE
 	 *   references will effectively disable RC6.
 	 */
-	stream->wakeref = intel_runtime_pm_get(dev_priv);
+	stream->wakeref = intel_runtime_pm_get(&dev_priv->runtime_pm);
 	intel_uncore_forcewake_get(&dev_priv->uncore, FORCEWAKE_ALL);
 
 	ret = alloc_oa_buffer(dev_priv);
@@ -2146,7 +2146,7 @@ static int i915_oa_stream_init(struct i915_perf_stream *stream,
 	put_oa_config(dev_priv, stream->oa_config);
 
 	intel_uncore_forcewake_put(&dev_priv->uncore, FORCEWAKE_ALL);
-	intel_runtime_pm_put(dev_priv, stream->wakeref);
+	intel_runtime_pm_put(&dev_priv->runtime_pm, stream->wakeref);
 
 err_config:
 	if (stream->ctx)
drivers/gpu/drm/i915/i915_pmu.c +4 -4
index 1ccda0ee4ff5..4c6ed652e840 100644
@@ -171,7 +171,7 @@ engines_sample(struct drm_i915_private *dev_priv, unsigned int period_ns)
 
 	wakeref = 0;
 	if (READ_ONCE(dev_priv->gt.awake))
-		wakeref = intel_runtime_pm_get_if_in_use(dev_priv);
+		wakeref = intel_runtime_pm_get_if_in_use(&dev_priv->runtime_pm);
 	if (!wakeref)
 		return;
 
@@ -207,7 +207,7 @@ engines_sample(struct drm_i915_private *dev_priv, unsigned int period_ns)
 	}
 	spin_unlock_irqrestore(&dev_priv->uncore.lock, flags);
 
-	intel_runtime_pm_put(dev_priv, wakeref);
+	intel_runtime_pm_put(&dev_priv->runtime_pm, wakeref);
 }
 
 static void
@@ -445,10 +445,10 @@ static u64 get_rc6(struct drm_i915_private *i915)
 	unsigned long flags;
 	u64 val;
 
-	wakeref = intel_runtime_pm_get_if_in_use(i915);
+	wakeref = intel_runtime_pm_get_if_in_use(&i915->runtime_pm);
 	if (wakeref) {
 		val = __get_rc6(i915);
-		intel_runtime_pm_put(i915, wakeref);
+		intel_runtime_pm_put(&i915->runtime_pm, wakeref);
 
 		/*
 		 * If we are coming back from being runtime suspended we must
drivers/gpu/drm/i915/i915_sysfs.c +6 -6
index 3ef07b987d40..75acbf686ec9 100644
@@ -264,7 +264,7 @@ static ssize_t gt_act_freq_mhz_show(struct device *kdev,
 	intel_wakeref_t wakeref;
 	u32 freq;
 
-	wakeref = intel_runtime_pm_get(dev_priv);
+	wakeref = intel_runtime_pm_get(&dev_priv->runtime_pm);
 
 	if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) {
 		vlv_punit_get(dev_priv);
@@ -276,7 +276,7 @@ static ssize_t gt_act_freq_mhz_show(struct device *kdev,
 		freq = intel_get_cagf(dev_priv, I915_READ(GEN6_RPSTAT1));
 	}
 
-	intel_runtime_pm_put(dev_priv, wakeref);
+	intel_runtime_pm_put(&dev_priv->runtime_pm, wakeref);
 
 	return snprintf(buf, PAGE_SIZE, "%d\n", intel_gpu_freq(dev_priv, freq));
 }
@@ -364,7 +364,7 @@ static ssize_t gt_max_freq_mhz_store(struct device *kdev,
 	if (ret)
 		return ret;
 
-	wakeref = intel_runtime_pm_get(dev_priv);
+	wakeref = intel_runtime_pm_get(&dev_priv->runtime_pm);
 	mutex_lock(&rps->lock);
 
 	val = intel_freq_opcode(dev_priv, val);
@@ -392,7 +392,7 @@ static ssize_t gt_max_freq_mhz_store(struct device *kdev,
 
 unlock:
 	mutex_unlock(&rps->lock);
-	intel_runtime_pm_put(dev_priv, wakeref);
+	intel_runtime_pm_put(&dev_priv->runtime_pm, wakeref);
 
 	return ret ?: count;
 }
@@ -420,7 +420,7 @@ static ssize_t gt_min_freq_mhz_store(struct device *kdev,
 	if (ret)
 		return ret;
 
-	wakeref = intel_runtime_pm_get(dev_priv);
+	wakeref = intel_runtime_pm_get(&dev_priv->runtime_pm);
 	mutex_lock(&rps->lock);
 
 	val = intel_freq_opcode(dev_priv, val);
@@ -444,7 +444,7 @@ static ssize_t gt_min_freq_mhz_store(struct device *kdev,
 
 unlock:
 	mutex_unlock(&rps->lock);
-	intel_runtime_pm_put(dev_priv, wakeref);
+	intel_runtime_pm_put(&dev_priv->runtime_pm, wakeref);
 
 	return ret ?: count;
 }
drivers/gpu/drm/i915/intel_display.c +2 -2
index 90cd1f51eda6..8829fee6af8f 100644
@@ -2102,7 +2102,7 @@ intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb,
 	 * intel_runtime_pm_put(), so it is correct to wrap only the
 	 * pin/unpin/fence and not more.
 	 */
-	wakeref = intel_runtime_pm_get(dev_priv);
+	wakeref = intel_runtime_pm_get(&dev_priv->runtime_pm);
 
 	atomic_inc(&dev_priv->gpu_error.pending_fb_pin);
 
@@ -2157,7 +2157,7 @@ intel_pin_and_fence_fb_obj(struct drm_framebuffer *fb,
 err:
 	atomic_dec(&dev_priv->gpu_error.pending_fb_pin);
 
-	intel_runtime_pm_put(dev_priv, wakeref);
+	intel_runtime_pm_put(&dev_priv->runtime_pm, wakeref);
 	return vma;
 }
 
drivers/gpu/drm/i915/intel_fbdev.c +3 -3
index 89db71996148..52d01b3f94f1 100644
@@ -213,7 +213,7 @@ static int intelfb_create(struct drm_fb_helper *helper,
 	}
 
 	mutex_lock(&dev->struct_mutex);
-	wakeref = intel_runtime_pm_get(dev_priv);
+	wakeref = intel_runtime_pm_get(&dev_priv->runtime_pm);
 
 	/* Pin the GGTT vma for our access via info->screen_base.
 	 * This also validates that any existing fb inherited from the
@@ -272,7 +272,7 @@ static int intelfb_create(struct drm_fb_helper *helper,
 	ifbdev->vma = vma;
 	ifbdev->vma_flags = flags;
 
-	intel_runtime_pm_put(dev_priv, wakeref);
+	intel_runtime_pm_put(&dev_priv->runtime_pm, wakeref);
 	mutex_unlock(&dev->struct_mutex);
 	vga_switcheroo_client_fb_set(pdev, info);
 	return 0;
@@ -280,7 +280,7 @@ static int intelfb_create(struct drm_fb_helper *helper,
 out_unpin:
 	intel_unpin_fb_vma(vma, flags);
 out_unlock:
-	intel_runtime_pm_put(dev_priv, wakeref);
+	intel_runtime_pm_put(&dev_priv->runtime_pm, wakeref);
 	mutex_unlock(&dev->struct_mutex);
 	return ret;
 }
drivers/gpu/drm/i915/intel_hotplug.c +2 -2
index ff9eb3c855d3..ea3de4acc850 100644
@@ -230,7 +230,7 @@ static void intel_hpd_irq_storm_reenable_work(struct work_struct *work)
 	intel_wakeref_t wakeref;
 	enum hpd_pin pin;
 
-	wakeref = intel_runtime_pm_get(dev_priv);
+	wakeref = intel_runtime_pm_get(&dev_priv->runtime_pm);
 
 	spin_lock_irq(&dev_priv->irq_lock);
 	for_each_hpd_pin(pin) {
@@ -263,7 +263,7 @@ static void intel_hpd_irq_storm_reenable_work(struct work_struct *work)
 		dev_priv->display.hpd_irq_setup(dev_priv);
 	spin_unlock_irq(&dev_priv->irq_lock);
 
-	intel_runtime_pm_put(dev_priv, wakeref);
+	intel_runtime_pm_put(&dev_priv->runtime_pm, wakeref);
 }
 
 bool intel_encoder_hotplug(struct intel_encoder *encoder,
drivers/gpu/drm/i915/intel_runtime_pm.c +22 -26

164 lines not on this page · raw message

drivers/gpu/drm/i915/intel_runtime_pm.h +11 -11
index 3cec3b90274a..c389e5f8f2c1 100644
@@ -246,26 +246,26 @@ intel_display_power_put_async(struct drm_i915_private *i915,
 void icl_dbuf_slices_update(struct drm_i915_private *dev_priv,
 			    u8 req_slices);
 
-intel_wakeref_t intel_runtime_pm_get(struct drm_i915_private *i915);
-intel_wakeref_t intel_runtime_pm_get_if_in_use(struct drm_i915_private *i915);
-intel_wakeref_t intel_runtime_pm_get_noresume(struct drm_i915_private *i915);
+intel_wakeref_t intel_runtime_pm_get(struct intel_runtime_pm *rpm);
+intel_wakeref_t intel_runtime_pm_get_if_in_use(struct intel_runtime_pm *rpm);
+intel_wakeref_t intel_runtime_pm_get_noresume(struct intel_runtime_pm *rpm);
 
 #define with_intel_runtime_pm(i915, wf) \
-	for ((wf) = intel_runtime_pm_get(i915); (wf); \
-	     intel_runtime_pm_put((i915), (wf)), (wf) = 0)
+	for ((wf) = intel_runtime_pm_get(&(i915)->runtime_pm); (wf); \
+	     intel_runtime_pm_put(&(i915)->runtime_pm, (wf)), (wf) = 0)
 
 #define with_intel_runtime_pm_if_in_use(i915, wf) \
-	for ((wf) = intel_runtime_pm_get_if_in_use(i915); (wf); \
-	     intel_runtime_pm_put((i915), (wf)), (wf) = 0)
+	for ((wf) = intel_runtime_pm_get_if_in_use(&(i915)->runtime_pm); (wf); \
+	     intel_runtime_pm_put(&(i915)->runtime_pm, (wf)), (wf) = 0)
 
-void intel_runtime_pm_put_unchecked(struct drm_i915_private *i915);
+void intel_runtime_pm_put_unchecked(struct intel_runtime_pm *rpm);
 #if IS_ENABLED(CONFIG_DRM_I915_DEBUG_RUNTIME_PM)
-void intel_runtime_pm_put(struct drm_i915_private *i915, intel_wakeref_t wref);
+void intel_runtime_pm_put(struct intel_runtime_pm *rpm, intel_wakeref_t wref);
 #else
 static inline void
-intel_runtime_pm_put(struct drm_i915_private *i915, intel_wakeref_t wref)
+intel_runtime_pm_put(struct intel_runtime_pm *rpm, intel_wakeref_t wref)
 {
-	intel_runtime_pm_put_unchecked(i915);
+	intel_runtime_pm_put_unchecked(rpm);
 }
 #endif
 
drivers/gpu/drm/i915/intel_wakeref.c +2 -2
index 91196d9612bb..ebc84fccd80f 100644
@@ -9,14 +9,14 @@
 
 static void rpm_get(struct drm_i915_private *i915, struct intel_wakeref *wf)
 {
-	wf->wakeref = intel_runtime_pm_get(i915);
+	wf->wakeref = intel_runtime_pm_get(&i915->runtime_pm);
 }
 
 static void rpm_put(struct drm_i915_private *i915, struct intel_wakeref *wf)
 {
 	intel_wakeref_t wakeref = fetch_and_zero(&wf->wakeref);
 
-	intel_runtime_pm_put(i915, wakeref);
+	intel_runtime_pm_put(&i915->runtime_pm, wakeref);
 	GEM_BUG_ON(!wakeref);
 }
 
drivers/gpu/drm/i915/selftests/huge_pages.c +2 -2
index 1e1f83326a96..afb90b79d326 100644
@@ -1770,7 +1770,7 @@ int i915_gem_huge_page_live_selftests(struct drm_i915_private *dev_priv)
 		return PTR_ERR(file);
 
 	mutex_lock(&dev_priv->drm.struct_mutex);
-	wakeref = intel_runtime_pm_get(dev_priv);
+	wakeref = intel_runtime_pm_get(&dev_priv->runtime_pm);
 
 	ctx = live_context(dev_priv, file);
 	if (IS_ERR(ctx)) {
@@ -1784,7 +1784,7 @@ int i915_gem_huge_page_live_selftests(struct drm_i915_private *dev_priv)
 	err = i915_subtests(tests, ctx);
 
 out_unlock:
-	intel_runtime_pm_put(dev_priv, wakeref);
+	intel_runtime_pm_put(&dev_priv->runtime_pm, wakeref);
 	mutex_unlock(&dev_priv->drm.struct_mutex);
 
 	mock_file_free(dev_priv, file);
drivers/gpu/drm/i915/selftests/i915_active.c +4 -4
index eee838dc0634..f6331f1aa097 100644
@@ -95,7 +95,7 @@ static int live_active_wait(void *arg)
 	/* Check that we get a callback when requests retire upon waiting */
 
 	mutex_lock(&i915->drm.struct_mutex);
-	wakeref = intel_runtime_pm_get(i915);
+	wakeref = intel_runtime_pm_get(&i915->runtime_pm);
 
 	err = __live_active_setup(i915, &active);
 
@@ -109,7 +109,7 @@ static int live_active_wait(void *arg)
 	if (igt_flush_test(i915, I915_WAIT_LOCKED))
 		err = -EIO;
 
-	intel_runtime_pm_put(i915, wakeref);
+	intel_runtime_pm_put(&i915->runtime_pm, wakeref);
 	mutex_unlock(&i915->drm.struct_mutex);
 	return err;
 }
@@ -124,7 +124,7 @@ static int live_active_retire(void *arg)
 	/* Check that we get a callback when requests are indirectly retired */
 
 	mutex_lock(&i915->drm.struct_mutex);
-	wakeref = intel_runtime_pm_get(i915);
+	wakeref = intel_runtime_pm_get(&i915->runtime_pm);
 
 	err = __live_active_setup(i915, &active);
 
@@ -138,7 +138,7 @@ static int live_active_retire(void *arg)
 	}
 
 	i915_active_fini(&active.base);
-	intel_runtime_pm_put(i915, wakeref);
+	intel_runtime_pm_put(&i915->runtime_pm, wakeref);
 	mutex_unlock(&i915->drm.struct_mutex);
 	return err;
 }
drivers/gpu/drm/i915/selftests/i915_gem.c +2 -2
index c6a9bff85311..c6985da29742 100644
@@ -61,7 +61,7 @@ static void simulate_hibernate(struct drm_i915_private *i915)
 {
 	intel_wakeref_t wakeref;
 
-	wakeref = intel_runtime_pm_get(i915);
+	wakeref = intel_runtime_pm_get(&i915->runtime_pm);
 
 	/*
 	 * As a final sting in the tail, invalidate stolen. Under a real S4,
@@ -72,7 +72,7 @@ static void simulate_hibernate(struct drm_i915_private *i915)
 	 */
 	trash_stolen(i915);
 
-	intel_runtime_pm_put(i915, wakeref);
+	intel_runtime_pm_put(&i915->runtime_pm, wakeref);
 }
 
 static int pm_prepare(struct drm_i915_private *i915)
drivers/gpu/drm/i915/selftests/i915_gem_coherency.c +2 -2
index 046a38743152..5ca4eb31d732 100644
@@ -299,7 +299,7 @@ static int igt_gem_coherency(void *arg)
 	values = offsets + ncachelines;
 
 	mutex_lock(&i915->drm.struct_mutex);
-	wakeref = intel_runtime_pm_get(i915);
+	wakeref = intel_runtime_pm_get(&i915->runtime_pm);
 	for (over = igt_coherency_mode; over->name; over++) {
 		if (!over->set)
 			continue;
@@ -377,7 +377,7 @@ static int igt_gem_coherency(void *arg)
 		}
 	}
 unlock:
-	intel_runtime_pm_put(i915, wakeref);
+	intel_runtime_pm_put(&i915->runtime_pm, wakeref);
 	mutex_unlock(&i915->drm.struct_mutex);
 	kfree(offsets);
 	return err;
drivers/gpu/drm/i915/selftests/i915_gem_context.c +6 -6
index 34ac5cc6d59f..1a67e0c742bc 100644
@@ -69,7 +69,7 @@ static int live_nop_switch(void *arg)
 		return PTR_ERR(file);
 
 	mutex_lock(&i915->drm.struct_mutex);
-	wakeref = intel_runtime_pm_get(i915);
+	wakeref = intel_runtime_pm_get(&i915->runtime_pm);
 
 	ctx = kcalloc(nctx, sizeof(*ctx), GFP_KERNEL);
 	if (!ctx) {
@@ -172,7 +172,7 @@ static int live_nop_switch(void *arg)
 	}
 
 out_unlock:
-	intel_runtime_pm_put(i915, wakeref);
+	intel_runtime_pm_put(&i915->runtime_pm, wakeref);
 	mutex_unlock(&i915->drm.struct_mutex);
 	mock_file_free(i915, file);
 	return err;
@@ -1093,7 +1093,7 @@ __igt_ctx_sseu(struct drm_i915_private *i915,
 		goto out_unlock;
 	}
 
-	wakeref = intel_runtime_pm_get(i915);
+	wakeref = intel_runtime_pm_get(&i915->runtime_pm);
 
 	ce = i915_gem_context_get_engine(ctx, RCS0);
 	if (IS_ERR(ce)) {
@@ -1133,7 +1133,7 @@ __igt_ctx_sseu(struct drm_i915_private *i915,
 out_context:
 	intel_context_put(ce);
 out_rpm:
-	intel_runtime_pm_put(i915, wakeref);
+	intel_runtime_pm_put(&i915->runtime_pm, wakeref);
 	i915_gem_object_put(obj);
 
 out_unlock:
@@ -1544,7 +1544,7 @@ static int igt_vm_isolation(void *arg)
 	GEM_BUG_ON(ctx_b->ppgtt->vm.total != vm_total);
 	vm_total -= I915_GTT_PAGE_SIZE;
 
-	wakeref = intel_runtime_pm_get(i915);
+	wakeref = intel_runtime_pm_get(&i915->runtime_pm);
 
 	count = 0;
 	for_each_engine(engine, i915, id) {
@@ -1589,7 +1589,7 @@ static int igt_vm_isolation(void *arg)
 		count, RUNTIME_INFO(i915)->num_engines);
 
 out_rpm:
-	intel_runtime_pm_put(i915, wakeref);
+	intel_runtime_pm_put(&i915->runtime_pm, wakeref);
 out_unlock:
 	if (igt_live_test_end(&t))
 		err = -EIO;
drivers/gpu/drm/i915/selftests/i915_gem_evict.c +2 -2
index 4fc6e5445dd1..f7fb2da689ba 100644
@@ -398,7 +398,7 @@ static int igt_evict_contexts(void *arg)
 		return 0;
 
 	mutex_lock(&i915->drm.struct_mutex);
-	wakeref = intel_runtime_pm_get(i915);
+	wakeref = intel_runtime_pm_get(&i915->runtime_pm);
 
 	/* Reserve a block so that we know we have enough to fit a few rq */
 	memset(&hole, 0, sizeof(hole));
@@ -509,7 +509,7 @@ static int igt_evict_contexts(void *arg)
 	}
 	if (drm_mm_node_allocated(&hole))
 		drm_mm_remove_node(&hole);
-	intel_runtime_pm_put(i915, wakeref);
+	intel_runtime_pm_put(&i915->runtime_pm, wakeref);
 	mutex_unlock(&i915->drm.struct_mutex);
 
 	return err;
drivers/gpu/drm/i915/selftests/i915_gem_gtt.c +4 -4
index 9cca66e4420a..0151e35d98e0 100644
@@ -294,9 +294,9 @@ static int lowlevel_hole(struct drm_i915_private *i915,
 			mock_vma.node.size = BIT_ULL(size);
 			mock_vma.node.start = addr;
 
-			wakeref = intel_runtime_pm_get(i915);
+			wakeref = intel_runtime_pm_get(&i915->runtime_pm);
 			vm->insert_entries(vm, &mock_vma, I915_CACHE_NONE, 0);
-			intel_runtime_pm_put(i915, wakeref);
+			intel_runtime_pm_put(&i915->runtime_pm, wakeref);
 		}
 		count = n;
 
@@ -1170,7 +1170,7 @@ static int igt_ggtt_page(void *arg)
 	if (err)
 		goto out_unpin;
 
-	wakeref = intel_runtime_pm_get(i915);
+	wakeref = intel_runtime_pm_get(&i915->runtime_pm);
 
 	for (n = 0; n < count; n++) {
 		u64 offset = tmp.start + n * PAGE_SIZE;
@@ -1217,7 +1217,7 @@ static int igt_ggtt_page(void *arg)
 	kfree(order);
 out_remove:
 	ggtt->vm.clear_range(&ggtt->vm, tmp.start, tmp.size);
-	intel_runtime_pm_put(i915, wakeref);
+	intel_runtime_pm_put(&i915->runtime_pm, wakeref);
 	drm_mm_remove_node(&tmp);
 out_unpin:
 	i915_gem_object_unpin_pages(obj);
drivers/gpu/drm/i915/selftests/i915_gem_object.c +2 -2
index b926d1cd165d..ed9d6c43113b 100644
@@ -335,7 +335,7 @@ static int igt_partial_tiling(void *arg)
 	}
 
 	mutex_lock(&i915->drm.struct_mutex);
-	wakeref = intel_runtime_pm_get(i915);
+	wakeref = intel_runtime_pm_get(&i915->runtime_pm);
 
 	if (1) {
 		IGT_TIMEOUT(end);
@@ -446,7 +446,7 @@ next_tiling: ;
 	}
 
 out_unlock:
-	intel_runtime_pm_put(i915, wakeref);
+	intel_runtime_pm_put(&i915->runtime_pm, wakeref);
 	mutex_unlock(&i915->drm.struct_mutex);
 	i915_gem_object_unpin_pages(obj);
 out:
drivers/gpu/drm/i915/selftests/i915_request.c +10 -10
index b60591531e4a..9a37606227bd 100644
@@ -535,7 +535,7 @@ static int live_nop_request(void *arg)
 	 */
 
 	mutex_lock(&i915->drm.struct_mutex);
-	wakeref = intel_runtime_pm_get(i915);
+	wakeref = intel_runtime_pm_get(&i915->runtime_pm);
 
 	for_each_engine(engine, i915, id) {
 		struct i915_request *request = NULL;
@@ -595,7 +595,7 @@ static int live_nop_request(void *arg)
 	}
 
 out_unlock:
-	intel_runtime_pm_put(i915, wakeref);
+	intel_runtime_pm_put(&i915->runtime_pm, wakeref);
 	mutex_unlock(&i915->drm.struct_mutex);
 	return err;
 }
@@ -680,7 +680,7 @@ static int live_empty_request(void *arg)
 	 */
 
 	mutex_lock(&i915->drm.struct_mutex);
-	wakeref = intel_runtime_pm_get(i915);
+	wakeref = intel_runtime_pm_get(&i915->runtime_pm);
 
 	batch = empty_batch(i915);
 	if (IS_ERR(batch)) {
@@ -744,7 +744,7 @@ static int live_empty_request(void *arg)
 	i915_vma_unpin(batch);
 	i915_vma_put(batch);
 out_unlock:
-	intel_runtime_pm_put(i915, wakeref);
+	intel_runtime_pm_put(&i915->runtime_pm, wakeref);
 	mutex_unlock(&i915->drm.struct_mutex);
 	return err;
 }
@@ -838,7 +838,7 @@ static int live_all_engines(void *arg)
 	 */
 
 	mutex_lock(&i915->drm.struct_mutex);
-	wakeref = intel_runtime_pm_get(i915);
+	wakeref = intel_runtime_pm_get(&i915->runtime_pm);
 
 	err = igt_live_test_begin(&t, i915, __func__, "");
 	if (err)
@@ -921,7 +921,7 @@ static int live_all_engines(void *arg)
 	i915_vma_unpin(batch);
 	i915_vma_put(batch);
 out_unlock:
-	intel_runtime_pm_put(i915, wakeref);
+	intel_runtime_pm_put(&i915->runtime_pm, wakeref);
 	mutex_unlock(&i915->drm.struct_mutex);
 	return err;
 }
@@ -944,7 +944,7 @@ static int live_sequential_engines(void *arg)
 	 */
 
 	mutex_lock(&i915->drm.struct_mutex);
-	wakeref = intel_runtime_pm_get(i915);
+	wakeref = intel_runtime_pm_get(&i915->runtime_pm);
 
 	err = igt_live_test_begin(&t, i915, __func__, "");
 	if (err)
@@ -1051,7 +1051,7 @@ static int live_sequential_engines(void *arg)
 		i915_request_put(request[id]);
 	}
 out_unlock:
-	intel_runtime_pm_put(i915, wakeref);
+	intel_runtime_pm_put(&i915->runtime_pm, wakeref);
 	mutex_unlock(&i915->drm.struct_mutex);
 	return err;
 }
@@ -1116,7 +1116,7 @@ static int live_breadcrumbs_smoketest(void *arg)
 	 * On real hardware this time.
 	 */
 
-	wakeref = intel_runtime_pm_get(i915);
+	wakeref = intel_runtime_pm_get(&i915->runtime_pm);
 
 	file = mock_file(i915);
 	if (IS_ERR(file)) {
@@ -1223,7 +1223,7 @@ static int live_breadcrumbs_smoketest(void *arg)
 out_file:
 	mock_file_free(i915, file);
 out_rpm:
-	intel_runtime_pm_put(i915, wakeref);
+	intel_runtime_pm_put(&i915->runtime_pm, wakeref);
 
 	return ret;
 }
drivers/gpu/drm/i915/selftests/i915_timeline.c +8 -8
index ff9ebe50fae8..4a097f7dd8d8 100644
@@ -513,7 +513,7 @@ static int live_hwsp_engine(void *arg)
 		return -ENOMEM;
 
 	mutex_lock(&i915->drm.struct_mutex);
-	wakeref = intel_runtime_pm_get(i915);
+	wakeref = intel_runtime_pm_get(&i915->runtime_pm);
 
 	count = 0;
 	for_each_engine(engine, i915, id) {
@@ -556,7 +556,7 @@ static int live_hwsp_engine(void *arg)
 		i915_timeline_put(tl);
 	}
 
-	intel_runtime_pm_put(i915, wakeref);
+	intel_runtime_pm_put(&i915->runtime_pm, wakeref);
 	mutex_unlock(&i915->drm.struct_mutex);
 
 	kvfree(timelines);
@@ -589,7 +589,7 @@ static int live_hwsp_alternate(void *arg)
 		return -ENOMEM;
 
 	mutex_lock(&i915->drm.struct_mutex);
-	wakeref = intel_runtime_pm_get(i915);
+	wakeref = intel_runtime_pm_get(&i915->runtime_pm);
 
 	count = 0;
 	for (n = 0; n < NUM_TIMELINES; n++) {
@@ -632,7 +632,7 @@ static int live_hwsp_alternate(void *arg)
 		i915_timeline_put(tl);
 	}
 
-	intel_runtime_pm_put(i915, wakeref);
+	intel_runtime_pm_put(&i915->runtime_pm, wakeref);
 	mutex_unlock(&i915->drm.struct_mutex);
 
 	kvfree(timelines);
@@ -656,7 +656,7 @@ static int live_hwsp_wrap(void *arg)
 	 */
 
 	mutex_lock(&i915->drm.struct_mutex);
-	wakeref = intel_runtime_pm_get(i915);
+	wakeref = intel_runtime_pm_get(&i915->runtime_pm);
 
 	tl = i915_timeline_create(i915, NULL);
 	if (IS_ERR(tl)) {
@@ -747,7 +747,7 @@ static int live_hwsp_wrap(void *arg)
 out_free:
 	i915_timeline_put(tl);
 out_rpm:
-	intel_runtime_pm_put(i915, wakeref);
+	intel_runtime_pm_put(&i915->runtime_pm, wakeref);
 	mutex_unlock(&i915->drm.struct_mutex);
 
 	return err;
@@ -769,7 +769,7 @@ static int live_hwsp_recycle(void *arg)
 	 */
 
 	mutex_lock(&i915->drm.struct_mutex);
-	wakeref = intel_runtime_pm_get(i915);
+	wakeref = intel_runtime_pm_get(&i915->runtime_pm);
 
 	count = 0;
 	for_each_engine(engine, i915, id) {
@@ -823,7 +823,7 @@ static int live_hwsp_recycle(void *arg)
 out:
 	if (igt_flush_test(i915, I915_WAIT_LOCKED))
 		err = -EIO;
-	intel_runtime_pm_put(i915, wakeref);
+	intel_runtime_pm_put(&i915->runtime_pm, wakeref);
 	mutex_unlock(&i915->drm.struct_mutex);
 
 	return err;
drivers/gpu/drm/i915/selftests/intel_guc.c +4 -4
index b05a21eaa8f4..34222abbeb23 100644
@@ -143,7 +143,7 @@ static int igt_guc_clients(void *args)
 
 	GEM_BUG_ON(!HAS_GUC(dev_priv));
 	mutex_lock(&dev_priv->drm.struct_mutex);
-	wakeref = intel_runtime_pm_get(dev_priv);
+	wakeref = intel_runtime_pm_get(&dev_priv->runtime_pm);
 
 	guc = &dev_priv->guc;
 	if (!guc) {
@@ -226,7 +226,7 @@ static int igt_guc_clients(void *args)
 	guc_clients_create(guc);
 	guc_clients_enable(guc);
 unlock:
-	intel_runtime_pm_put(dev_priv, wakeref);
+	intel_runtime_pm_put(&dev_priv->runtime_pm, wakeref);
 	mutex_unlock(&dev_priv->drm.struct_mutex);
 	return err;
 }
@@ -246,7 +246,7 @@ static int igt_guc_doorbells(void *arg)
 
 	GEM_BUG_ON(!HAS_GUC(dev_priv));
 	mutex_lock(&dev_priv->drm.struct_mutex);
-	wakeref = intel_runtime_pm_get(dev_priv);
+	wakeref = intel_runtime_pm_get(&dev_priv->runtime_pm);
 
 	guc = &dev_priv->guc;
 	if (!guc) {
@@ -339,7 +339,7 @@ static int igt_guc_doorbells(void *arg)
 			guc_client_free(clients[i]);
 		}
 unlock:
-	intel_runtime_pm_put(dev_priv, wakeref);
+	intel_runtime_pm_put(&dev_priv->runtime_pm, wakeref);
 	mutex_unlock(&dev_priv->drm.struct_mutex);
 	return err;
 }
drivers/gpu/drm/i915/selftests/intel_uncore.c +2 -2
index e0d7ebecb215..86815c6072a1 100644
@@ -176,7 +176,7 @@ static int live_forcewake_ops(void *arg)
 		return 0;
 	}
 
-	wakeref = intel_runtime_pm_get(i915);
+	wakeref = intel_runtime_pm_get(&i915->runtime_pm);
 
 	for_each_fw_domain(domain, uncore, tmp) {
 		smp_store_mb(domain->active, false);
@@ -247,7 +247,7 @@ static int live_forcewake_ops(void *arg)
 	}
 
 out_rpm:
-	intel_runtime_pm_put(i915, wakeref);
+	intel_runtime_pm_put(&i915->runtime_pm, wakeref);
 	return err;
 }
 
Signature · 6 lines
2.20.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#16 lore raw

RFC 7/7 drm/i915: update with_intel_runtime_pm to use the rpm structure

In reply to Daniele Ceraolo Spurio

Matching the underlying get/put functions.

---
 drivers/gpu/drm/i915/gt/intel_context.c       |  2 +-
 drivers/gpu/drm/i915/gt/intel_reset.c         |  2 +-
 .../gpu/drm/i915/gt/selftest_workarounds.c    |  4 ++--
 drivers/gpu/drm/i915/i915_debugfs.c           | 24 +++++++++----------
 drivers/gpu/drm/i915/i915_gem.c               |  2 +-
 drivers/gpu/drm/i915/i915_gem_gtt.c           |  8 +++----
 drivers/gpu/drm/i915/i915_gem_shrinker.c      |  8 +++----
 drivers/gpu/drm/i915/i915_pmu.c               |  3 ++-
 drivers/gpu/drm/i915/i915_sysfs.c             |  2 +-
 drivers/gpu/drm/i915/intel_guc_log.c          |  6 ++---
 drivers/gpu/drm/i915/intel_huc.c              |  2 +-
 drivers/gpu/drm/i915/intel_panel.c            |  2 +-
 drivers/gpu/drm/i915/intel_pm.c               |  8 +++----
 drivers/gpu/drm/i915/intel_runtime_pm.h       | 12 +++++-----
 drivers/gpu/drm/i915/intel_uc.c               |  2 +-
 drivers/gpu/drm/i915/intel_uncore.c           |  2 +-
 drivers/gpu/drm/i915/selftests/i915_gem.c     |  6 ++---
 .../gpu/drm/i915/selftests/i915_gem_context.c |  6 ++---
 .../gpu/drm/i915/selftests/i915_gem_evict.c   |  2 +-
 .../gpu/drm/i915/selftests/i915_gem_object.c  |  2 +-
 drivers/gpu/drm/i915/selftests/i915_request.c |  2 +-
 21 files changed, 54 insertions(+), 53 deletions(-)
drivers/gpu/drm/i915/gt/intel_context.c +1 -1
index 5b31e1e05ddd..21892683a804 100644
@@ -52,7 +52,7 @@ int __intel_context_do_pin(struct intel_context *ce)
 		intel_wakeref_t wakeref;
 
 		err = 0;
-		with_intel_runtime_pm(ce->engine->i915, wakeref)
+		with_intel_runtime_pm(&ce->engine->i915->runtime_pm, wakeref)
 			err = ce->ops->pin(ce);
 		if (err)
 			goto err;
drivers/gpu/drm/i915/gt/intel_reset.c +1 -1
index ad943810eded..4e0a56c36a2a 100644
@@ -849,7 +849,7 @@ void i915_gem_set_wedged(struct drm_i915_private *i915)
 	intel_wakeref_t wakeref;
 
 	mutex_lock(&error->wedge_mutex);
-	with_intel_runtime_pm(i915, wakeref)
+	with_intel_runtime_pm(&i915->runtime_pm, wakeref)
 		__i915_gem_set_wedged(i915);
 	mutex_unlock(&error->wedge_mutex);
 }
drivers/gpu/drm/i915/gt/selftest_workarounds.c +2 -2
index 6c1db2e403ba..1669f0016893 100644
@@ -246,7 +246,7 @@ switch_to_scratch_context(struct intel_engine_cs *engine,
 	GEM_BUG_ON(i915_gem_context_is_bannable(ctx));
 
 	rq = ERR_PTR(-ENODEV);
-	with_intel_runtime_pm(engine->i915, wakeref)
+	with_intel_runtime_pm(&engine->i915->runtime_pm, wakeref)
 		rq = igt_spinner_create_request(spin, ctx, engine, MI_NOOP);
 
 	kernel_context_close(ctx);
@@ -302,7 +302,7 @@ static int check_whitelist_across_reset(struct intel_engine_cs *engine,
 	if (err)
 		goto out;
 
-	with_intel_runtime_pm(i915, wakeref)
+	with_intel_runtime_pm(&i915->runtime_pm, wakeref)
 		err = reset(engine);
 
 	igt_spinner_end(&spin);
drivers/gpu/drm/i915/i915_debugfs.c +12 -12
index e58a0152b25f..4e8cd1e01e57 100644
@@ -976,7 +976,7 @@ static int i915_gpu_info_open(struct inode *inode, struct file *file)
 	intel_wakeref_t wakeref;
 
 	gpu = NULL;
-	with_intel_runtime_pm(i915, wakeref)
+	with_intel_runtime_pm(&i915->runtime_pm, wakeref)
 		gpu = i915_capture_gpu_state(i915);
 	if (IS_ERR(gpu))
 		return PTR_ERR(gpu);
@@ -1303,7 +1303,7 @@ static int i915_hangcheck_info(struct seq_file *m, void *unused)
 		return 0;
 	}
 
-	with_intel_runtime_pm(dev_priv, wakeref) {
+	with_intel_runtime_pm(&dev_priv->runtime_pm, wakeref) {
 		for_each_engine(engine, dev_priv, id)
 			acthd[id] = intel_engine_get_active_head(engine);
 
@@ -1562,7 +1562,7 @@ static int i915_drpc_info(struct seq_file *m, void *unused)
 	intel_wakeref_t wakeref;
 	int err = -ENODEV;
 
-	with_intel_runtime_pm(dev_priv, wakeref) {
+	with_intel_runtime_pm(&dev_priv->runtime_pm, wakeref) {
 		if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv))
 			err = vlv_drpc_info(m);
 		else if (INTEL_GEN(dev_priv) >= 6)
@@ -1729,7 +1729,7 @@ static int i915_emon_status(struct seq_file *m, void *unused)
 	if (!IS_GEN(i915, 5))
 		return -ENODEV;
 
-	with_intel_runtime_pm(i915, wakeref) {
+	with_intel_runtime_pm(&i915->runtime_pm, wakeref) {
 		unsigned long temp, chipset, gfx;
 
 		temp = i915_mch_val(i915);
@@ -2020,7 +2020,7 @@ static int i915_rps_boost_info(struct seq_file *m, void *data)
 	u32 act_freq = rps->cur_freq;
 	intel_wakeref_t wakeref;
 
-	with_intel_runtime_pm_if_in_use(dev_priv, wakeref) {
+	with_intel_runtime_pm_if_in_use(&dev_priv->runtime_pm, wakeref) {
 		if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) {
 			vlv_punit_get(dev_priv);
 			act_freq = vlv_punit_read(dev_priv,
@@ -2103,7 +2103,7 @@ static int i915_huc_load_status_info(struct seq_file *m, void *data)
 	p = drm_seq_file_printer(m);
 	intel_uc_fw_dump(&dev_priv->huc.fw, &p);
 
-	with_intel_runtime_pm(dev_priv, wakeref)
+	with_intel_runtime_pm(&dev_priv->runtime_pm, wakeref)
 		seq_printf(m, "\nHuC status 0x%08x:\n", I915_READ(HUC_STATUS2));
 
 	return 0;
@@ -2121,7 +2121,7 @@ static int i915_guc_load_status_info(struct seq_file *m, void *data)
 	p = drm_seq_file_printer(m);
 	intel_uc_fw_dump(&dev_priv->guc.fw, &p);
 
-	with_intel_runtime_pm(dev_priv, wakeref) {
+	with_intel_runtime_pm(&dev_priv->runtime_pm, wakeref) {
 		u32 tmp = I915_READ(GUC_STATUS);
 		u32 i;
 
@@ -2627,7 +2627,7 @@ static int i915_energy_uJ(struct seq_file *m, void *data)
 		return -ENODEV;
 
 	units = (power & 0x1f00) >> 8;
-	with_intel_runtime_pm(dev_priv, wakeref)
+	with_intel_runtime_pm(&dev_priv->runtime_pm, wakeref)
 		power = I915_READ(MCH_SECP_NRG_STTS);
 
 	power = (1000000 * power) >> units; /* convert to uJ */
@@ -3213,7 +3213,7 @@ static ssize_t i915_ipc_status_write(struct file *file, const char __user *ubuf,
 	if (ret < 0)
 		return ret;
 
-	with_intel_runtime_pm(dev_priv, wakeref) {
+	with_intel_runtime_pm(&dev_priv->runtime_pm, wakeref) {
 		if (!dev_priv->ipc_enabled && enable)
 			DRM_INFO("Enabling IPC: WM will be proper only after next commit\n");
 		dev_priv->wm.distrust_bios_wm = true;
@@ -3965,7 +3965,7 @@ i915_cache_sharing_get(void *data, u64 *val)
 	if (!(IS_GEN_RANGE(dev_priv, 6, 7)))
 		return -ENODEV;
 
-	with_intel_runtime_pm(dev_priv, wakeref)
+	with_intel_runtime_pm(&dev_priv->runtime_pm, wakeref)
 		snpcr = I915_READ(GEN6_MBCUNIT_SNPCR);
 
 	*val = (snpcr & GEN6_MBC_SNPCR_MASK) >> GEN6_MBC_SNPCR_SHIFT;
@@ -3986,7 +3986,7 @@ i915_cache_sharing_set(void *data, u64 val)
 		return -EINVAL;
 
 	DRM_DEBUG_DRIVER("Manually setting uncore sharing to %llu\n", val);
-	with_intel_runtime_pm(dev_priv, wakeref) {
+	with_intel_runtime_pm(&dev_priv->runtime_pm, wakeref) {
 		u32 snpcr;
 
 		/* Update the cache sharing policy here as well */
@@ -4232,7 +4232,7 @@ static int i915_sseu_status(struct seq_file *m, void *unused)
 	sseu.max_eus_per_subslice =
 		RUNTIME_INFO(dev_priv)->sseu.max_eus_per_subslice;
 
-	with_intel_runtime_pm(dev_priv, wakeref) {
+	with_intel_runtime_pm(&dev_priv->runtime_pm, wakeref) {
 		if (IS_CHERRYVIEW(dev_priv))
 			cherryview_sseu_device_status(dev_priv, &sseu);
 		else if (IS_BROADWELL(dev_priv))
drivers/gpu/drm/i915/i915_gem.c +1 -1
index 631fef6e4b7a..c58ef14dfa77 100644
@@ -629,7 +629,7 @@ void i915_gem_flush_ggtt_writes(struct drm_i915_private *dev_priv)
 
 	i915_gem_chipset_flush(dev_priv);
 
-	with_intel_runtime_pm(dev_priv, wakeref) {
+	with_intel_runtime_pm(&dev_priv->runtime_pm, wakeref) {
 		spin_lock_irq(&dev_priv->uncore.lock);
 
 		POSTING_READ_FW(RING_HEAD(RENDER_RING_BASE));
drivers/gpu/drm/i915/i915_gem_gtt.c +4 -4
index 8f5db787b7f2..02544c6dac79 100644
@@ -2525,7 +2525,7 @@ static int ggtt_bind_vma(struct i915_vma *vma,
 	if (i915_gem_object_is_readonly(obj))
 		pte_flags |= PTE_READ_ONLY;
 
-	with_intel_runtime_pm(i915, wakeref)
+	with_intel_runtime_pm(&i915->runtime_pm, wakeref)
 		vma->vm->insert_entries(vma->vm, vma, cache_level, pte_flags);
 
 	vma->page_sizes.gtt = I915_GTT_PAGE_SIZE;
@@ -2545,7 +2545,7 @@ static void ggtt_unbind_vma(struct i915_vma *vma)
 	struct drm_i915_private *i915 = vma->vm->i915;
 	intel_wakeref_t wakeref;
 
-	with_intel_runtime_pm(i915, wakeref)
+	with_intel_runtime_pm(&i915->runtime_pm, wakeref)
 		vma->vm->clear_range(vma->vm, vma->node.start, vma->size);
 }
 
@@ -2580,7 +2580,7 @@ static int aliasing_gtt_bind_vma(struct i915_vma *vma,
 	if (flags & I915_VMA_GLOBAL_BIND) {
 		intel_wakeref_t wakeref;
 
-		with_intel_runtime_pm(i915, wakeref) {
+		with_intel_runtime_pm(&i915->runtime_pm, wakeref) {
 			vma->vm->insert_entries(vma->vm, vma,
 						cache_level, pte_flags);
 		}
@@ -2597,7 +2597,7 @@ static void aliasing_gtt_unbind_vma(struct i915_vma *vma)
 		struct i915_address_space *vm = vma->vm;
 		intel_wakeref_t wakeref;
 
-		with_intel_runtime_pm(i915, wakeref)
+		with_intel_runtime_pm(&i915->runtime_pm, wakeref)
 			vm->clear_range(vm, vma->node.start, vma->size);
 	}
 
drivers/gpu/drm/i915/i915_gem_shrinker.c +4 -4
index 05b75a42dd1c..cfcf8b312452 100644
@@ -359,7 +359,7 @@ unsigned long i915_gem_shrink_all(struct drm_i915_private *i915)
 	intel_wakeref_t wakeref;
 	unsigned long freed = 0;
 
-	with_intel_runtime_pm(i915, wakeref) {
+	with_intel_runtime_pm(&i915->runtime_pm, wakeref) {
 		freed = i915_gem_shrink(i915, -1UL, NULL,
 					I915_SHRINK_BOUND |
 					I915_SHRINK_UNBOUND |
@@ -439,7 +439,7 @@ i915_gem_shrinker_scan(struct shrinker *shrinker, struct shrink_control *sc)
 	if (sc->nr_scanned < sc->nr_to_scan && current_is_kswapd()) {
 		intel_wakeref_t wakeref;
 
-		with_intel_runtime_pm(i915, wakeref) {
+		with_intel_runtime_pm(&i915->runtime_pm, wakeref) {
 			freed += i915_gem_shrink(i915,
 						 sc->nr_to_scan - sc->nr_scanned,
 						 &sc->nr_scanned,
@@ -465,7 +465,7 @@ i915_gem_shrinker_oom(struct notifier_block *nb, unsigned long event, void *ptr)
 	intel_wakeref_t wakeref;
 
 	freed_pages = 0;
-	with_intel_runtime_pm(i915, wakeref)
+	with_intel_runtime_pm(&i915->runtime_pm, wakeref)
 		freed_pages += i915_gem_shrink(i915, -1UL, NULL,
 					       I915_SHRINK_BOUND |
 					       I915_SHRINK_UNBOUND |
@@ -519,7 +519,7 @@ i915_gem_shrinker_vmap(struct notifier_block *nb, unsigned long event, void *ptr
 				   MAX_SCHEDULE_TIMEOUT))
 		goto out;
 
-	with_intel_runtime_pm(i915, wakeref)
+	with_intel_runtime_pm(&i915->runtime_pm, wakeref)
 		freed_pages += i915_gem_shrink(i915, -1UL, NULL,
 					       I915_SHRINK_BOUND |
 					       I915_SHRINK_UNBOUND |
drivers/gpu/drm/i915/i915_pmu.c +2 -1
index 4c6ed652e840..d71d16afcd8e 100644
@@ -227,7 +227,8 @@ frequency_sample(struct drm_i915_private *dev_priv, unsigned int period_ns)
 		if (dev_priv->gt.awake) {
 			intel_wakeref_t wakeref;
 
-			with_intel_runtime_pm_if_in_use(dev_priv, wakeref)
+			with_intel_runtime_pm_if_in_use(&dev_priv->runtime_pm,
+							wakeref)
 				val = intel_get_cagf(dev_priv,
 						     I915_READ_NOTRACE(GEN6_RPSTAT1));
 		}
drivers/gpu/drm/i915/i915_sysfs.c +1 -1
index 75acbf686ec9..ecac1c386109 100644
@@ -48,7 +48,7 @@ static u32 calc_residency(struct drm_i915_private *dev_priv,
 	intel_wakeref_t wakeref;
 	u64 res = 0;
 
-	with_intel_runtime_pm(dev_priv, wakeref)
+	with_intel_runtime_pm(&dev_priv->runtime_pm, wakeref)
 		res = intel_rc6_residency_us(dev_priv, reg);
 
 	return DIV_ROUND_CLOSEST_ULL(res, 1000);
drivers/gpu/drm/i915/intel_guc_log.c +3 -3
index 7146524264dd..8fe4bc8d7ba3 100644
@@ -447,7 +447,7 @@ static void guc_log_capture_logs(struct intel_guc_log *log)
 	 * Generally device is expected to be active only at this
 	 * time, so get/put should be really quick.
 	 */
-	with_intel_runtime_pm(dev_priv, wakeref)
+	with_intel_runtime_pm(&dev_priv->runtime_pm, wakeref)
 		guc_action_flush_log_complete(guc);
 }
 
@@ -526,7 +526,7 @@ int intel_guc_log_set_level(struct intel_guc_log *log, u32 level)
 	if (log->level == level)
 		goto out_unlock;
 
-	with_intel_runtime_pm(dev_priv, wakeref)
+	with_intel_runtime_pm(&dev_priv->runtime_pm, wakeref)
 		ret = guc_action_control_log(guc,
 					     GUC_LOG_LEVEL_IS_VERBOSE(level),
 					     GUC_LOG_LEVEL_IS_ENABLED(level),
@@ -611,7 +611,7 @@ void intel_guc_log_relay_flush(struct intel_guc_log *log)
 	 */
 	flush_work(&log->relay.flush_work);
 
-	with_intel_runtime_pm(i915, wakeref)
+	with_intel_runtime_pm(&i915->runtime_pm, wakeref)
 		guc_action_flush_log(guc);
 
 	/* GuC would have updated log buffer by now, so capture it */
drivers/gpu/drm/i915/intel_huc.c +1 -1
index 1ff1fb015e58..de397022d80f 100644
@@ -163,7 +163,7 @@ int intel_huc_check_status(struct intel_huc *huc)
 	if (!HAS_HUC(dev_priv))
 		return -ENODEV;
 
-	with_intel_runtime_pm(dev_priv, wakeref)
+	with_intel_runtime_pm(&dev_priv->runtime_pm, wakeref)
 		status = I915_READ(HUC_STATUS2) & HUC_FW_VERIFIED;
 
 	return status;
drivers/gpu/drm/i915/intel_panel.c +1 -1
index 9cd4e37e3934..39d742094065 100644
@@ -1288,7 +1288,7 @@ static int intel_backlight_device_get_brightness(struct backlight_device *bd)
 	intel_wakeref_t wakeref;
 	int ret = 0;
 
-	with_intel_runtime_pm(dev_priv, wakeref) {
+	with_intel_runtime_pm(&dev_priv->runtime_pm, wakeref) {
 		u32 hw_level;
 
 		drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
drivers/gpu/drm/i915/intel_pm.c +4 -4
index decdd79c3805..6c713de84532 100644
@@ -8148,7 +8148,7 @@ unsigned long i915_chipset_val(struct drm_i915_private *dev_priv)
 	if (!IS_GEN(dev_priv, 5))
 		return 0;
 
-	with_intel_runtime_pm(dev_priv, wakeref) {
+	with_intel_runtime_pm(&dev_priv->runtime_pm, wakeref) {
 		spin_lock_irq(&mchdev_lock);
 		val = __i915_chipset_val(dev_priv);
 		spin_unlock_irq(&mchdev_lock);
@@ -8234,7 +8234,7 @@ void i915_update_gfx_val(struct drm_i915_private *dev_priv)
 	if (!IS_GEN(dev_priv, 5))
 		return;
 
-	with_intel_runtime_pm(dev_priv, wakeref) {
+	with_intel_runtime_pm(&dev_priv->runtime_pm, wakeref) {
 		spin_lock_irq(&mchdev_lock);
 		__i915_update_gfx_val(dev_priv);
 		spin_unlock_irq(&mchdev_lock);
@@ -8286,7 +8286,7 @@ unsigned long i915_gfx_val(struct drm_i915_private *dev_priv)
 	if (!IS_GEN(dev_priv, 5))
 		return 0;
 
-	with_intel_runtime_pm(dev_priv, wakeref) {
+	with_intel_runtime_pm(&dev_priv->runtime_pm, wakeref) {
 		spin_lock_irq(&mchdev_lock);
 		val = __i915_gfx_val(dev_priv);
 		spin_unlock_irq(&mchdev_lock);
@@ -8327,7 +8327,7 @@ unsigned long i915_read_mch_val(void)
 	if (!i915)
 		return 0;
 
-	with_intel_runtime_pm(i915, wakeref) {
+	with_intel_runtime_pm(&i915->runtime_pm, wakeref) {
 		spin_lock_irq(&mchdev_lock);
 		chipset_val = __i915_chipset_val(i915);
 		graphics_val = __i915_gfx_val(i915);
drivers/gpu/drm/i915/intel_runtime_pm.h +6 -6
index c389e5f8f2c1..c498b62616ef 100644
@@ -250,13 +250,13 @@ intel_wakeref_t intel_runtime_pm_get(struct intel_runtime_pm *rpm);
 intel_wakeref_t intel_runtime_pm_get_if_in_use(struct intel_runtime_pm *rpm);
 intel_wakeref_t intel_runtime_pm_get_noresume(struct intel_runtime_pm *rpm);
 
-#define with_intel_runtime_pm(i915, wf) \
-	for ((wf) = intel_runtime_pm_get(&(i915)->runtime_pm); (wf); \
-	     intel_runtime_pm_put(&(i915)->runtime_pm, (wf)), (wf) = 0)
+#define with_intel_runtime_pm(rpm, wf) \
+	for ((wf) = intel_runtime_pm_get(rpm); (wf); \
+	     intel_runtime_pm_put((rpm), (wf)), (wf) = 0)
 
-#define with_intel_runtime_pm_if_in_use(i915, wf) \
-	for ((wf) = intel_runtime_pm_get_if_in_use(&(i915)->runtime_pm); (wf); \
-	     intel_runtime_pm_put(&(i915)->runtime_pm, (wf)), (wf) = 0)
+#define with_intel_runtime_pm_if_in_use(rpm, wf) \
+	for ((wf) = intel_runtime_pm_get_if_in_use(rpm); (wf); \
+	     intel_runtime_pm_put((rpm), (wf)), (wf) = 0)
 
 void intel_runtime_pm_put_unchecked(struct intel_runtime_pm *rpm);
 #if IS_ENABLED(CONFIG_DRM_I915_DEBUG_RUNTIME_PM)
drivers/gpu/drm/i915/intel_uc.c +1 -1
index 1ee70df51627..74a55cbd3f2f 100644
@@ -504,7 +504,7 @@ void intel_uc_suspend(struct drm_i915_private *i915)
 	if (guc->fw.load_status != INTEL_UC_FIRMWARE_SUCCESS)
 		return;
 
-	with_intel_runtime_pm(i915, wakeref)
+	with_intel_runtime_pm(&i915->runtime_pm, wakeref)
 		intel_uc_runtime_suspend(i915);
 }
 
drivers/gpu/drm/i915/intel_uncore.c +1 -1
index a5b7e99eb5e1..5277f865e541 100644
@@ -1701,7 +1701,7 @@ int i915_reg_read_ioctl(struct drm_device *dev,
 
 	flags = reg->offset & (entry->size - 1);
 
-	with_intel_runtime_pm(dev_priv, wakeref) {
+	with_intel_runtime_pm(&dev_priv->runtime_pm, wakeref) {
 		if (entry->size == 8 && flags == I915_REG_READ_8B_WA)
 			reg->val = I915_READ64_2x32(entry->offset_ldw,
 						    entry->offset_udw);
drivers/gpu/drm/i915/selftests/i915_gem.c +3 -3
index c6985da29742..09fafba8bbaf 100644
@@ -86,7 +86,7 @@ static void pm_suspend(struct drm_i915_private *i915)
 {
 	intel_wakeref_t wakeref;
 
-	with_intel_runtime_pm(i915, wakeref) {
+	with_intel_runtime_pm(&i915->runtime_pm, wakeref) {
 		i915_gem_suspend_gtt_mappings(i915);
 		i915_gem_suspend_late(i915);
 	}
@@ -96,7 +96,7 @@ static void pm_hibernate(struct drm_i915_private *i915)
 {
 	intel_wakeref_t wakeref;
 
-	with_intel_runtime_pm(i915, wakeref) {
+	with_intel_runtime_pm(&i915->runtime_pm, wakeref) {
 		i915_gem_suspend_gtt_mappings(i915);
 
 		i915_gem_freeze(i915);
@@ -112,7 +112,7 @@ static void pm_resume(struct drm_i915_private *i915)
 	 * Both suspend and hibernate follow the same wakeup path and assume
 	 * that runtime-pm just works.
 	 */
-	with_intel_runtime_pm(i915, wakeref) {
+	with_intel_runtime_pm(&i915->runtime_pm, wakeref) {
 		intel_gt_sanitize(i915, false);
 		i915_gem_sanitize(i915);
 		i915_gem_resume(i915);
drivers/gpu/drm/i915/selftests/i915_gem_context.c +3 -3
index 1a67e0c742bc..9d024535e11d 100644
@@ -543,7 +543,7 @@ static int igt_ctx_exec(void *arg)
 				}
 			}
 
-			with_intel_runtime_pm(i915, wakeref)
+			with_intel_runtime_pm(&i915->runtime_pm, wakeref)
 				err = gpu_fill(obj, ctx, engine, dw);
 			if (err) {
 				pr_err("Failed to fill dword %lu [%lu/%lu] with gpu (%s) in ctx %u [full-ppgtt? %s], err=%d\n",
@@ -663,7 +663,7 @@ static int igt_shared_ctx_exec(void *arg)
 			}
 
 			err = 0;
-			with_intel_runtime_pm(i915, wakeref)
+			with_intel_runtime_pm(&i915->runtime_pm, wakeref)
 				err = gpu_fill(obj, ctx, engine, dw);
 			if (err) {
 				pr_err("Failed to fill dword %lu [%lu/%lu] with gpu (%s) in ctx %u [full-ppgtt? %s], err=%d\n",
@@ -1239,7 +1239,7 @@ static int igt_ctx_readonly(void *arg)
 			}
 
 			err = 0;
-			with_intel_runtime_pm(i915, wakeref)
+			with_intel_runtime_pm(&i915->runtime_pm, wakeref)
 				err = gpu_fill(obj, ctx, engine, dw);
 			if (err) {
 				pr_err("Failed to fill dword %lu [%lu/%lu] with gpu (%s) in ctx %u [full-ppgtt? %s], err=%d\n",
drivers/gpu/drm/i915/selftests/i915_gem_evict.c +1 -1
index f7fb2da689ba..06e819cfc92d 100644
@@ -533,7 +533,7 @@ int i915_gem_evict_mock_selftests(void)
 		return -ENOMEM;
 
 	mutex_lock(&i915->drm.struct_mutex);
-	with_intel_runtime_pm(i915, wakeref)
+	with_intel_runtime_pm(&i915->runtime_pm, wakeref)
 		err = i915_subtests(tests, i915);
 
 	mutex_unlock(&i915->drm.struct_mutex);
drivers/gpu/drm/i915/selftests/i915_gem_object.c +1 -1
index ed9d6c43113b..6d3d0e50afa4 100644
@@ -599,7 +599,7 @@ static int igt_mmap_offset_exhaustion(void *arg)
 
 		err = 0;
 		mutex_lock(&i915->drm.struct_mutex);
-		with_intel_runtime_pm(i915, wakeref)
+		with_intel_runtime_pm(&i915->runtime_pm, wakeref)
 			err = make_obj_busy(obj);
 		mutex_unlock(&i915->drm.struct_mutex);
 		if (err) {
drivers/gpu/drm/i915/selftests/i915_request.c +1 -1
index 9a37606227bd..1b73c46d0eb5 100644
@@ -512,7 +512,7 @@ int i915_request_mock_selftests(void)
 	if (!i915)
 		return -ENOMEM;
 
-	with_intel_runtime_pm(i915, wakeref)
+	with_intel_runtime_pm(&i915->runtime_pm, wakeref)
 		err = i915_subtests(tests, i915);
 
 	drm_dev_put(&i915->drm);
Signature · 6 lines
2.20.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#17 lore raw

✗ Fi.CI.CHECKPATCH: warning for Runtime PM encapsulation

In reply to Daniele Ceraolo Spurio
== Series Details ==

== Series Details ==

Series: Runtime PM encapsulation
URL : https://patchwork.freedesktop.org/series/60751/
State : warning

== Summary ==

$ dim checkpatch origin/drm-tip
6abe6de9d69c drm/i915: prefer i915_runtime_pm in intel_runtime function
459ce16ea796 drm/i915: Remove rpm asserts that use i915
3786ba59fb44 drm/i915: make enable/disable rpm assert function use the rpm structure
f9fd0f317814 drm/i915: move and rename i915_runtime_pm
-:527: CHECK:UNCOMMENTED_DEFINITION: spinlock_t definition without comment
#527: FILE: drivers/gpu/drm/i915/intel_runtime_pm.h:62:
+		spinlock_t lock;

total: 0 errors, 0 warnings, 1 checks, 585 lines checked 5fade456b0bf drm/i915: move a few more functions to accept the rpm structure 14c3a5f20ed6 drm/i915: update rpm_get/put to use the rpm structure 2701026b6f98 drm/i915: update with_intel_runtime_pm to use the rpm structure -:399: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'rpm' - possible side-effects? #399: FILE: drivers/gpu/drm/i915/intel_runtime_pm.h:253:
+#define with_intel_runtime_pm(rpm, wf) \
+ for ((wf) = intel_runtime_pm_get(rpm); (wf); \
+ intel_runtime_pm_put((rpm), (wf)), (wf) = 0)

-:399: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'wf' - possible side-effects? #399: FILE: drivers/gpu/drm/i915/intel_runtime_pm.h:253:
+#define with_intel_runtime_pm(rpm, wf) \
+ for ((wf) = intel_runtime_pm_get(rpm); (wf); \
+ intel_runtime_pm_put((rpm), (wf)), (wf) = 0)

-:406: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'rpm' - possible side-effects? #406: FILE: drivers/gpu/drm/i915/intel_runtime_pm.h:257:
+#define with_intel_runtime_pm_if_in_use(rpm, wf) \
+ for ((wf) = intel_runtime_pm_get_if_in_use(rpm); (wf); \
+ intel_runtime_pm_put((rpm), (wf)), (wf) = 0)

-:406: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'wf' - possible side-effects? #406: FILE: drivers/gpu/drm/i915/intel_runtime_pm.h:257:
+#define with_intel_runtime_pm_if_in_use(rpm, wf) \
+ for ((wf) = intel_runtime_pm_get_if_in_use(rpm); (wf); \
+ intel_runtime_pm_put((rpm), (wf)), (wf) = 0)

total: 0 errors, 0 warnings, 4 checks, 396 lines checked

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#18 lore raw

✗ Fi.CI.SPARSE: warning for Runtime PM encapsulation

In reply to Daniele Ceraolo Spurio
== Series Details ==

== Series Details ==

Series: Runtime PM encapsulation
URL : https://patchwork.freedesktop.org/series/60751/
State : warning

== Summary ==

$ dim sparse origin/drm-tip
Sparse version: v0.5.2
Commit: drm/i915: prefer i915_runtime_pm in intel_runtime function
Okay!

Commit: drm/i915: Remove rpm asserts that use i915 Okay!

Commit: drm/i915: make enable/disable rpm assert function use the rpm structure Okay!

Commit: drm/i915: move and rename i915_runtime_pm
Okay!

Commit: drm/i915: move a few more functions to accept the rpm structure Okay!

Commit: drm/i915: update rpm_get/put to use the rpm structure
-O:drivers/gpu/drm/i915/gt/intel_reset.c:1311:5: warning: context imbalance in 'i915_reset_trylock' - different lock contexts for basic block +drivers/gpu/drm/i915/gt/intel_reset.c:1311:5: warning: context imbalance in 'i915_reset_trylock' - different lock contexts for basic block

Commit: drm/i915: update with_intel_runtime_pm to use the rpm structure Okay!

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#19 lore raw

✗ Fi.CI.BAT: failure for Runtime PM encapsulation

In reply to Daniele Ceraolo Spurio
== Series Details ==

== Series Details ==

Series: Runtime PM encapsulation
URL : https://patchwork.freedesktop.org/series/60751/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_6091 -> Patchwork_13028
====================================================

Summary
-------

**FAILURE**

Serious unknown changes coming with Patchwork_13028 absolutely need to be verified manually.

If you think the reported changes have nothing to do with the changes introduced in Patchwork_13028, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.

External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13028/

Possible new issues
-------------------

Here are the unknown changes that may have been introduced in Patchwork_13028:

### IGT changes ###

#### Possible regressions ####

* igt@i915_pm_rpm@basic-rte:
- fi-hsw-peppy: [PASS][1] -> [FAIL][2] +2 similar issues
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6091/fi-hsw-peppy/igt@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13028/fi-hsw-peppy/igt@[email protected]

Known issues
------------

Here are the changes found in Patchwork_13028 that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@gem_exec_basic@basic-blt:
- fi-icl-u2: [PASS][3] -> [INCOMPLETE][4] ([fdo#107713] / [fdo#110246])
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6091/fi-icl-u2/igt@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13028/fi-icl-u2/igt@[email protected]

* igt@gem_exec_suspend@basic-s3:
- fi-blb-e6850: [PASS][5] -> [INCOMPLETE][6] ([fdo#107718])
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6091/fi-blb-e6850/igt@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13028/fi-blb-e6850/igt@[email protected]

* igt@i915_selftest@live_guc:
- fi-apl-guc: [PASS][7] -> [INCOMPLETE][8] ([fdo#103927])
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6091/fi-apl-guc/igt@i915_selftest@live_guc.html
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13028/fi-apl-guc/igt@i915_selftest@live_guc.html

* igt@i915_selftest@live_hangcheck:
- fi-skl-iommu: [PASS][9] -> [INCOMPLETE][10] ([fdo#108602] / [fdo#108744])
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6091/fi-skl-iommu/igt@i915_selftest@live_hangcheck.html
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13028/fi-skl-iommu/igt@i915_selftest@live_hangcheck.html
- fi-apl-guc: [PASS][11] -> [DMESG-FAIL][12] ([fdo#110620])
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6091/fi-apl-guc/igt@i915_selftest@live_hangcheck.html
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13028/fi-apl-guc/igt@i915_selftest@live_hangcheck.html

#### Possible fixes ####

* igt@i915_pm_rpm@module-reload:
- fi-skl-6770hq: [FAIL][13] ([fdo#108511]) -> [PASS][14]
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6091/fi-skl-6770hq/igt@[email protected]
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13028/fi-skl-6770hq/igt@[email protected]

* igt@i915_selftest@live_contexts:
- fi-bdw-gvtdvm: [DMESG-FAIL][15] ([fdo#110235]) -> [PASS][16]
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6091/fi-bdw-gvtdvm/igt@i915_selftest@live_contexts.html
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13028/fi-bdw-gvtdvm/igt@i915_selftest@live_contexts.html

* igt@kms_frontbuffer_tracking@basic:
- fi-hsw-peppy: [DMESG-WARN][17] ([fdo#102614]) -> [PASS][18]
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6091/fi-hsw-peppy/igt@[email protected]
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13028/fi-hsw-peppy/igt@[email protected]

* igt@prime_vgem@basic-fence-flip:
- fi-ilk-650: [DMESG-WARN][19] ([fdo#106387]) -> [PASS][20] +1 similar issue
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6091/fi-ilk-650/igt@[email protected]
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13028/fi-ilk-650/igt@[email protected]

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

[fdo#102614]: https://bugs.freedesktop.org/show_bug.cgi?id=102614
[fdo#103927]: https://bugs.freedesktop.org/show_bug.cgi?id=103927
[fdo#106387]: https://bugs.freedesktop.org/show_bug.cgi?id=106387
[fdo#107713]: https://bugs.freedesktop.org/show_bug.cgi?id=107713
[fdo#107718]: https://bugs.freedesktop.org/show_bug.cgi?id=107718
[fdo#108511]: https://bugs.freedesktop.org/show_bug.cgi?id=108511
[fdo#108602]: https://bugs.freedesktop.org/show_bug.cgi?id=108602
[fdo#108744]: https://bugs.freedesktop.org/show_bug.cgi?id=108744
[fdo#109100]: https://bugs.freedesktop.org/show_bug.cgi?id=109100
[fdo#110235]: https://bugs.freedesktop.org/show_bug.cgi?id=110235
[fdo#110246]: https://bugs.freedesktop.org/show_bug.cgi?id=110246
[fdo#110620]: https://bugs.freedesktop.org/show_bug.cgi?id=110620

Participating hosts (50 -> 44)
------------------------------

Additional (2): fi-bsw-n3050 fi-pnv-d510
Missing (8): fi-kbl-soraka fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-byt-clapper fi-bdw-samus fi-snb-2600

Build changes
-------------

* Linux: CI_DRM_6091 -> Patchwork_13028

CI_DRM_6091: 0ad895242a8e957336088625a9a6ba48ab838ec9 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4994: 555019f862c35f1619627761d6da21385be40920 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_13028: 2701026b6f9821c4555f26dc63e2a8760af66cd5 @ git://anongit.freedesktop.org/gfx-ci/linux

== Linux commits ==

2701026b6f98 drm/i915: update with_intel_runtime_pm to use the rpm structure 14c3a5f20ed6 drm/i915: update rpm_get/put to use the rpm structure 5fade456b0bf drm/i915: move a few more functions to accept the rpm structure f9fd0f317814 drm/i915: move and rename i915_runtime_pm
3786ba59fb44 drm/i915: make enable/disable rpm assert function use the rpm structure 459ce16ea796 drm/i915: Remove rpm asserts that use i915
6abe6de9d69c drm/i915: prefer i915_runtime_pm in intel_runtime function

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13028/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx