drm/i915/gem: Almagamate clflushes on freeze
authorChris Wilson <chris@chris-wilson.co.uk>
Tue, 19 Jan 2021 21:43:32 +0000 (21:43 +0000)
committerChris Wilson <chris@chris-wilson.co.uk>
Wed, 20 Jan 2021 20:46:35 +0000 (20:46 +0000)
When flushing objects larger than the CPU cache it is preferrable to use
a single wbinvd() rather than overlapping clflush(). At runtime, we
avoid wbinvd() due to its system-wide latencies, but during
singlethreaded suspend, no one will observe the imposed latency and we
can opt for the faster wbinvd to clear all objects in a single hit.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210119214336.1463-2-chris@chris-wilson.co.uk
drivers/gpu/drm/i915/i915_gem.c

index c013148..d3a287b 100644 (file)
@@ -1175,19 +1175,13 @@ int i915_gem_freeze_late(struct drm_i915_private *i915)
         * the objects as well, see i915_gem_freeze()
         */
 
-       wakeref = intel_runtime_pm_get(&i915->runtime_pm);
-
-       i915_gem_shrink(i915, -1UL, NULL, ~0);
+       with_intel_runtime_pm(&i915->runtime_pm, wakeref)
+               i915_gem_shrink(i915, -1UL, NULL, ~0);
        i915_gem_drain_freed_objects(i915);
 
-       list_for_each_entry(obj, &i915->mm.shrink_list, mm.link) {
-               i915_gem_object_lock(obj, NULL);
-               drm_WARN_ON(&i915->drm,
-                           i915_gem_object_set_to_cpu_domain(obj, true));
-               i915_gem_object_unlock(obj);
-       }
-
-       intel_runtime_pm_put(&i915->runtime_pm, wakeref);
+       wbinvd_on_all_cpus();
+       list_for_each_entry(obj, &i915->mm.shrink_list, mm.link)
+               __start_cpu_write(obj);
 
        return 0;
 }