Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/i915/gem: Move freeze/freeze_late next to suspend/suspend_late

Push the hibernate pm routines next to the suspend pm routines in
gem/i915_gem_pm.c. This has the side-effect of putting the wbinvd()
abusers next to each other.

Reported-by: Guenter Roeck <linux@roeck-us.net>
Fixes: 30d2bfd09383 ("drm/i915/gem: Almagamate clflushes on freeze")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Matthew Auld <matthew.auld@intel.com>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210123145543.10533-1-chris@chris-wilson.co.uk
(cherry picked from commit 6d8f02207420e76db693a00ccb44792474e297fc)
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>

authored by

Chris Wilson and committed by
Rodrigo Vivi
29d88083 54fd4b9a

+46 -43
+41
drivers/gpu/drm/i915/gem/i915_gem_pm.c
··· 85 85 wbinvd_on_all_cpus(); 86 86 } 87 87 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 + 88 129 void i915_gem_resume(struct drm_i915_private *i915) 89 130 { 90 131 GEM_TRACE("%s\n", dev_name(i915->drm.dev));
+3
drivers/gpu/drm/i915/gem/i915_gem_pm.h
··· 19 19 void i915_gem_suspend(struct drm_i915_private *i915); 20 20 void i915_gem_suspend_late(struct drm_i915_private *i915); 21 21 22 + int i915_gem_freeze(struct drm_i915_private *i915); 23 + int i915_gem_freeze_late(struct drm_i915_private *i915); 24 + 22 25 #endif /* __I915_GEM_PM_H__ */
+1
drivers/gpu/drm/i915/i915_drv.c
··· 65 65 #include "gem/i915_gem_context.h" 66 66 #include "gem/i915_gem_ioctls.h" 67 67 #include "gem/i915_gem_mman.h" 68 + #include "gem/i915_gem_pm.h" 68 69 #include "gt/intel_gt.h" 69 70 #include "gt/intel_gt_pm.h" 70 71 #include "gt/intel_rc6.h"
-2
drivers/gpu/drm/i915/i915_drv.h
··· 1800 1800 void i915_gem_cleanup_userptr(struct drm_i915_private *dev_priv); 1801 1801 void i915_gem_init_early(struct drm_i915_private *dev_priv); 1802 1802 void i915_gem_cleanup_early(struct drm_i915_private *dev_priv); 1803 - int i915_gem_freeze(struct drm_i915_private *dev_priv); 1804 - int i915_gem_freeze_late(struct drm_i915_private *dev_priv); 1805 1803 1806 1804 struct intel_memory_region *i915_gem_shmem_setup(struct drm_i915_private *i915); 1807 1805
-41
drivers/gpu/drm/i915/i915_gem.c
··· 1145 1145 drm_WARN_ON(&dev_priv->drm, dev_priv->mm.shrink_count); 1146 1146 } 1147 1147 1148 - int i915_gem_freeze(struct drm_i915_private *dev_priv) 1149 - { 1150 - /* Discard all purgeable objects, let userspace recover those as 1151 - * required after resuming. 1152 - */ 1153 - i915_gem_shrink_all(dev_priv); 1154 - 1155 - return 0; 1156 - } 1157 - 1158 - int i915_gem_freeze_late(struct drm_i915_private *i915) 1159 - { 1160 - struct drm_i915_gem_object *obj; 1161 - intel_wakeref_t wakeref; 1162 - 1163 - /* 1164 - * Called just before we write the hibernation image. 1165 - * 1166 - * We need to update the domain tracking to reflect that the CPU 1167 - * will be accessing all the pages to create and restore from the 1168 - * hibernation, and so upon restoration those pages will be in the 1169 - * CPU domain. 1170 - * 1171 - * To make sure the hibernation image contains the latest state, 1172 - * we update that state just before writing out the image. 1173 - * 1174 - * To try and reduce the hibernation image, we manually shrink 1175 - * the objects as well, see i915_gem_freeze() 1176 - */ 1177 - 1178 - with_intel_runtime_pm(&i915->runtime_pm, wakeref) 1179 - i915_gem_shrink(i915, -1UL, NULL, ~0); 1180 - i915_gem_drain_freed_objects(i915); 1181 - 1182 - wbinvd_on_all_cpus(); 1183 - list_for_each_entry(obj, &i915->mm.shrink_list, mm.link) 1184 - __start_cpu_write(obj); 1185 - 1186 - return 0; 1187 - } 1188 - 1189 1148 int i915_gem_open(struct drm_i915_private *i915, struct drm_file *file) 1190 1149 { 1191 1150 struct drm_i915_file_private *file_priv;
+1
drivers/gpu/drm/i915/selftests/i915_gem.c
··· 8 8 9 9 #include "gem/selftests/igt_gem_utils.h" 10 10 #include "gem/selftests/mock_context.h" 11 + #include "gem/i915_gem_pm.h" 11 12 #include "gt/intel_gt.h" 12 13 #include "gt/intel_gt_pm.h" 13 14