History

drm/i915: Move the execbuffer objects list from the stack into the tracker

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.

Chris Wilson committed 13 years ago

Commit bcffc3f1 parent 3b96eff1 file · +27 −31Browse files

Unified · Split

drivers/gpu/drm/i915/i915_gem_execbuffer.c+27−31
@@ -34,6 +34,7 @@ · 33 unmodified lines
3434 #include <linux/dma_remapping.h>
3535
3636 struct eb_objects {
37+ struct list_head objects;
3738 int and;
3839 struct hlist_head buckets[0];
3940 };
@@ -53,6 +54,7 @@ eb_create(int size) · 13 unmodified lines
5354 return eb;
5455
5556 eb->and = count - 1;
57+ INIT_LIST_HEAD(&eb->objects);
5658 return eb;
5759 }
5860
@@ -73,8 +75,7 @@ static int · 14 unmodified lines
7375 eb_lookup_objects(struct eb_objects *eb,
7476 struct drm_i915_gem_exec_object2 *exec,
7577 int count,
76− struct drm_file *file,
77− struct list_head *objects)
78+ struct drm_file *file)
7879 {
7980 int i;
8081
@@ -98,7 +99,7 @@ eb_lookup_objects(struct eb_objects *eb, · 17 unmodified lines
9899 }
99100
100101 drm_gem_object_reference(&obj->base);
101− list_add_tail(&obj->exec_list, objects);
102+ list_add_tail(&obj->exec_list, &eb->objects);
102103
103104 obj->exec_handle = exec[i].handle;
104105 obj->exec_entry = &exec[i];
@@ -129,6 +130,15 @@ eb_get_object(struct eb_objects *eb, unsigned long handle) · 24 unmodified lines
129130 static void
130131 eb_destroy(struct eb_objects *eb)
131132 {
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+ }
132142 kfree(eb);
133143 }
134144
@@ -328,8 +338,7 @@ i915_gem_execbuffer_relocate_object_slow(struct drm_i915_gem_object *obj, · 193 unmodified lines
328338
329339 static int
330340 i915_gem_execbuffer_relocate(struct drm_device *dev,
331− struct eb_objects *eb,
332− struct list_head *objects)
341+ struct eb_objects *eb)
333342 {
334343 struct drm_i915_gem_object *obj;
335344 int ret = 0;
@@ -342,7 +351,7 @@ i915_gem_execbuffer_relocate(struct drm_device *dev, · 6 unmodified lines
342351 * lockdep complains vehemently.
343352 */
344353 pagefault_disable();
345− list_for_each_entry(obj, objects, exec_list) {
354+ list_for_each_entry(obj, &eb->objects, exec_list) {
346355 ret = i915_gem_execbuffer_relocate_object(obj, eb);
347356 if (ret)
348357 break;
@@ -531,7 +540,6 @@ static int · 182 unmodified lines
531540 i915_gem_execbuffer_relocate_slow(struct drm_device *dev,
532541 struct drm_file *file,
533542 struct intel_ring_buffer *ring,
534− struct list_head *objects,
535543 struct eb_objects *eb,
536544 struct drm_i915_gem_exec_object2 *exec,
537545 int count)
@@ -542,8 +550,8 @@ i915_gem_execbuffer_relocate_slow(struct drm_device *dev, · 4 unmodified lines
542550 int i, total, ret;
543551
544552 /* 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,
547555 struct drm_i915_gem_object,
548556 exec_list);
549557 list_del_init(&obj->exec_list);
@@ -590,15 +598,15 @@ i915_gem_execbuffer_relocate_slow(struct drm_device *dev, · 40 unmodified lines
590598
591599 /* reacquire the objects */
592600 eb_reset(eb);
593− ret = eb_lookup_objects(eb, exec, count, file, objects);
601+ ret = eb_lookup_objects(eb, exec, count, file);
594602 if (ret)
595603 goto err;
596604
597− ret = i915_gem_execbuffer_reserve(ring, file, objects);
605+ ret = i915_gem_execbuffer_reserve(ring, file, &eb->objects);
598606 if (ret)
599607 goto err;
600608
601− list_for_each_entry(obj, objects, exec_list) {
609+ list_for_each_entry(obj, &eb->objects, exec_list) {
602610 int offset = obj->exec_entry - exec;
603611 ret = i915_gem_execbuffer_relocate_object_slow(obj, eb,
604612 reloc + reloc_offset[offset]);
@@ -756,7 +764,6 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, · 151 unmodified lines
756764 struct drm_i915_gem_exec_object2 *exec)
757765 {
758766 drm_i915_private_t *dev_priv = dev->dev_private;
759− struct list_head objects;
760767 struct eb_objects *eb;
761768 struct drm_i915_gem_object *batch_obj;
762769 struct drm_clip_rect *cliprects = NULL;
@@ -899,28 +906,26 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, · 136 unmodified lines
899906 }
900907
901908 /* 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);
904910 if (ret)
905911 goto err;
906912
907913 /* 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,
909915 struct drm_i915_gem_object,
910916 exec_list);
911917
912918 /* 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);
914920 if (ret)
915921 goto err;
916922
917923 /* 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);
919925 if (ret) {
920926 if (ret == -EFAULT) {
921927 ret = i915_gem_execbuffer_relocate_slow(dev, file, ring,
922− &objects, eb,
923− exec,
928+ eb, exec,
924929 args->buffer_count);
925930 BUG_ON(!mutex_is_locked(&dev->struct_mutex));
926931 }
@@ -943,7 +948,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, · 16 unmodified lines
943948 if (flags & I915_DISPATCH_SECURE && !batch_obj->has_global_gtt_mapping)
944949 i915_gem_gtt_bind_object(batch_obj, batch_obj->cache_level);
945950
946− ret = i915_gem_execbuffer_move_to_gpu(ring, &objects);
951+ ret = i915_gem_execbuffer_move_to_gpu(ring, &eb->objects);
947952 if (ret)
948953 goto err;
949954
@@ -997,20 +1002,11 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, · 47 unmodified lines
9971002
9981003 trace_i915_gem_ring_dispatch(ring, intel_ring_get_seqno(ring), flags);
9991004
1000− i915_gem_execbuffer_move_to_active(&objects, ring);
1005+ i915_gem_execbuffer_move_to_active(&eb->objects, ring);
10011006 i915_gem_execbuffer_retire_commands(dev, file, ring);
10021007
10031008 err:
10041009 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− }
10141010
10151011 mutex_unlock(&dev->struct_mutex);
10161012

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t