Skip to contentSkip to conversation

drm/radeon: fix VMID use tracking

PATCH In review Christian König 2 participants 6 messages Jan 23, 2014 – Jan 24, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 drm/radeon: fix VMID use tracking

From: Christian König <[email protected]>

Otherwise we allocate a new VMID on nearly every submit.

---
 drivers/gpu/drm/radeon/radeon.h      | 2 ++
 drivers/gpu/drm/radeon/radeon_gart.c | 8 +++++++-
 2 files changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/radeon/radeon.h +2 -0
index c5519ca..4a8ac1c 100644
@@ -867,6 +867,8 @@ struct radeon_vm {
 	struct radeon_fence		*fence;
 	/* last flush or NULL if we still need to flush */
 	struct radeon_fence		*last_flush;
+	/* last use of vmid */
+	struct radeon_fence		*last_id_use;
 };
 
 struct radeon_vm_manager {
drivers/gpu/drm/radeon/radeon_gart.c +7 -1
index 96e4400..0e9143b 100644
@@ -713,7 +713,7 @@ struct radeon_fence *radeon_vm_grab_id(struct radeon_device *rdev,
 	unsigned i;
 
 	/* check if the id is still valid */
-	if (vm->fence && vm->fence == rdev->vm_manager.active[vm->id])
+	if (vm->last_id_use && vm->last_id_use == rdev->vm_manager.active[vm->id])
 		return NULL;
 
 	/* we definately need to flush */
@@ -769,6 +769,9 @@ void radeon_vm_fence(struct radeon_device *rdev,
 
 	radeon_fence_unref(&vm->fence);
 	vm->fence = radeon_fence_ref(fence);
+
+	radeon_fence_unref(&vm->last_id_use);
+	vm->last_id_use = radeon_fence_ref(fence);
 }
 
 /**
@@ -1303,6 +1306,8 @@ void radeon_vm_init(struct radeon_device *rdev, struct radeon_vm *vm)
 {
 	vm->id = 0;
 	vm->fence = NULL;
+	vm->last_flush = NULL;
+	vm->last_id_use = NULL;
 	mutex_init(&vm->mutex);
 	INIT_LIST_HEAD(&vm->list);
 	INIT_LIST_HEAD(&vm->va);
@@ -1341,5 +1346,6 @@ void radeon_vm_fini(struct radeon_device *rdev, struct radeon_vm *vm)
 	}
 	radeon_fence_unref(&vm->fence);
 	radeon_fence_unref(&vm->last_flush);
+	radeon_fence_unref(&vm->last_id_use);
 	mutex_unlock(&vm->mutex);
 }
Signature · 6 lines
1.8.1.2

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw

PATCH 2/3 drm/radeon: add missing trace point

From: Christian König <[email protected]>

---
 drivers/gpu/drm/radeon/radeon_gart.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/radeon/radeon_gart.c +1 -0
index 0e9143b..a8f9b46 100644
@@ -726,6 +726,7 @@ struct radeon_fence *radeon_vm_grab_id(struct radeon_device *rdev,
 		if (fence == NULL) {
 			/* found a free one */
 			vm->id = i;
+			trace_radeon_vm_grab_id(vm->id, ring);
 			return NULL;
 		}
 
Signature · 6 lines
1.8.1.2

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw

PATCH 3/3 drm/radeon: add ring to fence trace functions

In reply to Christian König

From: Christian König <[email protected]>

---
 drivers/gpu/drm/radeon/radeon_fence.c |  6 +++---
 drivers/gpu/drm/radeon/radeon_trace.h | 21 ++++++++++++---------
 2 files changed, 15 insertions(+), 12 deletions(-)
drivers/gpu/drm/radeon/radeon_fence.c +3 -3
index 866744e..c37cb79 100644
@@ -121,7 +121,7 @@ int radeon_fence_emit(struct radeon_device *rdev,
 	(*fence)->seq = ++rdev->fence_drv[ring].sync_seq[ring];
 	(*fence)->ring = ring;
 	radeon_fence_ring_emit(rdev, ring, *fence);
-	trace_radeon_fence_emit(rdev->ddev, (*fence)->seq);
+	trace_radeon_fence_emit(rdev->ddev, ring, (*fence)->seq);
 	return 0;
 }
 
@@ -313,7 +313,7 @@ static int radeon_fence_wait_seq(struct radeon_device *rdev, u64 *target_seq,
 				continue;
 
 			last_seq[i] = atomic64_read(&rdev->fence_drv[i].last_seq);
-			trace_radeon_fence_wait_begin(rdev->ddev, target_seq[i]);
+			trace_radeon_fence_wait_begin(rdev->ddev, i, target_seq[i]);
 			radeon_irq_kms_sw_irq_get(rdev, i);
 		}
 
@@ -332,7 +332,7 @@ static int radeon_fence_wait_seq(struct radeon_device *rdev, u64 *target_seq,
 				continue;
 
 			radeon_irq_kms_sw_irq_put(rdev, i);
-			trace_radeon_fence_wait_end(rdev->ddev, target_seq[i]);
+			trace_radeon_fence_wait_end(rdev->ddev, i, target_seq[i]);
 		}
 
 		if (unlikely(r < 0))
drivers/gpu/drm/radeon/radeon_trace.h +12 -9
index 0473257..f749f2c 100644
@@ -106,42 +106,45 @@ TRACE_EVENT(radeon_vm_set_page,
 
 DECLARE_EVENT_CLASS(radeon_fence_request,
 
-	    TP_PROTO(struct drm_device *dev, u32 seqno),
+	    TP_PROTO(struct drm_device *dev, int ring, u32 seqno),
 
-	    TP_ARGS(dev, seqno),
+	    TP_ARGS(dev, ring, seqno),
 
 	    TP_STRUCT__entry(
 			     __field(u32, dev)
+			     __field(int, ring)
 			     __field(u32, seqno)
 			     ),
 
 	    TP_fast_assign(
 			   __entry->dev = dev->primary->index;
+			   __entry->ring = ring;
 			   __entry->seqno = seqno;
 			   ),
 
-	    TP_printk("dev=%u, seqno=%u", __entry->dev, __entry->seqno)
+	    TP_printk("dev=%u, ring=%d, seqno=%u",
+		      __entry->dev, __entry->ring, __entry->seqno)
 );
 
 DEFINE_EVENT(radeon_fence_request, radeon_fence_emit,
 
-	    TP_PROTO(struct drm_device *dev, u32 seqno),
+	    TP_PROTO(struct drm_device *dev, int ring, u32 seqno),
 
-	    TP_ARGS(dev, seqno)
+	    TP_ARGS(dev, ring, seqno)
 );
 
 DEFINE_EVENT(radeon_fence_request, radeon_fence_wait_begin,
 
-	    TP_PROTO(struct drm_device *dev, u32 seqno),
+	    TP_PROTO(struct drm_device *dev, int ring, u32 seqno),
 
-	    TP_ARGS(dev, seqno)
+	    TP_ARGS(dev, ring, seqno)
 );
 
 DEFINE_EVENT(radeon_fence_request, radeon_fence_wait_end,
 
-	    TP_PROTO(struct drm_device *dev, u32 seqno),
+	    TP_PROTO(struct drm_device *dev, int ring, u32 seqno),
 
-	    TP_ARGS(dev, seqno)
+	    TP_ARGS(dev, ring, seqno)
 );
 
 DECLARE_EVENT_CLASS(radeon_semaphore_request,
Signature · 6 lines
1.8.1.2

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#3 lore raw
In reply to Christian König
Quoted 3 lines · Christian König

From: Christian König <[email protected]>

Otherwise we allocate a new VMID on nearly every submit.

I wonder if this fix would allow us to fix up this:
http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=466476dfdcafbb4286ffa232a3a792731b9dc852

Alex

Quoted 62 lines
---
 drivers/gpu/drm/radeon/radeon.h      | 2 ++
 drivers/gpu/drm/radeon/radeon_gart.c | 8 +++++++-
 2 files changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/radeon/radeon.h +2 -0
index c5519ca..4a8ac1c 100644
@@ -867,6 +867,8 @@ struct radeon_vm {
        struct radeon_fence             *fence;
        /* last flush or NULL if we still need to flush */
        struct radeon_fence             *last_flush;
+       /* last use of vmid */
+       struct radeon_fence             *last_id_use;
 };
 
 struct radeon_vm_manager {
drivers/gpu/drm/radeon/radeon_gart.c +7 -2
index 96e4400..0e9143b 100644
@@ -713,7 +713,7 @@ struct radeon_fence *radeon_vm_grab_id(struct radeon_device *rdev,
        unsigned i;
 
        /* check if the id is still valid */
-       if (vm->fence && vm->fence == rdev->vm_manager.active[vm->id])
+       if (vm->last_id_use && vm->last_id_use == rdev->vm_manager.active[vm->id])
                return NULL;
 
        /* we definately need to flush */
@@ -769,6 +769,9 @@ void radeon_vm_fence(struct radeon_device *rdev,
 
        radeon_fence_unref(&vm->fence);
        vm->fence = radeon_fence_ref(fence);
+
+       radeon_fence_unref(&vm->last_id_use);
+       vm->last_id_use = radeon_fence_ref(fence);
 }
 
 /**
@@ -1303,6 +1306,8 @@ void radeon_vm_init(struct radeon_device *rdev, struct radeon_vm *vm)
 {
        vm->id = 0;
        vm->fence = NULL;
+       vm->last_flush = NULL;
+       vm->last_id_use = NULL;
        mutex_init(&vm->mutex);
        INIT_LIST_HEAD(&vm->list);
        INIT_LIST_HEAD(&vm->va);
@@ -1341,5 +1346,6 @@ void radeon_vm_fini(struct radeon_device *rdev, struct radeon_vm *vm)
        }
        radeon_fence_unref(&vm->fence);
        radeon_fence_unref(&vm->last_flush);
+       radeon_fence_unref(&vm->last_id_use);
        mutex_unlock(&vm->mutex);
 }
--

1.8.1.2

#4 lore raw

Am 23.01.2014 18:46, schrieb Alex Deucher:

Quoted 7 lines
Quoted 3 lines · Christian König

From: Christian König <[email protected]>

Otherwise we allocate a new VMID on nearly every submit.

I wonder if this fix would allow us to fix up this:
http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=466476dfdcafbb4286ffa232a3a792731b9dc852

It's probably a step into the right direction, but not necessary the complete solution.

For now I would say we should keep the extra flushing as it is.

Christian.

Quoted 63 lines

Alex

Quoted 61 lines
---
  drivers/gpu/drm/radeon/radeon.h      | 2 ++
  drivers/gpu/drm/radeon/radeon_gart.c | 8 +++++++-
  2 files changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/radeon/radeon.h +2 -0
index c5519ca..4a8ac1c 100644
@@ -867,6 +867,8 @@ struct radeon_vm {
         struct radeon_fence             *fence;
         /* last flush or NULL if we still need to flush */
         struct radeon_fence             *last_flush;
+       /* last use of vmid */
+       struct radeon_fence             *last_id_use;
  };
 
  struct radeon_vm_manager {
drivers/gpu/drm/radeon/radeon_gart.c +7 -2
index 96e4400..0e9143b 100644
@@ -713,7 +713,7 @@ struct radeon_fence *radeon_vm_grab_id(struct radeon_device *rdev,
         unsigned i;
 
         /* check if the id is still valid */
-       if (vm->fence && vm->fence == rdev->vm_manager.active[vm->id])
+       if (vm->last_id_use && vm->last_id_use == rdev->vm_manager.active[vm->id])
                 return NULL;
 
         /* we definately need to flush */
@@ -769,6 +769,9 @@ void radeon_vm_fence(struct radeon_device *rdev,
 
         radeon_fence_unref(&vm->fence);
         vm->fence = radeon_fence_ref(fence);
+
+       radeon_fence_unref(&vm->last_id_use);
+       vm->last_id_use = radeon_fence_ref(fence);
  }
 
  /**
@@ -1303,6 +1306,8 @@ void radeon_vm_init(struct radeon_device *rdev, struct radeon_vm *vm)
  {
         vm->id = 0;
         vm->fence = NULL;
+       vm->last_flush = NULL;
+       vm->last_id_use = NULL;
         mutex_init(&vm->mutex);
         INIT_LIST_HEAD(&vm->list);
         INIT_LIST_HEAD(&vm->va);
@@ -1341,5 +1346,6 @@ void radeon_vm_fini(struct radeon_device *rdev, struct radeon_vm *vm)
         }
         radeon_fence_unref(&vm->fence);
         radeon_fence_unref(&vm->last_flush);
+       radeon_fence_unref(&vm->last_id_use);
         mutex_unlock(&vm->mutex);
  }
--

1.8.1.2

#5 lore raw
Quoted 11 lines · Christian König

Am 23.01.2014 18:46, schrieb Alex Deucher:

Quoted 9 lines
Quoted 4 lines · Christian König

From: Christian König <[email protected]>

Otherwise we allocate a new VMID on nearly every submit.

I wonder if this fix would allow us to fix up this:

Quoted 7 lines
Quoted 1 line

http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=466476dfdcafbb4286ffa232a3a792731b9dc852

It's probably a step into the right direction, but not necessary the complete solution.

For now I would say we should keep the extra flushing as it is.

Patches applied. thanks!

Alex

Quoted 74 lines

Christian.

Quoted 69 lines

Alex

Quoted 67 lines
---
  drivers/gpu/drm/radeon/radeon.h      | 2 ++
  drivers/gpu/drm/radeon/radeon_gart.c | 8 +++++++-
  2 files changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/radeon/radeon.h +2 -0
index c5519ca..4a8ac1c 100644
@@ -867,6 +867,8 @@ struct radeon_vm {
         struct radeon_fence             *fence;
         /* last flush or NULL if we still need to flush */
         struct radeon_fence             *last_flush;
+       /* last use of vmid */
+       struct radeon_fence             *last_id_use;
  };
 
  struct radeon_vm_manager {
drivers/gpu/drm/radeon/radeon_gart.c +1 -1
index 96e4400..0e9143b 100644
@@ -713,7 +713,7 @@ struct radeon_fence *radeon_vm_grab_id(struct
 radeon_device *rdev,
         unsigned i;
 
         /* check if the id is still valid */
-       if (vm->fence && vm->fence == rdev->vm_manager.active[vm->id])
+       if (vm->last_id_use && vm->last_id_use ==
 rdev->vm_manager.active[vm->id])
                 return NULL;
         /* we definately need to flush */
drivers/gpu/drm/radeon/radeon_gart.c +5 -0
@@ -769,6 +769,9 @@ void radeon_vm_fence(struct radeon_device *rdev,
 
         radeon_fence_unref(&vm->fence);
         vm->fence = radeon_fence_ref(fence);
+
+       radeon_fence_unref(&vm->last_id_use);
+       vm->last_id_use = radeon_fence_ref(fence);
  }
 
  /**
@@ -1303,6 +1306,8 @@ void radeon_vm_init(struct radeon_device *rdev,
 struct radeon_vm *vm)
  {
         vm->id = 0;
         vm->fence = NULL;
+       vm->last_flush = NULL;
+       vm->last_id_use = NULL;
         mutex_init(&vm->mutex);
         INIT_LIST_HEAD(&vm->list);
         INIT_LIST_HEAD(&vm->va);
drivers/gpu/drm/radeon/radeon_gart.c +1 -0
@@ -1341,5 +1346,6 @@ void radeon_vm_fini(struct radeon_device *rdev,
 struct radeon_vm *vm)
         }
         radeon_fence_unref(&vm->fence);
         radeon_fence_unref(&vm->last_flush);
+       radeon_fence_unref(&vm->last_id_use);
         mutex_unlock(&vm->mutex);

}
--
1.8.1.2