[PATCH 2/2] drm/ttm: remove available_caching
Dave Airlie
airlied at gmail.com
Mon Sep 14 21:53:27 UTC 2020
For both:
Reviewed-by: Dave Airlie <airlied at redhat.com>
On Sat, 12 Sep 2020 at 01:24, Christian König
<ckoenig.leichtzumerken at gmail.com> wrote:
>
> Instead of letting TTM make an educated guess based on
> some mask all drivers should just specify what caching
> they want for their CPU mappings.
>
> Signed-off-by: Christian König <christian.koenig at amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 1 -
> drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 1 -
> drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 2 --
> drivers/gpu/drm/drm_gem_vram_helper.c | 1 -
> drivers/gpu/drm/nouveau/nouveau_ttm.c | 9 ++-------
> drivers/gpu/drm/qxl/qxl_ttm.c | 3 +--
> drivers/gpu/drm/radeon/radeon_ttm.c | 2 --
> drivers/gpu/drm/ttm/ttm_bo.c | 8 ++------
> drivers/gpu/drm/ttm/ttm_range_manager.c | 5 +----
> drivers/gpu/drm/ttm/ttm_resource.c | 1 -
> drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 5 +----
> drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c | 1 -
> drivers/gpu/drm/vmwgfx/vmwgfx_thp.c | 10 +++-------
> include/drm/ttm/ttm_bo_driver.h | 5 +----
> include/drm/ttm/ttm_resource.h | 3 ---
> 15 files changed, 11 insertions(+), 46 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
> index b2ca693b8285..73fd2335e468 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
> @@ -93,7 +93,6 @@ int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size)
>
> man->use_tt = true;
> man->func = &amdgpu_gtt_mgr_func;
> - man->available_caching = TTM_PL_MASK_CACHING;
>
> ttm_resource_manager_init(man, gtt_size >> PAGE_SHIFT);
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> index 96aa8fcb9115..a761cc9cf422 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> @@ -68,7 +68,6 @@ static int amdgpu_ttm_init_on_chip(struct amdgpu_device *adev,
> uint64_t size)
> {
> return ttm_range_man_init(&adev->mman.bdev, type,
> - TTM_PL_FLAG_UNCACHED,
> false, size >> PAGE_SHIFT);
> }
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> index 8b4a9ab66586..76f1d8db0c85 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> @@ -177,8 +177,6 @@ int amdgpu_vram_mgr_init(struct amdgpu_device *adev)
> struct ttm_resource_manager *man = &mgr->manager;
> int ret;
>
> - man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC;
> -
> ttm_resource_manager_init(man, adev->gmc.real_vram_size >> PAGE_SHIFT);
>
> man->func = &amdgpu_vram_mgr_func;
> diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c
> index 34dc665eb891..e42cc361fe90 100644
> --- a/drivers/gpu/drm/drm_gem_vram_helper.c
> +++ b/drivers/gpu/drm/drm_gem_vram_helper.c
> @@ -1105,7 +1105,6 @@ static int drm_vram_mm_init(struct drm_vram_mm *vmm, struct drm_device *dev,
> return ret;
>
> ret = ttm_range_man_init(&vmm->bdev, TTM_PL_VRAM,
> - TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC,
> false, vram_size >> PAGE_SHIFT);
> if (ret)
> return ret;
> diff --git a/drivers/gpu/drm/nouveau/nouveau_ttm.c b/drivers/gpu/drm/nouveau/nouveau_ttm.c
> index 1b00f32b3849..427341753441 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_ttm.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_ttm.c
> @@ -200,7 +200,6 @@ nouveau_ttm_init_vram(struct nouveau_drm *drm)
> if (!man)
> return -ENOMEM;
>
> - man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC;
> man->func = &nouveau_vram_manager;
>
> ttm_resource_manager_init(man,
> @@ -209,9 +208,7 @@ nouveau_ttm_init_vram(struct nouveau_drm *drm)
> ttm_resource_manager_set_used(man, true);
> return 0;
> } else {
> - return ttm_range_man_init(&drm->ttm.bdev, TTM_PL_VRAM,
> - TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC,
> - false,
> + return ttm_range_man_init(&drm->ttm.bdev, TTM_PL_VRAM, false,
> drm->gem.vram_available >> PAGE_SHIFT);
> }
> }
> @@ -243,8 +240,7 @@ nouveau_ttm_init_gtt(struct nouveau_drm *drm)
> else if (!drm->agp.bridge)
> func = &nv04_gart_manager;
> else
> - return ttm_range_man_init(&drm->ttm.bdev, TTM_PL_TT,
> - TTM_PL_MASK_CACHING, true,
> + return ttm_range_man_init(&drm->ttm.bdev, TTM_PL_TT, true,
> size_pages);
>
> man = kzalloc(sizeof(*man), GFP_KERNEL);
> @@ -252,7 +248,6 @@ nouveau_ttm_init_gtt(struct nouveau_drm *drm)
> return -ENOMEM;
>
> man->func = func;
> - man->available_caching = TTM_PL_MASK_CACHING;
> man->use_tt = true;
> ttm_resource_manager_init(man, size_pages);
> ttm_set_driver_manager(&drm->ttm.bdev, TTM_PL_TT, man);
> diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
> index d39d7994ea34..bf3b091d0e2a 100644
> --- a/drivers/gpu/drm/qxl/qxl_ttm.c
> +++ b/drivers/gpu/drm/qxl/qxl_ttm.c
> @@ -202,8 +202,7 @@ static int qxl_ttm_init_mem_type(struct qxl_device *qdev,
> unsigned int type,
> uint64_t size)
> {
> - return ttm_range_man_init(&qdev->mman.bdev, type, TTM_PL_MASK_CACHING,
> - false, size);
> + return ttm_range_man_init(&qdev->mman.bdev, type, false, size);
> }
>
> int qxl_ttm_init(struct qxl_device *qdev)
> diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
> index b8e60b3630d7..96be5c3c1269 100644
> --- a/drivers/gpu/drm/radeon/radeon_ttm.c
> +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
> @@ -69,14 +69,12 @@ struct radeon_device *radeon_get_rdev(struct ttm_bo_device *bdev)
> static int radeon_ttm_init_vram(struct radeon_device *rdev)
> {
> return ttm_range_man_init(&rdev->mman.bdev, TTM_PL_VRAM,
> - TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC,
> false, rdev->mc.real_vram_size >> PAGE_SHIFT);
> }
>
> static int radeon_ttm_init_gtt(struct radeon_device *rdev)
> {
> return ttm_range_man_init(&rdev->mman.bdev, TTM_PL_TT,
> - TTM_PL_MASK_CACHING,
> true, rdev->mc.gtt_size >> PAGE_SHIFT);
> }
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index 43c0a5f09d67..ee2632128d3c 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -910,11 +910,8 @@ static int ttm_bo_mem_placement(struct ttm_buffer_object *bo,
> if (!man || !ttm_resource_manager_used(man))
> return -EBUSY;
>
> - if ((place->flags & man->available_caching) == 0)
> - return -EBUSY;
> -
> - cur_flags = place->flags & man->available_caching;
> - cur_flags = ttm_bo_select_caching(man, bo->mem.placement, cur_flags);
> + cur_flags = ttm_bo_select_caching(man, bo->mem.placement,
> + place->flags);
> cur_flags |= place->flags & ~TTM_PL_MASK_CACHING;
>
> mem->mem_type = place->mem_type;
> @@ -1432,7 +1429,6 @@ static void ttm_bo_init_sysman(struct ttm_bo_device *bdev)
> * Other types need to be driver / IOCTL initialized.
> */
> man->use_tt = true;
> - man->available_caching = TTM_PL_MASK_CACHING;
>
> ttm_resource_manager_init(man, 0);
> ttm_set_driver_manager(bdev, TTM_PL_SYSTEM, man);
> diff --git a/drivers/gpu/drm/ttm/ttm_range_manager.c b/drivers/gpu/drm/ttm/ttm_range_manager.c
> index c80d9fa022f7..1da0e277c511 100644
> --- a/drivers/gpu/drm/ttm/ttm_range_manager.c
> +++ b/drivers/gpu/drm/ttm/ttm_range_manager.c
> @@ -113,9 +113,7 @@ static void ttm_range_man_free(struct ttm_resource_manager *man,
> static const struct ttm_resource_manager_func ttm_range_manager_func;
>
> int ttm_range_man_init(struct ttm_bo_device *bdev,
> - unsigned type,
> - uint32_t available_caching,
> - bool use_tt,
> + unsigned type, bool use_tt,
> unsigned long p_size)
> {
> struct ttm_resource_manager *man;
> @@ -126,7 +124,6 @@ int ttm_range_man_init(struct ttm_bo_device *bdev,
> return -ENOMEM;
>
> man = &rman->manager;
> - man->available_caching = available_caching;
> man->use_tt = use_tt;
>
> man->func = &ttm_range_manager_func;
> diff --git a/drivers/gpu/drm/ttm/ttm_resource.c b/drivers/gpu/drm/ttm/ttm_resource.c
> index 80e10c28f3e8..b325b9264203 100644
> --- a/drivers/gpu/drm/ttm/ttm_resource.c
> +++ b/drivers/gpu/drm/ttm/ttm_resource.c
> @@ -140,7 +140,6 @@ void ttm_resource_manager_debug(struct ttm_resource_manager *man,
> drm_printf(p, " use_type: %d\n", man->use_type);
> drm_printf(p, " use_tt: %d\n", man->use_tt);
> drm_printf(p, " size: %llu\n", man->size);
> - drm_printf(p, " available_caching: 0x%08X\n", man->available_caching);
> if (man->func && man->func->debug)
> (*man->func->debug)(man, p);
> }
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> index 1020c991fd9b..31e3e5c9f362 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> @@ -626,8 +626,7 @@ static int vmw_vram_manager_init(struct vmw_private *dev_priv)
> #ifdef CONFIG_TRANSPARENT_HUGEPAGE
> ret = vmw_thp_init(dev_priv);
> #else
> - ret = ttm_range_man_init(&dev_priv->bdev, TTM_PL_VRAM,
> - TTM_PL_FLAG_CACHED, false,
> + ret = ttm_range_man_init(&dev_priv->bdev, TTM_PL_VRAM, false,
> dev_priv->vram_size >> PAGE_SHIFT);
> #endif
> ttm_resource_manager_set_used(ttm_manager_type(&dev_priv->bdev, TTM_PL_VRAM), false);
> @@ -882,8 +881,6 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)
> DRM_ERROR("Failed initializing TTM buffer object driver.\n");
> goto out_no_bdev;
> }
> - ttm_manager_type(&dev_priv->bdev, TTM_PL_SYSTEM)->available_caching =
> - TTM_PL_FLAG_CACHED;
>
> /*
> * Enable VRAM, but initially don't use it until SVGA is enabled and
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
> index 2d81a276b301..db64c3a90285 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
> @@ -112,7 +112,6 @@ int vmw_gmrid_man_init(struct vmw_private *dev_priv, int type)
> man = &gman->manager;
>
> man->func = &vmw_gmrid_manager_func;
> - man->available_caching = TTM_PL_FLAG_CACHED;
> /* TODO: This is most likely not correct */
> man->use_tt = true;
> ttm_resource_manager_init(man, 0);
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c b/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
> index b6cf5763c937..63fe7da4cbf4 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
> @@ -123,24 +123,20 @@ static void vmw_thp_put_node(struct ttm_resource_manager *man,
>
> int vmw_thp_init(struct vmw_private *dev_priv)
> {
> - struct ttm_resource_manager *man;
> struct vmw_thp_manager *rman;
>
> rman = kzalloc(sizeof(*rman), GFP_KERNEL);
> if (!rman)
> return -ENOMEM;
>
> - man = &rman->manager;
> - man->available_caching = TTM_PL_FLAG_CACHED;
> -
> - ttm_resource_manager_init(man,
> + ttm_resource_manager_init(&rman->manager,
> dev_priv->vram_size >> PAGE_SHIFT);
>
> - drm_mm_init(&rman->mm, 0, man->size);
> + drm_mm_init(&rman->mm, 0, rman->manager.size);
> spin_lock_init(&rman->lock);
>
> ttm_set_driver_manager(&dev_priv->bdev, TTM_PL_VRAM, &rman->manager);
> - ttm_resource_manager_set_used(man, true);
> + ttm_resource_manager_set_used(&rman->manager, true);
> return 0;
> }
>
> diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
> index bf000d69e533..0b7d18650dc5 100644
> --- a/include/drm/ttm/ttm_bo_driver.h
> +++ b/include/drm/ttm/ttm_bo_driver.h
> @@ -689,7 +689,6 @@ pgprot_t ttm_io_prot(uint32_t caching_flags, pgprot_t tmp);
> *
> * @bdev: ttm device
> * @type: memory manager type
> - * @available_caching: TTM_PL_FLAG_* for allowed caching modes
> * @use_tt: if the memory manager uses tt
> * @p_size: size of area to be managed in pages.
> *
> @@ -697,9 +696,7 @@ pgprot_t ttm_io_prot(uint32_t caching_flags, pgprot_t tmp);
> * The range manager is installed for this device in the type slot.
> */
> int ttm_range_man_init(struct ttm_bo_device *bdev,
> - unsigned type,
> - uint32_t available_caching,
> - bool use_tt,
> + unsigned type, bool use_tt,
> unsigned long p_size);
>
> /**
> diff --git a/include/drm/ttm/ttm_resource.h b/include/drm/ttm/ttm_resource.h
> index a6ae4bf9c3e1..0e172d94a0c1 100644
> --- a/include/drm/ttm/ttm_resource.h
> +++ b/include/drm/ttm/ttm_resource.h
> @@ -108,8 +108,6 @@ struct ttm_resource_manager_func {
> * @gpu_offset: If used, the GPU offset of the first managed page of
> * fixed memory or the first managed location in an aperture.
> * @size: Size of the managed region.
> - * @available_caching: A mask of available caching types, TTM_PL_FLAG_XX,
> - * as defined in ttm_placement_common.h
> * @func: structure pointer implementing the range manager. See above
> * @move_lock: lock for move fence
> * static information. bdev::driver::io_mem_free is never used.
> @@ -125,7 +123,6 @@ struct ttm_resource_manager {
> bool use_type;
> bool use_tt;
> uint64_t size;
> - uint32_t available_caching;
> const struct ttm_resource_manager_func *func;
> spinlock_t move_lock;
>
> --
> 2.17.1
>
More information about the dri-devel
mailing list