Skip to contentSkip to conversation

drm/ttm: partial revert "cleanup ttm_tt_(unbind|destroy)"

PATCH In review Christian König 3 participants 3 messages Jul 21, 2016 – Jul 22, 2016 1 message not in the archive

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

PATCH 1/1 drm/ttm: partial revert "cleanup ttm_tt_(unbind|destroy)"

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

We still need to unbind explicitely during a move.

This partial reverts commit ff20caa0bcbfef9f7686f8d1868a3b990921afd6.

---
 drivers/gpu/drm/ttm/ttm_bo_util.c |  1 +
 drivers/gpu/drm/ttm/ttm_tt.c      | 15 ++++++++++++---
 include/drm/ttm/ttm_bo_driver.h   |  9 +++++++++
 3 files changed, 22 insertions(+), 3 deletions(-)
drivers/gpu/drm/ttm/ttm_bo_util.c +1 -0
index 0c389a5..6c412c3 100644
@@ -53,6 +53,7 @@ int ttm_bo_move_ttm(struct ttm_buffer_object *bo,
 	int ret;
 
 	if (old_mem->mem_type != TTM_PL_SYSTEM) {
+		ttm_tt_unbind(ttm);
 		ttm_bo_free_old_node(bo);
 		ttm_flag_masked(&old_mem->placement, TTM_PL_FLAG_SYSTEM,
 				TTM_PL_MASK_MEM);
drivers/gpu/drm/ttm/ttm_tt.c +12 -3
index d28d4333..fa42dc3 100644
@@ -172,9 +172,7 @@ void ttm_tt_destroy(struct ttm_tt *ttm)
 		return;
 
 	if (ttm->state == tt_bound) {
-		ret = ttm->func->unbind(ttm);
-		BUG_ON(ret);
-		ttm->state = tt_unbound;
+		ttm_tt_unbind(ttm);
 	}
 
 	if (ttm->state == tt_unbound)
@@ -255,6 +253,17 @@ void ttm_dma_tt_fini(struct ttm_dma_tt *ttm_dma)
 }
 EXPORT_SYMBOL(ttm_dma_tt_fini);
 
+void ttm_tt_unbind(struct ttm_tt *ttm)
+{
+	int ret;
+
+	if (ttm->state == tt_bound) {
+		ret = ttm->func->unbind(ttm);
+		BUG_ON(ret);
+		ttm->state = tt_unbound;
+	}
+}
+
 int ttm_tt_bind(struct ttm_tt *ttm, struct ttm_mem_reg *bo_mem)
 {
 	int ret = 0;
include/drm/ttm/ttm_bo_driver.h +9 -0
index 141cefb..e7d81a8 100644
@@ -628,6 +628,15 @@ extern int ttm_tt_bind(struct ttm_tt *ttm, struct ttm_mem_reg *bo_mem);
 extern void ttm_tt_destroy(struct ttm_tt *ttm);
 
 /**
+ * ttm_ttm_unbind:
+ *
+ * @ttm: The struct ttm_tt.
+ *
+ * Unbind a struct ttm_tt.
+ */
+extern void ttm_tt_unbind(struct ttm_tt *ttm);
+
+/**
  * ttm_tt_swapin:
  *
  * @ttm: The struct ttm_tt.
Signature · 6 lines
2.5.0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1469097271-3378-1-git-send-email-deathsimple-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org

#2 lore raw

This patch introduces a compile warning:

/home/fkuehlin/compute/kernel/drivers/gpu/drm/ttm/ttm_tt.c: In function ‘ttm_tt_destroy’:
/home/fkuehlin/compute/kernel/drivers/gpu/drm/ttm/ttm_tt.c:169:6: warning: unused variable ‘ret’ [-Wunused-variable]

  int ret;
      ^

Regards,
Felix

Quoted 68 lines · Christian König

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

We still need to unbind explicitely during a move.

This partial reverts commit ff20caa0bcbfef9f7686f8d1868a3b990921afd6.

---
 drivers/gpu/drm/ttm/ttm_bo_util.c |  1 +
 drivers/gpu/drm/ttm/ttm_tt.c      | 15 ++++++++++++---
 include/drm/ttm/ttm_bo_driver.h   |  9 +++++++++
 3 files changed, 22 insertions(+), 3 deletions(-)
drivers/gpu/drm/ttm/ttm_bo_util.c +1 -0
index 0c389a5..6c412c3 100644
@@ -53,6 +53,7 @@ int ttm_bo_move_ttm(struct ttm_buffer_object *bo,
 	int ret;
 
 	if (old_mem->mem_type != TTM_PL_SYSTEM) {
+		ttm_tt_unbind(ttm);
 		ttm_bo_free_old_node(bo);
 		ttm_flag_masked(&old_mem->placement, TTM_PL_FLAG_SYSTEM,
 				TTM_PL_MASK_MEM);
drivers/gpu/drm/ttm/ttm_tt.c +12 -3
index d28d4333..fa42dc3 100644
@@ -172,9 +172,7 @@ void ttm_tt_destroy(struct ttm_tt *ttm)
 		return;
 
 	if (ttm->state == tt_bound) {
-		ret = ttm->func->unbind(ttm);
-		BUG_ON(ret);
-		ttm->state = tt_unbound;
+		ttm_tt_unbind(ttm);
 	}
 
 	if (ttm->state == tt_unbound)
@@ -255,6 +253,17 @@ void ttm_dma_tt_fini(struct ttm_dma_tt *ttm_dma)
 }
 EXPORT_SYMBOL(ttm_dma_tt_fini);
 
+void ttm_tt_unbind(struct ttm_tt *ttm)
+{
+	int ret;
+
+	if (ttm->state == tt_bound) {
+		ret = ttm->func->unbind(ttm);
+		BUG_ON(ret);
+		ttm->state = tt_unbound;
+	}
+}
+
 int ttm_tt_bind(struct ttm_tt *ttm, struct ttm_mem_reg *bo_mem)
 {
 	int ret = 0;
include/drm/ttm/ttm_bo_driver.h +2 -0
index 141cefb..e7d81a8 100644
@@ -628,6 +628,15 @@ extern int ttm_tt_bind(struct ttm_tt *ttm, struct ttm_mem_reg *bo_mem);
 extern void ttm_tt_destroy(struct ttm_tt *ttm);
 
 /**
+ * ttm_ttm_unbind:
+ *

include/drm/ttm/ttm_bo_driver.h extern int ttm_tt_bind(struct ttm_tt *ttm, struct ttm_mem_reg *bo_mem); · line 642

Quoted 10 lines
include/drm/ttm/ttm_bo_driver.h +7 -0
+ * @ttm: The struct ttm_tt.
+ *
+ * Unbind a struct ttm_tt.
+ */
+extern void ttm_tt_unbind(struct ttm_tt *ttm);
+
+/**
  * ttm_tt_swapin:
  *
  * @ttm: The struct ttm_tt.

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#3 lore raw
In reply to a message not in the archive
Quoted 30 lines · Christian König

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

We still need to unbind explicitely during a move.

This partial reverts commit ff20caa0bcbfef9f7686f8d1868a3b990921afd6.

---
 drivers/gpu/drm/ttm/ttm_bo_util.c |  1 +
 drivers/gpu/drm/ttm/ttm_tt.c      | 15 ++++++++++++---
 include/drm/ttm/ttm_bo_driver.h   |  9 +++++++++
 3 files changed, 22 insertions(+), 3 deletions(-)
drivers/gpu/drm/ttm/ttm_bo_util.c +1 -0
index 0c389a5..6c412c3 100644
@@ -53,6 +53,7 @@ int ttm_bo_move_ttm(struct ttm_buffer_object *bo,
 	int ret;
 
 	if (old_mem->mem_type != TTM_PL_SYSTEM) {
+		ttm_tt_unbind(ttm);
 		ttm_bo_free_old_node(bo);
 		ttm_flag_masked(&old_mem->placement, TTM_PL_FLAG_SYSTEM,
 				TTM_PL_MASK_MEM);
drivers/gpu/drm/ttm/ttm_tt.c +0 -0
index d28d4333..fa42dc3 100644

drivers/gpu/drm/ttm/ttm_tt.c void ttm_tt_destroy(struct ttm_tt *ttm) · line 176

Quoted 8 lines
drivers/gpu/drm/ttm/ttm_tt.c +1 -3
@@ -172,9 +172,7 @@ void ttm_tt_destroy(struct ttm_tt *ttm)
 		return;
 
 	if (ttm->state == tt_bound) {
-		ret = ttm->func->unbind(ttm);
-		BUG_ON(ret);
-		ttm->state = tt_unbound;
+		ttm_tt_unbind(ttm);
 	}

Why keep the branch here given that the branch is also within 'ttm_tt_unbind()'?

drivers/gpu/drm/ttm/ttm_tt.c void ttm_dma_tt_fini(struct ttm_dma_tt *ttm_dma) · line 261

Quoted 12 lines
drivers/gpu/drm/ttm/ttm_tt.c +6 -0
 	if (ttm->state == tt_unbound)
@@ -255,6 +253,17 @@ void ttm_dma_tt_fini(struct ttm_dma_tt *ttm_dma)
 }
 EXPORT_SYMBOL(ttm_dma_tt_fini);
 
+void ttm_tt_unbind(struct ttm_tt *ttm)
+{
+	int ret;
+
+	if (ttm->state == tt_bound) {
+		ret = ttm->func->unbind(ttm);

int ret; here

Kind Regards,
Edward.

Quoted 19 lines
drivers/gpu/drm/ttm/ttm_tt.c +5 -0
+		BUG_ON(ret);
+		ttm->state = tt_unbound;
+	}
+}
+
 int ttm_tt_bind(struct ttm_tt *ttm, struct ttm_mem_reg *bo_mem)
 {
 	int ret = 0;
include/drm/ttm/ttm_bo_driver.h +2 -0
index 141cefb..e7d81a8 100644
@@ -628,6 +628,15 @@ extern int ttm_tt_bind(struct ttm_tt *ttm, struct ttm_mem_reg *bo_mem);
 extern void ttm_tt_destroy(struct ttm_tt *ttm);
 
 /**
+ * ttm_ttm_unbind:
+ *

include/drm/ttm/ttm_bo_driver.h extern int ttm_tt_bind(struct ttm_tt *ttm, struct ttm_mem_reg *bo_mem); · line 642

Quoted 10 lines
include/drm/ttm/ttm_bo_driver.h +7 -0
+ * @ttm: The struct ttm_tt.
+ *
+ * Unbind a struct ttm_tt.
+ */
+extern void ttm_tt_unbind(struct ttm_tt *ttm);
+
+/**
  * ttm_tt_swapin:
  *
  * @ttm: The struct ttm_tt.

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx