Skip to contentSkip to conversation

drm/vmwgfx: free bo resource before assigning new one

PATCH In review Nirmoy Das 2 participants 8 messages Jun 8, 2021 – Jun 9, 2021

Subsystems (3)
lore
Share & tools
lore

Nirmoy Das

author
#0 lore raw

PATCH 1/1 drm/vmwgfx: free bo resource before assigning new one

ttm_bo_assign_mem() expects bo->resource to be free.

Fixes bfa3357ef9abc ("drm/ttm: allocate resource object instead of embedding it v2")
---
 drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c +1 -0
index bfcf31bf7e37..7281912436bb 100644
@@ -733,6 +733,7 @@ static int vmw_move(struct ttm_buffer_object *bo,
 
 	if (old_man->use_tt && new_man->use_tt) {
 		if (bo->resource->mem_type == TTM_PL_SYSTEM) {
+			ttm_resource_free(bo, &bo->resource);
 			ttm_bo_assign_mem(bo, new_mem);
 			return 0;
 		}
Signature · 1 line
2.31.1
#1 lore raw

Am 08.06.21 um 17:09 schrieb Nirmoy Das:

Quoted 13 lines

ttm_bo_assign_mem() expects bo->resource to be free.

Fixes bfa3357ef9abc ("drm/ttm: allocate resource object instead of embedding it v2")
---
  drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c | 1 +
  1 file changed, 1 insertion(+)
drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c +0 -0
index bfcf31bf7e37..7281912436bb 100644

drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c static int vmw_move(struct ttm_buffer_object *bo, · line 737

Quoted 5 lines
drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c +1 -0
@@ -733,6 +733,7 @@ static int vmw_move(struct ttm_buffer_object *bo,
 
  	if (old_man->use_tt && new_man->use_tt) {
  		if (bo->resource->mem_type == TTM_PL_SYSTEM) {
+			ttm_resource_free(bo, &bo->resource);
  			ttm_bo_assign_mem(bo, new_mem);

On second thought we should probably use ttm_bo_move_null() instead here.

Christian.

Quoted 2 lines
drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c +0 -0
  			return 0;
  		}
#2 lore raw
Quoted 11 lines · Christian König

Am 08.06.21 um 17:09 schrieb Nirmoy Das:

Quoted 8 lines

ttm_bo_assign_mem() expects bo->resource to be free.

Fixes bfa3357ef9abc ("drm/ttm: allocate resource object instead of embedding it v2")

---
  drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c | 1 +

  1 file changed, 1 insertion(+)
Quoted 11 lines

drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c static int vmw_move(struct ttm_buffer_object *bo, · line 736

Quoted 9 lines
drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c +1 -0
index bfcf31bf7e37..7281912436bb 100644
@@ -733,6 +733,7 @@ static int vmw_move(struct ttm_buffer_object *bo,
         if (old_man->use_tt && new_man->use_tt) {
           if (bo->resource->mem_type == TTM_PL_SYSTEM) {
+            ttm_resource_free(bo, &bo->resource);
               ttm_bo_assign_mem(bo, new_mem);

On second thought we should probably use ttm_bo_move_null() instead here.

That reminds of https://patchwork.kernel.org/project/dri-devel/patch/[email protected]/ :)

Quoted 6 lines

Christian.

Quoted 2 lines
drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c +0 -0
               return 0;
           }
author
#3 lore raw

PATCH 1/1 drm/vmwgfx: free bo resource before assigning new one

In reply to Christian König

ttm_bo_assign_mem() expects bo->resource to be free.

Fixes bfa3357ef9abc ("drm/ttm: allocate resource object instead of embedding it v2")
---
 drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c +1 -0
index bfcf31bf7e37..7281912436bb 100644
@@ -733,6 +733,7 @@ static int vmw_move(struct ttm_buffer_object *bo,
 
 	if (old_man->use_tt && new_man->use_tt) {
 		if (bo->resource->mem_type == TTM_PL_SYSTEM) {
+			ttm_resource_free(bo, &bo->resource);
 			ttm_bo_assign_mem(bo, new_mem);
 			return 0;
 		}
Signature · 1 line
2.31.1
#4 lore raw

Please ignore this,  I wanted to send https://patchwork.kernel.org/project/dri-devel/patch/[email protected]/

after rebase.

Quoted 20 lines · Nirmoy Das

ttm_bo_assign_mem() expects bo->resource to be free.

Fixes bfa3357ef9abc ("drm/ttm: allocate resource object instead of embedding it v2")
---
  drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c | 1 +
  1 file changed, 1 insertion(+)
drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c +1 -0
index bfcf31bf7e37..7281912436bb 100644
@@ -733,6 +733,7 @@ static int vmw_move(struct ttm_buffer_object *bo,
 
  	if (old_man->use_tt && new_man->use_tt) {
  		if (bo->resource->mem_type == TTM_PL_SYSTEM) {
+			ttm_resource_free(bo, &bo->resource);
  			ttm_bo_assign_mem(bo, new_mem);
  			return 0;
  		}
author
#5 lore raw

PATCH 1/1 drm/vmwgfx: use ttm_bo_move_null() when there is nothing to move

In reply to Christian König

Use ttm_bo_move_null() instead of ttm_bo_assign_mem().

---
 drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c +1 -1
index bfcf31bf7e37..0488042fb287 100644
@@ -733,7 +733,7 @@ static int vmw_move(struct ttm_buffer_object *bo,
 
 	if (old_man->use_tt && new_man->use_tt) {
 		if (bo->resource->mem_type == TTM_PL_SYSTEM) {
-			ttm_bo_assign_mem(bo, new_mem);
+			ttm_bo_move_null(bo, new_mem);
 			return 0;
 		}
 		ret = ttm_bo_wait_ctx(bo, ctx);
Signature · 1 line
2.31.1
#6 lore raw

Re: [PATCH 1/1] drm/vmwgfx: use ttm_bo_move_null() when there is nothing to move

Am 08.06.21 um 20:13 schrieb Nirmoy Das:

Quoted 4 lines

Use ttm_bo_move_null() instead of ttm_bo_assign_mem().

Looks like I've forgot to push that one. *sigh* I'm getting old.

Thanks,
Christian.

Quoted 17 lines
---
  drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c +1 -1
index bfcf31bf7e37..0488042fb287 100644
@@ -733,7 +733,7 @@ static int vmw_move(struct ttm_buffer_object *bo,
 
  	if (old_man->use_tt && new_man->use_tt) {
  		if (bo->resource->mem_type == TTM_PL_SYSTEM) {
-			ttm_bo_assign_mem(bo, new_mem);
+			ttm_bo_move_null(bo, new_mem);
  			return 0;
  		}
  		ret = ttm_bo_wait_ctx(bo, ctx);
#7 lore raw

Re: [PATCH 1/1] drm/vmwgfx: use ttm_bo_move_null() when there is nothing to move

Quoted 7 lines · Christian König

Am 08.06.21 um 20:13 schrieb Nirmoy Das:

Quoted 4 lines

Use ttm_bo_move_null() instead of ttm_bo_assign_mem().

Looks like I've forgot to push that one. *sigh* I'm getting old.

Nah, you have too many stuff on your plate. I should've pinged.

Regards,

Nirmoy

Quoted 21 lines

Thanks,
Christian.

Quoted 16 lines

---
  drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c | 2 +-

  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c +1 -1
index bfcf31bf7e37..0488042fb287 100644
@@ -733,7 +733,7 @@ static int vmw_move(struct ttm_buffer_object *bo,
         if (old_man->use_tt && new_man->use_tt) {
           if (bo->resource->mem_type == TTM_PL_SYSTEM) {
-            ttm_bo_assign_mem(bo, new_mem);
+            ttm_bo_move_null(bo, new_mem);
               return 0;
           }
           ret = ttm_bo_wait_ctx(bo, ctx);