Message ID | 20201019071314.1671485-2-airlied@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | ttm get rid of ttm_bo_move_ttm | expand |
Am 19.10.20 um 09:13 schrieb Dave Airlie: > From: Dave Airlie <airlied@redhat.com> > > This factors out the code to setup non-system tt. > > The same code was used twice in the move paths. > > Reviewed-by: Ben Skeggs <bskeggs@redhat.com> > Signed-off-by: Dave Airlie <airlied@redhat.com> Reviewed-by: Christian König <christian.koenig@amd.com> > --- > drivers/gpu/drm/ttm/ttm_bo.c | 12 +++-------- > drivers/gpu/drm/ttm/ttm_bo_util.c | 34 +++++++++++++++++++++---------- > include/drm/ttm/ttm_bo_driver.h | 4 ++++ > 3 files changed, 30 insertions(+), 20 deletions(-) > > diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c > index b97ed6ca8765..cbc74a320db2 100644 > --- a/drivers/gpu/drm/ttm/ttm_bo.c > +++ b/drivers/gpu/drm/ttm/ttm_bo.c > @@ -252,15 +252,9 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo, > if (ret) > goto out_err; > > - if (mem->mem_type != TTM_PL_SYSTEM) { > - ret = ttm_tt_populate(bdev, bo->ttm, ctx); > - if (ret) > - goto out_err; > - > - ret = ttm_bo_tt_bind(bo, mem); > - if (ret) > - goto out_err; > - } > + ret = ttm_bo_move_to_new_tt_mem(bo, ctx, mem); > + if (ret) > + goto out_err; > } > > if (bdev->driver->move_notify) > diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c > index ed1114235b66..a36c615bdf24 100644 > --- a/drivers/gpu/drm/ttm/ttm_bo_util.c > +++ b/drivers/gpu/drm/ttm/ttm_bo_util.c > @@ -45,11 +45,30 @@ struct ttm_transfer_obj { > struct ttm_buffer_object *bo; > }; > > +int ttm_bo_move_to_new_tt_mem(struct ttm_buffer_object *bo, > + struct ttm_operation_ctx *ctx, > + struct ttm_resource *new_mem) > +{ > + int ret; > + > + if (new_mem->mem_type == TTM_PL_SYSTEM) > + return 0; > + > + ret = ttm_tt_populate(bo->bdev, bo->ttm, ctx); > + if (unlikely(ret != 0)) > + return ret; > + > + ret = ttm_bo_tt_bind(bo, new_mem); > + if (unlikely(ret != 0)) > + return ret; > + > + return 0; > +} > + > int ttm_bo_move_ttm(struct ttm_buffer_object *bo, > struct ttm_operation_ctx *ctx, > struct ttm_resource *new_mem) > { > - struct ttm_tt *ttm = bo->ttm; > struct ttm_resource *old_mem = &bo->mem; > int ret; > > @@ -67,16 +86,9 @@ int ttm_bo_move_ttm(struct ttm_buffer_object *bo, > old_mem->mem_type = TTM_PL_SYSTEM; > } > > - if (new_mem->mem_type != TTM_PL_SYSTEM) { > - > - ret = ttm_tt_populate(bo->bdev, ttm, ctx); > - if (unlikely(ret != 0)) > - return ret; > - > - ret = ttm_bo_tt_bind(bo, new_mem); > - if (unlikely(ret != 0)) > - return ret; > - } > + ret = ttm_bo_move_to_new_tt_mem(bo, ctx, new_mem); > + if (unlikely(ret != 0)) > + return ret; > > ttm_bo_assign_mem(bo, new_mem); > return 0; > diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h > index 3dbc11eb6787..1f4d2b1febd0 100644 > --- a/include/drm/ttm/ttm_bo_driver.h > +++ b/include/drm/ttm/ttm_bo_driver.h > @@ -593,6 +593,10 @@ int ttm_bo_move_ttm(struct ttm_buffer_object *bo, > struct ttm_operation_ctx *ctx, > struct ttm_resource *new_mem); > > +int ttm_bo_move_to_new_tt_mem(struct ttm_buffer_object *bo, > + struct ttm_operation_ctx *ctx, > + struct ttm_resource *new_mem); > + > /** > * ttm_bo_move_memcpy > *
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index b97ed6ca8765..cbc74a320db2 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -252,15 +252,9 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo, if (ret) goto out_err; - if (mem->mem_type != TTM_PL_SYSTEM) { - ret = ttm_tt_populate(bdev, bo->ttm, ctx); - if (ret) - goto out_err; - - ret = ttm_bo_tt_bind(bo, mem); - if (ret) - goto out_err; - } + ret = ttm_bo_move_to_new_tt_mem(bo, ctx, mem); + if (ret) + goto out_err; } if (bdev->driver->move_notify) diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c index ed1114235b66..a36c615bdf24 100644 --- a/drivers/gpu/drm/ttm/ttm_bo_util.c +++ b/drivers/gpu/drm/ttm/ttm_bo_util.c @@ -45,11 +45,30 @@ struct ttm_transfer_obj { struct ttm_buffer_object *bo; }; +int ttm_bo_move_to_new_tt_mem(struct ttm_buffer_object *bo, + struct ttm_operation_ctx *ctx, + struct ttm_resource *new_mem) +{ + int ret; + + if (new_mem->mem_type == TTM_PL_SYSTEM) + return 0; + + ret = ttm_tt_populate(bo->bdev, bo->ttm, ctx); + if (unlikely(ret != 0)) + return ret; + + ret = ttm_bo_tt_bind(bo, new_mem); + if (unlikely(ret != 0)) + return ret; + + return 0; +} + int ttm_bo_move_ttm(struct ttm_buffer_object *bo, struct ttm_operation_ctx *ctx, struct ttm_resource *new_mem) { - struct ttm_tt *ttm = bo->ttm; struct ttm_resource *old_mem = &bo->mem; int ret; @@ -67,16 +86,9 @@ int ttm_bo_move_ttm(struct ttm_buffer_object *bo, old_mem->mem_type = TTM_PL_SYSTEM; } - if (new_mem->mem_type != TTM_PL_SYSTEM) { - - ret = ttm_tt_populate(bo->bdev, ttm, ctx); - if (unlikely(ret != 0)) - return ret; - - ret = ttm_bo_tt_bind(bo, new_mem); - if (unlikely(ret != 0)) - return ret; - } + ret = ttm_bo_move_to_new_tt_mem(bo, ctx, new_mem); + if (unlikely(ret != 0)) + return ret; ttm_bo_assign_mem(bo, new_mem); return 0; diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h index 3dbc11eb6787..1f4d2b1febd0 100644 --- a/include/drm/ttm/ttm_bo_driver.h +++ b/include/drm/ttm/ttm_bo_driver.h @@ -593,6 +593,10 @@ int ttm_bo_move_ttm(struct ttm_buffer_object *bo, struct ttm_operation_ctx *ctx, struct ttm_resource *new_mem); +int ttm_bo_move_to_new_tt_mem(struct ttm_buffer_object *bo, + struct ttm_operation_ctx *ctx, + struct ttm_resource *new_mem); + /** * ttm_bo_move_memcpy *