Instead of passing around the eb-objects hashtable and a separate object list, we can include the object list into the eb-objects structure for convenience.
Unified · Split
| @@ -34,6 +34,7 @@ · 33 unmodified lines | ||
| 34 | 34 | #include <linux/dma_remapping.h> |
| 35 | 35 | |
| 36 | 36 | struct eb_objects { |
| 37 | + struct list_head objects; | |
| 37 | 38 | int and; |
| 38 | 39 | struct hlist_head buckets[0]; |
| 39 | 40 | }; |
| @@ -53,6 +54,7 @@ eb_create(int size) · 13 unmodified lines | ||
| 53 | 54 | return eb; |
| 54 | 55 | |
| 55 | 56 | eb->and = count - 1; |
| 57 | + INIT_LIST_HEAD(&eb->objects); | |
| 56 | 58 | return eb; |
| 57 | 59 | } |
| 58 | 60 | |
| @@ -73,8 +75,7 @@ static int · 14 unmodified lines | ||
| 73 | 75 | eb_lookup_objects(struct eb_objects *eb, |
| 74 | 76 | struct drm_i915_gem_exec_object2 *exec, |
| 75 | 77 | int count, |
| 76 | − struct drm_file *file, | |
| 77 | − struct list_head *objects) | |
| 78 | + struct drm_file *file) | |
| 78 | 79 | { |
| 79 | 80 | int i; |
| 80 | 81 | |
| @@ -98,7 +99,7 @@ eb_lookup_objects(struct eb_objects *eb, · 17 unmodified lines | ||
| 98 | 99 | } |
| 99 | 100 | |
| 100 | 101 | drm_gem_object_reference(&obj->base); |
| 101 | − list_add_tail(&obj->exec_list, objects); | |
| 102 | + list_add_tail(&obj->exec_list, &eb->objects); | |
| 102 | 103 | |
| 103 | 104 | obj->exec_handle = exec[i].handle; |
| 104 | 105 | obj->exec_entry = &exec[i]; |
| @@ -129,6 +130,15 @@ eb_get_object(struct eb_objects *eb, unsigned long handle) · 24 unmodified lines | ||
| 129 | 130 | static void |
| 130 | 131 | eb_destroy(struct eb_objects *eb) |
| 131 | 132 | { |
| 133 | + while (!list_empty(&eb->objects)) { | |
| 134 | + struct drm_i915_gem_object *obj; | |
| 135 | + | |
| 136 | + obj = list_first_entry(&eb->objects, | |
| 137 | + struct drm_i915_gem_object, | |
| 138 | + exec_list); | |
| 139 | + list_del_init(&obj->exec_list); | |
| 140 | + drm_gem_object_unreference(&obj->base); | |
| 141 | + } | |
| 132 | 142 | kfree(eb); |
| 133 | 143 | } |
| 134 | 144 | |
| @@ -328,8 +338,7 @@ i915_gem_execbuffer_relocate_object_slow(struct drm_i915_gem_object *obj, · 193 unmodified lines | ||
| 328 | 338 | |
| 329 | 339 | static int |
| 330 | 340 | i915_gem_execbuffer_relocate(struct drm_device *dev, |
| 331 | − struct eb_objects *eb, | |
| 332 | − struct list_head *objects) | |
| 341 | + struct eb_objects *eb) | |
| 333 | 342 | { |
| 334 | 343 | struct drm_i915_gem_object *obj; |
| 335 | 344 | int ret = 0; |
| @@ -342,7 +351,7 @@ i915_gem_execbuffer_relocate(struct drm_device *dev, · 6 unmodified lines | ||
| 342 | 351 | * lockdep complains vehemently. |
| 343 | 352 | */ |
| 344 | 353 | pagefault_disable(); |
| 345 | − list_for_each_entry(obj, objects, exec_list) { | |
| 354 | + list_for_each_entry(obj, &eb->objects, exec_list) { | |
| 346 | 355 | ret = i915_gem_execbuffer_relocate_object(obj, eb); |
| 347 | 356 | if (ret) |
| 348 | 357 | break; |
| @@ -531,7 +540,6 @@ static int · 182 unmodified lines | ||
| 531 | 540 | i915_gem_execbuffer_relocate_slow(struct drm_device *dev, |
| 532 | 541 | struct drm_file *file, |
| 533 | 542 | struct intel_ring_buffer *ring, |
| 534 | − struct list_head *objects, | |
| 535 | 543 | struct eb_objects *eb, |
| 536 | 544 | struct drm_i915_gem_exec_object2 *exec, |
| 537 | 545 | int count) |
| @@ -542,8 +550,8 @@ i915_gem_execbuffer_relocate_slow(struct drm_device *dev, · 4 unmodified lines | ||
| 542 | 550 | int i, total, ret; |
| 543 | 551 | |
| 544 | 552 | /* We may process another execbuffer during the unlock... */ |
| 545 | − while (!list_empty(objects)) { | |
| 546 | − obj = list_first_entry(objects, | |
| 553 | + while (!list_empty(&eb->objects)) { | |
| 554 | + obj = list_first_entry(&eb->objects, | |
| 547 | 555 | struct drm_i915_gem_object, |
| 548 | 556 | exec_list); |
| 549 | 557 | list_del_init(&obj->exec_list); |
| @@ -590,15 +598,15 @@ i915_gem_execbuffer_relocate_slow(struct drm_device *dev, · 40 unmodified lines | ||
| 590 | 598 | |
| 591 | 599 | /* reacquire the objects */ |
| 592 | 600 | eb_reset(eb); |
| 593 | − ret = eb_lookup_objects(eb, exec, count, file, objects); | |
| 601 | + ret = eb_lookup_objects(eb, exec, count, file); | |
| 594 | 602 | if (ret) |
| 595 | 603 | goto err; |
| 596 | 604 | |
| 597 | − ret = i915_gem_execbuffer_reserve(ring, file, objects); | |
| 605 | + ret = i915_gem_execbuffer_reserve(ring, file, &eb->objects); | |
| 598 | 606 | if (ret) |
| 599 | 607 | goto err; |
| 600 | 608 | |
| 601 | − list_for_each_entry(obj, objects, exec_list) { | |
| 609 | + list_for_each_entry(obj, &eb->objects, exec_list) { | |
| 602 | 610 | int offset = obj->exec_entry - exec; |
| 603 | 611 | ret = i915_gem_execbuffer_relocate_object_slow(obj, eb, |
| 604 | 612 | reloc + reloc_offset[offset]); |
| @@ -756,7 +764,6 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, · 151 unmodified lines | ||
| 756 | 764 | struct drm_i915_gem_exec_object2 *exec) |
| 757 | 765 | { |
| 758 | 766 | drm_i915_private_t *dev_priv = dev->dev_private; |
| 759 | − struct list_head objects; | |
| 760 | 767 | struct eb_objects *eb; |
| 761 | 768 | struct drm_i915_gem_object *batch_obj; |
| 762 | 769 | struct drm_clip_rect *cliprects = NULL; |
| @@ -899,28 +906,26 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, · 136 unmodified lines | ||
| 899 | 906 | } |
| 900 | 907 | |
| 901 | 908 | /* Look up object handles */ |
| 902 | − INIT_LIST_HEAD(&objects); | |
| 903 | − ret = eb_lookup_objects(eb, exec, args->buffer_count, file, &objects); | |
| 909 | + ret = eb_lookup_objects(eb, exec, args->buffer_count, file); | |
| 904 | 910 | if (ret) |
| 905 | 911 | goto err; |
| 906 | 912 | |
| 907 | 913 | /* take note of the batch buffer before we might reorder the lists */ |
| 908 | − batch_obj = list_entry(objects.prev, | |
| 914 | + batch_obj = list_entry(eb->objects.prev, | |
| 909 | 915 | struct drm_i915_gem_object, |
| 910 | 916 | exec_list); |
| 911 | 917 | |
| 912 | 918 | /* Move the objects en-masse into the GTT, evicting if necessary. */ |
| 913 | − ret = i915_gem_execbuffer_reserve(ring, file, &objects); | |
| 919 | + ret = i915_gem_execbuffer_reserve(ring, file, &eb->objects); | |
| 914 | 920 | if (ret) |
| 915 | 921 | goto err; |
| 916 | 922 | |
| 917 | 923 | /* The objects are in their final locations, apply the relocations. */ |
| 918 | − ret = i915_gem_execbuffer_relocate(dev, eb, &objects); | |
| 924 | + ret = i915_gem_execbuffer_relocate(dev, eb); | |
| 919 | 925 | if (ret) { |
| 920 | 926 | if (ret == -EFAULT) { |
| 921 | 927 | ret = i915_gem_execbuffer_relocate_slow(dev, file, ring, |
| 922 | − &objects, eb, | |
| 923 | − exec, | |
| 928 | + eb, exec, | |
| 924 | 929 | args->buffer_count); |
| 925 | 930 | BUG_ON(!mutex_is_locked(&dev->struct_mutex)); |
| 926 | 931 | } |
| @@ -943,7 +948,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, · 16 unmodified lines | ||
| 943 | 948 | if (flags & I915_DISPATCH_SECURE && !batch_obj->has_global_gtt_mapping) |
| 944 | 949 | i915_gem_gtt_bind_object(batch_obj, batch_obj->cache_level); |
| 945 | 950 | |
| 946 | − ret = i915_gem_execbuffer_move_to_gpu(ring, &objects); | |
| 951 | + ret = i915_gem_execbuffer_move_to_gpu(ring, &eb->objects); | |
| 947 | 952 | if (ret) |
| 948 | 953 | goto err; |
| 949 | 954 | |
| @@ -997,20 +1002,11 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, · 47 unmodified lines | ||
| 997 | 1002 | |
| 998 | 1003 | trace_i915_gem_ring_dispatch(ring, intel_ring_get_seqno(ring), flags); |
| 999 | 1004 | |
| 1000 | − i915_gem_execbuffer_move_to_active(&objects, ring); | |
| 1005 | + i915_gem_execbuffer_move_to_active(&eb->objects, ring); | |
| 1001 | 1006 | i915_gem_execbuffer_retire_commands(dev, file, ring); |
| 1002 | 1007 | |
| 1003 | 1008 | err: |
| 1004 | 1009 | eb_destroy(eb); |
| 1005 | − while (!list_empty(&objects)) { | |
| 1006 | − struct drm_i915_gem_object *obj; | |
| 1007 | − | |
| 1008 | − obj = list_first_entry(&objects, | |
| 1009 | − struct drm_i915_gem_object, | |
| 1010 | − exec_list); | |
| 1011 | − list_del_init(&obj->exec_list); | |
| 1012 | − drm_gem_object_unreference(&obj->base); | |
| 1013 | − } | |
| 1014 | 1010 | |
| 1015 | 1011 | mutex_unlock(&dev->struct_mutex); |
| 1016 | 1012 | |