[PATCH 5/6] safe
Chris Wilson
chris at chris-wilson.co.uk
Thu Aug 9 19:31:44 UTC 2018
---
drivers/gpu/drm/i915/intel_drv.h | 59 +++++++++----
drivers/gpu/drm/i915/intel_runtime_pm.c | 105 +++++++++++++++---------
2 files changed, 110 insertions(+), 54 deletions(-)
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 983d3397e418..e9373d92ccbc 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -1976,23 +1976,23 @@ void icl_dbuf_slices_update(struct drm_i915_private *dev_priv,
u8 req_slices);
static inline void
-assert_rpm_device_not_suspended(struct drm_i915_private *dev_priv)
+assert_rpm_device_not_suspended(struct drm_i915_private *i915)
{
- WARN_ONCE(dev_priv->runtime_pm.suspended,
+ WARN_ONCE(i915->runtime_pm.suspended,
"Device suspended during HW access\n");
}
static inline void
-assert_rpm_wakelock_held(struct drm_i915_private *dev_priv)
+assert_rpm_wakelock_held(struct drm_i915_private *i915)
{
- assert_rpm_device_not_suspended(dev_priv);
- WARN_ONCE(!atomic_read(&dev_priv->runtime_pm.wakeref_count),
+ assert_rpm_device_not_suspended(i915);
+ WARN_ONCE(!atomic_read(&i915->runtime_pm.wakeref_count),
"RPM wakelock ref not held during HW access");
}
/**
* disable_rpm_wakeref_asserts - disable the RPM assert checks
- * @dev_priv: i915 device instance
+ * @i915: i915 device instance
*
* This function disable asserts that check if we hold an RPM wakelock
* reference, while keeping the device-not-suspended checks still enabled.
@@ -2009,14 +2009,14 @@ assert_rpm_wakelock_held(struct drm_i915_private *dev_priv)
* enable_rpm_wakeref_asserts().
*/
static inline void
-disable_rpm_wakeref_asserts(struct drm_i915_private *dev_priv)
+disable_rpm_wakeref_asserts(struct drm_i915_private *i915)
{
- atomic_inc(&dev_priv->runtime_pm.wakeref_count);
+ atomic_inc(&i915->runtime_pm.wakeref_count);
}
/**
* enable_rpm_wakeref_asserts - re-enable the RPM assert checks
- * @dev_priv: i915 device instance
+ * @i915: i915 device instance
*
* 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
@@ -2026,15 +2026,44 @@ disable_rpm_wakeref_asserts(struct drm_i915_private *dev_priv)
* disable_rpm_wakeref_asserts().
*/
static inline void
-enable_rpm_wakeref_asserts(struct drm_i915_private *dev_priv)
+enable_rpm_wakeref_asserts(struct drm_i915_private *i915)
{
- atomic_dec(&dev_priv->runtime_pm.wakeref_count);
+ atomic_dec(&i915->runtime_pm.wakeref_count);
}
-void intel_runtime_pm_get(struct drm_i915_private *dev_priv);
-bool intel_runtime_pm_get_if_in_use(struct drm_i915_private *dev_priv);
-void intel_runtime_pm_get_noresume(struct drm_i915_private *dev_priv);
-void intel_runtime_pm_put(struct drm_i915_private *dev_priv);
+void intel_runtime_pm_get(struct drm_i915_private *i915);
+bool intel_runtime_pm_get_if_in_use(struct drm_i915_private *i915);
+void intel_runtime_pm_get_noresume(struct drm_i915_private *i915);
+
+#if IS_ENABLED(CONFIG_DRM_I915_DEBUG_RPM)
+void __intel_runtime_pm_get(struct drm_i915_private *i915, bool safe);
+bool __intel_runtime_pm_get_if_in_use(struct drm_i915_private *i915, bool safe);
+void __intel_runtime_pm_get_noresume(struct drm_i915_private *i915, bool safe);
+
+#define intel_runtime_pm_get(i915) \
+ __intel_runtime_pm_get(i915, false)
+
+#define intel_runtime_pm_get_if_in_use(i915) \
+ __intel_runtime_pm_get_if_in_use(i915, false)
+
+#define intel_runtime_pm_get_noresume(i915) \
+ __intel_runtime_pm_get_noresume(i915, false)
+
+#else
+
+#define __intel_runtime_pm_get(i915, safe) \
+ intel_runtime_pm_get(i915)
+
+#define __intel_runtime_pm_get_if_in_use(i915, safe) \
+ intel_runtime_pm_get_if_in_use(i915)
+
+#define __intel_runtime_pm_get_noresume(i915, safe) \
+ intel_runtime_pm_get_noresume(i915)
+
+#endif
+
+void intel_runtime_pm_put(struct drm_i915_private *i915);
+
void intel_display_set_init_power(struct drm_i915_private *dev, bool enable);
diff --git a/drivers/gpu/drm/i915/intel_runtime_pm.c b/drivers/gpu/drm/i915/intel_runtime_pm.c
index ec772c987452..d2a44d33a6be 100644
--- a/drivers/gpu/drm/i915/intel_runtime_pm.c
+++ b/drivers/gpu/drm/i915/intel_runtime_pm.c
@@ -4054,7 +4054,7 @@ void intel_power_domains_verify_state(struct drm_i915_private *dev_priv)
/**
* intel_runtime_pm_get - grab a runtime pm reference
- * @dev_priv: i915 device instance
+ * @i915: i915 device instance
*
* This function grabs a device-level runtime pm reference (mostly used for GEM
* code to ensure the GTT or GT is on) and ensures that it is powered up.
@@ -4062,24 +4062,32 @@ void intel_power_domains_verify_state(struct drm_i915_private *dev_priv)
* Any runtime pm reference obtained by this function must have a symmetric
* call to intel_runtime_pm_put() to release the reference again.
*/
-void intel_runtime_pm_get(struct drm_i915_private *dev_priv)
+void (intel_runtime_pm_get)(struct drm_i915_private *i915)
{
- struct pci_dev *pdev = dev_priv->drm.pdev;
+ struct pci_dev *pdev = i915->drm.pdev;
struct device *kdev = &pdev->dev;
int ret;
ret = pm_runtime_get_sync(kdev);
WARN_ONCE(ret < 0, "pm_runtime_get_sync() failed: %d\n", ret);
- atomic_inc(&dev_priv->runtime_pm.wakeref_count);
- assert_rpm_wakelock_held(dev_priv);
+ atomic_inc(&i915->runtime_pm.wakeref_count);
+ assert_rpm_wakelock_held(i915);
+}
- track_intel_runtime_pm_wakeref(dev_priv);
+#if IS_ENABLED(CONFIG_DRM_I915_DEBUG_RPM)
+void __intel_runtime_pm_get(struct drm_i915_private *i915, bool safe)
+{
+ (intel_runtime_pm_get)(i915);
+
+ if (!safe)
+ track_intel_runtime_pm_wakeref(i915);
}
+#endif
/**
* intel_runtime_pm_get_if_in_use - grab a runtime pm reference if device in use
- * @dev_priv: i915 device instance
+ * @i915: i915 device instance
*
* This function grabs a device-level runtime pm reference if the device is
* already in use and ensures that it is powered up. It is illegal to try
@@ -4090,10 +4098,10 @@ void intel_runtime_pm_get(struct drm_i915_private *dev_priv)
*
* Returns: True if the wakeref was acquired, or False otherwise.
*/
-bool intel_runtime_pm_get_if_in_use(struct drm_i915_private *dev_priv)
+bool (intel_runtime_pm_get_if_in_use)(struct drm_i915_private *i915)
{
if (IS_ENABLED(CONFIG_PM)) {
- struct pci_dev *pdev = dev_priv->drm.pdev;
+ struct pci_dev *pdev = i915->drm.pdev;
struct device *kdev = &pdev->dev;
/*
@@ -4106,17 +4114,28 @@ bool intel_runtime_pm_get_if_in_use(struct drm_i915_private *dev_priv)
return false;
}
- atomic_inc(&dev_priv->runtime_pm.wakeref_count);
- assert_rpm_wakelock_held(dev_priv);
+ atomic_inc(&i915->runtime_pm.wakeref_count);
+ assert_rpm_wakelock_held(i915);
+
+ return true;
+}
+
+#if IS_ENABLED(CONFIG_DRM_I915_DEBUG_RPM)
+bool __intel_runtime_pm_get_if_in_use(struct drm_i915_private *i915, bool safe)
+{
+ if (!(intel_runtime_pm_get_if_in_use)(i915))
+ return false;
- track_intel_runtime_pm_wakeref(dev_priv);
+ if (!safe)
+ track_intel_runtime_pm_wakeref(i915);
return true;
}
+#endif
/**
* intel_runtime_pm_get_noresume - grab a runtime pm reference
- * @dev_priv: i915 device instance
+ * @i915: i915 device instance
*
* This function grabs a device-level runtime pm reference (mostly used for GEM
* code to ensure the GTT or GT is on).
@@ -4131,35 +4150,43 @@ bool intel_runtime_pm_get_if_in_use(struct drm_i915_private *dev_priv)
* Any runtime pm reference obtained by this function must have a symmetric
* call to intel_runtime_pm_put() to release the reference again.
*/
-void intel_runtime_pm_get_noresume(struct drm_i915_private *dev_priv)
+void (intel_runtime_pm_get_noresume)(struct drm_i915_private *i915)
{
- struct pci_dev *pdev = dev_priv->drm.pdev;
+ struct pci_dev *pdev = i915->drm.pdev;
struct device *kdev = &pdev->dev;
- assert_rpm_wakelock_held(dev_priv);
+ assert_rpm_wakelock_held(i915);
pm_runtime_get_noresume(kdev);
- atomic_inc(&dev_priv->runtime_pm.wakeref_count);
+ atomic_inc(&i915->runtime_pm.wakeref_count);
+}
+
+#if IS_ENABLED(CONFIG_DRM_I915_DEBUG_RPM)
+void __intel_runtime_pm_get_noresume(struct drm_i915_private *i915, bool safe)
+{
+ (intel_runtime_pm_get_noresume)(i915);
- track_intel_runtime_pm_wakeref(dev_priv);
+ if (!safe)
+ track_intel_runtime_pm_wakeref(i915);
}
+#endif
/**
* intel_runtime_pm_put - release a runtime pm reference
- * @dev_priv: i915 device instance
+ * @i915: i915 device instance
*
* This function drops the device-level runtime pm reference obtained by
* intel_runtime_pm_get() and might power down the corresponding
* hardware block right away if this is the last reference.
*/
-void intel_runtime_pm_put(struct drm_i915_private *dev_priv)
+void intel_runtime_pm_put(struct drm_i915_private *i915)
{
- struct pci_dev *pdev = dev_priv->drm.pdev;
+ struct pci_dev *pdev = i915->drm.pdev;
struct device *kdev = &pdev->dev;
- assert_rpm_wakelock_held(dev_priv);
- if (atomic_dec_and_test(&dev_priv->runtime_pm.wakeref_count))
- untrack_intel_runtime_pm_wakeref(dev_priv);
+ assert_rpm_wakelock_held(i915);
+ if (atomic_dec_and_test(&i915->runtime_pm.wakeref_count))
+ untrack_intel_runtime_pm_wakeref(i915);
pm_runtime_mark_last_busy(kdev);
pm_runtime_put_autosuspend(kdev);
@@ -4167,7 +4194,7 @@ void intel_runtime_pm_put(struct drm_i915_private *dev_priv)
/**
* intel_runtime_pm_enable - enable runtime pm
- * @dev_priv: i915 device instance
+ * @i915: i915 device instance
*
* This function enables runtime pm at the end of the driver load sequence.
*
@@ -4175,9 +4202,9 @@ void intel_runtime_pm_put(struct drm_i915_private *dev_priv)
* subordinate display power domains. That is only done on the first modeset
* using intel_display_set_init_power().
*/
-void intel_runtime_pm_enable(struct drm_i915_private *dev_priv)
+void intel_runtime_pm_enable(struct drm_i915_private *i915)
{
- struct pci_dev *pdev = dev_priv->drm.pdev;
+ struct pci_dev *pdev = i915->drm.pdev;
struct device *kdev = &pdev->dev;
pm_runtime_set_autosuspend_delay(kdev, 10000); /* 10s */
@@ -4189,7 +4216,7 @@ void intel_runtime_pm_enable(struct drm_i915_private *dev_priv)
* so the driver's own RPM reference tracking asserts also work on
* platforms without RPM support.
*/
- if (!HAS_RUNTIME_PM(dev_priv)) {
+ if (!HAS_RUNTIME_PM(i915)) {
int ret;
pm_runtime_dont_use_autosuspend(kdev);
@@ -4207,9 +4234,9 @@ void intel_runtime_pm_enable(struct drm_i915_private *dev_priv)
pm_runtime_put_autosuspend(kdev);
}
-void intel_runtime_pm_disable(struct drm_i915_private *dev_priv)
+void intel_runtime_pm_disable(struct drm_i915_private *i915)
{
- struct pci_dev *pdev = dev_priv->drm.pdev;
+ struct pci_dev *pdev = i915->drm.pdev;
struct device *kdev = &pdev->dev;
pm_runtime_dont_use_autosuspend(kdev);
@@ -4218,23 +4245,23 @@ void intel_runtime_pm_disable(struct drm_i915_private *dev_priv)
* Remove the refcount we took in intel_runtime_pm_enable() in case
* the platform doesn't support runtime PM.
*/
- if (!HAS_RUNTIME_PM(dev_priv))
+ if (!HAS_RUNTIME_PM(i915))
pm_runtime_put(kdev);
}
-void intel_runtime_pm_cleanup(struct drm_i915_private *dev_priv)
+void intel_runtime_pm_cleanup(struct drm_i915_private *i915)
{
- if (WARN(atomic_read(&dev_priv->runtime_pm.wakeref_count),
+ if (WARN(atomic_read(&i915->runtime_pm.wakeref_count),
"i915->runtime_pm.wakeref_count=%d on cleanup\n",
- atomic_read(&dev_priv->runtime_pm.wakeref_count))) {
- show_intel_runtime_pm_wakeref(dev_priv);
- atomic_set(&dev_priv->runtime_pm.wakeref_count, 0);
+ atomic_read(&i915->runtime_pm.wakeref_count))) {
+ show_intel_runtime_pm_wakeref(i915);
+ atomic_set(&i915->runtime_pm.wakeref_count, 0);
}
- untrack_intel_runtime_pm_wakeref(dev_priv);
+ untrack_intel_runtime_pm_wakeref(i915);
}
-void intel_runtime_pm_init_early(struct drm_i915_private *dev_priv)
+void intel_runtime_pm_init_early(struct drm_i915_private *i915)
{
- init_intel_runtime_pm_wakeref(dev_priv);
+ init_intel_runtime_pm_wakeref(i915);
}
--
2.18.0
More information about the Intel-gfx-trybot
mailing list