@@ -2115,6 +2115,7 @@ static struct i915_vma *__i915_gem_vma_create(struct drm_i915_gem_object *obj,
return ERR_PTR(-ENOMEM);
INIT_LIST_HEAD(&vma->vma_link);
+ INIT_LIST_HEAD(&vma->pin_capture_link);
INIT_LIST_HEAD(&vma->mm_list);
INIT_LIST_HEAD(&vma->exec_list);
vma->vm = vm;
@@ -126,6 +126,8 @@ struct i915_vma {
struct list_head vma_link; /* Link in the object's VMA list */
+ struct list_head pin_capture_link; /* Link in the error capture */
+
/** This vma's place in the batchbuffer or on the eviction list */
struct list_head exec_list;
@@ -677,14 +677,14 @@ static u32 capture_active_bo(struct drm_i915_error_buffer *err,
static u32 capture_pinned_bo(struct drm_i915_error_buffer *err,
int count, struct list_head *head)
{
- struct drm_i915_gem_object *obj;
+ struct i915_vma *vma;
int i = 0;
- list_for_each_entry(obj, head, global_list) {
- if (!i915_gem_obj_is_pinned(obj))
+ list_for_each_entry(vma, head, pin_capture_link) {
+ if (!i915_gem_obj_is_pinned(vma->obj))
continue;
- capture_bo(err++, obj);
+ capture_bo(err++, vma->obj);
if (++i == count)
break;
}
@@ -1031,21 +1031,32 @@ static void i915_gem_capture_vm(struct drm_i915_private *dev_priv,
const int vm_ndx)
{
struct drm_i915_error_buffer *active_bo = NULL, *pinned_bo = NULL;
- struct drm_i915_gem_object *obj;
struct i915_vma *vma;
int active_vma_count = 0;
+ int vma_pin_count = 0;
+ LIST_HEAD(pinned_vma);
- list_for_each_entry(vma, &vm->active_list, mm_list)
+ list_for_each_entry(vma, &vm->active_list, mm_list) {
active_vma_count++;
+ if (vma->pin_count) {
+ vma_pin_count++;
+ list_move_tail(&vma->pin_capture_link, &pinned_vma);
+ }
+ }
- error->active_bo_count[vm_ndx] = active_vma_count;
-
- list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list)
- if (i915_gem_obj_is_pinned(obj))
- active_vma_count++;
+ list_for_each_entry(vma, &vm->inactive_list, mm_list) {
+ /* Certain objects may be on the inactive list, but pinned, when
+ * in the global GGTT. */
+ if (WARN_ON(!i915_is_ggtt(vm) &&
+ vma->pin_count &&
+ !(vma->exec_entry->flags & (1<<31)))) { /* FIXME: need the actual flag */
+ vma_pin_count++;
+ list_move_tail(&vma->pin_capture_link, &pinned_vma);
+ }
+ }
- /* XXX: this is an incorrect measurement of pinned BOs */
- error->pinned_bo_count[vm_ndx] = active_vma_count - error->active_bo_count[vm_ndx];
+ error->active_bo_count[vm_ndx] = active_vma_count;
+ error->pinned_bo_count[vm_ndx] = vma_pin_count;
if (active_vma_count) {
active_bo = kcalloc(active_vma_count, sizeof(*active_bo), GFP_ATOMIC);
@@ -1063,7 +1074,7 @@ static void i915_gem_capture_vm(struct drm_i915_private *dev_priv,
error->pinned_bo_count[vm_ndx] =
capture_pinned_bo(pinned_bo,
error->pinned_bo_count[vm_ndx],
- &dev_priv->mm.bound_list);
+ &pinned_vma);
error->active_bo[vm_ndx] = active_bo;
error->pinned_bo[vm_ndx] = pinned_bo;
}