drm/i915: Return error in i915_gem_set_to_gtt_domain if we're not in the GTT.

It's only for flushing caches appropriately for GTT access, not for actually
getting it there. Prevents potential smashing of cpu read/write domains on
unbound objects.

Signed-off-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Dave Airlie <airlied@redhat.com>

authored by Eric Anholt and committed by Dave Airlie 02354392 ac94a962

+11
+11
drivers/gpu/drm/i915/i915_gem.c
··· 435 435 #endif 436 436 if (read_domains & I915_GEM_DOMAIN_GTT) { 437 437 ret = i915_gem_object_set_to_gtt_domain(obj, write_domain != 0); 438 + 439 + /* Silently promote "you're not bound, there was nothing to do" 440 + * to success, since the client was just asking us to 441 + * make sure everything was done. 442 + */ 443 + if (ret == -EINVAL) 444 + ret = 0; 438 445 } else { 439 446 ret = i915_gem_object_set_to_cpu_domain(obj, write_domain != 0); 440 447 } ··· 1310 1303 { 1311 1304 struct drm_i915_gem_object *obj_priv = obj->driver_private; 1312 1305 int ret; 1306 + 1307 + /* Not valid to be called on unbound objects. */ 1308 + if (obj_priv->gtt_space == NULL) 1309 + return -EINVAL; 1313 1310 1314 1311 i915_gem_object_flush_gpu_write_domain(obj); 1315 1312 /* Wait on any GPU rendering and flushing to occur. */