aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/i915_gem.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2010-11-23 10:26:33 -0500
committerChris Wilson <chris@chris-wilson.co.uk>2010-11-25 10:04:04 -0500
commit2021746e1d5ad1e3b51e24480c566acbb833c7c1 (patch)
tree6cefa547a20adfb6ea0c9ad267d6e9c11fdb2405 /drivers/gpu/drm/i915/i915_gem.c
parentab5793ad3ae11a5cbe2194b449e5fdd80b19f14f (diff)
drm/i915: Mark a few functions as __must_check
... to benefit from the compiler checking that we remember to handle and propagate errors. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'drivers/gpu/drm/i915/i915_gem.c')
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c37
1 files changed, 16 insertions, 21 deletions
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 939c9e34ce96..f6167c55a649 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -215,27 +215,19 @@ i915_gem_object_is_inactive(struct drm_i915_gem_object *obj)
215 return obj->gtt_space && !obj->active && obj->pin_count == 0; 215 return obj->gtt_space && !obj->active && obj->pin_count == 0;
216} 216}
217 217
218int i915_gem_do_init(struct drm_device *dev, 218void i915_gem_do_init(struct drm_device *dev,
219 unsigned long start, 219 unsigned long start,
220 unsigned long mappable_end, 220 unsigned long mappable_end,
221 unsigned long end) 221 unsigned long end)
222{ 222{
223 drm_i915_private_t *dev_priv = dev->dev_private; 223 drm_i915_private_t *dev_priv = dev->dev_private;
224 224
225 if (start >= end ||
226 (start & (PAGE_SIZE - 1)) != 0 ||
227 (end & (PAGE_SIZE - 1)) != 0) {
228 return -EINVAL;
229 }
230
231 drm_mm_init(&dev_priv->mm.gtt_space, start, 225 drm_mm_init(&dev_priv->mm.gtt_space, start,
232 end - start); 226 end - start);
233 227
234 dev_priv->mm.gtt_total = end - start; 228 dev_priv->mm.gtt_total = end - start;
235 dev_priv->mm.mappable_gtt_total = min(end, mappable_end) - start; 229 dev_priv->mm.mappable_gtt_total = min(end, mappable_end) - start;
236 dev_priv->mm.gtt_mappable_end = mappable_end; 230 dev_priv->mm.gtt_mappable_end = mappable_end;
237
238 return 0;
239} 231}
240 232
241int 233int
@@ -243,13 +235,16 @@ i915_gem_init_ioctl(struct drm_device *dev, void *data,
243 struct drm_file *file) 235 struct drm_file *file)
244{ 236{
245 struct drm_i915_gem_init *args = data; 237 struct drm_i915_gem_init *args = data;
246 int ret; 238
239 if (args->gtt_start >= args->gtt_end ||
240 (args->gtt_end | args->gtt_start) & (PAGE_SIZE - 1))
241 return -EINVAL;
247 242
248 mutex_lock(&dev->struct_mutex); 243 mutex_lock(&dev->struct_mutex);
249 ret = i915_gem_do_init(dev, args->gtt_start, args->gtt_end, args->gtt_end); 244 i915_gem_do_init(dev, args->gtt_start, args->gtt_end, args->gtt_end);
250 mutex_unlock(&dev->struct_mutex); 245 mutex_unlock(&dev->struct_mutex);
251 246
252 return ret; 247 return 0;
253} 248}
254 249
255int 250int
@@ -2949,7 +2944,7 @@ i915_gem_object_flush_cpu_write_domain(struct drm_i915_gem_object *obj)
2949 * flushes to occur. 2944 * flushes to occur.
2950 */ 2945 */
2951int 2946int
2952i915_gem_object_set_to_gtt_domain(struct drm_i915_gem_object *obj, int write) 2947i915_gem_object_set_to_gtt_domain(struct drm_i915_gem_object *obj, bool write)
2953{ 2948{
2954 uint32_t old_write_domain, old_read_domains; 2949 uint32_t old_write_domain, old_read_domains;
2955 int ret; 2950 int ret;
@@ -5177,8 +5172,8 @@ rescan:
5177 &dev_priv->mm.inactive_list, 5172 &dev_priv->mm.inactive_list,
5178 mm_list) { 5173 mm_list) {
5179 if (i915_gem_object_is_purgeable(obj)) { 5174 if (i915_gem_object_is_purgeable(obj)) {
5180 i915_gem_object_unbind(obj); 5175 if (i915_gem_object_unbind(obj) == 0 &&
5181 if (--nr_to_scan == 0) 5176 --nr_to_scan == 0)
5182 break; 5177 break;
5183 } 5178 }
5184 } 5179 }
@@ -5188,10 +5183,10 @@ rescan:
5188 list_for_each_entry_safe(obj, next, 5183 list_for_each_entry_safe(obj, next,
5189 &dev_priv->mm.inactive_list, 5184 &dev_priv->mm.inactive_list,
5190 mm_list) { 5185 mm_list) {
5191 if (nr_to_scan) { 5186 if (nr_to_scan &&
5192 i915_gem_object_unbind(obj); 5187 i915_gem_object_unbind(obj) == 0)
5193 nr_to_scan--; 5188 nr_to_scan--;
5194 } else 5189 else
5195 cnt++; 5190 cnt++;
5196 } 5191 }
5197 5192