Skip to contentSkip to conversation

drm/radeon: invalidate moved BOs in the VM

PATCH In review Christian König 2 participants 5 messages Jul 18, 2014 – Jul 29, 2014

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

PATCH 1/4 drm/radeon: invalidate moved BOs in the VM

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

Don't wait for the BO to be used again, just
update the PT on the next VM use.

---
 drivers/gpu/drm/radeon/radeon.h    |  7 +++++-
 drivers/gpu/drm/radeon/radeon_cs.c |  3 ++-
 drivers/gpu/drm/radeon/radeon_vm.c | 51 ++++++++++++++++++++++++++++++--------
 3 files changed, 49 insertions(+), 12 deletions(-)
drivers/gpu/drm/radeon/radeon.h +6 -1
index 5c9364b..0ec7864 100644
@@ -447,7 +447,7 @@ struct radeon_bo_va {
 	uint64_t			soffset;
 	uint64_t			eoffset;
 	uint32_t			flags;
-	bool				valid;
+	uint64_t			addr;
 	unsigned			ref_count;
 
 	/* protected by vm mutex */
@@ -871,6 +871,9 @@ struct radeon_vm {
 	struct list_head		va;
 	unsigned			id;
 
+	/* BOs moved, but not yet updated in the PT */
+	struct list_head		invalidated;
+
 	/* BOs freed, but not yet updated in the PT */
 	struct list_head		freed;
 
@@ -2875,6 +2878,8 @@ int radeon_vm_update_page_directory(struct radeon_device *rdev,
 				    struct radeon_vm *vm);
 int radeon_vm_clear_freed(struct radeon_device *rdev,
 			  struct radeon_vm *vm);
+int radeon_vm_clear_invalids(struct radeon_device *rdev,
+			     struct radeon_vm *vm);
 int radeon_vm_bo_update(struct radeon_device *rdev,
 			struct radeon_bo_va *bo_va,
 			struct ttm_mem_reg *mem);
drivers/gpu/drm/radeon/radeon_cs.c +2 -1
index 09fcf4d..e372c4142 100644
@@ -500,7 +500,8 @@ static int radeon_bo_vm_update_pte(struct radeon_cs_parser *p,
 		if (r)
 			return r;
 	}
-	return 0;
+
+	return radeon_vm_clear_invalids(rdev, vm);
 }
 
 static int radeon_cs_ib_vm_chunk(struct radeon_device *rdev,
drivers/gpu/drm/radeon/radeon_vm.c +41 -10

120 lines not on this page · raw message

Signature · 6 lines
1.9.1

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

PATCH 2/4 drm/radeon: remove radeon_bo_clear_va

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

Won't work anyway, instead WARN_ON if the VA list isn't empty when we free the BO.

---
 drivers/gpu/drm/radeon/radeon_object.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/gpu/drm/radeon/radeon_object.c +1 -11
index 6c717b2..5a575f6 100644
@@ -46,16 +46,6 @@ static void radeon_bo_clear_surface_reg(struct radeon_bo *bo);
  * function are calling it.
  */
 
-static void radeon_bo_clear_va(struct radeon_bo *bo)
-{
-	struct radeon_bo_va *bo_va, *tmp;
-
-	list_for_each_entry_safe(bo_va, tmp, &bo->va, bo_list) {
-		/* remove from all vm address space */
-		radeon_vm_bo_rmv(bo->rdev, bo_va);
-	}
-}
-
 static void radeon_update_memory_usage(struct radeon_bo *bo,
 				       unsigned mem_type, int sign)
 {
@@ -90,7 +80,7 @@ static void radeon_ttm_bo_destroy(struct ttm_buffer_object *tbo)
 	list_del_init(&bo->list);
 	mutex_unlock(&bo->rdev->gem.mutex);
 	radeon_bo_clear_surface_reg(bo);
-	radeon_bo_clear_va(bo);
+	WARN_ON(!list_empty(&bo->va));
 	drm_gem_object_release(&bo->gem_base);
 	kfree(bo);
 }
Signature · 6 lines
1.9.1

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

PATCH 3/4 drm/radeon: use an intervall tree to manage the VMA

In reply to Christian König

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

Scales much better than scanning the address range linearly.

---
 drivers/gpu/drm/Kconfig               |  1 +
 drivers/gpu/drm/radeon/radeon.h       |  7 ++-
 drivers/gpu/drm/radeon/radeon_gem.c   |  4 +-
 drivers/gpu/drm/radeon/radeon_trace.h |  4 +-
 drivers/gpu/drm/radeon/radeon_vm.c    | 84 +++++++++++++++++------------------
 5 files changed, 48 insertions(+), 52 deletions(-)
drivers/gpu/drm/Kconfig +1 -0
index f512004..9b2eedc 100644
@@ -114,6 +114,7 @@ config DRM_RADEON
 	select POWER_SUPPLY
 	select HWMON
 	select BACKLIGHT_CLASS_DEVICE
+	select INTERVAL_TREE
 	help
 	  Choose this option if you have an ATI Radeon graphics card.  There
 	  are both PCI and AGP versions.  You don't need to choose this to
drivers/gpu/drm/radeon/radeon.h +3 -4
index 0ec7864..aa8721b 100644
@@ -64,6 +64,7 @@
 #include <linux/wait.h>
 #include <linux/list.h>
 #include <linux/kref.h>
+#include <linux/interval_tree.h>
 
 #include <ttm/ttm_bo_api.h>
 #include <ttm/ttm_bo_driver.h>
@@ -444,14 +445,12 @@ struct radeon_mman {
 struct radeon_bo_va {
 	/* protected by bo being reserved */
 	struct list_head		bo_list;
-	uint64_t			soffset;
-	uint64_t			eoffset;
 	uint32_t			flags;
 	uint64_t			addr;
 	unsigned			ref_count;
 
 	/* protected by vm mutex */
-	struct list_head		vm_list;
+	struct interval_tree_node	it;
 	struct list_head		vm_status;
 
 	/* constant after initialization */
@@ -868,7 +867,7 @@ struct radeon_vm_pt {
 };
 
 struct radeon_vm {
-	struct list_head		va;
+	struct rb_root			va;
 	unsigned			id;
 
 	/* BOs moved, but not yet updated in the PT */
drivers/gpu/drm/radeon/radeon_gem.c +2 -2
index 07a13c9..b2f2ba2 100644
@@ -502,9 +502,9 @@ int radeon_gem_va_ioctl(struct drm_device *dev, void *data,
 
 	switch (args->operation) {
 	case RADEON_VA_MAP:
-		if (bo_va->soffset) {
+		if (bo_va->it.start) {
 			args->operation = RADEON_VA_RESULT_VA_EXIST;
-			args->offset = bo_va->soffset;
+			args->offset = bo_va->it.start;
 			goto out;
 		}
 		r = radeon_vm_bo_set_addr(rdev, bo_va, args->offset, args->flags);
drivers/gpu/drm/radeon/radeon_trace.h +2 -2
index f749f2c..2ae4eaa 100644
@@ -72,8 +72,8 @@ TRACE_EVENT(radeon_vm_bo_update,
 			     ),
 
 	    TP_fast_assign(
-			   __entry->soffset = bo_va->soffset;
-			   __entry->eoffset = bo_va->eoffset;
+			   __entry->soffset = bo_va->it.start;
+			   __entry->eoffset = bo_va->it.last + 1;
 			   __entry->flags = bo_va->flags;
 			   ),
 	    TP_printk("soffs=%010llx, eoffs=%010llx, flags=%08x",
drivers/gpu/drm/radeon/radeon_vm.c +40 -44

159 lines not on this page · raw message

Signature · 6 lines
1.9.1

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

PATCH 4/4 drm/radeon: try to enable VM flushing once more

In reply to Christian König

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

Let's try to fix bugs related to this instead of just disabling it.

---
 drivers/gpu/drm/radeon/radeon_vm.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/radeon/radeon_vm.c +1 -2
index dcbcfbf..f6787bb 100644
@@ -238,8 +238,7 @@ void radeon_vm_flush(struct radeon_device *rdev,
 	uint64_t pd_addr = radeon_bo_gpu_offset(vm->page_directory);
 
 	/* if we can't remember our last VM flush then flush now! */
-	/* XXX figure out why we have to flush all the time */
-	if (!vm->last_flush || true || pd_addr != vm->pd_gpu_addr) {
+	if (!vm->last_flush || pd_addr != vm->pd_gpu_addr) {
 		vm->pd_gpu_addr = pd_addr;
 		radeon_ring_vm_flush(rdev, ring, vm);
 	}
Signature · 6 lines
1.9.1

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