]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/i915: Compartmentalize i915_gem_suspend/restore_gtt_mappings
authorTvrtko Ursulin <tvrtko.ursulin@intel.com>
Fri, 21 Jun 2019 07:08:00 +0000 (08:08 +0100)
committerTvrtko Ursulin <tvrtko.ursulin@intel.com>
Fri, 21 Jun 2019 12:48:37 +0000 (13:48 +0100)
Having made start to better code compartmentalization by introducing
struct intel_gt, continue the theme elsewhere in code by making functions
take parameters take what logically makes most sense for them instead of
the global struct drm_i915_private.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190621070811.7006-22-tvrtko.ursulin@linux.intel.com
drivers/gpu/drm/i915/i915_gem_gtt.c

index 1467b65c9a100dabb2494e9c3059c20ef812f460..b38af1df1fe92b8ab6e2a0e44beda0a86454ffdd 100644 (file)
@@ -2273,23 +2273,28 @@ static bool needs_idle_maps(struct drm_i915_private *dev_priv)
        return IS_GEN(dev_priv, 5) && IS_MOBILE(dev_priv) && intel_vtd_active();
 }
 
-void i915_gem_suspend_gtt_mappings(struct drm_i915_private *dev_priv)
+static void ggtt_suspend_mappings(struct i915_ggtt *ggtt)
 {
-       struct i915_ggtt *ggtt = &dev_priv->ggtt;
+       struct drm_i915_private *i915 = ggtt->vm.i915;
 
        /* Don't bother messing with faults pre GEN6 as we have little
         * documentation supporting that it's a good idea.
         */
-       if (INTEL_GEN(dev_priv) < 6)
+       if (INTEL_GEN(i915) < 6)
                return;
 
-       intel_gt_check_and_clear_faults(&dev_priv->gt);
+       intel_gt_check_and_clear_faults(ggtt->vm.gt);
 
        ggtt->vm.clear_range(&ggtt->vm, 0, ggtt->vm.total);
 
        ggtt->invalidate(ggtt);
 }
 
+void i915_gem_suspend_gtt_mappings(struct drm_i915_private *i915)
+{
+       ggtt_suspend_mappings(&i915->ggtt);
+}
+
 int i915_gem_gtt_prepare_pages(struct drm_i915_gem_object *obj,
                               struct sg_table *pages)
 {
@@ -3624,12 +3629,11 @@ void i915_ggtt_disable_guc(struct drm_i915_private *i915)
        ggtt->invalidate(ggtt);
 }
 
-void i915_gem_restore_gtt_mappings(struct drm_i915_private *dev_priv)
+static void ggtt_restore_mappings(struct i915_ggtt *ggtt)
 {
-       struct i915_ggtt *ggtt = &dev_priv->ggtt;
        struct i915_vma *vma, *vn;
 
-       intel_gt_check_and_clear_faults(&dev_priv->gt);
+       intel_gt_check_and_clear_faults(ggtt->vm.gt);
 
        mutex_lock(&ggtt->vm.mutex);
 
@@ -3666,12 +3670,17 @@ lock:
        ggtt->invalidate(ggtt);
 
        mutex_unlock(&ggtt->vm.mutex);
+}
+
+void i915_gem_restore_gtt_mappings(struct drm_i915_private *i915)
+{
+       ggtt_restore_mappings(&i915->ggtt);
 
-       if (INTEL_GEN(dev_priv) >= 8) {
-               struct intel_ppat *ppat = &dev_priv->ppat;
+       if (INTEL_GEN(i915) >= 8) {
+               struct intel_ppat *ppat = &i915->ppat;
 
                bitmap_set(ppat->dirty, 0, ppat->max_entries);
-               dev_priv->ppat.update_hw(dev_priv);
+               i915->ppat.update_hw(i915);
                return;
        }
 }