Rev 3480 | Rev 4104 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3480 | Rev 3746 | ||
---|---|---|---|
Line 24... | Line 24... | ||
24 | * Eric Anholt |
24 | * Eric Anholt |
25 | * Chris Wilson |
25 | * Chris Wilson |
26 | * |
26 | * |
27 | */ |
27 | */ |
Line 28... | Line -... | ||
28 | - | ||
29 | #define iowrite32(v, addr) writel((v), (addr)) |
- | |
30 | 28 | ||
31 | #include |
29 | #include |
32 | #include |
30 | #include |
33 | #include "i915_drv.h" |
31 | #include "i915_drv.h" |
34 | #include "i915_trace.h" |
32 | #include "i915_trace.h" |
Line 382... | Line 380... | ||
382 | 380 | ||
383 | return 0; |
381 | return 0; |
Line 384... | Line 382... | ||
384 | } |
382 | } |
385 | 383 | ||
386 | static int |
- | |
387 | i915_gem_execbuffer_relocate(struct drm_device *dev, |
384 | static int |
388 | struct eb_objects *eb) |
385 | i915_gem_execbuffer_relocate(struct eb_objects *eb) |
389 | { |
386 | { |
Line 390... | Line 387... | ||
390 | struct drm_i915_gem_object *obj; |
387 | struct drm_i915_gem_object *obj; |
Line 506... | Line 503... | ||
506 | entry->flags &= ~(__EXEC_OBJECT_HAS_FENCE | __EXEC_OBJECT_HAS_PIN); |
503 | entry->flags &= ~(__EXEC_OBJECT_HAS_FENCE | __EXEC_OBJECT_HAS_PIN); |
507 | } |
504 | } |
Line 508... | Line 505... | ||
508 | 505 | ||
509 | static int |
506 | static int |
510 | i915_gem_execbuffer_reserve(struct intel_ring_buffer *ring, |
- | |
511 | struct drm_file *file, |
507 | i915_gem_execbuffer_reserve(struct intel_ring_buffer *ring, |
512 | struct list_head *objects, |
508 | struct list_head *objects, |
513 | bool *need_relocs) |
509 | bool *need_relocs) |
514 | { |
510 | { |
515 | struct drm_i915_gem_object *obj; |
511 | struct drm_i915_gem_object *obj; |
Line 699... | Line 695... | ||
699 | ret = eb_lookup_objects(eb, exec, args, file); |
695 | ret = eb_lookup_objects(eb, exec, args, file); |
700 | if (ret) |
696 | if (ret) |
701 | goto err; |
697 | goto err; |
Line 702... | Line 698... | ||
702 | 698 | ||
703 | need_relocs = (args->flags & I915_EXEC_NO_RELOC) == 0; |
699 | need_relocs = (args->flags & I915_EXEC_NO_RELOC) == 0; |
704 | ret = i915_gem_execbuffer_reserve(ring, file, &eb->objects, &need_relocs); |
700 | ret = i915_gem_execbuffer_reserve(ring, &eb->objects, &need_relocs); |
705 | if (ret) |
701 | if (ret) |
Line 706... | Line 702... | ||
706 | goto err; |
702 | goto err; |
707 | 703 | ||
Line 772... | Line 768... | ||
772 | int i; |
768 | int i; |
773 | int relocs_total = 0; |
769 | int relocs_total = 0; |
774 | int relocs_max = INT_MAX / sizeof(struct drm_i915_gem_relocation_entry); |
770 | int relocs_max = INT_MAX / sizeof(struct drm_i915_gem_relocation_entry); |
Line 775... | Line 771... | ||
775 | 771 | ||
776 | for (i = 0; i < count; i++) { |
772 | for (i = 0; i < count; i++) { |
777 | char __user *ptr = (char __user *)(uintptr_t)exec[i].relocs_ptr; |
773 | char __user *ptr = to_user_ptr(exec[i].relocs_ptr); |
Line 778... | Line 774... | ||
778 | int length; /* limited by fault_in_pages_readable() */ |
774 | int length; /* limited by fault_in_pages_readable() */ |
779 | 775 | ||
Line 788... | Line 784... | ||
788 | return -EINVAL; |
784 | return -EINVAL; |
789 | relocs_total += exec[i].relocation_count; |
785 | relocs_total += exec[i].relocation_count; |
Line 790... | Line 786... | ||
790 | 786 | ||
791 | length = exec[i].relocation_count * |
787 | length = exec[i].relocation_count * |
- | 788 | sizeof(struct drm_i915_gem_relocation_entry); |
|
- | 789 | /* |
|
792 | sizeof(struct drm_i915_gem_relocation_entry); |
790 | * We must check that the entire relocation array is safe |
- | 791 | * to read, but since we may need to update the presumed |
|
- | 792 | * offsets during execution, check for full write access. |
|
793 | /* we may also need to update the presumed offsets */ |
793 | */ |
794 | // if (!access_ok(VERIFY_WRITE, ptr, length)) |
794 | // if (!access_ok(VERIFY_WRITE, ptr, length)) |
Line 795... | Line 795... | ||
795 | // return -EFAULT; |
795 | // return -EFAULT; |
796 | 796 | ||
Line 990... | Line 990... | ||
990 | ret = -ENOMEM; |
990 | ret = -ENOMEM; |
991 | goto pre_mutex_err; |
991 | goto pre_mutex_err; |
992 | } |
992 | } |
Line 993... | Line 993... | ||
993 | 993 | ||
994 | if (copy_from_user(cliprects, |
- | |
995 | (struct drm_clip_rect __user *)(uintptr_t) |
994 | if (copy_from_user(cliprects, |
996 | args->cliprects_ptr, |
995 | to_user_ptr(args->cliprects_ptr), |
997 | sizeof(*cliprects)*args->num_cliprects)) { |
996 | sizeof(*cliprects)*args->num_cliprects)) { |
998 | ret = -EFAULT; |
997 | ret = -EFAULT; |
999 | goto pre_mutex_err; |
998 | goto pre_mutex_err; |
1000 | } |
999 | } |
Line 1027... | Line 1026... | ||
1027 | struct drm_i915_gem_object, |
1026 | struct drm_i915_gem_object, |
1028 | exec_list); |
1027 | exec_list); |
Line 1029... | Line 1028... | ||
1029 | 1028 | ||
1030 | /* Move the objects en-masse into the GTT, evicting if necessary. */ |
1029 | /* Move the objects en-masse into the GTT, evicting if necessary. */ |
1031 | need_relocs = (args->flags & I915_EXEC_NO_RELOC) == 0; |
1030 | need_relocs = (args->flags & I915_EXEC_NO_RELOC) == 0; |
1032 | ret = i915_gem_execbuffer_reserve(ring, file, &eb->objects, &need_relocs); |
1031 | ret = i915_gem_execbuffer_reserve(ring, &eb->objects, &need_relocs); |
1033 | if (ret) |
1032 | if (ret) |
Line 1034... | Line 1033... | ||
1034 | goto err; |
1033 | goto err; |
1035 | 1034 | ||
1036 | /* The objects are in their final locations, apply the relocations. */ |
1035 | /* The objects are in their final locations, apply the relocations. */ |
1037 | if (need_relocs) |
1036 | if (need_relocs) |
1038 | ret = i915_gem_execbuffer_relocate(dev, eb); |
1037 | ret = i915_gem_execbuffer_relocate(eb); |
1039 | if (ret) { |
1038 | if (ret) { |
1040 | if (ret == -EFAULT) { |
1039 | if (ret == -EFAULT) { |
1041 | ret = i915_gem_execbuffer_relocate_slow(dev, args, file, ring, |
1040 | ret = i915_gem_execbuffer_relocate_slow(dev, args, file, ring, |