We only used the RPM sequence checking inside the lowlevel GTT
accessors, when we had to rely on callers taking the wakeref on our
behalf. Now that we take the RPM wakeref inside the GTT management
routines themselves, we can forgo the sanitycheck of the callers.

Signed-off-by: Chris Wilson <ch...@chris-wilson.co.uk>
Cc: Imre Deak <imre.d...@intel.com>
---
 drivers/gpu/drm/i915/i915_drv.h         |  1 -
 drivers/gpu/drm/i915/i915_gem_gtt.c     | 55 +--------------------------------
 drivers/gpu/drm/i915/intel_drv.h        | 17 ----------
 drivers/gpu/drm/i915/intel_pm.c         |  1 -
 drivers/gpu/drm/i915/intel_runtime_pm.c |  3 +-
 5 files changed, 2 insertions(+), 75 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index b3c00cc6ab32..7c686145861b 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1690,7 +1690,6 @@ struct skl_wm_level {
  */
 struct i915_runtime_pm {
        atomic_t wakeref_count;
-       atomic_t atomic_seq;
        bool suspended;
        bool irqs_enabled;
 };
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c 
b/drivers/gpu/drm/i915/i915_gem_gtt.c
index c6e743f96e6d..430ed500054c 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -2323,16 +2323,11 @@ static void gen8_ggtt_insert_page(struct 
i915_address_space *vm,
        gen8_pte_t __iomem *pte =
                (gen8_pte_t __iomem *)dev_priv->ggtt.gsm +
                (offset >> PAGE_SHIFT);
-       int rpm_atomic_seq;
-
-       rpm_atomic_seq = assert_rpm_atomic_begin(dev_priv);
 
        gen8_set_pte(pte, gen8_pte_encode(addr, level, true));
 
        I915_WRITE(GFX_FLSH_CNTL_GEN6, GFX_FLSH_CNTL_EN);
        POSTING_READ(GFX_FLSH_CNTL_GEN6);
-
-       assert_rpm_atomic_end(dev_priv, rpm_atomic_seq);
 }
 
 static void gen8_ggtt_insert_entries(struct i915_address_space *vm,
@@ -2346,11 +2341,8 @@ static void gen8_ggtt_insert_entries(struct 
i915_address_space *vm,
        gen8_pte_t __iomem *gtt_entries;
        gen8_pte_t gtt_entry;
        dma_addr_t addr;
-       int rpm_atomic_seq;
        int i = 0;
 
-       rpm_atomic_seq = assert_rpm_atomic_begin(dev_priv);
-
        gtt_entries = (gen8_pte_t __iomem *)ggtt->gsm + (start >> PAGE_SHIFT);
 
        for_each_sgt_dma(addr, sgt_iter, st) {
@@ -2374,8 +2366,6 @@ static void gen8_ggtt_insert_entries(struct 
i915_address_space *vm,
         */
        I915_WRITE(GFX_FLSH_CNTL_GEN6, GFX_FLSH_CNTL_EN);
        POSTING_READ(GFX_FLSH_CNTL_GEN6);
-
-       assert_rpm_atomic_end(dev_priv, rpm_atomic_seq);
 }
 
 struct insert_entries {
@@ -2414,16 +2404,11 @@ static void gen6_ggtt_insert_page(struct 
i915_address_space *vm,
        gen6_pte_t __iomem *pte =
                (gen6_pte_t __iomem *)dev_priv->ggtt.gsm +
                (offset >> PAGE_SHIFT);
-       int rpm_atomic_seq;
-
-       rpm_atomic_seq = assert_rpm_atomic_begin(dev_priv);
 
        iowrite32(vm->pte_encode(addr, level, true, flags), pte);
 
        I915_WRITE(GFX_FLSH_CNTL_GEN6, GFX_FLSH_CNTL_EN);
        POSTING_READ(GFX_FLSH_CNTL_GEN6);
-
-       assert_rpm_atomic_end(dev_priv, rpm_atomic_seq);
 }
 
 /*
@@ -2443,11 +2428,8 @@ static void gen6_ggtt_insert_entries(struct 
i915_address_space *vm,
        gen6_pte_t __iomem *gtt_entries;
        gen6_pte_t gtt_entry;
        dma_addr_t addr;
-       int rpm_atomic_seq;
        int i = 0;
 
-       rpm_atomic_seq = assert_rpm_atomic_begin(dev_priv);
-
        gtt_entries = (gen6_pte_t __iomem *)ggtt->gsm + (start >> PAGE_SHIFT);
 
        for_each_sgt_dma(addr, sgt_iter, st) {
@@ -2470,8 +2452,6 @@ static void gen6_ggtt_insert_entries(struct 
i915_address_space *vm,
         */
        I915_WRITE(GFX_FLSH_CNTL_GEN6, GFX_FLSH_CNTL_EN);
        POSTING_READ(GFX_FLSH_CNTL_GEN6);
-
-       assert_rpm_atomic_end(dev_priv, rpm_atomic_seq);
 }
 
 static void nop_clear_range(struct i915_address_space *vm,
@@ -2486,7 +2466,6 @@ static void gen8_ggtt_clear_range(struct 
i915_address_space *vm,
                                  uint64_t length,
                                  bool use_scratch)
 {
-       struct drm_i915_private *dev_priv = to_i915(vm->dev);
        struct i915_ggtt *ggtt = i915_vm_to_ggtt(vm);
        unsigned first_entry = start >> PAGE_SHIFT;
        unsigned num_entries = length >> PAGE_SHIFT;
@@ -2494,9 +2473,6 @@ static void gen8_ggtt_clear_range(struct 
i915_address_space *vm,
                (gen8_pte_t __iomem *)ggtt->gsm + first_entry;
        const int max_entries = ggtt_total_entries(ggtt) - first_entry;
        int i;
-       int rpm_atomic_seq;
-
-       rpm_atomic_seq = assert_rpm_atomic_begin(dev_priv);
 
        if (WARN(num_entries > max_entries,
                 "First entry = %d; Num entries = %d (max=%d)\n",
@@ -2509,8 +2485,6 @@ static void gen8_ggtt_clear_range(struct 
i915_address_space *vm,
        for (i = 0; i < num_entries; i++)
                gen8_set_pte(&gtt_base[i], scratch_pte);
        readl(gtt_base);
-
-       assert_rpm_atomic_end(dev_priv, rpm_atomic_seq);
 }
 
 static void gen6_ggtt_clear_range(struct i915_address_space *vm,
@@ -2518,7 +2492,6 @@ static void gen6_ggtt_clear_range(struct 
i915_address_space *vm,
                                  uint64_t length,
                                  bool use_scratch)
 {
-       struct drm_i915_private *dev_priv = to_i915(vm->dev);
        struct i915_ggtt *ggtt = i915_vm_to_ggtt(vm);
        unsigned first_entry = start >> PAGE_SHIFT;
        unsigned num_entries = length >> PAGE_SHIFT;
@@ -2526,9 +2499,6 @@ static void gen6_ggtt_clear_range(struct 
i915_address_space *vm,
                (gen6_pte_t __iomem *)ggtt->gsm + first_entry;
        const int max_entries = ggtt_total_entries(ggtt) - first_entry;
        int i;
-       int rpm_atomic_seq;
-
-       rpm_atomic_seq = assert_rpm_atomic_begin(dev_priv);
 
        if (WARN(num_entries > max_entries,
                 "First entry = %d; Num entries = %d (max=%d)\n",
@@ -2541,8 +2511,6 @@ static void gen6_ggtt_clear_range(struct 
i915_address_space *vm,
        for (i = 0; i < num_entries; i++)
                iowrite32(scratch_pte, &gtt_base[i]);
        readl(gtt_base);
-
-       assert_rpm_atomic_end(dev_priv, rpm_atomic_seq);
 }
 
 static void i915_ggtt_insert_page(struct i915_address_space *vm,
@@ -2551,16 +2519,10 @@ static void i915_ggtt_insert_page(struct 
i915_address_space *vm,
                                  enum i915_cache_level cache_level,
                                  u32 unused)
 {
-       struct drm_i915_private *dev_priv = to_i915(vm->dev);
        unsigned int flags = (cache_level == I915_CACHE_NONE) ?
                AGP_USER_MEMORY : AGP_USER_CACHED_MEMORY;
-       int rpm_atomic_seq;
-
-       rpm_atomic_seq = assert_rpm_atomic_begin(dev_priv);
 
        intel_gtt_insert_page(addr, offset >> PAGE_SHIFT, flags);
-
-       assert_rpm_atomic_end(dev_priv, rpm_atomic_seq);
 }
 
 static void i915_ggtt_insert_entries(struct i915_address_space *vm,
@@ -2568,17 +2530,11 @@ static void i915_ggtt_insert_entries(struct 
i915_address_space *vm,
                                     uint64_t start,
                                     enum i915_cache_level cache_level, u32 
unused)
 {
-       struct drm_i915_private *dev_priv = to_i915(vm->dev);
        unsigned int flags = (cache_level == I915_CACHE_NONE) ?
                AGP_USER_MEMORY : AGP_USER_CACHED_MEMORY;
-       int rpm_atomic_seq;
-
-       rpm_atomic_seq = assert_rpm_atomic_begin(dev_priv);
 
        intel_gtt_insert_sg_entries(pages, start >> PAGE_SHIFT, flags);
 
-       assert_rpm_atomic_end(dev_priv, rpm_atomic_seq);
-
 }
 
 static void i915_ggtt_clear_range(struct i915_address_space *vm,
@@ -2586,16 +2542,7 @@ static void i915_ggtt_clear_range(struct 
i915_address_space *vm,
                                  uint64_t length,
                                  bool unused)
 {
-       struct drm_i915_private *dev_priv = to_i915(vm->dev);
-       unsigned first_entry = start >> PAGE_SHIFT;
-       unsigned num_entries = length >> PAGE_SHIFT;
-       int rpm_atomic_seq;
-
-       rpm_atomic_seq = assert_rpm_atomic_begin(dev_priv);
-
-       intel_gtt_clear_range(first_entry, num_entries);
-
-       assert_rpm_atomic_end(dev_priv, rpm_atomic_seq);
+       intel_gtt_clear_range(start >> PAGE_SHIFT, length >> PAGE_SHIFT);
 }
 
 static int ggtt_bind_vma(struct i915_vma *vma,
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 07b93f23b8bf..083c7a3746bd 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -1648,23 +1648,6 @@ assert_rpm_wakelock_held(struct drm_i915_private 
*dev_priv)
                DRM_DEBUG_DRIVER("RPM wakelock ref not held during HW access");
 }
 
-static inline int
-assert_rpm_atomic_begin(struct drm_i915_private *dev_priv)
-{
-       int seq = atomic_read(&dev_priv->pm.atomic_seq);
-
-       assert_rpm_wakelock_held(dev_priv);
-
-       return seq;
-}
-
-static inline void
-assert_rpm_atomic_end(struct drm_i915_private *dev_priv, int begin_seq)
-{
-       WARN_ONCE(atomic_read(&dev_priv->pm.atomic_seq) != begin_seq,
-                 "HW access outside of RPM atomic section\n");
-}
-
 /**
  * disable_rpm_wakeref_asserts - disable the RPM assert checks
  * @dev_priv: i915 device instance
diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
index 15f21c6eb4f4..e7660537ccea 100644
--- a/drivers/gpu/drm/i915/intel_pm.c
+++ b/drivers/gpu/drm/i915/intel_pm.c
@@ -8040,5 +8040,4 @@ void intel_pm_setup(struct drm_device *dev)
 
        dev_priv->pm.suspended = false;
        atomic_set(&dev_priv->pm.wakeref_count, 0);
-       atomic_set(&dev_priv->pm.atomic_seq, 0);
 }
diff --git a/drivers/gpu/drm/i915/intel_runtime_pm.c 
b/drivers/gpu/drm/i915/intel_runtime_pm.c
index 6c11168facd6..ca0500abcf34 100644
--- a/drivers/gpu/drm/i915/intel_runtime_pm.c
+++ b/drivers/gpu/drm/i915/intel_runtime_pm.c
@@ -2738,8 +2738,7 @@ void intel_runtime_pm_put(struct drm_i915_private 
*dev_priv)
        struct device *kdev = &pdev->dev;
 
        assert_rpm_wakelock_held(dev_priv);
-       if (atomic_dec_and_test(&dev_priv->pm.wakeref_count))
-               atomic_inc(&dev_priv->pm.atomic_seq);
+       atomic_dec(&dev_priv->pm.wakeref_count);
 
        pm_runtime_mark_last_busy(kdev);
        pm_runtime_put_autosuspend(kdev);
-- 
2.9.3

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reply via email to