Skip to content

Commit f5a9a93

Browse files
drm/ttm: remove TTM_MEMTYPE_FLAG_CMA
The original intention was to avoid CPU page table unmaps when BOs move between the GTT and SYSTEM domain. The problem is that this never correctly handled changes in the caching attributes or backing pages. Just drop this for now and simply unmap the CPU page tables in all cases. Signed-off-by: Christian König <[email protected]> Reviewed-by: Daniel Vetter <[email protected]> Link: https://patchwork.freedesktop.org/patch/378240/
1 parent c1c440d commit f5a9a93

File tree

6 files changed

+11
-35
lines changed

6 files changed

+11
-35
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ static int amdgpu_init_mem_type(struct ttm_bo_device *bdev, uint32_t type,
9393
man->func = &amdgpu_gtt_mgr_func;
9494
man->available_caching = TTM_PL_MASK_CACHING;
9595
man->default_caching = TTM_PL_FLAG_CACHED;
96-
man->flags = TTM_MEMTYPE_FLAG_MAPPABLE | TTM_MEMTYPE_FLAG_CMA;
96+
man->flags = TTM_MEMTYPE_FLAG_MAPPABLE;
9797
break;
9898
case TTM_PL_VRAM:
9999
/* "On-card" video ram */
@@ -108,7 +108,7 @@ static int amdgpu_init_mem_type(struct ttm_bo_device *bdev, uint32_t type,
108108
case AMDGPU_PL_OA:
109109
/* On-chip GDS memory*/
110110
man->func = &ttm_bo_manager_func;
111-
man->flags = TTM_MEMTYPE_FLAG_FIXED | TTM_MEMTYPE_FLAG_CMA;
111+
man->flags = TTM_MEMTYPE_FLAG_FIXED;
112112
man->available_caching = TTM_PL_FLAG_UNCACHED;
113113
man->default_caching = TTM_PL_FLAG_UNCACHED;
114114
break;

drivers/gpu/drm/nouveau/nouveau_bo.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -695,8 +695,7 @@ nouveau_bo_init_mem_type(struct ttm_bo_device *bdev, uint32_t type,
695695
TTM_PL_FLAG_WC;
696696
man->default_caching = TTM_PL_FLAG_WC;
697697
} else {
698-
man->flags = TTM_MEMTYPE_FLAG_MAPPABLE |
699-
TTM_MEMTYPE_FLAG_CMA;
698+
man->flags = TTM_MEMTYPE_FLAG_MAPPABLE;
700699
man->available_caching = TTM_PL_MASK_CACHING;
701700
man->default_caching = TTM_PL_FLAG_CACHED;
702701
}

drivers/gpu/drm/radeon/radeon_ttm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ static int radeon_init_mem_type(struct ttm_bo_device *bdev, uint32_t type,
8484
man->func = &ttm_bo_manager_func;
8585
man->available_caching = TTM_PL_MASK_CACHING;
8686
man->default_caching = TTM_PL_FLAG_CACHED;
87-
man->flags = TTM_MEMTYPE_FLAG_MAPPABLE | TTM_MEMTYPE_FLAG_CMA;
87+
man->flags = TTM_MEMTYPE_FLAG_MAPPABLE;
8888
#if IS_ENABLED(CONFIG_AGP)
8989
if (rdev->flags & RADEON_IS_AGP) {
9090
if (!rdev->ddev->agp) {

drivers/gpu/drm/ttm/ttm_bo.c

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -272,20 +272,15 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
272272
struct ttm_operation_ctx *ctx)
273273
{
274274
struct ttm_bo_device *bdev = bo->bdev;
275-
bool old_is_pci = ttm_mem_reg_is_pci(bdev, &bo->mem);
276-
bool new_is_pci = ttm_mem_reg_is_pci(bdev, mem);
277275
struct ttm_mem_type_manager *old_man = &bdev->man[bo->mem.mem_type];
278276
struct ttm_mem_type_manager *new_man = &bdev->man[mem->mem_type];
279-
int ret = 0;
277+
int ret;
280278

281-
if (old_is_pci || new_is_pci ||
282-
((mem->placement & bo->mem.placement & TTM_PL_MASK_CACHING) == 0)) {
283-
ret = ttm_mem_io_lock(old_man, true);
284-
if (unlikely(ret != 0))
285-
goto out_err;
286-
ttm_bo_unmap_virtual_locked(bo);
287-
ttm_mem_io_unlock(old_man);
288-
}
279+
ret = ttm_mem_io_lock(old_man, true);
280+
if (unlikely(ret != 0))
281+
goto out_err;
282+
ttm_bo_unmap_virtual_locked(bo);
283+
ttm_mem_io_unlock(old_man);
289284

290285
/*
291286
* Create and bind a ttm if required.
@@ -1698,23 +1693,6 @@ EXPORT_SYMBOL(ttm_bo_device_init);
16981693
* buffer object vm functions.
16991694
*/
17001695

1701-
bool ttm_mem_reg_is_pci(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem)
1702-
{
1703-
struct ttm_mem_type_manager *man = &bdev->man[mem->mem_type];
1704-
1705-
if (!(man->flags & TTM_MEMTYPE_FLAG_FIXED)) {
1706-
if (mem->mem_type == TTM_PL_SYSTEM)
1707-
return false;
1708-
1709-
if (man->flags & TTM_MEMTYPE_FLAG_CMA)
1710-
return false;
1711-
1712-
if (mem->placement & TTM_PL_FLAG_CACHED)
1713-
return false;
1714-
}
1715-
return true;
1716-
}
1717-
17181696
void ttm_bo_unmap_virtual_locked(struct ttm_buffer_object *bo)
17191697
{
17201698
struct ttm_bo_device *bdev = bo->bdev;

drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ static int vmw_init_mem_type(struct ttm_bo_device *bdev, uint32_t type,
762762
* slots as well as the bo size.
763763
*/
764764
man->func = &vmw_gmrid_manager_func;
765-
man->flags = TTM_MEMTYPE_FLAG_CMA | TTM_MEMTYPE_FLAG_MAPPABLE;
765+
man->flags = TTM_MEMTYPE_FLAG_MAPPABLE;
766766
man->available_caching = TTM_PL_FLAG_CACHED;
767767
man->default_caching = TTM_PL_FLAG_CACHED;
768768
break;

include/drm/ttm/ttm_bo_driver.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747

4848
#define TTM_MEMTYPE_FLAG_FIXED (1 << 0) /* Fixed (on-card) PCI memory */
4949
#define TTM_MEMTYPE_FLAG_MAPPABLE (1 << 1) /* Memory mappable */
50-
#define TTM_MEMTYPE_FLAG_CMA (1 << 3) /* Can't map aperture */
5150

5251
struct ttm_mem_type_manager;
5352

0 commit comments

Comments
 (0)