Re: [Nouveau] [PATCH 1/6] drm/ttm: rename and cleanup ttm_bo_init_reserved
>-Original Message- >From: dri-devel On Behalf Of >Christian König >Sent: Thursday, July 7, 2022 6:25 AM >To: intel-...@lists.freedesktop.org; dri-de...@lists.freedesktop.org; >nouveau@lists.freedesktop.org; amd-...@lists.freedesktop.org >Cc: Christian König >Subject: [PATCH 1/6] drm/ttm: rename and cleanup ttm_bo_init_reserved > >Rename ttm_bo_init_reserved to ttm_bo_init_validate since that better >matches what the function is actually doing. > >Remove the unused size parameter, move the function's kerneldoc to the >implementation and cleanup the whole error handling. > >Signed-off-by: Christian König >--- > drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 2 +- > drivers/gpu/drm/drm_gem_vram_helper.c | 6 +- > drivers/gpu/drm/i915/gem/i915_gem_ttm.c| 5 +- > drivers/gpu/drm/nouveau/nouveau_bo.c | 6 +- > drivers/gpu/drm/qxl/qxl_object.c | 2 +- > drivers/gpu/drm/radeon/radeon_object.c | 6 +- > drivers/gpu/drm/ttm/ttm_bo.c | 147 +++-- > drivers/gpu/drm/vmwgfx/vmwgfx_bo.c | 12 +- > include/drm/ttm/ttm_bo_api.h | 93 ++--- > 9 files changed, 129 insertions(+), 150 deletions(-) > >diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c >b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c >index 2c82b1d5a0d7..d9cfe259f2a9 100644 >--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c >+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c >@@ -591,7 +591,7 @@ int amdgpu_bo_create(struct amdgpu_device *adev, > if (!bp->destroy) > bp->destroy = &amdgpu_bo_destroy; > >- r = ttm_bo_init_reserved(&adev->mman.bdev, &bo->tbo, size, bp- >>type, >+ r = ttm_bo_init_reserved(&adev->mman.bdev, &bo->tbo, bp->type, >&bo->placement, page_align, &ctx, NULL, >bp->resv, bp->destroy); > if (unlikely(r != 0)) >diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c >b/drivers/gpu/drm/drm_gem_vram_helper.c >index d607043716d3..125160b534be 100644 >--- a/drivers/gpu/drm/drm_gem_vram_helper.c >+++ b/drivers/gpu/drm/drm_gem_vram_helper.c >@@ -226,9 +226,9 @@ struct drm_gem_vram_object >*drm_gem_vram_create(struct drm_device *dev, >* A failing ttm_bo_init will call ttm_buffer_object_destroy >* to release gbo->bo.base and kfree gbo. >*/ >- ret = ttm_bo_init(bdev, &gbo->bo, size, ttm_bo_type_device, >-&gbo->placement, pg_align, false, NULL, NULL, >-ttm_buffer_object_destroy); >+ ret = ttm_bo_init_validate(bdev, &gbo->bo, ttm_bo_type_device, >+ &gbo->placement, pg_align, false, NULL, >NULL, >+ ttm_buffer_object_destroy); > if (ret) > return ERR_PTR(ret); > >diff --git a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c >b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c >index 4c25d9b2f138..70e2ed4e99df 100644 >--- a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c >+++ b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c >@@ -1229,9 +1229,8 @@ int __i915_gem_ttm_object_init(struct >intel_memory_region *mem, >* Similarly, in delayed_destroy, we can't call ttm_bo_put() >* until successful initialization. >*/ >- ret = ttm_bo_init_reserved(&i915->bdev, i915_gem_to_ttm(obj), >size, >- bo_type, &i915_sys_placement, >- page_size >> PAGE_SHIFT, >+ ret = ttm_bo_init_reserved(&i915->bdev, i915_gem_to_ttm(obj), >bo_type, >+ &i915_sys_placement, page_size >> >PAGE_SHIFT, > &ctx, NULL, NULL, i915_ttm_bo_destroy); > if (ret) > return i915_ttm_err_to_gem(ret); >diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c >b/drivers/gpu/drm/nouveau/nouveau_bo.c >index 05076e530e7d..92cd19021084 100644 >--- a/drivers/gpu/drm/nouveau/nouveau_bo.c >+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c >@@ -307,9 +307,9 @@ nouveau_bo_init(struct nouveau_bo *nvbo, u64 size, >int align, u32 domain, > nouveau_bo_placement_set(nvbo, domain, 0); > INIT_LIST_HEAD(&nvbo->io_reserve_lru); > >- ret = ttm_bo_init(nvbo->bo.bdev, &nvbo->bo, size, type, >-&nvbo->placement, align >> PAGE_SHIFT, false, sg, >-robj, nouveau_bo_del_ttm); >+ ret = ttm_bo_init_validate(nvbo->bo.bdev, &nvbo->bo, type, >+ &nvbo->placement, align >> PAGE_SHIFT, >false, >+ sg, robj, nouveau_bo_del_ttm); > if (ret) { > /* ttm will call nouveau_bo_del_ttm if it fails.. */ > return ret; >diff --git a/drivers/gpu/drm/qxl/qxl_object.c >b/drivers/gpu/drm/qxl/qxl_object.c >index b42a657e4c2f..695d9308d1f0 100644 >--- a/drivers/gpu/drm/qxl/qxl_object.c >+++ b/drivers/gpu/drm/qxl/qxl_object.c >@@ -141,7 +141,7 @@ int qxl_bo_create(struct qxl_device *qdev, unsigned >long size, >
[Nouveau] [PATCH 1/6] drm/ttm: rename and cleanup ttm_bo_init_reserved
Rename ttm_bo_init_reserved to ttm_bo_init_validate since that better matches what the function is actually doing. Remove the unused size parameter, move the function's kerneldoc to the implementation and cleanup the whole error handling. Signed-off-by: Christian König --- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 2 +- drivers/gpu/drm/drm_gem_vram_helper.c | 6 +- drivers/gpu/drm/i915/gem/i915_gem_ttm.c| 5 +- drivers/gpu/drm/nouveau/nouveau_bo.c | 6 +- drivers/gpu/drm/qxl/qxl_object.c | 2 +- drivers/gpu/drm/radeon/radeon_object.c | 6 +- drivers/gpu/drm/ttm/ttm_bo.c | 147 +++-- drivers/gpu/drm/vmwgfx/vmwgfx_bo.c | 12 +- include/drm/ttm/ttm_bo_api.h | 93 ++--- 9 files changed, 129 insertions(+), 150 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c index 2c82b1d5a0d7..d9cfe259f2a9 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c @@ -591,7 +591,7 @@ int amdgpu_bo_create(struct amdgpu_device *adev, if (!bp->destroy) bp->destroy = &amdgpu_bo_destroy; - r = ttm_bo_init_reserved(&adev->mman.bdev, &bo->tbo, size, bp->type, + r = ttm_bo_init_reserved(&adev->mman.bdev, &bo->tbo, bp->type, &bo->placement, page_align, &ctx, NULL, bp->resv, bp->destroy); if (unlikely(r != 0)) diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c index d607043716d3..125160b534be 100644 --- a/drivers/gpu/drm/drm_gem_vram_helper.c +++ b/drivers/gpu/drm/drm_gem_vram_helper.c @@ -226,9 +226,9 @@ struct drm_gem_vram_object *drm_gem_vram_create(struct drm_device *dev, * A failing ttm_bo_init will call ttm_buffer_object_destroy * to release gbo->bo.base and kfree gbo. */ - ret = ttm_bo_init(bdev, &gbo->bo, size, ttm_bo_type_device, - &gbo->placement, pg_align, false, NULL, NULL, - ttm_buffer_object_destroy); + ret = ttm_bo_init_validate(bdev, &gbo->bo, ttm_bo_type_device, + &gbo->placement, pg_align, false, NULL, NULL, + ttm_buffer_object_destroy); if (ret) return ERR_PTR(ret); diff --git a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c index 4c25d9b2f138..70e2ed4e99df 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c @@ -1229,9 +1229,8 @@ int __i915_gem_ttm_object_init(struct intel_memory_region *mem, * Similarly, in delayed_destroy, we can't call ttm_bo_put() * until successful initialization. */ - ret = ttm_bo_init_reserved(&i915->bdev, i915_gem_to_ttm(obj), size, - bo_type, &i915_sys_placement, - page_size >> PAGE_SHIFT, + ret = ttm_bo_init_reserved(&i915->bdev, i915_gem_to_ttm(obj), bo_type, + &i915_sys_placement, page_size >> PAGE_SHIFT, &ctx, NULL, NULL, i915_ttm_bo_destroy); if (ret) return i915_ttm_err_to_gem(ret); diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c index 05076e530e7d..92cd19021084 100644 --- a/drivers/gpu/drm/nouveau/nouveau_bo.c +++ b/drivers/gpu/drm/nouveau/nouveau_bo.c @@ -307,9 +307,9 @@ nouveau_bo_init(struct nouveau_bo *nvbo, u64 size, int align, u32 domain, nouveau_bo_placement_set(nvbo, domain, 0); INIT_LIST_HEAD(&nvbo->io_reserve_lru); - ret = ttm_bo_init(nvbo->bo.bdev, &nvbo->bo, size, type, - &nvbo->placement, align >> PAGE_SHIFT, false, sg, - robj, nouveau_bo_del_ttm); + ret = ttm_bo_init_validate(nvbo->bo.bdev, &nvbo->bo, type, + &nvbo->placement, align >> PAGE_SHIFT, false, + sg, robj, nouveau_bo_del_ttm); if (ret) { /* ttm will call nouveau_bo_del_ttm if it fails.. */ return ret; diff --git a/drivers/gpu/drm/qxl/qxl_object.c b/drivers/gpu/drm/qxl/qxl_object.c index b42a657e4c2f..695d9308d1f0 100644 --- a/drivers/gpu/drm/qxl/qxl_object.c +++ b/drivers/gpu/drm/qxl/qxl_object.c @@ -141,7 +141,7 @@ int qxl_bo_create(struct qxl_device *qdev, unsigned long size, qxl_ttm_placement_from_domain(bo, domain); bo->tbo.priority = priority; - r = ttm_bo_init_reserved(&qdev->mman.bdev, &bo->tbo, size, type, + r = ttm_bo_init_reserved(&qdev->mman.bdev, &bo->tbo, type, &bo->placement, 0, &ctx, NULL, NULL, &qxl_ttm_bo_destroy); if (unlikely(r != 0)) { diff --gi