Skip to content

Commit 1b50247

Browse files
ickledanvet
authored andcommitted
drm/i915: Remove the list of pinned inactive objects
Simplify object tracking by removing the inactive but pinned list. The only place where this was used is for counting the available memory, which is just as easy performed by checking all objects on the rare occasions it is required (application startup). For ease of debugging, we keep the reporting of pinned objects through the error-state and debugfs. Signed-off-by: Chris Wilson <[email protected]> Signed-off-by: Daniel Vetter <[email protected]>
1 parent a39d7ef commit 1b50247

File tree

6 files changed

+69
-99
lines changed

6 files changed

+69
-99
lines changed

drivers/gpu/drm/i915/i915_debugfs.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,6 @@ static int i915_gem_object_list_info(struct seq_file *m, void *data)
178178
seq_printf(m, "Inactive:\n");
179179
head = &dev_priv->mm.inactive_list;
180180
break;
181-
case PINNED_LIST:
182-
seq_printf(m, "Pinned:\n");
183-
head = &dev_priv->mm.pinned_list;
184-
break;
185181
case FLUSHING_LIST:
186182
seq_printf(m, "Flushing:\n");
187183
head = &dev_priv->mm.flushing_list;
@@ -251,11 +247,6 @@ static int i915_gem_object_info(struct seq_file *m, void* data)
251247
seq_printf(m, " %u [%u] active objects, %zu [%zu] bytes\n",
252248
count, mappable_count, size, mappable_size);
253249

254-
size = count = mappable_size = mappable_count = 0;
255-
count_objects(&dev_priv->mm.pinned_list, mm_list);
256-
seq_printf(m, " %u [%u] pinned objects, %zu [%zu] bytes\n",
257-
count, mappable_count, size, mappable_size);
258-
259250
size = count = mappable_size = mappable_count = 0;
260251
count_objects(&dev_priv->mm.inactive_list, mm_list);
261252
seq_printf(m, " %u [%u] inactive objects, %zu [%zu] bytes\n",
@@ -294,6 +285,7 @@ static int i915_gem_gtt_info(struct seq_file *m, void* data)
294285
{
295286
struct drm_info_node *node = (struct drm_info_node *) m->private;
296287
struct drm_device *dev = node->minor->dev;
288+
uintptr_t list = (uintptr_t) node->info_ent->data;
297289
struct drm_i915_private *dev_priv = dev->dev_private;
298290
struct drm_i915_gem_object *obj;
299291
size_t total_obj_size, total_gtt_size;
@@ -305,6 +297,9 @@ static int i915_gem_gtt_info(struct seq_file *m, void* data)
305297

306298
total_obj_size = total_gtt_size = count = 0;
307299
list_for_each_entry(obj, &dev_priv->mm.gtt_list, gtt_list) {
300+
if (list == PINNED_LIST && obj->pin_count == 0)
301+
continue;
302+
308303
seq_printf(m, " ");
309304
describe_obj(m, obj);
310305
seq_printf(m, "\n");
@@ -321,7 +316,6 @@ static int i915_gem_gtt_info(struct seq_file *m, void* data)
321316
return 0;
322317
}
323318

324-
325319
static int i915_gem_pageflip_info(struct seq_file *m, void *data)
326320
{
327321
struct drm_info_node *node = (struct drm_info_node *) m->private;
@@ -1842,10 +1836,10 @@ static struct drm_info_list i915_debugfs_list[] = {
18421836
{"i915_capabilities", i915_capabilities, 0},
18431837
{"i915_gem_objects", i915_gem_object_info, 0},
18441838
{"i915_gem_gtt", i915_gem_gtt_info, 0},
1839+
{"i915_gem_pinned", i915_gem_gtt_info, 0, (void *) PINNED_LIST},
18451840
{"i915_gem_active", i915_gem_object_list_info, 0, (void *) ACTIVE_LIST},
18461841
{"i915_gem_flushing", i915_gem_object_list_info, 0, (void *) FLUSHING_LIST},
18471842
{"i915_gem_inactive", i915_gem_object_list_info, 0, (void *) INACTIVE_LIST},
1848-
{"i915_gem_pinned", i915_gem_object_list_info, 0, (void *) PINNED_LIST},
18491843
{"i915_gem_deferred_free", i915_gem_object_list_info, 0, (void *) DEFERRED_FREE_LIST},
18501844
{"i915_gem_pageflip", i915_gem_pageflip_info, 0},
18511845
{"i915_gem_request", i915_gem_request_info, 0},

drivers/gpu/drm/i915/i915_drv.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -689,12 +689,6 @@ typedef struct drm_i915_private {
689689
*/
690690
struct list_head inactive_list;
691691

692-
/**
693-
* LRU list of objects which are not in the ringbuffer but
694-
* are still pinned in the GTT.
695-
*/
696-
struct list_head pinned_list;
697-
698692
/** LRU list of objects with fence regs on them. */
699693
struct list_head fence_list;
700694

drivers/gpu/drm/i915/i915_gem.c

Lines changed: 8 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ int i915_mutex_lock_interruptible(struct drm_device *dev)
132132
static inline bool
133133
i915_gem_object_is_inactive(struct drm_i915_gem_object *obj)
134134
{
135-
return !obj->active && obj->pin_count == 0;
135+
return !obj->active;
136136
}
137137

138138
int
@@ -171,8 +171,9 @@ i915_gem_get_aperture_ioctl(struct drm_device *dev, void *data,
171171

172172
pinned = 0;
173173
mutex_lock(&dev->struct_mutex);
174-
list_for_each_entry(obj, &dev_priv->mm.pinned_list, mm_list)
175-
pinned += obj->gtt_space->size;
174+
list_for_each_entry(obj, &dev_priv->mm.gtt_list, gtt_list)
175+
if (obj->pin_count)
176+
pinned += obj->gtt_space->size;
176177
mutex_unlock(&dev->struct_mutex);
177178

178179
args->aper_size = dev_priv->mm.gtt_total;
@@ -1455,10 +1456,7 @@ i915_gem_object_move_to_inactive(struct drm_i915_gem_object *obj)
14551456
struct drm_device *dev = obj->base.dev;
14561457
struct drm_i915_private *dev_priv = dev->dev_private;
14571458

1458-
if (obj->pin_count != 0)
1459-
list_move_tail(&obj->mm_list, &dev_priv->mm.pinned_list);
1460-
else
1461-
list_move_tail(&obj->mm_list, &dev_priv->mm.inactive_list);
1459+
list_move_tail(&obj->mm_list, &dev_priv->mm.inactive_list);
14621460

14631461
BUG_ON(!list_empty(&obj->gpu_write_list));
14641462
BUG_ON(!obj->active);
@@ -3063,12 +3061,9 @@ i915_gem_object_pin(struct drm_i915_gem_object *obj,
30633061
uint32_t alignment,
30643062
bool map_and_fenceable)
30653063
{
3066-
struct drm_device *dev = obj->base.dev;
3067-
struct drm_i915_private *dev_priv = dev->dev_private;
30683064
int ret;
30693065

30703066
BUG_ON(obj->pin_count == DRM_I915_GEM_OBJECT_MAX_PIN_COUNT);
3071-
WARN_ON(i915_verify_lists(dev));
30723067

30733068
if (obj->gtt_space != NULL) {
30743069
if ((alignment && obj->gtt_offset & (alignment - 1)) ||
@@ -3096,34 +3091,20 @@ i915_gem_object_pin(struct drm_i915_gem_object *obj,
30963091
if (!obj->has_global_gtt_mapping && map_and_fenceable)
30973092
i915_gem_gtt_bind_object(obj, obj->cache_level);
30983093

3099-
if (obj->pin_count++ == 0) {
3100-
if (!obj->active)
3101-
list_move_tail(&obj->mm_list,
3102-
&dev_priv->mm.pinned_list);
3103-
}
3094+
obj->pin_count++;
31043095
obj->pin_mappable |= map_and_fenceable;
31053096

3106-
WARN_ON(i915_verify_lists(dev));
31073097
return 0;
31083098
}
31093099

31103100
void
31113101
i915_gem_object_unpin(struct drm_i915_gem_object *obj)
31123102
{
3113-
struct drm_device *dev = obj->base.dev;
3114-
drm_i915_private_t *dev_priv = dev->dev_private;
3115-
3116-
WARN_ON(i915_verify_lists(dev));
31173103
BUG_ON(obj->pin_count == 0);
31183104
BUG_ON(obj->gtt_space == NULL);
31193105

3120-
if (--obj->pin_count == 0) {
3121-
if (!obj->active)
3122-
list_move_tail(&obj->mm_list,
3123-
&dev_priv->mm.inactive_list);
3106+
if (--obj->pin_count == 0)
31243107
obj->pin_mappable = false;
3125-
}
3126-
WARN_ON(i915_verify_lists(dev));
31273108
}
31283109

31293110
int
@@ -3426,12 +3407,10 @@ void i915_gem_free_object(struct drm_gem_object *gem_obj)
34263407
struct drm_i915_gem_object *obj = to_intel_bo(gem_obj);
34273408
struct drm_device *dev = obj->base.dev;
34283409

3429-
while (obj->pin_count > 0)
3430-
i915_gem_object_unpin(obj);
3431-
34323410
if (obj->phys_obj)
34333411
i915_gem_detach_phys_object(dev, obj);
34343412

3413+
obj->pin_count = 0;
34353414
i915_gem_free_object_tail(obj);
34363415
}
34373416

@@ -3699,7 +3678,6 @@ i915_gem_load(struct drm_device *dev)
36993678
INIT_LIST_HEAD(&dev_priv->mm.active_list);
37003679
INIT_LIST_HEAD(&dev_priv->mm.flushing_list);
37013680
INIT_LIST_HEAD(&dev_priv->mm.inactive_list);
3702-
INIT_LIST_HEAD(&dev_priv->mm.pinned_list);
37033681
INIT_LIST_HEAD(&dev_priv->mm.fence_list);
37043682
INIT_LIST_HEAD(&dev_priv->mm.deferred_free_list);
37053683
INIT_LIST_HEAD(&dev_priv->mm.gtt_list);

drivers/gpu/drm/i915/i915_gem_debug.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -114,22 +114,6 @@ i915_verify_lists(struct drm_device *dev)
114114
}
115115
}
116116

117-
list_for_each_entry(obj, &dev_priv->mm.pinned_list, list) {
118-
if (obj->base.dev != dev ||
119-
!atomic_read(&obj->base.refcount.refcount)) {
120-
DRM_ERROR("freed pinned %p\n", obj);
121-
err++;
122-
break;
123-
} else if (!obj->pin_count || obj->active ||
124-
(obj->base.write_domain & I915_GEM_GPU_DOMAINS)) {
125-
DRM_ERROR("invalid pinned %p (p %d a %d w %x)\n",
126-
obj,
127-
obj->pin_count, obj->active,
128-
obj->base.write_domain);
129-
err++;
130-
}
131-
}
132-
133117
return warned = err;
134118
}
135119
#endif /* WATCH_INACTIVE */

drivers/gpu/drm/i915/i915_gem_evict.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@
3535
static bool
3636
mark_free(struct drm_i915_gem_object *obj, struct list_head *unwind)
3737
{
38+
if (obj->pin_count)
39+
return false;
40+
3841
list_add(&obj->exec_list, unwind);
3942
return drm_mm_scan_add_block(obj->gtt_space);
4043
}
@@ -90,7 +93,7 @@ i915_gem_evict_something(struct drm_device *dev, int min_size,
9093
/* Now merge in the soon-to-be-expired objects... */
9194
list_for_each_entry(obj, &dev_priv->mm.active_list, mm_list) {
9295
/* Does the object require an outstanding flush? */
93-
if (obj->base.write_domain || obj->pin_count)
96+
if (obj->base.write_domain)
9497
continue;
9598

9699
if (mark_free(obj, &unwind_list))
@@ -99,14 +102,11 @@ i915_gem_evict_something(struct drm_device *dev, int min_size,
99102

100103
/* Finally add anything with a pending flush (in order of retirement) */
101104
list_for_each_entry(obj, &dev_priv->mm.flushing_list, mm_list) {
102-
if (obj->pin_count)
103-
continue;
104-
105105
if (mark_free(obj, &unwind_list))
106106
goto found;
107107
}
108108
list_for_each_entry(obj, &dev_priv->mm.active_list, mm_list) {
109-
if (!obj->base.write_domain || obj->pin_count)
109+
if (!obj->base.write_domain)
110110
continue;
111111

112112
if (mark_free(obj, &unwind_list))

drivers/gpu/drm/i915/i915_irq.c

Lines changed: 51 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -918,37 +918,56 @@ i915_error_state_free(struct drm_device *dev,
918918
kfree(error->overlay);
919919
kfree(error);
920920
}
921-
922-
static u32 capture_bo_list(struct drm_i915_error_buffer *err,
923-
int count,
924-
struct list_head *head)
921+
static void capture_bo(struct drm_i915_error_buffer *err,
922+
struct drm_i915_gem_object *obj)
923+
{
924+
err->size = obj->base.size;
925+
err->name = obj->base.name;
926+
err->seqno = obj->last_rendering_seqno;
927+
err->gtt_offset = obj->gtt_offset;
928+
err->read_domains = obj->base.read_domains;
929+
err->write_domain = obj->base.write_domain;
930+
err->fence_reg = obj->fence_reg;
931+
err->pinned = 0;
932+
if (obj->pin_count > 0)
933+
err->pinned = 1;
934+
if (obj->user_pin_count > 0)
935+
err->pinned = -1;
936+
err->tiling = obj->tiling_mode;
937+
err->dirty = obj->dirty;
938+
err->purgeable = obj->madv != I915_MADV_WILLNEED;
939+
err->ring = obj->ring ? obj->ring->id : -1;
940+
err->cache_level = obj->cache_level;
941+
}
942+
943+
static u32 capture_active_bo(struct drm_i915_error_buffer *err,
944+
int count, struct list_head *head)
925945
{
926946
struct drm_i915_gem_object *obj;
927947
int i = 0;
928948

929949
list_for_each_entry(obj, head, mm_list) {
930-
err->size = obj->base.size;
931-
err->name = obj->base.name;
932-
err->seqno = obj->last_rendering_seqno;
933-
err->gtt_offset = obj->gtt_offset;
934-
err->read_domains = obj->base.read_domains;
935-
err->write_domain = obj->base.write_domain;
936-
err->fence_reg = obj->fence_reg;
937-
err->pinned = 0;
938-
if (obj->pin_count > 0)
939-
err->pinned = 1;
940-
if (obj->user_pin_count > 0)
941-
err->pinned = -1;
942-
err->tiling = obj->tiling_mode;
943-
err->dirty = obj->dirty;
944-
err->purgeable = obj->madv != I915_MADV_WILLNEED;
945-
err->ring = obj->ring ? obj->ring->id : -1;
946-
err->cache_level = obj->cache_level;
947-
950+
capture_bo(err++, obj);
948951
if (++i == count)
949952
break;
953+
}
954+
955+
return i;
956+
}
950957

951-
err++;
958+
static u32 capture_pinned_bo(struct drm_i915_error_buffer *err,
959+
int count, struct list_head *head)
960+
{
961+
struct drm_i915_gem_object *obj;
962+
int i = 0;
963+
964+
list_for_each_entry(obj, head, gtt_list) {
965+
if (obj->pin_count == 0)
966+
continue;
967+
968+
capture_bo(err++, obj);
969+
if (++i == count)
970+
break;
952971
}
953972

954973
return i;
@@ -1155,8 +1174,9 @@ static void i915_capture_error_state(struct drm_device *dev)
11551174
list_for_each_entry(obj, &dev_priv->mm.active_list, mm_list)
11561175
i++;
11571176
error->active_bo_count = i;
1158-
list_for_each_entry(obj, &dev_priv->mm.pinned_list, mm_list)
1159-
i++;
1177+
list_for_each_entry(obj, &dev_priv->mm.gtt_list, gtt_list)
1178+
if (obj->pin_count)
1179+
i++;
11601180
error->pinned_bo_count = i - error->active_bo_count;
11611181

11621182
error->active_bo = NULL;
@@ -1171,15 +1191,15 @@ static void i915_capture_error_state(struct drm_device *dev)
11711191

11721192
if (error->active_bo)
11731193
error->active_bo_count =
1174-
capture_bo_list(error->active_bo,
1175-
error->active_bo_count,
1176-
&dev_priv->mm.active_list);
1194+
capture_active_bo(error->active_bo,
1195+
error->active_bo_count,
1196+
&dev_priv->mm.active_list);
11771197

11781198
if (error->pinned_bo)
11791199
error->pinned_bo_count =
1180-
capture_bo_list(error->pinned_bo,
1181-
error->pinned_bo_count,
1182-
&dev_priv->mm.pinned_list);
1200+
capture_pinned_bo(error->pinned_bo,
1201+
error->pinned_bo_count,
1202+
&dev_priv->mm.gtt_list);
11831203

11841204
do_gettimeofday(&error->time);
11851205

0 commit comments

Comments
 (0)