diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2012-11-20 05:45:17 -0500 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2012-11-21 11:45:04 -0500 |
commit | c9839303d186d6270f570ff3c5f56c2327958086 (patch) | |
tree | c3d97e0bbf8f8bb3eba541026f2bebaffb0e2710 /drivers/gpu | |
parent | fbdda6fb5ee5da401af42226878880069a6b8615 (diff) |
drm/i915: Pin the object whilst faulting it in
In order to prevent reaping of the object whilst setting it up to
handle the pagefault, we need to mark it as pinned. This has the nice
side-effect of eliminating some special cases from the pagefault handler
as well!
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers/gpu')
-rw-r--r-- | drivers/gpu/drm/i915/i915_gem.c | 29 |
1 files changed, 9 insertions, 20 deletions
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 643b7f6368a0..e9c80065805b 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c | |||
@@ -1345,30 +1345,17 @@ int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf) | |||
1345 | trace_i915_gem_object_fault(obj, page_offset, true, write); | 1345 | trace_i915_gem_object_fault(obj, page_offset, true, write); |
1346 | 1346 | ||
1347 | /* Now bind it into the GTT if needed */ | 1347 | /* Now bind it into the GTT if needed */ |
1348 | if (!obj->map_and_fenceable) { | 1348 | ret = i915_gem_object_pin(obj, 0, true, false); |
1349 | ret = i915_gem_object_unbind(obj); | 1349 | if (ret) |
1350 | if (ret) | 1350 | goto unlock; |
1351 | goto unlock; | ||
1352 | } | ||
1353 | if (!obj->gtt_space) { | ||
1354 | ret = i915_gem_object_bind_to_gtt(obj, 0, true, false); | ||
1355 | if (ret) | ||
1356 | goto unlock; | ||
1357 | |||
1358 | ret = i915_gem_object_set_to_gtt_domain(obj, write); | ||
1359 | if (ret) | ||
1360 | goto unlock; | ||
1361 | } | ||
1362 | 1351 | ||
1363 | if (!obj->has_global_gtt_mapping) | 1352 | ret = i915_gem_object_set_to_gtt_domain(obj, write); |
1364 | i915_gem_gtt_bind_object(obj, obj->cache_level); | 1353 | if (ret) |
1354 | goto unpin; | ||
1365 | 1355 | ||
1366 | ret = i915_gem_object_get_fence(obj); | 1356 | ret = i915_gem_object_get_fence(obj); |
1367 | if (ret) | 1357 | if (ret) |
1368 | goto unlock; | 1358 | goto unpin; |
1369 | |||
1370 | if (i915_gem_object_is_inactive(obj)) | ||
1371 | list_move_tail(&obj->mm_list, &dev_priv->mm.inactive_list); | ||
1372 | 1359 | ||
1373 | obj->fault_mappable = true; | 1360 | obj->fault_mappable = true; |
1374 | 1361 | ||
@@ -1377,6 +1364,8 @@ int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf) | |||
1377 | 1364 | ||
1378 | /* Finally, remap it using the new GTT offset */ | 1365 | /* Finally, remap it using the new GTT offset */ |
1379 | ret = vm_insert_pfn(vma, (unsigned long)vmf->virtual_address, pfn); | 1366 | ret = vm_insert_pfn(vma, (unsigned long)vmf->virtual_address, pfn); |
1367 | unpin: | ||
1368 | i915_gem_object_unpin(obj); | ||
1380 | unlock: | 1369 | unlock: |
1381 | mutex_unlock(&dev->struct_mutex); | 1370 | mutex_unlock(&dev->struct_mutex); |
1382 | out: | 1371 | out: |