From: Dave Airlie <[email protected]> This flag does nothing yet, but this just changes the APIs to accept it in the future across all users.
This flag will eventually be filled out with when to account a tt populate to a memcg. Reviewed-by: Christian König <[email protected]> Signed-off-by: Dave Airlie <[email protected]> --- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 3 ++- drivers/gpu/drm/i915/gem/i915_gem_ttm.c | 5 +++-- drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c | 2 +- drivers/gpu/drm/i915/gem/i915_gem_ttm_pm.c | 4 ++-- drivers/gpu/drm/loongson/lsdc_ttm.c | 3 ++- drivers/gpu/drm/nouveau/nouveau_bo.c | 6 ++++-- drivers/gpu/drm/radeon/radeon_ttm.c | 3 ++- drivers/gpu/drm/ttm/tests/ttm_bo_validate_test.c | 2 +- drivers/gpu/drm/ttm/tests/ttm_pool_test.c | 16 ++++++++-------- drivers/gpu/drm/ttm/tests/ttm_tt_test.c | 12 ++++++------ drivers/gpu/drm/ttm/ttm_bo.c | 7 ++++--- drivers/gpu/drm/ttm/ttm_bo_util.c | 6 +++--- drivers/gpu/drm/ttm/ttm_bo_vm.c | 4 +++- drivers/gpu/drm/ttm/ttm_pool.c | 6 ++++-- drivers/gpu/drm/ttm/ttm_tt.c | 8 +++++--- drivers/gpu/drm/vmwgfx/vmwgfx_blit.c | 4 ++-- drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c | 7 ++++--- drivers/gpu/drm/xe/xe_bo.c | 5 +++-- include/drm/ttm/ttm_bo.h | 1 + include/drm/ttm/ttm_device.h | 1 + include/drm/ttm/ttm_pool.h | 1 + include/drm/ttm/ttm_tt.h | 1 + 22 files changed, 63 insertions(+), 44 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index eeaa56c8d129..e50c133e87df 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -1203,6 +1203,7 @@ static struct ttm_tt *amdgpu_ttm_tt_create(struct ttm_buffer_object *bo, */ static int amdgpu_ttm_tt_populate(struct ttm_device *bdev, struct ttm_tt *ttm, + bool memcg_account, struct ttm_operation_ctx *ctx) { struct amdgpu_device *adev = amdgpu_ttm_adev(bdev); @@ -1226,7 +1227,7 @@ static int amdgpu_ttm_tt_populate(struct ttm_device *bdev, pool = &adev->mman.ttm_pools[gtt->pool_id]; else pool = &adev->mman.bdev.pool; - ret = ttm_pool_alloc(pool, ttm, ctx); + ret = ttm_pool_alloc(pool, ttm, memcg_account, ctx); if (ret) return ret; diff --git a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c index 033eda38e4b5..da4421cf2623 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c @@ -317,6 +317,7 @@ static struct ttm_tt *i915_ttm_tt_create(struct ttm_buffer_object *bo, static int i915_ttm_tt_populate(struct ttm_device *bdev, struct ttm_tt *ttm, + bool memcg_account, struct ttm_operation_ctx *ctx) { struct i915_ttm_tt *i915_tt = container_of(ttm, typeof(*i915_tt), ttm); @@ -324,7 +325,7 @@ static int i915_ttm_tt_populate(struct ttm_device *bdev, if (i915_tt->is_shmem) return i915_ttm_tt_shmem_populate(bdev, ttm, ctx); - return ttm_pool_alloc(&bdev->pool, ttm, ctx); + return ttm_pool_alloc(&bdev->pool, ttm, memcg_account, ctx); } static void i915_ttm_tt_unpopulate(struct ttm_device *bdev, struct ttm_tt *ttm) @@ -811,7 +812,7 @@ static int __i915_ttm_get_pages(struct drm_i915_gem_object *obj, } if (bo->ttm && !ttm_tt_is_populated(bo->ttm)) { - ret = ttm_bo_populate(bo, &ctx); + ret = ttm_bo_populate(bo, false, &ctx); if (ret) return ret; diff --git a/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c b/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c index 3a7e202ae87d..ec475b311aea 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c @@ -624,7 +624,7 @@ int i915_ttm_move(struct ttm_buffer_object *bo, bool evict, /* Populate ttm with pages if needed. Typically system memory. */ if (ttm && (dst_man->use_tt || (ttm->page_flags & TTM_TT_FLAG_SWAPPED))) { - ret = ttm_bo_populate(bo, ctx); + ret = ttm_bo_populate(bo, false, ctx); if (ret) return ret; } diff --git a/drivers/gpu/drm/i915/gem/i915_gem_ttm_pm.c b/drivers/gpu/drm/i915/gem/i915_gem_ttm_pm.c index 4824f948daed..d951e58f78ea 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_ttm_pm.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_ttm_pm.c @@ -91,7 +91,7 @@ static int i915_ttm_backup(struct i915_gem_apply_to_region *apply, goto out_no_lock; backup_bo = i915_gem_to_ttm(backup); - err = ttm_bo_populate(backup_bo, &ctx); + err = ttm_bo_populate(backup_bo, false, &ctx); if (err) goto out_no_populate; @@ -190,7 +190,7 @@ static int i915_ttm_restore(struct i915_gem_apply_to_region *apply, if (!backup_bo->resource) err = ttm_bo_validate(backup_bo, i915_ttm_sys_placement(), &ctx); if (!err) - err = ttm_bo_populate(backup_bo, &ctx); + err = ttm_bo_populate(backup_bo, false, &ctx); if (!err) { err = i915_gem_obj_copy_ttm(obj, backup, pm_apply->allow_gpu, false); diff --git a/drivers/gpu/drm/loongson/lsdc_ttm.c b/drivers/gpu/drm/loongson/lsdc_ttm.c index d7441d96a0dc..bfb5f1b1ec91 100644 --- a/drivers/gpu/drm/loongson/lsdc_ttm.c +++ b/drivers/gpu/drm/loongson/lsdc_ttm.c @@ -111,6 +111,7 @@ lsdc_ttm_tt_create(struct ttm_buffer_object *tbo, uint32_t page_flags) static int lsdc_ttm_tt_populate(struct ttm_device *bdev, struct ttm_tt *ttm, + bool memcg_account, struct ttm_operation_ctx *ctx) { bool slave = !!(ttm->page_flags & TTM_TT_FLAG_EXTERNAL); @@ -123,7 +124,7 @@ static int lsdc_ttm_tt_populate(struct ttm_device *bdev, return 0; } - return ttm_pool_alloc(&bdev->pool, ttm, ctx); + return ttm_pool_alloc(&bdev->pool, ttm, memcg_account, ctx); } static void lsdc_ttm_tt_unpopulate(struct ttm_device *bdev, diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c index 3c7d2e5b3850..e8b0692afd0c 100644 --- a/drivers/gpu/drm/nouveau/nouveau_bo.c +++ b/drivers/gpu/drm/nouveau/nouveau_bo.c @@ -1417,7 +1417,9 @@ vm_fault_t nouveau_ttm_fault_reserve_notify(struct ttm_buffer_object *bo) static int nouveau_ttm_tt_populate(struct ttm_device *bdev, - struct ttm_tt *ttm, struct ttm_operation_ctx *ctx) + struct ttm_tt *ttm, + bool memcg_account, + struct ttm_operation_ctx *ctx) { struct ttm_tt *ttm_dma = (void *)ttm; struct nouveau_drm *drm; @@ -1434,7 +1436,7 @@ nouveau_ttm_tt_populate(struct ttm_device *bdev, drm = nouveau_bdev(bdev); - return ttm_pool_alloc(&drm->ttm.bdev.pool, ttm, ctx); + return ttm_pool_alloc(&drm->ttm.bdev.pool, ttm, memcg_account, ctx); } static void diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c index e7ab8162ac69..98b09463abc2 100644 --- a/drivers/gpu/drm/radeon/radeon_ttm.c +++ b/drivers/gpu/drm/radeon/radeon_ttm.c @@ -526,6 +526,7 @@ static struct radeon_ttm_tt *radeon_ttm_tt_to_gtt(struct radeon_device *rdev, static int radeon_ttm_tt_populate(struct ttm_device *bdev, struct ttm_tt *ttm, + bool memcg_account, struct ttm_operation_ctx *ctx) { struct radeon_device *rdev = radeon_get_rdev(bdev); @@ -547,7 +548,7 @@ static int radeon_ttm_tt_populate(struct ttm_device *bdev, return 0; } - return ttm_pool_alloc(&rdev->mman.bdev.pool, ttm, ctx); + return ttm_pool_alloc(&rdev->mman.bdev.pool, ttm, memcg_account, ctx); } static void radeon_ttm_tt_unpopulate(struct ttm_device *bdev, struct ttm_tt *ttm) diff --git a/drivers/gpu/drm/ttm/tests/ttm_bo_validate_test.c b/drivers/gpu/drm/ttm/tests/ttm_bo_validate_test.c index 6d95447a989d..cef326ebf25a 100644 --- a/drivers/gpu/drm/ttm/tests/ttm_bo_validate_test.c +++ b/drivers/gpu/drm/ttm/tests/ttm_bo_validate_test.c @@ -538,7 +538,7 @@ static void ttm_bo_validate_no_placement_signaled(struct kunit *test) if (params->with_ttm) { old_tt = priv->ttm_dev->funcs->ttm_tt_create(bo, 0); - ttm_pool_alloc(&priv->ttm_dev->pool, old_tt, &ctx); + ttm_pool_alloc(&priv->ttm_dev->pool, old_tt, false, &ctx); bo->ttm = old_tt; } diff --git a/drivers/gpu/drm/ttm/tests/ttm_pool_test.c b/drivers/gpu/drm/ttm/tests/ttm_pool_test.c index 01197014b83f..456241bdaf41 100644 --- a/drivers/gpu/drm/ttm/tests/ttm_pool_test.c +++ b/drivers/gpu/drm/ttm/tests/ttm_pool_test.c @@ -89,7 +89,7 @@ static struct ttm_pool *ttm_pool_pre_populated(struct kunit *test, ttm_pool_init(pool, devs->dev, NUMA_NO_NODE, TTM_ALLOCATION_POOL_USE_DMA_ALLOC); - err = ttm_pool_alloc(pool, tt, &simple_ctx); + err = ttm_pool_alloc(pool, tt, false, &simple_ctx); KUNIT_ASSERT_EQ(test, err, 0); ttm_pool_free(pool, tt); @@ -157,7 +157,7 @@ static void ttm_pool_alloc_basic(struct kunit *test) KUNIT_ASSERT_EQ(test, pool->nid, NUMA_NO_NODE); KUNIT_ASSERT_EQ(test, pool->alloc_flags, params->alloc_flags); - err = ttm_pool_alloc(pool, tt, &simple_ctx); + err = ttm_pool_alloc(pool, tt, false, &simple_ctx); KUNIT_ASSERT_EQ(test, err, 0); KUNIT_ASSERT_EQ(test, tt->num_pages, expected_num_pages); @@ -220,7 +220,7 @@ static void ttm_pool_alloc_basic_dma_addr(struct kunit *test) ttm_pool_init(pool, devs->dev, NUMA_NO_NODE, TTM_ALLOCATION_POOL_USE_DMA_ALLOC); - err = ttm_pool_alloc(pool, tt, &simple_ctx); + err = ttm_pool_alloc(pool, tt, false, &simple_ctx); KUNIT_ASSERT_EQ(test, err, 0); KUNIT_ASSERT_EQ(test, tt->num_pages, expected_num_pages); @@ -253,7 +253,7 @@ static void ttm_pool_alloc_order_caching_match(struct kunit *test) tt = ttm_tt_kunit_init(test, 0, caching, size); KUNIT_ASSERT_NOT_NULL(test, tt); - err = ttm_pool_alloc(pool, tt, &simple_ctx); + err = ttm_pool_alloc(pool, tt, false, &simple_ctx); KUNIT_ASSERT_EQ(test, err, 0); KUNIT_ASSERT_TRUE(test, !list_lru_count(&pt->pages)); @@ -285,7 +285,7 @@ static void ttm_pool_alloc_caching_mismatch(struct kunit *test) KUNIT_ASSERT_FALSE(test, !list_lru_count(&pt_pool->pages)); KUNIT_ASSERT_TRUE(test, !list_lru_count(&pt_tt->pages)); - err = ttm_pool_alloc(pool, tt, &simple_ctx); + err = ttm_pool_alloc(pool, tt, false, &simple_ctx); KUNIT_ASSERT_EQ(test, err, 0); ttm_pool_free(pool, tt); @@ -319,7 +319,7 @@ static void ttm_pool_alloc_order_mismatch(struct kunit *test) KUNIT_ASSERT_FALSE(test, !list_lru_count(&pt_pool->pages)); KUNIT_ASSERT_TRUE(test, !list_lru_count(&pt_tt->pages)); - err = ttm_pool_alloc(pool, tt, &simple_ctx); + err = ttm_pool_alloc(pool, tt, false, &simple_ctx); KUNIT_ASSERT_EQ(test, err, 0); ttm_pool_free(pool, tt); @@ -349,7 +349,7 @@ static void ttm_pool_free_dma_alloc(struct kunit *test) KUNIT_ASSERT_NOT_NULL(test, pool); ttm_pool_init(pool, devs->dev, NUMA_NO_NODE, TTM_ALLOCATION_POOL_USE_DMA_ALLOC); - ttm_pool_alloc(pool, tt, &simple_ctx); + ttm_pool_alloc(pool, tt, false, &simple_ctx); pt = &pool->caching[caching].orders[order]; KUNIT_ASSERT_TRUE(test, !list_lru_count(&pt->pages)); @@ -380,7 +380,7 @@ static void ttm_pool_free_no_dma_alloc(struct kunit *test) KUNIT_ASSERT_NOT_NULL(test, pool); ttm_pool_init(pool, devs->dev, NUMA_NO_NODE, 0); - ttm_pool_alloc(pool, tt, &simple_ctx); + ttm_pool_alloc(pool, tt, false, &simple_ctx); pt = &pool->caching[caching].orders[order]; KUNIT_ASSERT_TRUE(test, list_lru_count(&pt->pages) == 1); diff --git a/drivers/gpu/drm/ttm/tests/ttm_tt_test.c b/drivers/gpu/drm/ttm/tests/ttm_tt_test.c index bd5f7d0b9b62..dfa38bbfd829 100644 --- a/drivers/gpu/drm/ttm/tests/ttm_tt_test.c +++ b/drivers/gpu/drm/ttm/tests/ttm_tt_test.c @@ -262,7 +262,7 @@ static void ttm_tt_populate_null_ttm(struct kunit *test) struct ttm_operation_ctx ctx = { }; int err; - err = ttm_tt_populate(devs->ttm_dev, NULL, &ctx); + err = ttm_tt_populate(devs->ttm_dev, NULL, false, &ctx); KUNIT_ASSERT_EQ(test, err, -EINVAL); } @@ -283,11 +283,11 @@ static void ttm_tt_populate_populated_ttm(struct kunit *test) err = ttm_tt_init(tt, bo, 0, ttm_cached, 0); KUNIT_ASSERT_EQ(test, err, 0); - err = ttm_tt_populate(devs->ttm_dev, tt, &ctx); + err = ttm_tt_populate(devs->ttm_dev, tt, false, &ctx); KUNIT_ASSERT_EQ(test, err, 0); populated_page = *tt->pages; - err = ttm_tt_populate(devs->ttm_dev, tt, &ctx); + err = ttm_tt_populate(devs->ttm_dev, tt, false, &ctx); KUNIT_ASSERT_PTR_EQ(test, populated_page, *tt->pages); } @@ -307,7 +307,7 @@ static void ttm_tt_unpopulate_basic(struct kunit *test) err = ttm_tt_init(tt, bo, 0, ttm_cached, 0); KUNIT_ASSERT_EQ(test, err, 0); - err = ttm_tt_populate(devs->ttm_dev, tt, &ctx); + err = ttm_tt_populate(devs->ttm_dev, tt, false, &ctx); KUNIT_ASSERT_EQ(test, err, 0); KUNIT_ASSERT_TRUE(test, ttm_tt_is_populated(tt)); @@ -351,7 +351,7 @@ static void ttm_tt_swapin_basic(struct kunit *test) err = ttm_tt_init(tt, bo, 0, ttm_cached, 0); KUNIT_ASSERT_EQ(test, err, 0); - err = ttm_tt_populate(devs->ttm_dev, tt, &ctx); + err = ttm_tt_populate(devs->ttm_dev, tt, false, &ctx); KUNIT_ASSERT_EQ(test, err, 0); KUNIT_ASSERT_TRUE(test, ttm_tt_is_populated(tt)); @@ -361,7 +361,7 @@ static void ttm_tt_swapin_basic(struct kunit *test) KUNIT_ASSERT_TRUE(test, tt->page_flags & TTM_TT_FLAG_SWAPPED); /* Swapout depopulates TT, allocate pages and then swap them in */ - err = ttm_pool_alloc(&devs->ttm_dev->pool, tt, &ctx); + err = ttm_pool_alloc(&devs->ttm_dev->pool, tt, false, &ctx); KUNIT_ASSERT_EQ(test, err, 0); err = ttm_tt_swapin(tt); diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index acb9197db879..704af3cfc47a 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -144,7 +144,7 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo, goto out_err; if (mem->mem_type != TTM_PL_SYSTEM) { - ret = ttm_bo_populate(bo, ctx); + ret = ttm_bo_populate(bo, false, ctx); if (ret) goto out_err; } @@ -1260,6 +1260,7 @@ void ttm_bo_tt_destroy(struct ttm_buffer_object *bo) * is set to true. */ int ttm_bo_populate(struct ttm_buffer_object *bo, + bool memcg_account, struct ttm_operation_ctx *ctx) { struct ttm_device *bdev = bo->bdev; @@ -1273,7 +1274,7 @@ int ttm_bo_populate(struct ttm_buffer_object *bo, return 0; swapped = ttm_tt_is_swapped(tt); - ret = ttm_tt_populate(bdev, tt, ctx); + ret = ttm_tt_populate(bdev, tt, memcg_account, ctx); if (ret) return ret; @@ -1298,7 +1299,7 @@ int ttm_bo_setup_export(struct ttm_buffer_object *bo, if (ret != 0) return ret; - ret = ttm_bo_populate(bo, ctx); + ret = ttm_bo_populate(bo, false, ctx); ttm_bo_unreserve(bo); return ret; } diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c index f83b7d5ec6c6..1502515043c0 100644 --- a/drivers/gpu/drm/ttm/ttm_bo_util.c +++ b/drivers/gpu/drm/ttm/ttm_bo_util.c @@ -167,7 +167,7 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo, src_man = ttm_manager_type(bdev, src_mem->mem_type); if (ttm && ((ttm->page_flags & TTM_TT_FLAG_SWAPPED) || dst_man->use_tt)) { - ret = ttm_bo_populate(bo, ctx); + ret = ttm_bo_populate(bo, false, ctx); if (ret) return ret; } @@ -352,7 +352,7 @@ static int ttm_bo_kmap_ttm(struct ttm_buffer_object *bo, BUG_ON(!ttm); - ret = ttm_bo_populate(bo, &ctx); + ret = ttm_bo_populate(bo, false, &ctx); if (ret) return ret; @@ -533,7 +533,7 @@ int ttm_bo_vmap(struct ttm_buffer_object *bo, struct iosys_map *map) pgprot_t prot; void *vaddr; - ret = ttm_bo_populate(bo, &ctx); + ret = ttm_bo_populate(bo, false, &ctx); if (ret) return ret; diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c index a80510489c45..2e59836b6085 100644 --- a/drivers/gpu/drm/ttm/ttm_bo_vm.c +++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c @@ -224,7 +224,9 @@ vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault *vmf, }; ttm = bo->ttm; - err = ttm_bo_populate(bo, &ctx); + err = ttm_bo_populate(bo, + false, + &ctx); if (err) { if (err == -EINTR || err == -ERESTARTSYS || err == -EAGAIN) diff --git a/drivers/gpu/drm/ttm/ttm_pool.c b/drivers/gpu/drm/ttm/ttm_pool.c index 6b288558ac3b..f58147a83142 100644 --- a/drivers/gpu/drm/ttm/ttm_pool.c +++ b/drivers/gpu/drm/ttm/ttm_pool.c @@ -752,6 +752,7 @@ static unsigned int ttm_pool_alloc_find_order(unsigned int highest, } static int __ttm_pool_alloc(struct ttm_pool *pool, struct ttm_tt *tt, + bool memcg_account, const struct ttm_operation_ctx *ctx, struct ttm_pool_alloc_state *alloc, struct ttm_pool_tt_restore *restore) @@ -862,6 +863,7 @@ static int __ttm_pool_alloc(struct ttm_pool *pool, struct ttm_tt *tt, * Returns: 0 on successe, negative error code otherwise. */ int ttm_pool_alloc(struct ttm_pool *pool, struct ttm_tt *tt, + bool memcg_account, struct ttm_operation_ctx *ctx) { struct ttm_pool_alloc_state alloc; @@ -871,7 +873,7 @@ int ttm_pool_alloc(struct ttm_pool *pool, struct ttm_tt *tt, ttm_pool_alloc_state_init(tt, &alloc); - return __ttm_pool_alloc(pool, tt, ctx, &alloc, NULL); + return __ttm_pool_alloc(pool, tt, memcg_account, ctx, &alloc, NULL); } EXPORT_SYMBOL(ttm_pool_alloc); @@ -926,7 +928,7 @@ int ttm_pool_restore_and_alloc(struct ttm_pool *pool, struct ttm_tt *tt, return 0; } - return __ttm_pool_alloc(pool, tt, ctx, &alloc, restore); + return __ttm_pool_alloc(pool, tt, false, ctx, &alloc, restore); } /** diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c index b645a1818184..aa0f17fca770 100644 --- a/drivers/gpu/drm/ttm/ttm_tt.c +++ b/drivers/gpu/drm/ttm/ttm_tt.c @@ -368,7 +368,9 @@ int ttm_tt_swapout(struct ttm_device *bdev, struct ttm_tt *ttm, EXPORT_SYMBOL_FOR_TESTS_ONLY(ttm_tt_swapout); int ttm_tt_populate(struct ttm_device *bdev, - struct ttm_tt *ttm, struct ttm_operation_ctx *ctx) + struct ttm_tt *ttm, + bool memcg_account, + struct ttm_operation_ctx *ctx) { int ret; @@ -397,9 +399,9 @@ int ttm_tt_populate(struct ttm_device *bdev, } if (bdev->funcs->ttm_tt_populate) - ret = bdev->funcs->ttm_tt_populate(bdev, ttm, ctx); + ret = bdev->funcs->ttm_tt_populate(bdev, ttm, memcg_account, ctx); else - ret = ttm_pool_alloc(&bdev->pool, ttm, ctx); + ret = ttm_pool_alloc(&bdev->pool, ttm, memcg_account, ctx); if (ret) goto error; diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_blit.c b/drivers/gpu/drm/vmwgfx/vmwgfx_blit.c index 135b75a3e013..baa1c3fdb12c 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_blit.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_blit.c @@ -569,13 +569,13 @@ int vmw_bo_cpu_blit(struct vmw_bo *vmw_dst, dma_resv_assert_held(src->base.resv); if (!ttm_tt_is_populated(dst->ttm)) { - ret = dst->bdev->funcs->ttm_tt_populate(dst->bdev, dst->ttm, &ctx); + ret = dst->bdev->funcs->ttm_tt_populate(dst->bdev, dst->ttm, false, &ctx); if (ret) return ret; } if (!ttm_tt_is_populated(src->ttm)) { - ret = src->bdev->funcs->ttm_tt_populate(src->bdev, src->ttm, &ctx); + ret = src->bdev->funcs->ttm_tt_populate(src->bdev, src->ttm, false, &ctx); if (ret) return ret; } diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c index dfd08ee19041..368701756119 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c @@ -360,7 +360,8 @@ static void vmw_ttm_destroy(struct ttm_device *bdev, struct ttm_tt *ttm) static int vmw_ttm_populate(struct ttm_device *bdev, - struct ttm_tt *ttm, struct ttm_operation_ctx *ctx) + struct ttm_tt *ttm, bool memcg_account, + struct ttm_operation_ctx *ctx) { bool external = (ttm->page_flags & TTM_TT_FLAG_EXTERNAL) != 0; @@ -372,7 +373,7 @@ static int vmw_ttm_populate(struct ttm_device *bdev, ttm->dma_address, ttm->num_pages); - return ttm_pool_alloc(&bdev->pool, ttm, ctx); + return ttm_pool_alloc(&bdev->pool, ttm, memcg_account, ctx); } static void vmw_ttm_unpopulate(struct ttm_device *bdev, @@ -580,7 +581,7 @@ int vmw_bo_create_and_populate(struct vmw_private *dev_priv, if (unlikely(ret != 0)) return ret; - ret = vmw_ttm_populate(vbo->tbo.bdev, vbo->tbo.ttm, &ctx); + ret = vmw_ttm_populate(vbo->tbo.bdev, vbo->tbo.ttm, false, &ctx); if (likely(ret == 0)) { struct vmw_ttm_tt *vmw_tt = container_of(vbo->tbo.ttm, struct vmw_ttm_tt, dma_ttm); diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c index 29fffc81f240..9cb4344c93df 100644 --- a/drivers/gpu/drm/xe/xe_bo.c +++ b/drivers/gpu/drm/xe/xe_bo.c @@ -551,6 +551,7 @@ static struct ttm_tt *xe_ttm_tt_create(struct ttm_buffer_object *ttm_bo, } static int xe_ttm_tt_populate(struct ttm_device *ttm_dev, struct ttm_tt *tt, + bool memcg_account, struct ttm_operation_ctx *ctx) { struct xe_ttm_tt *xe_tt = container_of(tt, struct xe_ttm_tt, ttm); @@ -568,7 +569,7 @@ static int xe_ttm_tt_populate(struct ttm_device *ttm_dev, struct ttm_tt *tt, err = ttm_tt_restore(ttm_dev, tt, ctx); } else { ttm_tt_clear_backed_up(tt); - err = ttm_pool_alloc(&ttm_dev->pool, tt, ctx); + err = ttm_pool_alloc(&ttm_dev->pool, tt, memcg_account, ctx); } if (err) return err; @@ -1809,7 +1810,7 @@ static int xe_bo_fault_migrate(struct xe_bo *bo, struct ttm_operation_ctx *ctx, if (ttm_manager_type(tbo->bdev, tbo->resource->mem_type)->use_tt) { err = xe_bo_wait_usage_kernel(bo, ctx); if (!err) - err = ttm_bo_populate(&bo->ttm, ctx); + err = ttm_bo_populate(&bo->ttm, false, ctx); } else if (should_migrate_to_smem(bo)) { xe_assert(xe_bo_device(bo), bo->flags & XE_BO_FLAG_SYSTEM); err = xe_bo_migrate(bo, XE_PL_TT, ctx, exec); diff --git a/include/drm/ttm/ttm_bo.h b/include/drm/ttm/ttm_bo.h index bca3a8849d47..ea745edc2882 100644 --- a/include/drm/ttm/ttm_bo.h +++ b/include/drm/ttm/ttm_bo.h @@ -465,6 +465,7 @@ pgprot_t ttm_io_prot(struct ttm_buffer_object *bo, struct ttm_resource *res, pgprot_t tmp); void ttm_bo_tt_destroy(struct ttm_buffer_object *bo); int ttm_bo_populate(struct ttm_buffer_object *bo, + bool memcg_account, struct ttm_operation_ctx *ctx); int ttm_bo_setup_export(struct ttm_buffer_object *bo, struct ttm_operation_ctx *ctx); diff --git a/include/drm/ttm/ttm_device.h b/include/drm/ttm/ttm_device.h index 5618aef462f2..a4bd23988ee0 100644 --- a/include/drm/ttm/ttm_device.h +++ b/include/drm/ttm/ttm_device.h @@ -85,6 +85,7 @@ struct ttm_device_funcs { */ int (*ttm_tt_populate)(struct ttm_device *bdev, struct ttm_tt *ttm, + bool memcg_account, struct ttm_operation_ctx *ctx); /** diff --git a/include/drm/ttm/ttm_pool.h b/include/drm/ttm/ttm_pool.h index 26ee592e1994..7f3f168c536c 100644 --- a/include/drm/ttm/ttm_pool.h +++ b/include/drm/ttm/ttm_pool.h @@ -78,6 +78,7 @@ struct ttm_pool { }; int ttm_pool_alloc(struct ttm_pool *pool, struct ttm_tt *tt, + bool memcg_account, struct ttm_operation_ctx *ctx); void ttm_pool_free(struct ttm_pool *pool, struct ttm_tt *tt); diff --git a/include/drm/ttm/ttm_tt.h b/include/drm/ttm/ttm_tt.h index 406437ad674b..15d4019685f6 100644 --- a/include/drm/ttm/ttm_tt.h +++ b/include/drm/ttm/ttm_tt.h @@ -250,6 +250,7 @@ int ttm_tt_swapout(struct ttm_device *bdev, struct ttm_tt *ttm, * Calls the driver method to allocate pages for a ttm */ int ttm_tt_populate(struct ttm_device *bdev, struct ttm_tt *ttm, + bool memcg_account, struct ttm_operation_ctx *ctx); /** -- 2.52.0
