Skip to contentSkip to conversation

drm/nouveau: init the base GEM fields for internal BOs

PATCH In review Christian König 5 participants 5 messages Jun 9, 2021 – Jun 10, 2021

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

PATCH 1/1 drm/nouveau: init the base GEM fields for internal BOs

TTMs buffer objects are based on GEM objects for quite a while and rely on initializing those fields before initializing the TTM BO.

Noveau now doesn't init the GEM object for internally allocated BOs, so make sure that we at least initialize some necessary fields.

---
 drivers/gpu/drm/nouveau/nouveau_bo.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/gpu/drm/nouveau/nouveau_bo.c +6 -0
index 520b1ea9d16c..085023624fb0 100644
@@ -149,6 +149,8 @@ nouveau_bo_del_ttm(struct ttm_buffer_object *bo)
 	 */
 	if (bo->base.dev)
 		drm_gem_object_release(&bo->base);
+	else
+		dma_resv_fini(&bo->base._resv);
 
 	kfree(nvbo);
 }
@@ -330,6 +332,10 @@ nouveau_bo_new(struct nouveau_cli *cli, u64 size, int align,
 	if (IS_ERR(nvbo))
 		return PTR_ERR(nvbo);
 
+	nvbo->bo.base.size = size;
+	dma_resv_init(&nvbo->bo.base._resv);
+	drm_vma_node_reset(&nvbo->bo.base.vma_node);
+
 	ret = nouveau_bo_init(nvbo, size, align, domain, sg, robj);
 	if (ret)
 		return ret;
Signature · 6 lines
2.25.1

_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau
Tested-by on v1 1/1
#1 lore raw
Quoted 4 lines · Christian König

TTMs buffer objects are based on GEM objects for quite a while and rely on initializing those fields before initializing the TTM BO.

Noveau now doesn't init the GEM object for internally allocated BOs,

Nouveau

Quoted 22 lines

so make sure that we at least initialize some necessary fields.

---
  drivers/gpu/drm/nouveau/nouveau_bo.c | 6 ++++++
  1 file changed, 6 insertions(+)
drivers/gpu/drm/nouveau/nouveau_bo.c +2 -0
index 520b1ea9d16c..085023624fb0 100644
@@ -149,6 +149,8 @@ nouveau_bo_del_ttm(struct ttm_buffer_object *bo)
  	 */
  	if (bo->base.dev)
  		drm_gem_object_release(&bo->base);
+	else
+		dma_resv_fini(&bo->base._resv);
 
  	kfree(nvbo);
  }

drivers/gpu/drm/nouveau/nouveau_bo.c nouveau_bo_new(struct nouveau_cli *cli, u64 size, int align, · line 341

Quoted 10 lines
drivers/gpu/drm/nouveau/nouveau_bo.c +4 -0
@@ -330,6 +332,10 @@ nouveau_bo_new(struct nouveau_cli *cli, u64 size, int align,
  	if (IS_ERR(nvbo))
  		return PTR_ERR(nvbo);
 
+	nvbo->bo.base.size = size;
+	dma_resv_init(&nvbo->bo.base._resv);
+	drm_vma_node_reset(&nvbo->bo.base.vma_node);
+
  	ret = nouveau_bo_init(nvbo, size, align, domain, sg, robj);
  	if (ret)
  		return ret;

That works, thanks for the fix!

Mikko

#2 lore raw

Am 09.06.21 um 19:45 schrieb Mikko Perttunen:

Quoted 42 lines · Christian König
Quoted 4 lines

TTMs buffer objects are based on GEM objects for quite a while and rely on initializing those fields before initializing the TTM BO.

Noveau now doesn't init the GEM object for internally allocated BOs,

Nouveau

Quoted 29 lines

so make sure that we at least initialize some necessary fields.

---
  drivers/gpu/drm/nouveau/nouveau_bo.c | 6 ++++++

  1 file changed, 6 insertions(+)
drivers/gpu/drm/nouveau/nouveau_bo.c +5 -0
index 520b1ea9d16c..085023624fb0 100644
@@ -149,6 +149,8 @@ nouveau_bo_del_ttm(struct ttm_buffer_object *bo)
        */
       if (bo->base.dev)
           drm_gem_object_release(&bo->base);
+    else
+        dma_resv_fini(&bo->base._resv);
         kfree(nvbo);
   }
@@ -330,6 +332,10 @@ nouveau_bo_new(struct nouveau_cli *cli, u64 
 size, int align,
       if (IS_ERR(nvbo))
           return PTR_ERR(nvbo);
   +    nvbo->bo.base.size = size;
+    dma_resv_init(&nvbo->bo.base._resv);
+    drm_vma_node_reset(&nvbo->bo.base.vma_node);
+
       ret = nouveau_bo_init(nvbo, size, align, domain, sg, robj);
       if (ret)
Quoted 2 lines

          return ret;

That works, thanks for the fix!

Quoted 1 line

Thanks. Can anybody give me an rb that I can push this to drm-misc-next before the weekend?

Regards,
Christian.

Quoted 2 lines

Mikko

Reviewed-by
#3 lore raw
Quoted 47 lines · Christian

Am 09.06.21 um 19:45 schrieb Mikko Perttunen:

Quoted 44 lines · Christian König
Quoted 4 lines

TTMs buffer objects are based on GEM objects for quite a while and rely on initializing those fields before initializing the TTM BO.

Noveau now doesn't init the GEM object for internally allocated BOs,

Nouveau

Quoted 30 lines

so make sure that we at least initialize some necessary fields.

---
  drivers/gpu/drm/nouveau/nouveau_bo.c | 6 ++++++

  1 file changed, 6 insertions(+)
drivers/gpu/drm/nouveau/nouveau_bo.c +5 -0
index 520b1ea9d16c..085023624fb0 100644
@@ -149,6 +149,8 @@ nouveau_bo_del_ttm(struct ttm_buffer_object *bo)
        */
       if (bo->base.dev)
           drm_gem_object_release(&bo->base);
+    else
+        dma_resv_fini(&bo->base._resv);
         kfree(nvbo);
   }
@@ -330,6 +332,10 @@ nouveau_bo_new(struct nouveau_cli *cli, u64 
 size, int align,
       if (IS_ERR(nvbo))
           return PTR_ERR(nvbo);
   +    nvbo->bo.base.size = size;
+    dma_resv_init(&nvbo->bo.base._resv);
+    drm_vma_node_reset(&nvbo->bo.base.vma_node);
+
       ret = nouveau_bo_init(nvbo, size, align, domain, sg, robj);
       if (ret)
Quoted 2 lines

          return ret;

That works, thanks for the fix!

Quoted 10 lines

Thanks. Can anybody give me an rb that I can push this to drm-misc-next before the weekend?

Regards,
Christian.

Quoted 2 lines

Mikko

Reviewed-by on v1 1/1
#4 lore raw
In reply to Christian König
Quoted 8 lines · Christian König

TTMs buffer objects are based on GEM objects for quite a while and rely on initializing those fields before initializing the TTM BO.

Noveau now doesn't init the GEM object for internally allocated BOs, so make sure that we at least initialize some necessary fields.

fwiw,

Quoted 31 lines
---
 drivers/gpu/drm/nouveau/nouveau_bo.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/gpu/drm/nouveau/nouveau_bo.c +6 -1
index 520b1ea9d16c..085023624fb0 100644
@@ -149,6 +149,8 @@ nouveau_bo_del_ttm(struct ttm_buffer_object *bo)
         */
        if (bo->base.dev)
                drm_gem_object_release(&bo->base);
+       else
+               dma_resv_fini(&bo->base._resv);
 
        kfree(nvbo);
 }
@@ -330,6 +332,10 @@ nouveau_bo_new(struct nouveau_cli *cli, u64 size, int align,
        if (IS_ERR(nvbo))
                return PTR_ERR(nvbo);
 
+       nvbo->bo.base.size = size;
+       dma_resv_init(&nvbo->bo.base._resv);
+       drm_vma_node_reset(&nvbo->bo.base.vma_node);
+
        ret = nouveau_bo_init(nvbo, size, align, domain, sg, robj);
        if (ret)
                return ret;
--

2.25.1