aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2016-02-26 06:03:20 -0500
committerTvrtko Ursulin <tvrtko.ursulin@intel.com>2016-02-26 08:15:39 -0500
commit596c5923197b889e2b7dc9d2188799933125bbb5 (patch)
tree23ee26e85e760b73e7c5ca93cfbab1c7410b0294
parent1c7f4bca5a6f53c8aa5ecf52fc9f68194e44aede (diff)
drm/i915: Reduce the pointer dance of i915_is_ggtt()
The multiple levels of indirect do nothing but hinder the compiler and the pointer chasing turns to be quite painful but painless to fix. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Reviewed-by: Dave Gordon <david.s.gordon@intel.com> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Link: http://patchwork.freedesktop.org/patch/msgid/1456484600-11477-1-git-send-email-tvrtko.ursulin@linux.intel.com
-rw-r--r--drivers/gpu/drm/i915/i915_debugfs.c13
-rw-r--r--drivers/gpu/drm/i915/i915_drv.h7
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c18
-rw-r--r--drivers/gpu/drm/i915/i915_gem_execbuffer.c5
-rw-r--r--drivers/gpu/drm/i915/i915_gem_gtt.c12
-rw-r--r--drivers/gpu/drm/i915/i915_gem_gtt.h5
-rw-r--r--drivers/gpu/drm/i915/i915_trace.h27
7 files changed, 33 insertions, 54 deletions
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index d7f03bceea57..a0f1bd711b53 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -118,7 +118,7 @@ static u64 i915_gem_obj_total_ggtt_size(struct drm_i915_gem_object *obj)
118 struct i915_vma *vma; 118 struct i915_vma *vma;
119 119
120 list_for_each_entry(vma, &obj->vma_list, obj_link) { 120 list_for_each_entry(vma, &obj->vma_list, obj_link) {
121 if (i915_is_ggtt(vma->vm) && drm_mm_node_allocated(&vma->node)) 121 if (vma->is_ggtt && drm_mm_node_allocated(&vma->node))
122 size += vma->node.size; 122 size += vma->node.size;
123 } 123 }
124 124
@@ -165,12 +165,11 @@ describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj)
165 seq_printf(m, " (fence: %d)", obj->fence_reg); 165 seq_printf(m, " (fence: %d)", obj->fence_reg);
166 list_for_each_entry(vma, &obj->vma_list, obj_link) { 166 list_for_each_entry(vma, &obj->vma_list, obj_link) {
167 seq_printf(m, " (%sgtt offset: %08llx, size: %08llx", 167 seq_printf(m, " (%sgtt offset: %08llx, size: %08llx",
168 i915_is_ggtt(vma->vm) ? "g" : "pp", 168 vma->is_ggtt ? "g" : "pp",
169 vma->node.start, vma->node.size); 169 vma->node.start, vma->node.size);
170 if (i915_is_ggtt(vma->vm)) 170 if (vma->is_ggtt)
171 seq_printf(m, ", type: %u)", vma->ggtt_view.type); 171 seq_printf(m, ", type: %u", vma->ggtt_view.type);
172 else 172 seq_puts(m, ")");
173 seq_puts(m, ")");
174 } 173 }
175 if (obj->stolen) 174 if (obj->stolen)
176 seq_printf(m, " (stolen: %08llx)", obj->stolen->start); 175 seq_printf(m, " (stolen: %08llx)", obj->stolen->start);
@@ -347,7 +346,7 @@ static int per_file_stats(int id, void *ptr, void *data)
347 if (!drm_mm_node_allocated(&vma->node)) 346 if (!drm_mm_node_allocated(&vma->node))
348 continue; 347 continue;
349 348
350 if (i915_is_ggtt(vma->vm)) { 349 if (vma->is_ggtt) {
351 stats->global += obj->base.size; 350 stats->global += obj->base.size;
352 continue; 351 continue;
353 } 352 }
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 9e76bfc7d5ab..a4dcb744bfe8 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -3156,18 +3156,11 @@ bool i915_gem_obj_is_pinned(struct drm_i915_gem_object *obj);
3156/* Some GGTT VM helpers */ 3156/* Some GGTT VM helpers */
3157#define i915_obj_to_ggtt(obj) \ 3157#define i915_obj_to_ggtt(obj) \
3158 (&((struct drm_i915_private *)(obj)->base.dev->dev_private)->gtt.base) 3158 (&((struct drm_i915_private *)(obj)->base.dev->dev_private)->gtt.base)
3159static inline bool i915_is_ggtt(struct i915_address_space *vm)
3160{
3161 struct i915_address_space *ggtt =
3162 &((struct drm_i915_private *)(vm)->dev->dev_private)->gtt.base;
3163 return vm == ggtt;
3164}
3165 3159
3166static inline struct i915_hw_ppgtt * 3160static inline struct i915_hw_ppgtt *
3167i915_vm_to_ppgtt(struct i915_address_space *vm) 3161i915_vm_to_ppgtt(struct i915_address_space *vm)
3168{ 3162{
3169 WARN_ON(i915_is_ggtt(vm)); 3163 WARN_ON(i915_is_ggtt(vm));
3170
3171 return container_of(vm, struct i915_hw_ppgtt, base); 3164 return container_of(vm, struct i915_hw_ppgtt, base);
3172} 3165}
3173 3166
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index bcd2e481d014..3d31d3ac589e 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -3336,8 +3336,7 @@ static int __i915_vma_unbind(struct i915_vma *vma, bool wait)
3336 return ret; 3336 return ret;
3337 } 3337 }
3338 3338
3339 if (i915_is_ggtt(vma->vm) && 3339 if (vma->is_ggtt && vma->ggtt_view.type == I915_GGTT_VIEW_NORMAL) {
3340 vma->ggtt_view.type == I915_GGTT_VIEW_NORMAL) {
3341 i915_gem_object_finish_gtt(obj); 3340 i915_gem_object_finish_gtt(obj);
3342 3341
3343 /* release the fence reg _after_ flushing */ 3342 /* release the fence reg _after_ flushing */
@@ -3352,7 +3351,7 @@ static int __i915_vma_unbind(struct i915_vma *vma, bool wait)
3352 vma->bound = 0; 3351 vma->bound = 0;
3353 3352
3354 list_del_init(&vma->vm_link); 3353 list_del_init(&vma->vm_link);
3355 if (i915_is_ggtt(vma->vm)) { 3354 if (vma->is_ggtt) {
3356 if (vma->ggtt_view.type == I915_GGTT_VIEW_NORMAL) { 3355 if (vma->ggtt_view.type == I915_GGTT_VIEW_NORMAL) {
3357 obj->map_and_fenceable = false; 3356 obj->map_and_fenceable = false;
3358 } else if (vma->ggtt_view.pages) { 3357 } else if (vma->ggtt_view.pages) {
@@ -4639,17 +4638,14 @@ struct i915_vma *i915_gem_obj_to_ggtt_view(struct drm_i915_gem_object *obj,
4639 4638
4640void i915_gem_vma_destroy(struct i915_vma *vma) 4639void i915_gem_vma_destroy(struct i915_vma *vma)
4641{ 4640{
4642 struct i915_address_space *vm = NULL;
4643 WARN_ON(vma->node.allocated); 4641 WARN_ON(vma->node.allocated);
4644 4642
4645 /* Keep the vma as a placeholder in the execbuffer reservation lists */ 4643 /* Keep the vma as a placeholder in the execbuffer reservation lists */
4646 if (!list_empty(&vma->exec_list)) 4644 if (!list_empty(&vma->exec_list))
4647 return; 4645 return;
4648 4646
4649 vm = vma->vm; 4647 if (!vma->is_ggtt)
4650 4648 i915_ppgtt_put(i915_vm_to_ppgtt(vma->vm));
4651 if (!i915_is_ggtt(vm))
4652 i915_ppgtt_put(i915_vm_to_ppgtt(vm));
4653 4649
4654 list_del(&vma->obj_link); 4650 list_del(&vma->obj_link);
4655 4651
@@ -5202,7 +5198,7 @@ u64 i915_gem_obj_offset(struct drm_i915_gem_object *o,
5202 WARN_ON(vm == &dev_priv->mm.aliasing_ppgtt->base); 5198 WARN_ON(vm == &dev_priv->mm.aliasing_ppgtt->base);
5203 5199
5204 list_for_each_entry(vma, &o->vma_list, obj_link) { 5200 list_for_each_entry(vma, &o->vma_list, obj_link) {
5205 if (i915_is_ggtt(vma->vm) && 5201 if (vma->is_ggtt &&
5206 vma->ggtt_view.type != I915_GGTT_VIEW_NORMAL) 5202 vma->ggtt_view.type != I915_GGTT_VIEW_NORMAL)
5207 continue; 5203 continue;
5208 if (vma->vm == vm) 5204 if (vma->vm == vm)
@@ -5235,7 +5231,7 @@ bool i915_gem_obj_bound(struct drm_i915_gem_object *o,
5235 struct i915_vma *vma; 5231 struct i915_vma *vma;
5236 5232
5237 list_for_each_entry(vma, &o->vma_list, obj_link) { 5233 list_for_each_entry(vma, &o->vma_list, obj_link) {
5238 if (i915_is_ggtt(vma->vm) && 5234 if (vma->is_ggtt &&
5239 vma->ggtt_view.type != I915_GGTT_VIEW_NORMAL) 5235 vma->ggtt_view.type != I915_GGTT_VIEW_NORMAL)
5240 continue; 5236 continue;
5241 if (vma->vm == vm && drm_mm_node_allocated(&vma->node)) 5237 if (vma->vm == vm && drm_mm_node_allocated(&vma->node))
@@ -5282,7 +5278,7 @@ unsigned long i915_gem_obj_size(struct drm_i915_gem_object *o,
5282 BUG_ON(list_empty(&o->vma_list)); 5278 BUG_ON(list_empty(&o->vma_list));
5283 5279
5284 list_for_each_entry(vma, &o->vma_list, obj_link) { 5280 list_for_each_entry(vma, &o->vma_list, obj_link) {
5285 if (i915_is_ggtt(vma->vm) && 5281 if (vma->is_ggtt &&
5286 vma->ggtt_view.type != I915_GGTT_VIEW_NORMAL) 5282 vma->ggtt_view.type != I915_GGTT_VIEW_NORMAL)
5287 continue; 5283 continue;
5288 if (vma->vm == vm) 5284 if (vma->vm == vm)
diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
index 8fd00d279447..1328bc5021b4 100644
--- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
@@ -668,7 +668,7 @@ need_reloc_mappable(struct i915_vma *vma)
668 if (entry->relocation_count == 0) 668 if (entry->relocation_count == 0)
669 return false; 669 return false;
670 670
671 if (!i915_is_ggtt(vma->vm)) 671 if (!vma->is_ggtt)
672 return false; 672 return false;
673 673
674 /* See also use_cpu_reloc() */ 674 /* See also use_cpu_reloc() */
@@ -687,8 +687,7 @@ eb_vma_misplaced(struct i915_vma *vma)
687 struct drm_i915_gem_exec_object2 *entry = vma->exec_entry; 687 struct drm_i915_gem_exec_object2 *entry = vma->exec_entry;
688 struct drm_i915_gem_object *obj = vma->obj; 688 struct drm_i915_gem_object *obj = vma->obj;
689 689
690 WARN_ON(entry->flags & __EXEC_OBJECT_NEEDS_MAP && 690 WARN_ON(entry->flags & __EXEC_OBJECT_NEEDS_MAP && !vma->is_ggtt);
691 !i915_is_ggtt(vma->vm));
692 691
693 if (entry->alignment && 692 if (entry->alignment &&
694 vma->node.start & (entry->alignment - 1)) 693 vma->node.start & (entry->alignment - 1))
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index 68d3af6854d1..49e4f26b79d8 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -3198,6 +3198,7 @@ int i915_gem_gtt_init(struct drm_device *dev)
3198 } 3198 }
3199 3199
3200 gtt->base.dev = dev; 3200 gtt->base.dev = dev;
3201 gtt->base.is_ggtt = true;
3201 3202
3202 ret = gtt->gtt_probe(dev, &gtt->base.total, &gtt->stolen_size, 3203 ret = gtt->gtt_probe(dev, &gtt->base.total, &gtt->stolen_size,
3203 &gtt->mappable_base, &gtt->mappable_end); 3204 &gtt->mappable_base, &gtt->mappable_end);
@@ -3319,13 +3320,14 @@ __i915_gem_vma_create(struct drm_i915_gem_object *obj,
3319 INIT_LIST_HEAD(&vma->exec_list); 3320 INIT_LIST_HEAD(&vma->exec_list);
3320 vma->vm = vm; 3321 vma->vm = vm;
3321 vma->obj = obj; 3322 vma->obj = obj;
3323 vma->is_ggtt = i915_is_ggtt(vm);
3322 3324
3323 if (i915_is_ggtt(vm)) 3325 if (i915_is_ggtt(vm))
3324 vma->ggtt_view = *ggtt_view; 3326 vma->ggtt_view = *ggtt_view;
3327 else
3328 i915_ppgtt_get(i915_vm_to_ppgtt(vm));
3325 3329
3326 list_add_tail(&vma->obj_link, &obj->vma_list); 3330 list_add_tail(&vma->obj_link, &obj->vma_list);
3327 if (!i915_is_ggtt(vm))
3328 i915_ppgtt_get(i915_vm_to_ppgtt(vm));
3329 3331
3330 return vma; 3332 return vma;
3331} 3333}
@@ -3598,13 +3600,9 @@ int i915_vma_bind(struct i915_vma *vma, enum i915_cache_level cache_level,
3598 return 0; 3600 return 0;
3599 3601
3600 if (vma->bound == 0 && vma->vm->allocate_va_range) { 3602 if (vma->bound == 0 && vma->vm->allocate_va_range) {
3601 trace_i915_va_alloc(vma->vm,
3602 vma->node.start,
3603 vma->node.size,
3604 VM_TO_TRACE_NAME(vma->vm));
3605
3606 /* XXX: i915_vma_pin() will fix this +- hack */ 3603 /* XXX: i915_vma_pin() will fix this +- hack */
3607 vma->pin_count++; 3604 vma->pin_count++;
3605 trace_i915_va_alloc(vma);
3608 ret = vma->vm->allocate_va_range(vma->vm, 3606 ret = vma->vm->allocate_va_range(vma->vm,
3609 vma->node.start, 3607 vma->node.start,
3610 vma->node.size); 3608 vma->node.size);
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.h b/drivers/gpu/drm/i915/i915_gem_gtt.h
index 31eb0b261fbf..8774f1ba46e7 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.h
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.h
@@ -183,6 +183,7 @@ struct i915_vma {
183#define GLOBAL_BIND (1<<0) 183#define GLOBAL_BIND (1<<0)
184#define LOCAL_BIND (1<<1) 184#define LOCAL_BIND (1<<1)
185 unsigned int bound : 4; 185 unsigned int bound : 4;
186 bool is_ggtt : 1;
186 187
187 /** 188 /**
188 * Support different GGTT views into the same object. 189 * Support different GGTT views into the same object.
@@ -275,6 +276,8 @@ struct i915_address_space {
275 u64 start; /* Start offset always 0 for dri2 */ 276 u64 start; /* Start offset always 0 for dri2 */
276 u64 total; /* size addr space maps (ex. 2GB for ggtt) */ 277 u64 total; /* size addr space maps (ex. 2GB for ggtt) */
277 278
279 bool is_ggtt;
280
278 struct i915_page_scratch *scratch_page; 281 struct i915_page_scratch *scratch_page;
279 struct i915_page_table *scratch_pt; 282 struct i915_page_table *scratch_pt;
280 struct i915_page_directory *scratch_pd; 283 struct i915_page_directory *scratch_pd;
@@ -330,6 +333,8 @@ struct i915_address_space {
330 u32 flags); 333 u32 flags);
331}; 334};
332 335
336#define i915_is_ggtt(V) ((V)->is_ggtt)
337
333/* The Graphics Translation Table is the way in which GEN hardware translates a 338/* The Graphics Translation Table is the way in which GEN hardware translates a
334 * Graphics Virtual Address into a Physical Address. In addition to the normal 339 * Graphics Virtual Address into a Physical Address. In addition to the normal
335 * collateral associated with any va->pa translations GEN hardware also has a 340 * collateral associated with any va->pa translations GEN hardware also has a
diff --git a/drivers/gpu/drm/i915/i915_trace.h b/drivers/gpu/drm/i915/i915_trace.h
index 52b2d409945d..fa09e5581137 100644
--- a/drivers/gpu/drm/i915/i915_trace.h
+++ b/drivers/gpu/drm/i915/i915_trace.h
@@ -175,35 +175,24 @@ TRACE_EVENT(i915_vma_unbind,
175 __entry->obj, __entry->offset, __entry->size, __entry->vm) 175 __entry->obj, __entry->offset, __entry->size, __entry->vm)
176); 176);
177 177
178#define VM_TO_TRACE_NAME(vm) \ 178TRACE_EVENT(i915_va_alloc,
179 (i915_is_ggtt(vm) ? "G" : \ 179 TP_PROTO(struct i915_vma *vma),
180 "P") 180 TP_ARGS(vma),
181
182DECLARE_EVENT_CLASS(i915_va,
183 TP_PROTO(struct i915_address_space *vm, u64 start, u64 length, const char *name),
184 TP_ARGS(vm, start, length, name),
185 181
186 TP_STRUCT__entry( 182 TP_STRUCT__entry(
187 __field(struct i915_address_space *, vm) 183 __field(struct i915_address_space *, vm)
188 __field(u64, start) 184 __field(u64, start)
189 __field(u64, end) 185 __field(u64, end)
190 __string(name, name)
191 ), 186 ),
192 187
193 TP_fast_assign( 188 TP_fast_assign(
194 __entry->vm = vm; 189 __entry->vm = vma->vm;
195 __entry->start = start; 190 __entry->start = vma->node.start;
196 __entry->end = start + length - 1; 191 __entry->end = vma->node.start + vma->node.size - 1;
197 __assign_str(name, name);
198 ), 192 ),
199 193
200 TP_printk("vm=%p (%s), 0x%llx-0x%llx", 194 TP_printk("vm=%p (%c), 0x%llx-0x%llx",
201 __entry->vm, __get_str(name), __entry->start, __entry->end) 195 __entry->vm, i915_is_ggtt(__entry->vm) ? 'G' : 'P', __entry->start, __entry->end)
202);
203
204DEFINE_EVENT(i915_va, i915_va_alloc,
205 TP_PROTO(struct i915_address_space *vm, u64 start, u64 length, const char *name),
206 TP_ARGS(vm, start, length, name)
207); 196);
208 197
209DECLARE_EVENT_CLASS(i915_px_entry, 198DECLARE_EVENT_CLASS(i915_px_entry,