drm: remove optional dummy function from drivers using TTM
Subsystems (7)
PATCH 1/4 drm: remove optional dummy function from drivers using TTM
Implementing those is completely unecessary.
Signed-off-by Christian König <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 5 ----- drivers/gpu/drm/drm_gem_vram_helper.c | 5 ----- drivers/gpu/drm/qxl/qxl_ttm.c | 6 ------ drivers/gpu/drm/radeon/radeon_ttm.c | 5 ----- drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c | 11 ----------- 5 files changed, 32 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -5
@@ -836,10 +836,6 @@ static int amdgpu_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_return 0 ; } -static void amdgpu_ttm_io_mem_free (struct ttm_bo_device *bdev,struct ttm_mem_reg *mem) -{ -} -static unsigned long amdgpu_ttm_io_mem_pfn (struct ttm_buffer_object *bo,unsigned long page_offset) {
@@ -1754,7 +1750,6 @@ static struct ttm_bo_driver amdgpu_bo_driver = { .release_notify = &amdgpu_bo_release_notify, .fault_reserve_notify = &amdgpu_bo_fault_reserve_notify, .io_mem_reserve = &amdgpu_ttm_io_mem_reserve, - .io_mem_free = &amdgpu_ttm_io_mem_free, .io_mem_pfn = amdgpu_ttm_io_mem_pfn, .access_memory = &amdgpu_ttm_access_memory, .del_from_lru_notify = &amdgpu_vm_del_from_lru_notify
drivers/gpu/drm/drm_gem_vram_helper.c +0 -5
@@ -1094,10 +1094,6 @@ static int bo_driver_io_mem_reserve(struct ttm_bo_device *bdev,return 0 ; } -static void bo_driver_io_mem_free (struct ttm_bo_device *bdev, -struct ttm_mem_reg *mem) -{ } -static struct ttm_bo_driver bo_driver = { .ttm_tt_create = bo_driver_ttm_tt_create, .ttm_tt_populate = ttm_pool_populate,
@@ -1107,7 +1103,6 @@ static struct ttm_bo_driver bo_driver = { .evict_flags = bo_driver_evict_flags, .move_notify = bo_driver_move_notify, .io_mem_reserve = bo_driver_io_mem_reserve, - .io_mem_free = bo_driver_io_mem_free, };/*
drivers/gpu/drm/qxl/qxl_ttm.c +0 -6
@@ -129,11 +129,6 @@ int qxl_ttm_io_mem_reserve(struct ttm_bo_device *bdev,return 0 ; } -static void qxl_ttm_io_mem_free (struct ttm_bo_device *bdev, -struct ttm_mem_reg *mem) -{ -} -/* * TTM backend functions. */
@@ -247,7 +242,6 @@ static struct ttm_bo_driver qxl_bo_driver = { .evict_flags = &qxl_evict_flags, .move = &qxl_bo_move, .io_mem_reserve = &qxl_ttm_io_mem_reserve, - .io_mem_free = &qxl_ttm_io_mem_free, .move_notify = &qxl_bo_move_notify, };
drivers/gpu/drm/radeon/radeon_ttm.c +0 -5
@@ -457,10 +457,6 @@ static int radeon_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_return 0 ; } -static void radeon_ttm_io_mem_free (struct ttm_bo_device *bdev,struct ttm_mem_reg *mem) -{ -} -/* * TTM backend functions. */
@@ -774,7 +770,6 @@ static struct ttm_bo_driver radeon_bo_driver = { .move_notify = &radeon_bo_move_notify, .fault_reserve_notify = &radeon_bo_fault_reserve_notify, .io_mem_reserve = &radeon_ttm_io_mem_reserve, - .io_mem_free = &radeon_ttm_io_mem_free, };int radeon_ttm_init (struct radeon_device *rdev)
drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c +0 -11
@@ -815,15 +815,6 @@ static int vmw_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_regreturn 0 ; } -static void vmw_ttm_io_mem_free (struct ttm_bo_device *bdev,struct ttm_mem_reg *mem) -{ -} - -static int vmw_ttm_fault_reserve_notify (struct ttm_buffer_object *bo) -{ -return 0 ; -} -/** * vmw_move_notify - TTM move_notify_callback *
@@ -866,7 +857,5 @@ struct ttm_bo_driver vmw_bo_driver = { .verify_access = vmw_verify_access, .move_notify = vmw_move_notify, .swap_notify = vmw_swap_notify, - .fault_reserve_notify = &vmw_ttm_fault_reserve_notify, .io_mem_reserve = &vmw_ttm_io_mem_reserve, - .io_mem_free = &vmw_ttm_io_mem_free, };
Signature · 6 lines
2.17.1 _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau
PATCH 2/4 drm/ttm: cleanup io_mem interface with nouveau
Nouveau is the only user of this functionality and evicting io space on -EAGAIN is really a misuse of the return code.
Instead switch to using -ENOSPC here which makes much more sense and simplifies the code.
Signed-off-by Christian König <[email protected]>
--- drivers/gpu/drm/nouveau/nouveau_bo.c | 2 -- drivers/gpu/drm/ttm/ttm_bo_util.c | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-)
drivers/gpu/drm/nouveau/nouveau_bo.c +0 -2
@@ -1505,8 +1505,6 @@ nouveau_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg *reg)if (ret !=1 ) {if (WARN_ON (ret ==0 ))return -EINVAL ; -if (ret == -ENOSPC ) -return -EAGAIN ;return ret; }
drivers/gpu/drm/ttm/ttm_bo_util.c +2 -2
@@ -116,7 +116,7 @@ static int ttm_mem_io_evict(struct ttm_mem_type_manager *man)struct ttm_buffer_object *bo;if (!man->use_io_reserve_lru ||list_empty (&man->io_reserve_lru)) -return -EAGAIN ; +return -ENOSPC ; bo = list_first_entry(&man->io_reserve_lru, struct ttm_buffer_object,
@@ -143,7 +143,7 @@ int ttm_mem_io_reserve(struct ttm_bo_device *bdev, mem->bus.io_reserved_count++ == 0) { retry: ret = bdev->driver->io_mem_reserve (bdev, mem); -if (ret == -EAGAIN ) { +if (ret == -ENOSPC ) { ret =ttm_mem_io_evict (man);if (ret ==0 ) goto retry;
Signature · 6 lines
2.17.1 _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau
PATCH 3/4 drm/ttm: remove io_reserve_fastpath flag
In reply to Christian KönigJust use the use_io_reserve_lru flag. It doesn't make much sense to have two flags.
Signed-off-by Christian König <[email protected]>
--- drivers/gpu/drm/nouveau/nouveau_bo.c | 1 - drivers/gpu/drm/ttm/ttm_bo.c | 1 - drivers/gpu/drm/ttm/ttm_bo_util.c | 8 ++++---- include/drm/ttm/ttm_bo_driver.h | 2 -- 4 files changed, 4 insertions(+), 8 deletions(-)
drivers/gpu/drm/nouveau/nouveau_bo.c +0 -1
@@ -675,7 +675,6 @@ nouveau_bo_init_mem_type(struct ttm_bo_device *bdev, uint32_t type, } man->func = &nouveau_vram_manager; - man->io_reserve_fastpath = false; man->use_io_reserve_lru = true; }else { man->func = &ttm_bo_manager_func;
drivers/gpu/drm/ttm/ttm_bo.c +0 -1
@@ -1521,7 +1521,6 @@ int ttm_bo_init_mm(struct ttm_bo_device *bdev, unsigned type,BUG_ON (type >=TTM_NUM_MEM_TYPES ); man = &bdev->man[type];BUG_ON (man->has_type); - man->io_reserve_fastpath = true; man->use_io_reserve_lru = false;mutex_init (&man->io_reserve_mutex);spin_lock_init (&man->move_lock);
drivers/gpu/drm/ttm/ttm_bo_util.c +4 -4
@@ -93,7 +93,7 @@ EXPORT_SYMBOL(ttm_bo_move_ttm);int ttm_mem_io_lock (struct ttm_mem_type_manager *man,bool interruptible) { -if (likely (man->io_reserve_fastpath)) +if (likely (!man->use_io_reserve_lru))return 0 ;if (interruptible)
@@ -105,7 +105,7 @@ int ttm_mem_io_lock(struct ttm_mem_type_manager *man, bool interruptible)void ttm_mem_io_unlock (struct ttm_mem_type_manager *man) { -if (likely (man->io_reserve_fastpath)) +if (likely (!man->use_io_reserve_lru))return ;mutex_unlock (&man->io_reserve_mutex);
@@ -136,7 +136,7 @@ int ttm_mem_io_reserve(struct ttm_bo_device *bdev,if (!bdev->driver->io_mem_reserve)return 0 ; -if (likely (man->io_reserve_fastpath)) +if (likely (!man->use_io_reserve_lru))return bdev->driver->io_mem_reserve (bdev, mem); if (bdev->driver->io_mem_reserve &&
@@ -157,7 +157,7 @@ void ttm_mem_io_free(struct ttm_bo_device *bdev, {struct ttm_mem_type_manager *man = &bdev->man[mem->mem_type]; -if (likely (man->io_reserve_fastpath)) +if (likely (!man->use_io_reserve_lru))return ; if (bdev->driver->io_mem_reserve &&
include/drm/ttm/ttm_bo_driver.h +0 -2
@@ -155,7 +155,6 @@ struct ttm_mem_type_manager_func {* @use_io_reserve_lru: Use an lru list to try to unreserve io_mem_regions * reserved by the TTM vm system. * @io_reserve_lru: Optional lru list for unreserving io mem regions. -* @io_reserve_fastpath: Only use bdev::driver::io_mem_reserve to obtain * @move_lock: lock for move fence * static information. bdev::driver::io_mem_free is never used. * @lru: The lru list for this memory type.
@@ -184,7 +183,6 @@ struct ttm_mem_type_manager {void *priv;struct mutex io_reserve_mutex;bool use_io_reserve_lru; -bool io_reserve_fastpath;spinlock_t move_lock;/*
Signature · 6 lines
2.17.1 _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau
PATCH 4/4 drm/ttm: cleanup coding style and implementation.
In reply to Christian KönigOnly functional change is to always keep io_reserved_count up to date for debugging even when it is not used otherwise.
Signed-off-by Christian König <[email protected]>
--- drivers/gpu/drm/ttm/ttm_bo_util.c | 97 +++++++++++++++---------------- 1 file changed, 48 insertions(+), 49 deletions(-)
drivers/gpu/drm/ttm/ttm_bo_util.c +48 -49
@@ -115,39 +115,35 @@ static int ttm_mem_io_evict(struct ttm_mem_type_manager *man) {struct ttm_buffer_object *bo; -if (!man->use_io_reserve_lru ||list_empty (&man->io_reserve_lru)) + bo =list_first_entry_or_null (&man->io_reserve_lru, + struct ttm_buffer_object, + io_reserve_lru); +if (!bo)return -ENOSPC ; - bo =list_first_entry (&man->io_reserve_lru, - struct ttm_buffer_object, - io_reserve_lru);list_del_init (&bo->io_reserve_lru);ttm_bo_unmap_virtual_locked (bo); -return 0 ; } -int ttm_mem_io_reserve (struct ttm_bo_device *bdev,struct ttm_mem_reg *mem) {struct ttm_mem_type_manager *man = &bdev->man[mem->mem_type]; -int ret =0 ; +int ret; + +if (mem->bus.io_reserved_count++) +return 0 ;if (!bdev->driver->io_mem_reserve)return 0 ; -if (likely (!man->use_io_reserve_lru)) -return bdev->driver->io_mem_reserve (bdev, mem); -if (bdev->driver->io_mem_reserve && - mem->bus.io_reserved_count++ ==0 ) { retry: - ret = bdev->driver->io_mem_reserve (bdev, mem); -if (ret == -ENOSPC ) { - ret =ttm_mem_io_evict (man); -if (ret ==0 ) - goto retry; - } + ret = bdev->driver->io_mem_reserve (bdev, mem); +if (ret == -ENOSPC ) { + ret =ttm_mem_io_evict (man); +if (ret ==0 ) + goto retry; }return ret; }
@@ -155,35 +151,31 @@ int ttm_mem_io_reserve(struct ttm_bo_device *bdev,void ttm_mem_io_free (struct ttm_bo_device *bdev,struct ttm_mem_reg *mem) { -struct ttm_mem_type_manager *man = &bdev->man[mem->mem_type]; - -if (likely (!man->use_io_reserve_lru)) +if (--mem->bus.io_reserved_count)return ; -if (bdev->driver->io_mem_reserve && - --mem->bus.io_reserved_count ==0 && - bdev->driver->io_mem_free) - bdev->driver->io_mem_free (bdev, mem); +if (!bdev->driver->io_mem_free) +return ; + bdev->driver->io_mem_free (bdev, mem); }int ttm_mem_io_reserve_vm (struct ttm_buffer_object *bo) { +struct ttm_mem_type_manager *man = &bo->bdev->man[bo->mem.mem_type];struct ttm_mem_reg *mem = &bo->mem;int ret; -if (!mem->bus.io_reserved_vm) { -struct ttm_mem_type_manager *man = - &bo->bdev->man[mem->mem_type]; +if (mem->bus.io_reserved_vm) +return 0 ; - ret =ttm_mem_io_reserve (bo->bdev, mem); -if (unlikely (ret !=0 )) -return ret; - mem->bus.io_reserved_vm = true; -if (man->use_io_reserve_lru) -list_add_tail (&bo->io_reserve_lru, - &man->io_reserve_lru); - } + ret =ttm_mem_io_reserve (bo->bdev, mem); +if (unlikely (ret !=0 )) +return ret; + mem->bus.io_reserved_vm = true; +if (man->use_io_reserve_lru) +list_add_tail (&bo->io_reserve_lru, + &man->io_reserve_lru);return 0 ; }
@@ -191,15 +183,17 @@ void ttm_mem_io_free_vm(struct ttm_buffer_object *bo) {struct ttm_mem_reg *mem = &bo->mem; -if (mem->bus.io_reserved_vm) { - mem->bus.io_reserved_vm = false; -list_del_init (&bo->io_reserve_lru); -ttm_mem_io_free (bo->bdev, mem); - } +if (!mem->bus.io_reserved_vm) +return ; + + mem->bus.io_reserved_vm = false; +list_del_init (&bo->io_reserve_lru); +ttm_mem_io_free (bo->bdev, mem); } -static int ttm_mem_reg_ioremap (struct ttm_bo_device *bdev,struct ttm_mem_reg *mem, -void **virtual) +static int ttm_mem_reg_ioremap (struct ttm_bo_device *bdev, +struct ttm_mem_reg *mem, +void **virtual) {struct ttm_mem_type_manager *man = &bdev->man[mem->mem_type];int ret;
@@ -216,9 +210,11 @@ static int ttm_mem_reg_ioremap(struct ttm_bo_device *bdev, struct ttm_mem_reg *m addr = mem->bus.addr; }else {if (mem->placement &TTM_PL_FLAG_WC ) - addr =ioremap_wc (mem->bus.base + mem->bus.offset, mem->bus.size); + addr =ioremap_wc (mem->bus.base + mem->bus.offset, + mem->bus.size);else - addr =ioremap (mem->bus.base + mem->bus.offset, mem->bus.size); + addr =ioremap (mem->bus.base + mem->bus.offset, + mem->bus.size);if (!addr) { (void )ttm_mem_io_lock (man, false);ttm_mem_io_free (bdev, mem);
@@ -230,8 +226,9 @@ static int ttm_mem_reg_ioremap(struct ttm_bo_device *bdev, struct ttm_mem_reg *mreturn 0 ; } -static void ttm_mem_reg_iounmap (struct ttm_bo_device *bdev,struct ttm_mem_reg *mem, -void *virtual) +static void ttm_mem_reg_iounmap (struct ttm_bo_device *bdev, +struct ttm_mem_reg *mem, +void *virtual) {struct ttm_mem_type_manager *man;
@@ -513,11 +510,13 @@ static int ttm_bo_ioremap(struct ttm_buffer_object *bo, }else { map->bo_kmap_type = ttm_bo_map_iomap;if (mem->placement &TTM_PL_FLAG_WC ) - map->virtual =ioremap_wc (bo->mem.bus.base + bo->mem.bus.offset + offset, + map->virtual =ioremap_wc (bo->mem.bus.base + + bo->mem.bus.offset + offset, size);else - map->virtual =ioremap (bo->mem.bus.base + bo->mem.bus.offset + offset, - size); + map->virtual =ioremap (bo->mem.bus.base + + bo->mem.bus.offset + offset, + size); }return (!map->virtual) ? -ENOMEM :0 ; }
Signature · 6 lines
2.17.1 _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau