@@ -85,6 +85,47 @@ void i915_gem_suspend_late(struct drm_i915_private *i915)
8585 wbinvd_on_all_cpus ();
8686}
8787
88+ int i915_gem_freeze (struct drm_i915_private * i915 )
89+ {
90+ /* Discard all purgeable objects, let userspace recover those as
91+ * required after resuming.
92+ */
93+ i915_gem_shrink_all (i915 );
94+
95+ return 0 ;
96+ }
97+
98+ int i915_gem_freeze_late (struct drm_i915_private * i915 )
99+ {
100+ struct drm_i915_gem_object * obj ;
101+ intel_wakeref_t wakeref ;
102+
103+ /*
104+ * Called just before we write the hibernation image.
105+ *
106+ * We need to update the domain tracking to reflect that the CPU
107+ * will be accessing all the pages to create and restore from the
108+ * hibernation, and so upon restoration those pages will be in the
109+ * CPU domain.
110+ *
111+ * To make sure the hibernation image contains the latest state,
112+ * we update that state just before writing out the image.
113+ *
114+ * To try and reduce the hibernation image, we manually shrink
115+ * the objects as well, see i915_gem_freeze()
116+ */
117+
118+ with_intel_runtime_pm (& i915 -> runtime_pm , wakeref )
119+ i915_gem_shrink (i915 , -1UL , NULL , ~0 );
120+ i915_gem_drain_freed_objects (i915 );
121+
122+ wbinvd_on_all_cpus ();
123+ list_for_each_entry (obj , & i915 -> mm .shrink_list , mm .link )
124+ __start_cpu_write (obj );
125+
126+ return 0 ;
127+ }
128+
88129void i915_gem_resume (struct drm_i915_private * i915 )
89130{
90131 GEM_TRACE ("%s\n" , dev_name (i915 -> drm .dev ));
0 commit comments