Skip to content

Commit d0cef9f

Browse files
Roger Healexdeucher
authored andcommitted
drm/ttm: use an operation ctx for ttm_tt_populate in ttm_bo_driver (v2)
forward the operation context to ttm_tt_populate as well, and the ultimate goal is swapout enablement for reserved BOs. v2: squash in fix for vboxvideo Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Roger He <Hongbo.He@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent 9de2fb9 commit d0cef9f

21 files changed

Lines changed: 95 additions & 64 deletions

File tree

‎drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,8 @@ static struct ttm_tt *amdgpu_ttm_tt_create(struct ttm_bo_device *bdev,
990990
return &gtt->ttm.ttm;
991991
}
992992

993-
static int amdgpu_ttm_tt_populate(struct ttm_tt *ttm)
993+
static int amdgpu_ttm_tt_populate(struct ttm_tt *ttm,
994+
struct ttm_operation_ctx *ctx)
994995
{
995996
struct amdgpu_device *adev = amdgpu_ttm_adev(ttm->bdev);
996997
struct amdgpu_ttm_tt *gtt = (void *)ttm;
@@ -1018,11 +1019,11 @@ static int amdgpu_ttm_tt_populate(struct ttm_tt *ttm)
10181019

10191020
#ifdef CONFIG_SWIOTLB
10201021
if (swiotlb_nr_tbl()) {
1021-
return ttm_dma_populate(&gtt->ttm, adev->dev);
1022+
return ttm_dma_populate(&gtt->ttm, adev->dev, ctx);
10221023
}
10231024
#endif
10241025

1025-
return ttm_populate_and_map_pages(adev->dev, &gtt->ttm);
1026+
return ttm_populate_and_map_pages(adev->dev, &gtt->ttm, ctx);
10261027
}
10271028

10281029
static void amdgpu_ttm_tt_unpopulate(struct ttm_tt *ttm)

‎drivers/gpu/drm/ast/ast_ttm.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,10 @@ static struct ttm_tt *ast_ttm_tt_create(struct ttm_bo_device *bdev,
216216
return tt;
217217
}
218218

219-
static int ast_ttm_tt_populate(struct ttm_tt *ttm)
219+
static int ast_ttm_tt_populate(struct ttm_tt *ttm,
220+
struct ttm_operation_ctx *ctx)
220221
{
221-
return ttm_pool_populate(ttm);
222+
return ttm_pool_populate(ttm, ctx);
222223
}
223224

224225
static void ast_ttm_tt_unpopulate(struct ttm_tt *ttm)

‎drivers/gpu/drm/cirrus/cirrus_ttm.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,10 @@ static struct ttm_tt *cirrus_ttm_tt_create(struct ttm_bo_device *bdev,
216216
return tt;
217217
}
218218

219-
static int cirrus_ttm_tt_populate(struct ttm_tt *ttm)
219+
static int cirrus_ttm_tt_populate(struct ttm_tt *ttm,
220+
struct ttm_operation_ctx *ctx)
220221
{
221-
return ttm_pool_populate(ttm);
222+
return ttm_pool_populate(ttm, ctx);
222223
}
223224

224225
static void cirrus_ttm_tt_unpopulate(struct ttm_tt *ttm)

‎drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,10 @@ static struct ttm_tt *hibmc_ttm_tt_create(struct ttm_bo_device *bdev,
223223
return tt;
224224
}
225225

226-
static int hibmc_ttm_tt_populate(struct ttm_tt *ttm)
226+
static int hibmc_ttm_tt_populate(struct ttm_tt *ttm,
227+
struct ttm_operation_ctx *ctx)
227228
{
228-
return ttm_pool_populate(ttm);
229+
return ttm_pool_populate(ttm, ctx);
229230
}
230231

231232
static void hibmc_ttm_tt_unpopulate(struct ttm_tt *ttm)

‎drivers/gpu/drm/mgag200/mgag200_ttm.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,10 @@ static struct ttm_tt *mgag200_ttm_tt_create(struct ttm_bo_device *bdev,
216216
return tt;
217217
}
218218

219-
static int mgag200_ttm_tt_populate(struct ttm_tt *ttm)
219+
static int mgag200_ttm_tt_populate(struct ttm_tt *ttm,
220+
struct ttm_operation_ctx *ctx)
220221
{
221-
return ttm_pool_populate(ttm);
222+
return ttm_pool_populate(ttm, ctx);
222223
}
223224

224225
static void mgag200_ttm_tt_unpopulate(struct ttm_tt *ttm)

‎drivers/gpu/drm/nouveau/nouveau_bo.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1547,7 +1547,7 @@ nouveau_ttm_fault_reserve_notify(struct ttm_buffer_object *bo)
15471547
}
15481548

15491549
static int
1550-
nouveau_ttm_tt_populate(struct ttm_tt *ttm)
1550+
nouveau_ttm_tt_populate(struct ttm_tt *ttm, struct ttm_operation_ctx *ctx)
15511551
{
15521552
struct ttm_dma_tt *ttm_dma = (void *)ttm;
15531553
struct nouveau_drm *drm;
@@ -1572,17 +1572,17 @@ nouveau_ttm_tt_populate(struct ttm_tt *ttm)
15721572

15731573
#if IS_ENABLED(CONFIG_AGP)
15741574
if (drm->agp.bridge) {
1575-
return ttm_agp_tt_populate(ttm);
1575+
return ttm_agp_tt_populate(ttm, ctx);
15761576
}
15771577
#endif
15781578

15791579
#if IS_ENABLED(CONFIG_SWIOTLB) && IS_ENABLED(CONFIG_X86)
15801580
if (swiotlb_nr_tbl()) {
1581-
return ttm_dma_populate((void *)ttm, dev);
1581+
return ttm_dma_populate((void *)ttm, dev, ctx);
15821582
}
15831583
#endif
15841584

1585-
r = ttm_pool_populate(ttm);
1585+
r = ttm_pool_populate(ttm, ctx);
15861586
if (r) {
15871587
return r;
15881588
}

‎drivers/gpu/drm/qxl/qxl_ttm.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,14 +291,15 @@ static struct ttm_backend_func qxl_backend_func = {
291291
.destroy = &qxl_ttm_backend_destroy,
292292
};
293293

294-
static int qxl_ttm_tt_populate(struct ttm_tt *ttm)
294+
static int qxl_ttm_tt_populate(struct ttm_tt *ttm,
295+
struct ttm_operation_ctx *ctx)
295296
{
296297
int r;
297298

298299
if (ttm->state != tt_unpopulated)
299300
return 0;
300301

301-
r = ttm_pool_populate(ttm);
302+
r = ttm_pool_populate(ttm, ctx);
302303
if (r)
303304
return r;
304305

‎drivers/gpu/drm/radeon/radeon_ttm.c‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,8 @@ static struct radeon_ttm_tt *radeon_ttm_tt_to_gtt(struct ttm_tt *ttm)
721721
return (struct radeon_ttm_tt *)ttm;
722722
}
723723

724-
static int radeon_ttm_tt_populate(struct ttm_tt *ttm)
724+
static int radeon_ttm_tt_populate(struct ttm_tt *ttm,
725+
struct ttm_operation_ctx *ctx)
725726
{
726727
struct radeon_ttm_tt *gtt = radeon_ttm_tt_to_gtt(ttm);
727728
struct radeon_device *rdev;
@@ -750,17 +751,17 @@ static int radeon_ttm_tt_populate(struct ttm_tt *ttm)
750751
rdev = radeon_get_rdev(ttm->bdev);
751752
#if IS_ENABLED(CONFIG_AGP)
752753
if (rdev->flags & RADEON_IS_AGP) {
753-
return ttm_agp_tt_populate(ttm);
754+
return ttm_agp_tt_populate(ttm, ctx);
754755
}
755756
#endif
756757

757758
#ifdef CONFIG_SWIOTLB
758759
if (swiotlb_nr_tbl()) {
759-
return ttm_dma_populate(&gtt->ttm, rdev->dev);
760+
return ttm_dma_populate(&gtt->ttm, rdev->dev, ctx);
760761
}
761762
#endif
762763

763-
return ttm_populate_and_map_pages(rdev->dev, &gtt->ttm);
764+
return ttm_populate_and_map_pages(rdev->dev, &gtt->ttm, ctx);
764765
}
765766

766767
static void radeon_ttm_tt_unpopulate(struct ttm_tt *ttm)

‎drivers/gpu/drm/ttm/ttm_agp_backend.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,12 @@ struct ttm_tt *ttm_agp_tt_create(struct ttm_bo_device *bdev,
133133
}
134134
EXPORT_SYMBOL(ttm_agp_tt_create);
135135

136-
int ttm_agp_tt_populate(struct ttm_tt *ttm)
136+
int ttm_agp_tt_populate(struct ttm_tt *ttm, struct ttm_operation_ctx *ctx)
137137
{
138138
if (ttm->state != tt_unpopulated)
139139
return 0;
140140

141-
return ttm_pool_populate(ttm);
141+
return ttm_pool_populate(ttm, ctx);
142142
}
143143
EXPORT_SYMBOL(ttm_agp_tt_populate);
144144

‎drivers/gpu/drm/ttm/ttm_bo_util.c‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo,
376376
* TTM might be null for moves within the same region.
377377
*/
378378
if (ttm && ttm->state == tt_unpopulated) {
379-
ret = ttm->bdev->driver->ttm_tt_populate(ttm);
379+
ret = ttm->bdev->driver->ttm_tt_populate(ttm, ctx);
380380
if (ret)
381381
goto out1;
382382
}
@@ -545,14 +545,19 @@ static int ttm_bo_kmap_ttm(struct ttm_buffer_object *bo,
545545
unsigned long num_pages,
546546
struct ttm_bo_kmap_obj *map)
547547
{
548-
struct ttm_mem_reg *mem = &bo->mem; pgprot_t prot;
548+
struct ttm_mem_reg *mem = &bo->mem;
549+
struct ttm_operation_ctx ctx = {
550+
.interruptible = false,
551+
.no_wait_gpu = false
552+
};
549553
struct ttm_tt *ttm = bo->ttm;
554+
pgprot_t prot;
550555
int ret;
551556

552557
BUG_ON(!ttm);
553558

554559
if (ttm->state == tt_unpopulated) {
555-
ret = ttm->bdev->driver->ttm_tt_populate(ttm);
560+
ret = ttm->bdev->driver->ttm_tt_populate(ttm, &ctx);
556561
if (ret)
557562
return ret;
558563
}

0 commit comments

Comments
 (0)