aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/i915_gem_evict.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-10-04 02:29:23 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-10-04 02:29:23 -0400
commit612a9aab56a93533e76e3ad91642db7033e03b69 (patch)
tree8402096973f67af941f9392f7da06cca03e0b58a /drivers/gpu/drm/i915/i915_gem_evict.c
parent3a494318b14b1bc0f59d2d6ce84c505c74d82d2a (diff)
parent268d28371cd326be4dfcd7eba5917bf4b9d30c8f (diff)
Merge branch 'drm-next' of git://people.freedesktop.org/~airlied/linux
Pull drm merge (part 1) from Dave Airlie: "So first of all my tree and uapi stuff has a conflict mess, its my fault as the nouveau stuff didn't hit -next as were trying to rebase regressions out of it before we merged. Highlights: - SH mobile modesetting driver and associated helpers - some DRM core documentation - i915 modesetting rework, haswell hdmi, haswell and vlv fixes, write combined pte writing, ilk rc6 support, - nouveau: major driver rework into a hw core driver, makes features like SLI a lot saner to implement, - psb: add eDP/DP support for Cedarview - radeon: 2 layer page tables, async VM pte updates, better PLL selection for > 2 screens, better ACPI interactions The rest is general grab bag of fixes. So why part 1? well I have the exynos pull req which came in a bit late but was waiting for me to do something they shouldn't have and it looks fairly safe, and David Howells has some more header cleanups he'd like me to pull, that seem like a good idea, but I'd like to get this merge out of the way so -next dosen't get blocked." Tons of conflicts mostly due to silly include line changes, but mostly mindless. A few other small semantic conflicts too, noted from Dave's pre-merged branch. * 'drm-next' of git://people.freedesktop.org/~airlied/linux: (447 commits) drm/nv98/crypt: fix fuc build with latest envyas drm/nouveau/devinit: fixup various issues with subdev ctor/init ordering drm/nv41/vm: fix and enable use of "real" pciegart drm/nv44/vm: fix and enable use of "real" pciegart drm/nv04/dmaobj: fixup vm target handling in preparation for nv4x pcie drm/nouveau: store supported dma mask in vmmgr drm/nvc0/ibus: initial implementation of subdev drm/nouveau/therm: add support for fan-control modes drm/nouveau/hwmon: rename pwm0* to pmw1* to follow hwmon's rules drm/nouveau/therm: calculate the pwm divisor on nv50+ drm/nouveau/fan: rewrite the fan tachometer driver to get more precision, faster drm/nouveau/therm: move thermal-related functions to the therm subdev drm/nouveau/bios: parse the pwm divisor from the perf table drm/nouveau/therm: use the EXTDEV table to detect i2c monitoring devices drm/nouveau/therm: rework thermal table parsing drm/nouveau/gpio: expose the PWM/TOGGLE parameter found in the gpio vbios table drm/nouveau: fix pm initialization order drm/nouveau/bios: check that fixed tvdac gpio data is valid before using it drm/nouveau: log channel debug/error messages from client object rather than drm client drm/nouveau: have drm debugging macros build on top of core macros ...
Diffstat (limited to 'drivers/gpu/drm/i915/i915_gem_evict.c')
-rw-r--r--drivers/gpu/drm/i915/i915_gem_evict.c44
1 files changed, 13 insertions, 31 deletions
diff --git a/drivers/gpu/drm/i915/i915_gem_evict.c b/drivers/gpu/drm/i915/i915_gem_evict.c
index fd408995a783..776a3225184c 100644
--- a/drivers/gpu/drm/i915/i915_gem_evict.c
+++ b/drivers/gpu/drm/i915/i915_gem_evict.c
@@ -43,7 +43,8 @@ mark_free(struct drm_i915_gem_object *obj, struct list_head *unwind)
43 43
44int 44int
45i915_gem_evict_something(struct drm_device *dev, int min_size, 45i915_gem_evict_something(struct drm_device *dev, int min_size,
46 unsigned alignment, bool mappable) 46 unsigned alignment, unsigned cache_level,
47 bool mappable, bool nonblocking)
47{ 48{
48 drm_i915_private_t *dev_priv = dev->dev_private; 49 drm_i915_private_t *dev_priv = dev->dev_private;
49 struct list_head eviction_list, unwind_list; 50 struct list_head eviction_list, unwind_list;
@@ -78,11 +79,11 @@ i915_gem_evict_something(struct drm_device *dev, int min_size,
78 INIT_LIST_HEAD(&unwind_list); 79 INIT_LIST_HEAD(&unwind_list);
79 if (mappable) 80 if (mappable)
80 drm_mm_init_scan_with_range(&dev_priv->mm.gtt_space, 81 drm_mm_init_scan_with_range(&dev_priv->mm.gtt_space,
81 min_size, alignment, 0, 82 min_size, alignment, cache_level,
82 0, dev_priv->mm.gtt_mappable_end); 83 0, dev_priv->mm.gtt_mappable_end);
83 else 84 else
84 drm_mm_init_scan(&dev_priv->mm.gtt_space, 85 drm_mm_init_scan(&dev_priv->mm.gtt_space,
85 min_size, alignment, 0); 86 min_size, alignment, cache_level);
86 87
87 /* First see if there is a large enough contiguous idle region... */ 88 /* First see if there is a large enough contiguous idle region... */
88 list_for_each_entry(obj, &dev_priv->mm.inactive_list, mm_list) { 89 list_for_each_entry(obj, &dev_priv->mm.inactive_list, mm_list) {
@@ -90,29 +91,16 @@ i915_gem_evict_something(struct drm_device *dev, int min_size,
90 goto found; 91 goto found;
91 } 92 }
92 93
93 /* Now merge in the soon-to-be-expired objects... */ 94 if (nonblocking)
94 list_for_each_entry(obj, &dev_priv->mm.active_list, mm_list) { 95 goto none;
95 /* Does the object require an outstanding flush? */
96 if (obj->base.write_domain)
97 continue;
98
99 if (mark_free(obj, &unwind_list))
100 goto found;
101 }
102 96
103 /* Finally add anything with a pending flush (in order of retirement) */ 97 /* Now merge in the soon-to-be-expired objects... */
104 list_for_each_entry(obj, &dev_priv->mm.flushing_list, mm_list) {
105 if (mark_free(obj, &unwind_list))
106 goto found;
107 }
108 list_for_each_entry(obj, &dev_priv->mm.active_list, mm_list) { 98 list_for_each_entry(obj, &dev_priv->mm.active_list, mm_list) {
109 if (!obj->base.write_domain)
110 continue;
111
112 if (mark_free(obj, &unwind_list)) 99 if (mark_free(obj, &unwind_list))
113 goto found; 100 goto found;
114 } 101 }
115 102
103none:
116 /* Nothing found, clean up and bail out! */ 104 /* Nothing found, clean up and bail out! */
117 while (!list_empty(&unwind_list)) { 105 while (!list_empty(&unwind_list)) {
118 obj = list_first_entry(&unwind_list, 106 obj = list_first_entry(&unwind_list,
@@ -163,7 +151,7 @@ found:
163} 151}
164 152
165int 153int
166i915_gem_evict_everything(struct drm_device *dev, bool purgeable_only) 154i915_gem_evict_everything(struct drm_device *dev)
167{ 155{
168 drm_i915_private_t *dev_priv = dev->dev_private; 156 drm_i915_private_t *dev_priv = dev->dev_private;
169 struct drm_i915_gem_object *obj, *next; 157 struct drm_i915_gem_object *obj, *next;
@@ -171,12 +159,11 @@ i915_gem_evict_everything(struct drm_device *dev, bool purgeable_only)
171 int ret; 159 int ret;
172 160
173 lists_empty = (list_empty(&dev_priv->mm.inactive_list) && 161 lists_empty = (list_empty(&dev_priv->mm.inactive_list) &&
174 list_empty(&dev_priv->mm.flushing_list) &&
175 list_empty(&dev_priv->mm.active_list)); 162 list_empty(&dev_priv->mm.active_list));
176 if (lists_empty) 163 if (lists_empty)
177 return -ENOSPC; 164 return -ENOSPC;
178 165
179 trace_i915_gem_evict_everything(dev, purgeable_only); 166 trace_i915_gem_evict_everything(dev);
180 167
181 /* The gpu_idle will flush everything in the write domain to the 168 /* The gpu_idle will flush everything in the write domain to the
182 * active list. Then we must move everything off the active list 169 * active list. Then we must move everything off the active list
@@ -188,16 +175,11 @@ i915_gem_evict_everything(struct drm_device *dev, bool purgeable_only)
188 175
189 i915_gem_retire_requests(dev); 176 i915_gem_retire_requests(dev);
190 177
191 BUG_ON(!list_empty(&dev_priv->mm.flushing_list));
192
193 /* Having flushed everything, unbind() should never raise an error */ 178 /* Having flushed everything, unbind() should never raise an error */
194 list_for_each_entry_safe(obj, next, 179 list_for_each_entry_safe(obj, next,
195 &dev_priv->mm.inactive_list, mm_list) { 180 &dev_priv->mm.inactive_list, mm_list)
196 if (!purgeable_only || obj->madv != I915_MADV_WILLNEED) { 181 if (obj->pin_count == 0)
197 if (obj->pin_count == 0) 182 WARN_ON(i915_gem_object_unbind(obj));
198 WARN_ON(i915_gem_object_unbind(obj));
199 }
200 }
201 183
202 return 0; 184 return 0;
203} 185}