unmappable vram V5
Subsystems (6)
I think i have addressed all concern.
Patch doesn't follow 80colons limit as their was discussion about dropping that on lkml.
only compile tested on nouveau & vmwgfx.
Sorry for short mail but i wrote a lot longer one which got lost ... don't feel like rewriting it.
Cheers,
Jerome
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--
PATCH 1/14 drm/ttm: split no_wait argument in 2 GPU or reserve wait
There is case where we want to be able to wait only for the GPU while not waiting for other buffer to be unreserved. This patch split the no_wait argument all the way down in the whole ttm path so that upper level can decide on what to wait on or not.
This patch break the API to other modules, update to others driver are following in separate patches.
--- drivers/gpu/drm/ttm/ttm_bo.c | 57 ++++++++++++++++++++---------------- drivers/gpu/drm/ttm/ttm_bo_util.c | 9 ++++-- include/drm/ttm/ttm_bo_api.h | 6 ++- include/drm/ttm/ttm_bo_driver.h | 29 +++++++++++------- 4 files changed, 60 insertions(+), 41 deletions(-)
drivers/gpu/drm/ttm/ttm_bo.c +32 -25
@@ -357,7 +357,8 @@ static int ttm_bo_add_ttm(struct ttm_buffer_object *bo, bool zero_alloc)static int ttm_bo_handle_move_mem (struct ttm_buffer_object *bo,struct ttm_mem_reg *mem, -bool evict,bool interruptible,bool no_wait) +bool evict,bool interruptible, +bool no_wait_reserve,bool no_wait_gpu) {struct ttm_bo_device *bdev = bo->bdev;bool old_is_pci =ttm_mem_reg_is_pci (bdev, &bo->mem);
@@ -402,12 +403,12 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,if (!(old_man->flags &TTM_MEMTYPE_FLAG_FIXED ) && !(new_man->flags &TTM_MEMTYPE_FLAG_FIXED )) - ret =ttm_bo_move_ttm (bo, evict, no_wait, mem); + ret =ttm_bo_move_ttm (bo, evict, no_wait_reserve, no_wait_gpu, mem);else if (bdev->driver->move) ret = bdev->driver->move (bo, evict, interruptible, - no_wait, mem); + no_wait_reserve, no_wait_gpu, mem);else - ret =ttm_bo_move_memcpy (bo, evict, no_wait, mem); + ret =ttm_bo_move_memcpy (bo, evict, no_wait_reserve, no_wait_gpu, mem);if (ret) goto out_err;
@@ -606,7 +607,7 @@ void ttm_bo_unref(struct ttm_buffer_object **p_bo)EXPORT_SYMBOL (ttm_bo_unref);static int ttm_bo_evict (struct ttm_buffer_object *bo,bool interruptible, -bool no_wait) +bool no_wait_reserve,bool no_wait_gpu) {struct ttm_bo_device *bdev = bo->bdev;struct ttm_bo_global *glob = bo->glob;
@@ -615,7 +616,7 @@ static int ttm_bo_evict(struct ttm_buffer_object *bo, bool interruptible,int ret =0 ;spin_lock (&bo->lock); - ret =ttm_bo_wait (bo, false, interruptible, no_wait); + ret =ttm_bo_wait (bo, false, interruptible, no_wait_gpu);spin_unlock (&bo->lock);if (unlikely (ret !=0 )) {
@@ -638,7 +639,7 @@ static int ttm_bo_evict(struct ttm_buffer_object *bo, bool interruptible, placement.num_busy_placement =0 ; bdev->driver->evict_flags (bo, &placement); ret =ttm_bo_mem_space (bo, &placement, &evict_mem, interruptible, - no_wait); + no_wait_reserve, no_wait_gpu);if (ret) {if (ret != -ERESTARTSYS ) { printk(KERN_ERR TTM_PFX
@@ -650,7 +651,7 @@ static int ttm_bo_evict(struct ttm_buffer_object *bo, bool interruptible, } ret =ttm_bo_handle_move_mem (bo, &evict_mem, true, interruptible, - no_wait); + no_wait_reserve, no_wait_gpu);if (ret) {if (ret != -ERESTARTSYS ) printk(KERN_ERR TTM_PFX "Buffer eviction failed\n");
@@ -670,7 +671,8 @@ out:static int ttm_mem_evict_first (struct ttm_bo_device *bdev,uint32_t mem_type, -bool interruptible,bool no_wait) +bool interruptible,bool no_wait_reserve, +bool no_wait_gpu) {struct ttm_bo_global *glob = bdev->glob;struct ttm_mem_type_manager *man = &bdev->man[mem_type];
@@ -687,11 +689,11 @@ retry: bo = list_first_entry(&man->lru, struct ttm_buffer_object, lru);kref_get (&bo->list_kref); - ret =ttm_bo_reserve_locked (bo, false, true, false,0 ); + ret =ttm_bo_reserve_locked (bo, false, no_wait_reserve, false,0 );if (unlikely (ret == -EBUSY )) {spin_unlock (&glob->lru_lock); -if (likely (!no_wait)) +if (likely (!no_wait_gpu)) ret =ttm_bo_wait_unreserved (bo, interruptible);kref_put (&bo->list_kref, ttm_bo_release_list);
@@ -713,7 +715,7 @@ retry:while (put_count--)kref_put (&bo->list_kref, ttm_bo_ref_bug); - ret =ttm_bo_evict (bo, interruptible, no_wait); + ret =ttm_bo_evict (bo, interruptible, no_wait_reserve, no_wait_gpu);ttm_bo_unreserve (bo);kref_put (&bo->list_kref, ttm_bo_release_list);
@@ -764,7 +766,9 @@ static int ttm_bo_mem_force_space(struct ttm_buffer_object *bo,uint32_t mem_type, struct ttm_placement *placement, struct ttm_mem_reg *mem, - bool interruptible, bool no_wait) + bool interruptible, + bool no_wait_reserve, + bool no_wait_gpu) { struct ttm_bo_device *bdev = bo->bdev;struct ttm_bo_global *glob = bdev->glob;
@@ -785,7 +789,7 @@ static int ttm_bo_mem_force_space(struct ttm_buffer_object *bo, }spin_unlock (&glob->lru_lock); ret =ttm_mem_evict_first (bdev, mem_type, interruptible, - no_wait); + no_wait_reserve, no_wait_gpu);if (unlikely (ret !=0 ))return ret; }while (1 );
@@ -855,7 +859,8 @@ static bool ttm_bo_mt_compatible(struct ttm_mem_type_manager *man,int ttm_bo_mem_space (struct ttm_buffer_object *bo,struct ttm_placement *placement,struct ttm_mem_reg *mem, -bool interruptible,bool no_wait) +bool interruptible,bool no_wait_reserve, +bool no_wait_gpu) {struct ttm_bo_device *bdev = bo->bdev;struct ttm_mem_type_manager *man;
@@ -952,7 +957,7 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo, } ret =ttm_bo_mem_force_space (bo, mem_type, placement, mem, - interruptible, no_wait); + interruptible, no_wait_reserve, no_wait_gpu);if (ret ==0 && mem->mm_node) { mem->placement = cur_flags; mem->mm_node->private = bo;
@@ -978,7 +983,8 @@ EXPORT_SYMBOL(ttm_bo_wait_cpu);int ttm_bo_move_buffer (struct ttm_buffer_object *bo,struct ttm_placement *placement, -bool interruptible,bool no_wait) +bool interruptible,bool no_wait_reserve, +bool no_wait_gpu) {struct ttm_bo_global *glob = bo->glob;int ret =0 ;
@@ -992,7 +998,7 @@ int ttm_bo_move_buffer(struct ttm_buffer_object *bo,* instead of doing it here. */ spin_lock (&bo->lock); - ret =ttm_bo_wait (bo, false, interruptible, no_wait); + ret =ttm_bo_wait (bo, false, interruptible, no_wait_gpu);spin_unlock (&bo->lock);if (ret)return ret;
@@ -1002,10 +1008,10 @@ int ttm_bo_move_buffer(struct ttm_buffer_object *bo,/* * Determine where to move the buffer. */ - ret =ttm_bo_mem_space (bo, placement, &mem, interruptible, no_wait); + ret =ttm_bo_mem_space (bo, placement, &mem, interruptible, no_wait_reserve, no_wait_gpu);if (ret) goto out_unlock; - ret =ttm_bo_handle_move_mem (bo, &mem, false, interruptible, no_wait); + ret =ttm_bo_handle_move_mem (bo, &mem, false, interruptible, no_wait_reserve, no_wait_gpu); out_unlock:if (ret && mem.mm_node) {spin_lock (&glob->lru_lock);
@@ -1039,7 +1045,8 @@ static int ttm_bo_mem_compat(struct ttm_placement *placement,int ttm_bo_validate (struct ttm_buffer_object *bo,struct ttm_placement *placement, -bool interruptible,bool no_wait) +bool interruptible,bool no_wait_reserve, +bool no_wait_gpu) {int ret;
@@ -1054,7 +1061,7 @@ int ttm_bo_validate(struct ttm_buffer_object *bo,*/ ret =ttm_bo_mem_compat (placement, &bo->mem);if (ret <0 ) { - ret =ttm_bo_move_buffer (bo, placement, interruptible, no_wait); + ret =ttm_bo_move_buffer (bo, placement, interruptible, no_wait_reserve, no_wait_gpu);if (ret)return ret; }else {
@@ -1175,7 +1182,7 @@ int ttm_bo_init(struct ttm_bo_device *bdev, goto out_err; } - ret =ttm_bo_validate (bo, placement, interruptible, false); + ret =ttm_bo_validate (bo, placement, interruptible, false, false);if (ret) goto out_err;
@@ -1249,7 +1256,7 @@ static int ttm_bo_force_list_clean(struct ttm_bo_device *bdev,spin_lock (&glob->lru_lock);while (!list_empty (&man->lru)) {spin_unlock (&glob->lru_lock); - ret =ttm_mem_evict_first (bdev, mem_type, false, false); + ret =ttm_mem_evict_first (bdev, mem_type, false, false, false);if (ret) {if (allow_errors) {return ret;
@@ -1839,7 +1846,7 @@ static int ttm_bo_swapout(struct ttm_mem_shrink *shrink) evict_mem.mem_type =TTM_PL_SYSTEM ; ret =ttm_bo_handle_move_mem (bo, &evict_mem, true, - false, false); + false, false, false);if (unlikely (ret !=0 )) goto out; }
drivers/gpu/drm/ttm/ttm_bo_util.c +6 -3
@@ -49,7 +49,8 @@ void ttm_bo_free_old_node(struct ttm_buffer_object *bo) }int ttm_bo_move_ttm (struct ttm_buffer_object *bo, -bool evict,bool no_wait,struct ttm_mem_reg *new_mem) +bool evict,bool no_wait_reserve, +bool no_wait_gpu,struct ttm_mem_reg *new_mem) {struct ttm_tt *ttm = bo->ttm;struct ttm_mem_reg *old_mem = &bo->mem;
@@ -207,7 +208,8 @@ static int ttm_copy_ttm_io_page(struct ttm_tt *ttm, void *dst, }int ttm_bo_move_memcpy (struct ttm_buffer_object *bo, -bool evict,bool no_wait,struct ttm_mem_reg *new_mem) +bool evict,bool no_wait_reserve,bool no_wait_gpu, +struct ttm_mem_reg *new_mem) {struct ttm_bo_device *bdev = bo->bdev;struct ttm_mem_type_manager *man = &bdev->man[new_mem->mem_type];
@@ -525,7 +527,8 @@ int ttm_bo_pfn_prot(struct ttm_buffer_object *bo,int ttm_bo_move_accel_cleanup (struct ttm_buffer_object *bo,void *sync_obj,void *sync_obj_arg, -bool evict,bool no_wait, +bool evict,bool no_wait_reserve, +bool no_wait_gpu,struct ttm_mem_reg *new_mem) {struct ttm_bo_device *bdev = bo->bdev;
include/drm/ttm/ttm_bo_api.h +4 -2
@@ -313,7 +313,8 @@ extern int ttm_bo_wait(struct ttm_buffer_object *bo, bool lazy,* @bo: The buffer object. * @placement: Proposed placement for the buffer object. * @interruptible: Sleep interruptible if sleeping. -* @no_wait: Return immediately if the buffer is busy. +* @no_wait_reserve: Return immediately if other buffers are busy. +* @no_wait_gpu: Return immediately if the GPU is busy. * * Changes placement and caching policy of the buffer object * according proposed placement.
@@ -325,7 +326,8 @@ extern int ttm_bo_wait(struct ttm_buffer_object *bo, bool lazy,*/ extern int ttm_bo_validate (struct ttm_buffer_object *bo,struct ttm_placement *placement, -bool interruptible,bool no_wait); +bool interruptible,bool no_wait_reserve, +bool no_wait_gpu);/** * ttm_bo_unref
include/drm/ttm/ttm_bo_driver.h +18 -11
@@ -311,7 +311,8 @@ struct ttm_bo_driver {*/ int (*move) (struct ttm_buffer_object *bo,bool evict,bool interruptible, -bool no_wait,struct ttm_mem_reg *new_mem); +bool no_wait_reserve,bool no_wait_gpu, +struct ttm_mem_reg *new_mem);/** * struct ttm_bo_driver_member verify_access
@@ -633,7 +634,8 @@ extern bool ttm_mem_reg_is_pci(struct ttm_bo_device *bdev,* @proposed_placement: Proposed new placement for the buffer object. * @mem: A struct ttm_mem_reg. * @interruptible: Sleep interruptible when sliping. -* @no_wait: Don't sleep waiting for space to become available. +* @no_wait_reserve: Return immediately if other buffers are busy. +* @no_wait_gpu: Return immediately if the GPU is busy. * * Allocate memory space for the buffer object pointed to by @bo, using * the placement flags in @mem, potentially evicting other idle buffer objects.
@@ -647,7 +649,8 @@ extern bool ttm_mem_reg_is_pci(struct ttm_bo_device *bdev,extern int ttm_bo_mem_space (struct ttm_buffer_object *bo,struct ttm_placement *placement,struct ttm_mem_reg *mem, -bool interruptible,bool no_wait); +bool interruptible, +bool no_wait_reserve,bool no_wait_gpu);/** * ttm_bo_wait_for_cpu *
@@ -826,7 +829,8 @@ extern void ttm_bo_unblock_reservation(struct ttm_buffer_object *bo);* * @bo: A pointer to a struct ttm_buffer_object. * @evict: 1: This is an eviction. Don't try to pipeline. -* @no_wait: Never sleep, but rather return with -EBUSY. +* @no_wait_reserve: Return immediately if other buffers are busy. +* @no_wait_gpu: Return immediately if the GPU is busy. * @new_mem: struct ttm_mem_reg indicating where to move. * * Optimized move function for a buffer object with both old and
@@ -840,15 +844,16 @@ extern void ttm_bo_unblock_reservation(struct ttm_buffer_object *bo);*/ extern int ttm_bo_move_ttm (struct ttm_buffer_object *bo, -bool evict,bool no_wait, -struct ttm_mem_reg *new_mem); +bool evict,bool no_wait_reserve, +bool no_wait_gpu,struct ttm_mem_reg *new_mem);/** * ttm_bo_move_memcpy * * @bo: A pointer to a struct ttm_buffer_object. * @evict: 1: This is an eviction. Don't try to pipeline. -* @no_wait: Never sleep, but rather return with -EBUSY. +* @no_wait_reserve: Return immediately if other buffers are busy. +* @no_wait_gpu: Return immediately if the GPU is busy. * @new_mem: struct ttm_mem_reg indicating where to move. * * Fallback move function for a mappable buffer object in mappable memory.
@@ -862,8 +867,8 @@ extern int ttm_bo_move_ttm(struct ttm_buffer_object *bo,*/ extern int ttm_bo_move_memcpy (struct ttm_buffer_object *bo, -bool evict, -bool no_wait,struct ttm_mem_reg *new_mem); +bool evict,bool no_wait_reserve, +bool no_wait_gpu,struct ttm_mem_reg *new_mem);/** * ttm_bo_free_old_node
@@ -882,7 +887,8 @@ extern void ttm_bo_free_old_node(struct ttm_buffer_object *bo);* @sync_obj_arg: An argument to pass to the sync object idle / wait * functions. * @evict: This is an evict move. Don't return until the buffer is idle. -* @no_wait: Never sleep, but rather return with -EBUSY. +* @no_wait_reserve: Return immediately if other buffers are busy. +* @no_wait_gpu: Return immediately if the GPU is busy. * @new_mem: struct ttm_mem_reg indicating where to move. * * Accelerated move function to be called when an accelerated move
@@ -896,7 +902,8 @@ extern void ttm_bo_free_old_node(struct ttm_buffer_object *bo);extern int ttm_bo_move_accel_cleanup (struct ttm_buffer_object *bo,void *sync_obj,void *sync_obj_arg, -bool evict,bool no_wait, +bool evict,bool no_wait_reserve, +bool no_wait_gpu,struct ttm_mem_reg *new_mem);/** * ttm_io_prot
Signature · 10 lines
1.6.6.1 ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev --
PATCH 2/14 drm/radeon/kms: update to TTM no_wait splitted argument
This patch update radeon to the new no_wait splitted argument TTM functionality.
--- drivers/gpu/drm/radeon/radeon_object.c | 6 ++-- drivers/gpu/drm/radeon/radeon_ttm.c | 39 +++++++++++++++++-------------- 2 files changed, 24 insertions(+), 21 deletions(-)
drivers/gpu/drm/radeon/radeon_object.c +3 -3
@@ -189,7 +189,7 @@ int radeon_bo_pin(struct radeon_bo *bo, u32 domain, u64 *gpu_addr) bo->placement.lpfn = bo->rdev->mc.visible_vram_size >>PAGE_SHIFT ;for (i =0 ; i < bo->placement.num_placement; i++) bo->placements[i] |=TTM_PL_FLAG_NO_EVICT ; - r =ttm_bo_validate (&bo->tbo, &bo->placement, false, false); + r =ttm_bo_validate (&bo->tbo, &bo->placement, false, false, false);if (likely (r ==0 )) { bo->pin_count =1 ;if (gpu_addr !=NULL )
@@ -213,7 +213,7 @@ int radeon_bo_unpin(struct radeon_bo *bo)return 0 ;for (i =0 ; i < bo->placement.num_placement; i++) bo->placements[i] &= ~TTM_PL_FLAG_NO_EVICT ; - r =ttm_bo_validate (&bo->tbo, &bo->placement, false, false); + r =ttm_bo_validate (&bo->tbo, &bo->placement, false, false, false);if (unlikely (r !=0 ))dev_err (bo->rdev->dev,"%p validate failed for unpin\n" , bo);return r;
@@ -328,7 +328,7 @@ int radeon_bo_list_validate(struct list_head *head) lobj->rdomain); } r =ttm_bo_validate (&bo->tbo, &bo->placement, - true, false); + true, false, false);if (unlikely (r))return r; }
drivers/gpu/drm/radeon/radeon_ttm.c +21 -18
@@ -243,9 +243,9 @@ static void radeon_move_null(struct ttm_buffer_object *bo, }static int radeon_move_blit (struct ttm_buffer_object *bo, -bool evict,int no_wait, -struct ttm_mem_reg *new_mem, -struct ttm_mem_reg *old_mem) +bool evict,int no_wait_reserve,bool no_wait_gpu, +struct ttm_mem_reg *new_mem, +struct ttm_mem_reg *old_mem) {struct radeon_device *rdev;uint64_t old_start, new_start;
@@ -289,13 +289,14 @@ static int radeon_move_blit(struct ttm_buffer_object *bo, r =radeon_copy (rdev, old_start, new_start, new_mem->num_pages, fence);/* FIXME: handle copy error */ r =ttm_bo_move_accel_cleanup (bo, (void *)fence,NULL , - evict, no_wait, new_mem); + evict, no_wait_reserve, no_wait_gpu, new_mem);radeon_fence_unref (&fence);return r; }static int radeon_move_vram_ram (struct ttm_buffer_object *bo, -bool evict,bool interruptible,bool no_wait, +bool evict,bool interruptible, +bool no_wait_reserve,bool no_wait_gpu,struct ttm_mem_reg *new_mem) {struct radeon_device *rdev;
@@ -316,7 +317,7 @@ static int radeon_move_vram_ram(struct ttm_buffer_object *bo, placement.busy_placement = &placements; placements =TTM_PL_MASK_CACHING |TTM_PL_FLAG_TT ; r =ttm_bo_mem_space (bo, &placement, &tmp_mem, - interruptible, no_wait); + interruptible, no_wait_reserve, no_wait_gpu);if (unlikely (r)) {return r; }
@@ -330,11 +331,11 @@ static int radeon_move_vram_ram(struct ttm_buffer_object *bo,if (unlikely (r)) { goto out_cleanup; } - r =radeon_move_blit (bo, true, no_wait, &tmp_mem, old_mem); + r =radeon_move_blit (bo, true, no_wait_reserve, no_wait_gpu, &tmp_mem, old_mem);if (unlikely (r)) { goto out_cleanup; } - r =ttm_bo_move_ttm (bo, true, no_wait, new_mem); + r =ttm_bo_move_ttm (bo, true, no_wait_reserve, no_wait_gpu, new_mem); out_cleanup:if (tmp_mem.mm_node) {struct ttm_bo_global *glob = rdev->mman.bdev.glob;
@@ -348,7 +349,8 @@ out_cleanup: }static int radeon_move_ram_vram (struct ttm_buffer_object *bo, -bool evict,bool interruptible,bool no_wait, +bool evict,bool interruptible, +bool no_wait_reserve,bool no_wait_gpu,struct ttm_mem_reg *new_mem) {struct radeon_device *rdev;
@@ -368,15 +370,15 @@ static int radeon_move_ram_vram(struct ttm_buffer_object *bo, placement.num_busy_placement =1 ; placement.busy_placement = &placements; placements =TTM_PL_MASK_CACHING |TTM_PL_FLAG_TT ; - r =ttm_bo_mem_space (bo, &placement, &tmp_mem, interruptible, no_wait); + r =ttm_bo_mem_space (bo, &placement, &tmp_mem, interruptible, no_wait_reserve, no_wait_gpu);if (unlikely (r)) {return r; } - r =ttm_bo_move_ttm (bo, true, no_wait, &tmp_mem); + r =ttm_bo_move_ttm (bo, true, no_wait_reserve, no_wait_gpu, &tmp_mem);if (unlikely (r)) { goto out_cleanup; } - r =radeon_move_blit (bo, true, no_wait, new_mem, old_mem); + r =radeon_move_blit (bo, true, no_wait_reserve, no_wait_gpu, new_mem, old_mem);if (unlikely (r)) { goto out_cleanup; }
@@ -393,8 +395,9 @@ out_cleanup: }static int radeon_bo_move (struct ttm_buffer_object *bo, -bool evict,bool interruptible,bool no_wait, -struct ttm_mem_reg *new_mem) +bool evict,bool interruptible, +bool no_wait_reserve,bool no_wait_gpu, +struct ttm_mem_reg *new_mem) {struct radeon_device *rdev;struct ttm_mem_reg *old_mem = &bo->mem;
@@ -421,18 +424,18 @@ static int radeon_bo_move(struct ttm_buffer_object *bo,if (old_mem->mem_type ==TTM_PL_VRAM && new_mem->mem_type ==TTM_PL_SYSTEM ) { r =radeon_move_vram_ram (bo, evict, interruptible, - no_wait, new_mem); + no_wait_reserve, no_wait_gpu, new_mem); }else if (old_mem->mem_type ==TTM_PL_SYSTEM && new_mem->mem_type ==TTM_PL_VRAM ) { r =radeon_move_ram_vram (bo, evict, interruptible, - no_wait, new_mem); + no_wait_reserve, no_wait_gpu, new_mem); }else { - r =radeon_move_blit (bo, evict, no_wait, new_mem, old_mem); + r =radeon_move_blit (bo, evict, no_wait_reserve, no_wait_gpu, new_mem, old_mem); }if (r) { memcpy: - r =ttm_bo_move_memcpy (bo, evict, no_wait, new_mem); + r =ttm_bo_move_memcpy (bo, evict, no_wait_reserve, no_wait_gpu, new_mem); }return r;
Signature · 10 lines
1.6.6.1 ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev --
PATCH 3/14 drm/nouveau: update to TTM no_wait splitted argument
This patch update radeon to the new no_wait splitted argument TTM functionality.
Compile tested only (but thing should run as there is no operating change from driver point of view)
--- drivers/gpu/drm/nouveau/nouveau_bo.c | 45 ++++++++++++++++++-------------- drivers/gpu/drm/nouveau/nouveau_gem.c | 2 +- 2 files changed, 26 insertions(+), 21 deletions(-)
drivers/gpu/drm/nouveau/nouveau_bo.c +25 -20
@@ -219,7 +219,7 @@ nouveau_bo_pin(struct nouveau_bo *nvbo, uint32_t memtype)for (i =0 ; i < nvbo->placement.num_placement; i++) nvbo->placements[i] |=TTM_PL_FLAG_NO_EVICT ; - ret =ttm_bo_validate (bo, &nvbo->placement, false, false); + ret =ttm_bo_validate (bo, &nvbo->placement, false, false, false);if (ret ==0 ) {switch (bo->mem.mem_type) {case TTM_PL_VRAM :
@@ -256,7 +256,7 @@ nouveau_bo_unpin(struct nouveau_bo *nvbo)for (i =0 ; i < nvbo->placement.num_placement; i++) nvbo->placements[i] &= ~TTM_PL_FLAG_NO_EVICT ; - ret =ttm_bo_validate (bo, &nvbo->placement, false, false); + ret =ttm_bo_validate (bo, &nvbo->placement, false, false, false);if (ret ==0 ) {switch (bo->mem.mem_type) {case TTM_PL_VRAM :
@@ -456,7 +456,8 @@ nouveau_bo_evict_flags(struct ttm_buffer_object *bo, struct ttm_placement *pl)static int nouveau_bo_move_accel_cleanup (struct nouveau_channel *chan, -struct nouveau_bo *nvbo,bool evict,bool no_wait, +struct nouveau_bo *nvbo,bool evict, +bool no_wait_reserve,bool no_wait_gpu,struct ttm_mem_reg *new_mem) {struct nouveau_fence *fence =NULL ;
@@ -467,7 +468,7 @@ nouveau_bo_move_accel_cleanup(struct nouveau_channel *chan,return ret; ret =ttm_bo_move_accel_cleanup (&nvbo->bo, fence,NULL , - evict, no_wait, new_mem); + evict, no_wait_reserve, no_wait_gpu, new_mem);if (nvbo->channel && nvbo->channel != chan) ret =nouveau_fence_wait (fence,NULL , false, false);nouveau_fence_unref ((void *)&fence);
@@ -491,7 +492,8 @@ nouveau_bo_mem_ctxdma(struct nouveau_bo *nvbo, struct nouveau_channel *chan,static int nouveau_bo_move_m2mf (struct ttm_buffer_object *bo,int evict,bool intr, -int no_wait,struct ttm_mem_reg *new_mem) +bool no_wait_reserve,bool no_wait_gpu, +struct ttm_mem_reg *new_mem) {struct nouveau_bo *nvbo =nouveau_bo (bo);struct drm_nouveau_private *dev_priv =nouveau_bdev (bo->bdev);
@@ -569,12 +571,13 @@ nouveau_bo_move_m2mf(struct ttm_buffer_object *bo, int evict, bool intr, dst_offset += (PAGE_SIZE * line_count); } -return nouveau_bo_move_accel_cleanup (chan, nvbo, evict, no_wait, new_mem); +return nouveau_bo_move_accel_cleanup (chan, nvbo, evict, no_wait_reserve, no_wait_gpu, new_mem); }static int nouveau_bo_move_flipd (struct ttm_buffer_object *bo,bool evict,bool intr, -bool no_wait,struct ttm_mem_reg *new_mem) +bool no_wait_reserve,bool no_wait_gpu, +struct ttm_mem_reg *new_mem) {u32 placement_memtype =TTM_PL_FLAG_TT |TTM_PL_MASK_CACHING ;struct ttm_placement placement;
@@ -587,7 +590,7 @@ nouveau_bo_move_flipd(struct ttm_buffer_object *bo, bool evict, bool intr, tmp_mem = *new_mem; tmp_mem.mm_node =NULL ; - ret =ttm_bo_mem_space (bo, &placement, &tmp_mem, intr, no_wait); + ret =ttm_bo_mem_space (bo, &placement, &tmp_mem, intr, no_wait_reserve, no_wait_gpu);if (ret)return ret;
@@ -595,11 +598,11 @@ nouveau_bo_move_flipd(struct ttm_buffer_object *bo, bool evict, bool intr,if (ret) goto out; - ret =nouveau_bo_move_m2mf (bo, true, intr, no_wait, &tmp_mem); + ret =nouveau_bo_move_m2mf (bo, true, intr, no_wait_reserve, no_wait_gpu, &tmp_mem);if (ret) goto out; - ret =ttm_bo_move_ttm (bo, evict, no_wait, new_mem); + ret =ttm_bo_move_ttm (bo, evict, no_wait_reserve, no_wait_gpu, new_mem); out:if (tmp_mem.mm_node) {spin_lock (&bo->bdev->glob->lru_lock);
@@ -612,7 +615,8 @@ out:static int nouveau_bo_move_flips (struct ttm_buffer_object *bo,bool evict,bool intr, -bool no_wait,struct ttm_mem_reg *new_mem) +bool no_wait_reserve,bool no_wait_gpu, +struct ttm_mem_reg *new_mem) {u32 placement_memtype =TTM_PL_FLAG_TT |TTM_PL_MASK_CACHING ;struct ttm_placement placement;
@@ -625,15 +629,15 @@ nouveau_bo_move_flips(struct ttm_buffer_object *bo, bool evict, bool intr, tmp_mem = *new_mem; tmp_mem.mm_node =NULL ; - ret =ttm_bo_mem_space (bo, &placement, &tmp_mem, intr, no_wait); + ret =ttm_bo_mem_space (bo, &placement, &tmp_mem, intr, no_wait_reserve, no_wait_gpu);if (ret)return ret; - ret =ttm_bo_move_ttm (bo, evict, no_wait, &tmp_mem); + ret =ttm_bo_move_ttm (bo, evict, no_wait_reserve, no_wait_gpu, &tmp_mem);if (ret) goto out; - ret =nouveau_bo_move_m2mf (bo, evict, intr, no_wait, new_mem); + ret =nouveau_bo_move_m2mf (bo, evict, intr, no_wait_reserve, no_wait_gpu, new_mem);if (ret) goto out;
@@ -700,7 +704,8 @@ nouveau_bo_vm_cleanup(struct ttm_buffer_object *bo,static int nouveau_bo_move (struct ttm_buffer_object *bo,bool evict,bool intr, -bool no_wait,struct ttm_mem_reg *new_mem) +bool no_wait_reserve,bool no_wait_gpu, +struct ttm_mem_reg *new_mem) {struct drm_nouveau_private *dev_priv =nouveau_bdev (bo->bdev);struct nouveau_bo *nvbo =nouveau_bo (bo);
@@ -715,7 +720,7 @@ nouveau_bo_move(struct ttm_buffer_object *bo, bool evict, bool intr,/* Software copy if the card isn't up and running yet. */ if (dev_priv->init_state !=NOUVEAU_CARD_INIT_DONE || !dev_priv->channel) { - ret =ttm_bo_move_memcpy (bo, evict, no_wait, new_mem); + ret =ttm_bo_move_memcpy (bo, evict, no_wait_reserve, no_wait_gpu, new_mem); goto out; }
@@ -729,17 +734,17 @@ nouveau_bo_move(struct ttm_buffer_object *bo, bool evict, bool intr,/* Hardware assisted copy. */ if (new_mem->mem_type ==TTM_PL_SYSTEM ) - ret =nouveau_bo_move_flipd (bo, evict, intr, no_wait, new_mem); + ret =nouveau_bo_move_flipd (bo, evict, intr, no_wait_reserve, no_wait_gpu, new_mem);else if (old_mem->mem_type ==TTM_PL_SYSTEM ) - ret =nouveau_bo_move_flips (bo, evict, intr, no_wait, new_mem); + ret =nouveau_bo_move_flips (bo, evict, intr, no_wait_reserve, no_wait_gpu, new_mem);else - ret =nouveau_bo_move_m2mf (bo, evict, intr, no_wait, new_mem); + ret =nouveau_bo_move_m2mf (bo, evict, intr, no_wait_reserve, no_wait_gpu, new_mem);if (!ret) goto out;/* Fallback to software copy. */ - ret =ttm_bo_move_memcpy (bo, evict, no_wait, new_mem); + ret =ttm_bo_move_memcpy (bo, evict, no_wait_reserve, no_wait_gpu, new_mem); out:if (ret)
drivers/gpu/drm/nouveau/nouveau_gem.c +1 -1
@@ -387,7 +387,7 @@ validate_list(struct nouveau_channel *chan, struct list_head *list, nvbo->channel = chan; ret =ttm_bo_validate (&nvbo->bo, &nvbo->placement, - false, false); + false, false, false); nvbo->channel =NULL ;if (unlikely (ret)) {NV_ERROR (dev,"fail ttm_validate\n" );
Signature · 10 lines
1.6.6.1 ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev --
PATCH 4/14 drm/vmwgfx: update to TTM no_wait splitted argument
This patch update radeon to the new no_wait splitted argument TTM functionality.
Compile tested only (but thing should run as there is no operating change from driver point of view)
--- drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 4 ++-- drivers/gpu/drm/vmwgfx/vmwgfx_fb.c | 4 ++-- drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +2 -2
@@ -570,7 +570,7 @@ static int vmw_validate_single_buffer(struct vmw_private *dev_priv,* Put BO in VRAM, only if there is space. */ - ret =ttm_bo_validate (bo, &vmw_vram_sys_placement, true, false); + ret =ttm_bo_validate (bo, &vmw_vram_sys_placement, true, false, false);if (unlikely (ret == -ERESTARTSYS ))return ret;
@@ -590,7 +590,7 @@ static int vmw_validate_single_buffer(struct vmw_private *dev_priv,* previous contents. */ - ret =ttm_bo_validate (bo, &vmw_vram_placement, true, false); + ret =ttm_bo_validate (bo, &vmw_vram_placement, true, false, false);return ret; }
drivers/gpu/drm/vmwgfx/vmwgfx_fb.c +2 -2
@@ -628,7 +628,7 @@ int vmw_dmabuf_from_vram(struct vmw_private *vmw_priv,if (unlikely (ret !=0 ))return ret; - ret =ttm_bo_validate (bo, &vmw_sys_placement, false, false); + ret =ttm_bo_validate (bo, &vmw_sys_placement, false, false, false);ttm_bo_unreserve (bo);return ret;
@@ -652,7 +652,7 @@ int vmw_dmabuf_to_start_of_vram(struct vmw_private *vmw_priv,if (unlikely (ret !=0 )) goto err_unlock; - ret =ttm_bo_validate (bo, &ne_placement, false, false); + ret =ttm_bo_validate (bo, &ne_placement, false, false, false);ttm_bo_unreserve (bo); err_unlock:ttm_write_unlock (&vmw_priv->active_master->lock);
drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c +1 -1
@@ -118,7 +118,7 @@ static int vmw_dmabuf_pin_in_vram(struct vmw_private *dev_priv,if (pin) overlay_placement = &vmw_vram_ne_placement; - ret =ttm_bo_validate (bo, overlay_placement, interruptible, false); + ret =ttm_bo_validate (bo, overlay_placement, interruptible, false, false);ttm_bo_unreserve (bo);
Signature · 10 lines
1.6.6.1 ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev --
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 6/14 drm/radeon/kms: add support for new fault callback V5
This add the support for the new fault callback and also the infrastructure for supporting unmappable VRAM.
V2 validate BO with no_wait = true
V3 don't derefence bo->mem.mm_node as it's not NULL only for
VRAM or GTT
V4 update to splitted no_wait ttm change
V5 update to new balanced io_mem_reserve/free change
--- drivers/gpu/drm/radeon/radeon_object.c | 26 ++++++++++++++++- drivers/gpu/drm/radeon/radeon_object.h | 2 +- drivers/gpu/drm/radeon/radeon_ttm.c | 47 +++++++++++++++++++++++++++++++- 3 files changed, 71 insertions(+), 4 deletions(-)
drivers/gpu/drm/radeon/radeon_object.c +24 -2
@@ -496,11 +496,33 @@ void radeon_bo_move_notify(struct ttm_buffer_object *bo,radeon_bo_check_tiling (rbo,0 ,1 ); } -void radeon_bo_fault_reserve_notify (struct ttm_buffer_object *bo) +int radeon_bo_fault_reserve_notify (struct ttm_buffer_object *bo) { +struct radeon_device *rdev;struct radeon_bo *rbo; +unsigned long offset, size; +int r; +if (!radeon_ttm_bo_is_radeon_bo (bo)) -return ; +return 0 ; rbo = container_of(bo, struct radeon_bo, tbo);radeon_bo_check_tiling (rbo,0 ,0 ); + rdev = rbo->rdev; +if (bo->mem.mem_type ==TTM_PL_VRAM ) { + size = bo->mem.num_pages <<PAGE_SHIFT ; + offset = bo->mem.mm_node->start <<PAGE_SHIFT ; +if ((offset + size) > rdev->mc.visible_vram_size) { +/* hurrah the memory is not visible ! */ +radeon_ttm_placement_from_domain (rbo,RADEON_GEM_DOMAIN_VRAM ); + rbo->placement.lpfn = rdev->mc.visible_vram_size >>PAGE_SHIFT ; + r =ttm_bo_validate (bo, &rbo->placement, false, true, false); +if (unlikely (r !=0 )) +return r; + offset = bo->mem.mm_node->start <<PAGE_SHIFT ; +/* this should not happen */ +if ((offset + size) > rdev->mc.visible_vram_size) +return -EINVAL ; + } + } +return 0 ; }
drivers/gpu/drm/radeon/radeon_object.h +1 -1
@@ -168,6 +168,6 @@ extern int radeon_bo_check_tiling(struct radeon_bo *bo, bool has_moved, bool force_drop);extern void radeon_bo_move_notify (struct ttm_buffer_object *bo,struct ttm_mem_reg *mem); -extern void radeon_bo_fault_reserve_notify (struct ttm_buffer_object *bo); +extern int radeon_bo_fault_reserve_notify (struct ttm_buffer_object *bo);extern int radeon_bo_get_surface_reg (struct radeon_bo *bo);#endif
drivers/gpu/drm/radeon/radeon_ttm.c +46 -1
62 lines not on this page · raw message
Signature · 10 lines
1.6.6.1 ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev --
PATCH 7/14 drm/nouveau/kms: add support for new TTM fault callback V3
This add the support for the new fault callback, does change anything from driver point of view, thought it should allow nouveau to add support for unmappable VRAM.
Improvement: store the aperture base in a variable so that we don't call a function to get it on each fault.
Patch hasn't been tested on any hw.
V2 don't derefence bo->mem.mm_node as it's not NULL only for
VRAM or GTT
V3 update after io_mem_reserve/io_mem_free callback balancing
--- drivers/gpu/drm/nouveau/nouveau_bo.c | 51 ++++++++++++++++++++++++++++++++++ 1 files changed, 51 insertions(+), 0 deletions(-)
drivers/gpu/drm/nouveau/nouveau_bo.c +51 -0
@@ -761,6 +761,54 @@ nouveau_bo_verify_access(struct ttm_buffer_object *bo, struct file *filp)return 0 ; } +static int +nouveau_ttm_io_mem_reserve (struct ttm_bo_device *bdev,struct ttm_mem_reg *mem) +{ +struct ttm_mem_type_manager *man = &bdev->man[mem->mem_type]; +struct drm_nouveau_private *dev_priv =nouveau_bdev (bdev); +struct drm_device *dev = dev_priv->dev; + + mem->bus.offset =0 ; + mem->bus.size = mem->num_pages <<PAGE_SHIFT ; + mem->bus.base =0 ; + mem->bus.is_iomem = false; +if (!(man->flags &TTM_MEMTYPE_FLAG_MAPPABLE )) +return -EINVAL ; +switch (mem->mem_type) { +case TTM_PL_SYSTEM : +/* System memory */ +return 0 ; +case TTM_PL_TT : +#if __OS_HAS_AGP +if (dev_priv->gart_info.type ==NOUVEAU_GART_AGP ) { + mem->bus.offset = mem->mm_node->start <<PAGE_SHIFT ; + mem->bus.base = dev_priv->gart_info.aper_base; + mem->bus.is_iomem = true; + } +#endif +return 0 ; +case TTM_PL_VRAM : + mem->bus.offset = mem->mm_node->start <<PAGE_SHIFT ; + mem->bus.base =drm_get_resource_start (dev,1 ); + mem->bus.is_iomem = true; +break ; +default : +return -EINVAL ; + } +return 0 ; +} + +static void +nouveau_ttm_io_mem_free (struct ttm_bo_device *bdev,struct ttm_mem_reg *mem) +{ +} + +static int +nouveau_ttm_fault_reserve_notify (struct ttm_buffer_object *bo) +{ +return 0 ; +} +struct ttm_bo_driver nouveau_bo_driver = { .create_ttm_backend_entry = nouveau_bo_create_ttm_backend_entry, .invalidate_caches = nouveau_bo_invalidate_caches,
@@ -773,5 +821,8 @@ struct ttm_bo_driver nouveau_bo_driver = { .sync_obj_flush = nouveau_fence_flush, .sync_obj_unref = nouveau_fence_unref, .sync_obj_ref = nouveau_fence_ref, + .fault_reserve_notify = &nouveau_ttm_fault_reserve_notify, + .io_mem_reserve = &nouveau_ttm_io_mem_reserve, + .io_mem_free = &nouveau_ttm_io_mem_free, };
Signature · 10 lines
1.6.6.1 ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev --
PATCH 8/14 drm/vmwgfx: add support for new TTM fault callback V3
This add the support for the new fault callback, does change anything from driver point of view.
Improvement: store the aperture base in a variable so that we don't call a function to get it on each fault.
Patch hasn't been tested.
V2 don't derefence bo->mem.mm_node as it's not NULL only for
VRAM or GTT
V3 update after io_mem_reserve/io_mem_free callback balancing
--- drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c | 40 +++++++++++++++++++++++++++++++- 1 files changed, 39 insertions(+), 1 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c +39 -1
@@ -193,6 +193,41 @@ static void vmw_swap_notify(struct ttm_buffer_object *bo)vmw_dmabuf_gmr_unbind (bo); } +static int vmw_ttm_io_mem_reserve (struct ttm_bo_device *bdev,struct ttm_mem_reg *mem) +{ +struct ttm_mem_type_manager *man = &bdev->man[mem->mem_type]; + struct vmw_private *dev_priv = container_of(bdev, struct vmw_private, bdev); + + mem->bus.is_iomem = false; + mem->bus.offset =0 ; + mem->bus.size = mem->num_pages <<PAGE_SHIFT ; + mem->bus.base =0 ; +if (!(man->flags &TTM_MEMTYPE_FLAG_MAPPABLE )) +return -EINVAL ; +switch (mem->mem_type) { +case TTM_PL_SYSTEM : +/* System memory */ +return 0 ; +case TTM_PL_VRAM : + mem->bus.offset = mem->mm_node->start <<PAGE_SHIFT ; + mem->bus.base = dev_priv->vram_start; + mem->bus.is_iomem = true; +break ; +default : +return -EINVAL ; + } +return 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 ; +} +/** * FIXME: We're using the old vmware polling method to sync. * Do this with fences instead.
@@ -248,5 +283,8 @@ struct ttm_bo_driver vmw_bo_driver = { .sync_obj_unref = vmw_sync_obj_unref, .sync_obj_ref = vmw_sync_obj_ref, .move_notify = vmw_move_notify, - .swap_notify = vmw_swap_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 · 10 lines
1.6.6.1 ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev --
PATCH 9/14 drm/radeon/kms: don't initialize TTM io memory manager field
This isn't needed anymore with the new TTM fault callback
--- drivers/gpu/drm/radeon/radeon_ttm.c | 13 +------------ 1 files changed, 1 insertions(+), 12 deletions(-)
drivers/gpu/drm/radeon/radeon_ttm.c +1 -12
@@ -161,22 +161,14 @@ static int radeon_init_mem_type(struct ttm_bo_device *bdev, uint32_t type, (unsigned)type); return -EINVAL; } - man->io_offset = rdev->mc.agp_base; - man->io_size = rdev->mc.gtt_size; - man->io_addr =NULL ;if (!rdev->ddev->agp->cant_use_aperture) man->flags =TTM_MEMTYPE_FLAG_NEEDS_IOREMAP |TTM_MEMTYPE_FLAG_MAPPABLE ; man->available_caching =TTM_PL_FLAG_UNCACHED |TTM_PL_FLAG_WC ; man->default_caching =TTM_PL_FLAG_WC ; - } else -#endif - { - man->io_offset =0 ; - man->io_size =0 ; - man->io_addr =NULL ; } +#endif break ;case TTM_PL_VRAM :/* "On-card" video ram */
@@ -186,9 +178,6 @@ static int radeon_init_mem_type(struct ttm_bo_device *bdev, uint32_t type,TTM_MEMTYPE_FLAG_MAPPABLE ; man->available_caching =TTM_PL_FLAG_UNCACHED |TTM_PL_FLAG_WC ; man->default_caching =TTM_PL_FLAG_WC ; - man->io_addr =NULL ; - man->io_offset = rdev->mc.aper_base; - man->io_size = rdev->mc.aper_size;break ;default :DRM_ERROR ("Unsupported memory type %u\n" , (unsigned )type);
Signature · 10 lines
1.6.6.1 ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev --
PATCH 10/14 drm/nouveau/kms: don't initialize TTM io memory manager field
This isn't needed anymore with the new TTM fault callback
--- drivers/gpu/drm/nouveau/nouveau_bo.c | 11 ----------- 1 files changed, 0 insertions(+), 11 deletions(-)
drivers/gpu/drm/nouveau/nouveau_bo.c +0 -11
@@ -391,13 +391,6 @@ nouveau_bo_init_mem_type(struct ttm_bo_device *bdev, uint32_t type, man->available_caching =TTM_PL_FLAG_UNCACHED |TTM_PL_FLAG_WC ; man->default_caching =TTM_PL_FLAG_WC ; - - man->io_addr =NULL ; - man->io_offset =drm_get_resource_start (dev,1 ); - man->io_size =drm_get_resource_len (dev,1 ); -if (man->io_size >nouveau_mem_fb_amount (dev)) - man->io_size =nouveau_mem_fb_amount (dev); - man->gpu_offset = dev_priv->vm_vram_base;break ;case TTM_PL_TT :
@@ -419,10 +412,6 @@ nouveau_bo_init_mem_type(struct ttm_bo_device *bdev, uint32_t type, dev_priv->gart_info.type);return -EINVAL ; } - - man->io_offset = dev_priv->gart_info.aper_base; - man->io_size = dev_priv->gart_info.aper_size; - man->io_addr =NULL ; man->gpu_offset = dev_priv->vm_gart_base;break ;default :
Signature · 10 lines
1.6.6.1 ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev --
PATCH 11/14 drm/vmwgfx: don't initialize TTM io memory manager field
This isn't needed anymore with the new TTM fault callback
--- drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c | 6 ------ 1 files changed, 0 insertions(+), 6 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c +0 -6
@@ -137,9 +137,6 @@ int vmw_invalidate_caches(struct ttm_bo_device *bdev, uint32_t flags)int vmw_init_mem_type (struct ttm_bo_device *bdev,uint32_t type,struct ttm_mem_type_manager *man) { -struct vmw_private *dev_priv = - container_of(bdev, struct vmw_private, bdev); -switch (type) {case TTM_PL_SYSTEM :/* System memory */
@@ -151,11 +148,8 @@ int vmw_init_mem_type(struct ttm_bo_device *bdev, uint32_t type,case TTM_PL_VRAM :/* "On-card" video ram */ man->gpu_offset =0 ; - man->io_offset = dev_priv->vram_start; - man->io_size = dev_priv->vram_size; man->flags =TTM_MEMTYPE_FLAG_FIXED |TTM_MEMTYPE_FLAG_NEEDS_IOREMAP |TTM_MEMTYPE_FLAG_MAPPABLE ; - man->io_addr =NULL ; man->available_caching =TTM_PL_MASK_CACHING ; man->default_caching =TTM_PL_FLAG_WC ;break ;
Signature · 10 lines
1.6.6.1 ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev --
PATCH 12/14 drm/ttm: remove io_ field from TTM V3
All TTM driver have been converted to new io_mem_reserve/free interface which allow driver to choose and return proper io base, offset to core TTM for ioremapping if necessary. This patch remove what is now deadcode.
V2 adapt to match with change in first patch of the patchset V3 update after io_mem_reserve/io_mem_free callback balancing
--- drivers/gpu/drm/ttm/ttm_bo.c | 22 ---------------------- drivers/gpu/drm/ttm/ttm_bo_util.c | 26 +++++++------------------- include/drm/ttm/ttm_bo_driver.h | 10 ---------- 3 files changed, 7 insertions(+), 51 deletions(-)
drivers/gpu/drm/ttm/ttm_bo.c +0 -22
@@ -79,8 +79,6 @@ static void ttm_mem_type_debug(struct ttm_bo_device *bdev, int mem_type) printk(KERN_ERR TTM_PFX " use_type: %d\n", man->use_type); printk(KERN_ERR TTM_PFX " flags: 0x%08X\n", man->flags); printk(KERN_ERR TTM_PFX " gpu_offset: 0x%08lX\n", man->gpu_offset); - printk(KERN_ERR TTM_PFX " io_offset: 0x%08lX\n", man->io_offset); - printk(KERN_ERR TTM_PFX " io_size: %ld\n", man->io_size); printk(KERN_ERR TTM_PFX " size: %llu\n", man->size); printk(KERN_ERR TTM_PFX " available_caching: 0x%08X\n", man->available_caching);
@@ -1563,26 +1561,6 @@ bool ttm_mem_reg_is_pci(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem)return true; } -int ttm_bo_pci_offset (struct ttm_bo_device *bdev, -struct ttm_mem_reg *mem, -unsigned long *bus_base, -unsigned long *bus_offset,unsigned long *bus_size) -{ -struct ttm_mem_type_manager *man = &bdev->man[mem->mem_type]; - - *bus_size =0 ; -if (!(man->flags &TTM_MEMTYPE_FLAG_MAPPABLE )) -return -EINVAL ; - -if (ttm_mem_reg_is_pci (bdev, mem)) { - *bus_offset = mem->mm_node->start <<PAGE_SHIFT ; - *bus_size = mem->num_pages <<PAGE_SHIFT ; - *bus_base = man->io_offset + (uintptr_t )man->io_addr; - } - -return 0 ; -} -void ttm_bo_unmap_virtual (struct ttm_buffer_object *bo) {struct ttm_bo_device *bdev = bo->bdev;
drivers/gpu/drm/ttm/ttm_bo_util.c +7 -19
@@ -83,30 +83,18 @@ EXPORT_SYMBOL(ttm_bo_move_ttm);int ttm_mem_io_reserve (struct ttm_bo_device *bdev,struct ttm_mem_reg *mem) { -int ret; +int ret =0 ; -if (bdev->driver->io_mem_reserve) { -if (!atomic_xchg (&mem->bus.use_count,1 )) { - ret = bdev->driver->io_mem_reserve (bdev, mem); -if (unlikely (ret !=0 )) { -return ret; - } - } - }else { - ret =ttm_bo_pci_offset (bdev, mem, &mem->bus.base, &mem->bus.offset, &mem->bus.size); -if (unlikely (ret !=0 )) -return ret; - mem->bus.is_iomem = (mem->bus.size >0 ) ?1 :0 ; +if (!atomic_xchg (&mem->bus.use_count,1 )) { + ret = bdev->driver->io_mem_reserve (bdev, mem); } -return 0 ; +return ret; }void ttm_mem_io_free (struct ttm_bo_device *bdev,struct ttm_mem_reg *mem) { -if (bdev->driver->io_mem_reserve) { -atomic_set (&mem->bus.use_count,0 ); - bdev->driver->io_mem_free (bdev, mem); - } +atomic_set (&mem->bus.use_count,0 ); + bdev->driver->io_mem_free (bdev, mem); } int ttm_mem_reg_ioremap(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem,
@@ -409,7 +397,7 @@ static int ttm_bo_ioremap(struct ttm_buffer_object *bo,if (!(man->flags &TTM_MEMTYPE_FLAG_NEEDS_IOREMAP )) { map->bo_kmap_type = ttm_bo_map_premapped; - map->virtual = (void *)(((u8 *) man->io_addr) + bus_offset); + map->virtual = (void *)(bus_base + bus_offset); }else { map->bo_kmap_type = ttm_bo_map_iomap;if (mem->placement &TTM_PL_FLAG_WC )
include/drm/ttm/ttm_bo_driver.h +0 -10
@@ -189,13 +189,6 @@ struct ttm_tt {* managed by this memory type. * @gpu_offset: If used, the GPU offset of the first managed page of * fixed memory or the first managed location in an aperture. -* @io_offset: The io_offset of the first managed page of IO memory or -* the first managed location in an aperture. For TTM_MEMTYPE_FLAG_CMA -* memory, this should be set to NULL. -* @io_size: The size of a managed IO region (fixed memory or aperture). -* @io_addr: Virtual kernel address if the io region is pre-mapped. For -* TTM_MEMTYPE_FLAG_NEEDS_IOREMAP there is no pre-mapped io map and -* @io_addr should be set to NULL. * @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
@@ -221,9 +214,6 @@ struct ttm_mem_type_manager {bool use_type;uint32_t flags;unsigned long gpu_offset; -unsigned long io_offset; -unsigned long io_size; -void *io_addr;uint64_t size;uint32_t available_caching;uint32_t default_caching;
Signature · 10 lines
1.6.6.1 ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev --
PATCH 13/14 drm/radeon/kms: enable use of unmappable VRAM V2
This patch enable the use of unmappable VRAM thanks to previous TTM infrastructure change.
V2 update after io_mem_reserve/io_mem_free callback balancing
--- drivers/gpu/drm/radeon/evergreen.c | 5 ----- drivers/gpu/drm/radeon/r100.c | 5 ----- drivers/gpu/drm/radeon/r600.c | 5 ----- drivers/gpu/drm/radeon/rv770.c | 5 ----- 4 files changed, 0 insertions(+), 20 deletions(-)
drivers/gpu/drm/radeon/evergreen.c +0 -5
@@ -475,11 +475,6 @@ int evergreen_mc_init(struct radeon_device *rdev) rdev->mc.mc_vram_size =RREG32 (CONFIG_MEMSIZE ) *1024 *1024 ; rdev->mc.real_vram_size =RREG32 (CONFIG_MEMSIZE ) *1024 *1024 ; rdev->mc.visible_vram_size = rdev->mc.aper_size; -/* FIXME remove this once we support unmappable VRAM */ -if (rdev->mc.mc_vram_size > rdev->mc.aper_size) { - rdev->mc.mc_vram_size = rdev->mc.aper_size; - rdev->mc.real_vram_size = rdev->mc.aper_size; - }r600_vram_gtt_location (rdev, &rdev->mc);radeon_update_bandwidth_info (rdev);
drivers/gpu/drm/radeon/r100.c +0 -5
@@ -2026,11 +2026,6 @@ void r100_vram_init_sizes(struct radeon_device *rdev)else rdev->mc.mc_vram_size = rdev->mc.real_vram_size; } -/* FIXME remove this once we support unmappable VRAM */ -if (rdev->mc.mc_vram_size > rdev->mc.aper_size) { - rdev->mc.mc_vram_size = rdev->mc.aper_size; - rdev->mc.real_vram_size = rdev->mc.aper_size; - } }void r100_vga_set_state (struct radeon_device *rdev,bool state)
drivers/gpu/drm/radeon/r600.c +0 -5
@@ -713,11 +713,6 @@ int r600_mc_init(struct radeon_device *rdev) rdev->mc.mc_vram_size =RREG32 (CONFIG_MEMSIZE ); rdev->mc.real_vram_size =RREG32 (CONFIG_MEMSIZE ); rdev->mc.visible_vram_size = rdev->mc.aper_size; -/* FIXME remove this once we support unmappable VRAM */ -if (rdev->mc.mc_vram_size > rdev->mc.aper_size) { - rdev->mc.mc_vram_size = rdev->mc.aper_size; - rdev->mc.real_vram_size = rdev->mc.aper_size; - }r600_vram_gtt_location (rdev, &rdev->mc);if (rdev->flags &RADEON_IS_IGP )
drivers/gpu/drm/radeon/rv770.c +0 -5
@@ -905,11 +905,6 @@ int rv770_mc_init(struct radeon_device *rdev) rdev->mc.mc_vram_size =RREG32 (CONFIG_MEMSIZE ); rdev->mc.real_vram_size =RREG32 (CONFIG_MEMSIZE ); rdev->mc.visible_vram_size = rdev->mc.aper_size; -/* FIXME remove this once we support unmappable VRAM */ -if (rdev->mc.mc_vram_size > rdev->mc.aper_size) { - rdev->mc.mc_vram_size = rdev->mc.aper_size; - rdev->mc.real_vram_size = rdev->mc.aper_size; - }r600_vram_gtt_location (rdev, &rdev->mc);radeon_update_bandwidth_info (rdev);
Signature · 10 lines
1.6.6.1 ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev --
Re: [PATCH] drm/ttm: ttm_fault callback to allow driver to handle bo placement V3
In reply to a message not in the archiveQuoted 21 lines · Jerome Glisse
On fault the driver is given the opportunity to perform any operation it sees fit in order to place the buffer into a CPU visible area of memory. This patch doesn't break TTM users, nouveau, vmwgfx and radeon should keep working properly. Future patch will take advantage of this infrastructure and remove the old path from TTM once driver are converted.
V2 return
VM_FAULT_NOPAGEif callback return-EBUSYor-ERESTARTSYSV3 balanceio_mem_reserveandio_mem_freecall,fault_reserve_notify
is responsible to perform any necessary task for mapping to succeedSigned-off-by Jerome Glisse <[email protected]>--- drivers/gpu/drm/ttm/ttm_bo.c | 7 ++- drivers/gpu/drm/ttm/ttm_bo_util.c | 95 ++++++++++++++++++------------------- drivers/gpu/drm/ttm/ttm_bo_vm.c | 46 ++++++++---------- include/drm/ttm/ttm_bo_api.h | 21 ++++++++ include/drm/ttm/ttm_bo_driver.h | 16 ++++++- 5 files changed, 108 insertions(+), 77 deletions(-)
Review void ttm_bo_unmap_virtual(struct ttm_buffer_object *bo) · line 1594
Quoted 5 lines
(quoted diff) +0
-1@@ -1588,8 +1591,8 @@ void ttm_bo_unmap_virtual(struct ttm_buffer_object *bo) if (!bdev->dev_mapping) return; -
Still a lot of these. Please remove.
Quoted 15 lines
(quoted diff) +13
-0+int ttm_mem_io_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem) +{ + int ret; + + if (bdev->driver->io_mem_reserve) { + if (!atomic_xchg(&mem->bus.use_count, 1)) { + ret = bdev->driver->io_mem_reserve(bdev, mem); + if (unlikely(ret != 0)) + return ret; + } + } else { + ret = ttm_bo_pci_offset(bdev, mem, &mem->bus.base, &mem->bus.offset, &mem->bus.size); + if (unlikely(ret != 0))
Review void ttm_bo_unmap_virtual(struct ttm_buffer_object *bo)
Quoted 10 lines
(quoted diff) +10
-0+ return ret; + mem->bus.is_iomem = (mem->bus.size > 0) ? 1 : 0; + } + return 0; +} + +void ttm_mem_io_free(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem) +{ + if (bdev->driver->io_mem_reserve) { + atomic_set(&mem->bus.use_count, 0);
Shouldn't there be a test for zero before calling this?
Review
Quoted 5 lines
(quoted diff) +4
-0+ bdev->driver->io_mem_free(bdev, mem); + } +} +
Hmm. I don't get the logic of the above refcounting. First, the kernel can preempt between refcounting and driver calls:
Thread a sets use_count to 1 and preempts.
Thread b sees use_count 1 and calls ttm_bo_pci_offset(), but we haven't yet done an io_mem_reserve??
Otoh, from the last section it seems we always will hold bo::reserved around these calls, so instead we could make use_count a non-atomic variable.
Then, for the rest please consider the following use cases:
1) We want to temporarily map a bo within the kernel. We do:reserve_bo().make_mappable().kmap().kunmap().free_mappable_resources(). // This is just a hint. When the bo is unreserved, the manager is free to evict the mappable region. unreserve_bo().
2) We want to permanently map a bo within the kernel (kernel map for fbdev). We do (bo is not reserved).pin_mappable().kmap().
accesskunmap().unpin_mappable().
3) Fault.reserve_bo().make_mappable().set_up user_space_map().unreserve_bo().
/// Here the manager is free to evict the mappable range by reserving and then calling ttm_bo_unmap_virtual().
4) Unmap Virtual. (Called reserved).unmap_user_space_mappings().free_mappable_resources().
It looks to me like you've implemented make_mappable() = ttm_mem_io_reserve() and free_mappable_resources() = ttm_mem_io_free(), and from the above use cases we can see that they always will be called when the bo is reserved. Hence no need for an atomic variable and we can ignore the race scenarios above.
but what about pin_mappable() and unpin_mappable()? A general mapping manager must be able to perform these operations. Perhaps
Finally, consider a very simple mapping manager that uses the two ttm regions VRAM and VRAM_MAPPABLE. We'd implement the driver operations as follows, assuming we add io_mem_pin and io_mem_unpin:
io_mem_reserve:ttm_bo_validate(VRAM_MAPPABLE); (Evicting as needed).
io_mem_unreserve:noop().
io_mem_pin:ttm_bo_reserve()
if (pin_count++ == 0)
ttm_bo_validate(VRAM_MAPPABLE | NO_EVICT);ttm_bo_unreserve()
io_mem_unpin:ttm_bo_reserve()
if (--pin_count == 0)
ttm_bo_validate(VRAM_MAPPABLE);ttm_bo_unreserve()
This simple mapping manager would need a struct ttm_buffer_object as an argument. Not just the mem argument.
/Thomas
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--
Re: [PATCH] drm/ttm: ttm_fault callback to allow driver to handle bo placement V3
Quoted 65 lines · Thomas Hellstrom
Quoted 21 lines · Jerome Glisse
On fault the driver is given the opportunity to perform any operation it sees fit in order to place the buffer into a CPU visible area of memory. This patch doesn't break TTM users, nouveau, vmwgfx and radeon should keep working properly. Future patch will take advantage of this infrastructure and remove the old path from TTM once driver are converted.
V2 return
VM_FAULT_NOPAGEif callback return-EBUSYor-ERESTARTSYSV3 balanceio_mem_reserveandio_mem_freecall,fault_reserve_notify
is responsible to perform any necessary task for mapping to succeedSigned-off-by Jerome Glisse <[email protected]>--- drivers/gpu/drm/ttm/ttm_bo.c | 7 ++- drivers/gpu/drm/ttm/ttm_bo_util.c | 95 ++++++++++++++++++------------------- drivers/gpu/drm/ttm/ttm_bo_vm.c | 46 ++++++++---------- include/drm/ttm/ttm_bo_api.h | 21 ++++++++ include/drm/ttm/ttm_bo_driver.h | 16 ++++++- 5 files changed, 108 insertions(+), 77 deletions(-)Review void ttm_bo_unmap_virtual(struct ttm_buffer_object *bo) · line 1594
Quoted 5 lines
(quoted diff) +0
-1@@ -1588,8 +1591,8 @@ void ttm_bo_unmap_virtual(struct ttm_buffer_object *bo) if (!bdev->dev_mapping) return; -Still a lot of these. Please remove.
Quoted 15 lines
(quoted diff) +13
-0+int ttm_mem_io_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem) +{ + int ret; + + if (bdev->driver->io_mem_reserve) { + if (!atomic_xchg(&mem->bus.use_count, 1)) { + ret = bdev->driver->io_mem_reserve(bdev, mem); + if (unlikely(ret != 0)) + return ret; + } + } else { + ret = ttm_bo_pci_offset(bdev, mem, &mem->bus.base, &mem->bus.offset, &mem->bus.size); + if (unlikely(ret != 0))Review void ttm_bo_unmap_virtual(struct ttm_buffer_object *bo)
Quoted 10 lines
(quoted diff) +10
-0+ return ret; + mem->bus.is_iomem = (mem->bus.size > 0) ? 1 : 0; + } + return 0; +} + +void ttm_mem_io_free(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem) +{ + if (bdev->driver->io_mem_reserve) { + atomic_set(&mem->bus.use_count, 0);Shouldn't there be a test for zero before calling this?
Review
Quoted 5 lines
(quoted diff) +4
-0+ bdev->driver->io_mem_free(bdev, mem); + } +} +Hmm. I don't get the logic of the above refcounting. First, the kernel can preempt between refcounting and driver calls:
Quoted 8 lines
Thread a sets
use_countto 1 and preempts.
Thread b seesuse_count1 and callsttm_bo_pci_offset(), but we haven't yet done anio_mem_reserve??Otoh, from the last section it seems we always will hold
bo::reservedaround these calls, so instead we could makeuse_counta non-atomic variable.
use_count could become bool io_reserved it's atomic for patch historical reason, will respawn a patch without atomic and blank line removal.
Quoted 32 lines
Then, for the rest please consider the following use cases:
1) We want to temporarily map a bo within the kernel. We do:
reserve_bo().make_mappable().kmap().kunmap().free_mappable_resources(). // This is just a hint. When the bo is unreserved, the manager is free to evict the mappable region.unreserve_bo().2) We want to permanently map a bo within the kernel (kernel map for fbdev). We do (bo is not reserved).
pin_mappable().kmap().
accesskunmap().unpin_mappable().3) Fault.
reserve_bo().make_mappable().set_upuser_space_map().unreserve_bo()./// Here the manager is free to evict the mappable range by reserving and then calling
ttm_bo_unmap_virtual().4) Unmap Virtual. (Called reserved).
unmap_user_space_mappings().free_mappable_resources().
Quoted 8 lines
It looks to me like you've implemented
make_mappable()=ttm_mem_io_reserve()andfree_mappable_resources()=ttm_mem_io_free(), and from the above use cases we can see that they always will be called when the bo is reserved. Hence no need for an atomic variable and we can ignore the race scenarios above.but what about
pin_mappable()andunpin_mappable()? A general mapping manager must be able to perform these operations. Perhaps
Idea is that buffer that will be mapped the whole time will also be set with no evict so unmap virtual is never call on them (at least that is my feeling from the code). So iomeme_reserve works also for pinned buffer and i don't separate the pined/not pinned case from the driver io manager (if driver has any).
Quoted 24 lines
Finally, consider a very simple mapping manager that uses the two ttm regions VRAM and
VRAM_MAPPABLE. We'd implement the driver operations as follows, assuming we addio_mem_pinandio_mem_unpin:
io_mem_reserve:ttm_bo_validate(VRAM_MAPPABLE); (Evicting as needed).
io_mem_unreserve:noop().
io_mem_pin:ttm_bo_reserve()
if (pin_count++ == 0)
ttm_bo_validate(VRAM_MAPPABLE | NO_EVICT);ttm_bo_unreserve()
io_mem_unpin:ttm_bo_reserve()
if (--pin_count == 0)
ttm_bo_validate(VRAM_MAPPABLE);ttm_bo_unreserve()
Quoted 5 lines
This simple mapping manager would need a struct
ttm_buffer_objectas an argument. Not just the mem argument./Thomas
I didn't go the splitted way to avoid having a frontier btw mappable & unmappable vram, i think it's better to avoid this Hope being that not much buffer in vram need to be mapped (best case being buffer never mapped ;))
Cheers,
Jerome
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--
Re: [PATCH] drm/ttm: ttm_fault callback to allow driver to handle bo placement V3
Quoted 74 lines · Jerome Glisse
Quoted 72 lines · Thomas Hellstrom
Quoted 21 lines · Jerome Glisse
On fault the driver is given the opportunity to perform any operation it sees fit in order to place the buffer into a CPU visible area of memory. This patch doesn't break TTM users, nouveau, vmwgfx and radeon should keep working properly. Future patch will take advantage of this infrastructure and remove the old path from TTM once driver are converted.
V2 return
VM_FAULT_NOPAGEif callback return-EBUSYor-ERESTARTSYSV3 balanceio_mem_reserveandio_mem_freecall,fault_reserve_notify
is responsible to perform any necessary task for mapping to succeedSigned-off-by Jerome Glisse <[email protected]>--- drivers/gpu/drm/ttm/ttm_bo.c | 7 ++- drivers/gpu/drm/ttm/ttm_bo_util.c | 95 ++++++++++++++++++------------------- drivers/gpu/drm/ttm/ttm_bo_vm.c | 46 ++++++++---------- include/drm/ttm/ttm_bo_api.h | 21 ++++++++ include/drm/ttm/ttm_bo_driver.h | 16 ++++++- 5 files changed, 108 insertions(+), 77 deletions(-)Review void ttm_bo_unmap_virtual(struct ttm_buffer_object *bo) · line 1595
Quoted 6 lines
(quoted diff) +0
-1@@ -1588,8 +1591,8 @@ void ttm_bo_unmap_virtual(struct ttm_buffer_object *bo) if (!bdev->dev_mapping) return; -Still a lot of these. Please remove.
Quoted 16 lines
(quoted diff) +13
-0+int ttm_mem_io_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem) +{ + int ret; + + if (bdev->driver->io_mem_reserve) { + if (!atomic_xchg(&mem->bus.use_count, 1)) { + ret = bdev->driver->io_mem_reserve(bdev, mem); + if (unlikely(ret != 0)) + return ret; + } + } else { + ret = ttm_bo_pci_offset(bdev, mem, &mem->bus.base, &mem->bus.offset, &mem->bus.size); + if (unlikely(ret != 0))Review void ttm_bo_unmap_virtual(struct ttm_buffer_object *bo)
Quoted 10 lines
(quoted diff) +10
-0+ return ret; + mem->bus.is_iomem = (mem->bus.size > 0) ? 1 : 0; + } + return 0; +} + +void ttm_mem_io_free(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem) +{ + if (bdev->driver->io_mem_reserve) { + atomic_set(&mem->bus.use_count, 0);Shouldn't there be a test for zero before calling this?
Review
Quoted 6 lines
(quoted diff) +4
-0+ bdev->driver->io_mem_free(bdev, mem); + } +} +Hmm. I don't get the logic of the above refcounting. First, the kernel can preempt between refcounting and driver calls:
Thread a sets
use_countto 1 and preempts.
Thread b seesuse_count1 and callsttm_bo_pci_offset(), but we haven't yet done anio_mem_reserve??
Quoted 9 lines
Quoted 5 lines
Otoh, from the last section it seems we always will hold
bo::reservedaround these calls, so instead we could makeuse_counta non-atomic variable.
use_countcould become boolio_reservedit's atomic for patch historical reason, will respawn a patch without atomic and blank line removal.
Great. Please also consider the test for 0 on unreserve.
Quoted 43 lines
Quoted 33 lines
Then, for the rest please consider the following use cases:
1) We want to temporarily map a bo within the kernel. We do:
reserve_bo().make_mappable().kmap().kunmap().free_mappable_resources(). // This is just a hint. When the bo is unreserved, the manager is free to evict the mappable region.unreserve_bo().2) We want to permanently map a bo within the kernel (kernel map for fbdev). We do (bo is not reserved).
pin_mappable().kmap().
accesskunmap().unpin_mappable().3) Fault.
reserve_bo().make_mappable().set_upuser_space_map().unreserve_bo()./// Here the manager is free to evict the mappable range by reserving and then calling
ttm_bo_unmap_virtual().4) Unmap Virtual. (Called reserved).
unmap_user_space_mappings().free_mappable_resources().Quoted 9 lines
It looks to me like you've implemented
make_mappable()=ttm_mem_io_reserve()andfree_mappable_resources()=ttm_mem_io_free(), and from the above use cases we can see that they always will be called when the bo is reserved. Hence no need for an atomic variable and we can ignore the race scenarios above.but what about
pin_mappable()andunpin_mappable()? A general mapping manager must be able to perform these operations. Perhaps
Quoted 6 lines
Idea is that buffer that will be mapped the whole time will also be set with no evict so unmap virtual is never call on them (at least that is my feeling from the code). So
iomeme_reserveworks also for pinned buffer and i don't separate the pined/not pinned case from the driver io manager (if driver has any).
Yes, That's the case for simple io managers, where the mappable range is simply a (sub)TTM region. Then TTM NO_EVICT is equivalent to io manager NO_EVICT. However, if the IO manager is not a TTM region manager but something the driver implements with its own LRU list, the IO manager must be informed about this. Admitted, we have no driver like this yet, and the common code won't be using that API, so I'm OK with leaving it for now. I might add a comment about this close to the io manager hooks later on.
Quoted 26 lines
Quoted 26 lines
Finally, consider a very simple mapping manager that uses the two ttm regions VRAM and
VRAM_MAPPABLE. We'd implement the driver operations as follows, assuming we addio_mem_pinandio_mem_unpin:
io_mem_reserve:ttm_bo_validate(VRAM_MAPPABLE); (Evicting as needed).
io_mem_unreserve:noop().
io_mem_pin:ttm_bo_reserve()
if (pin_count++ == 0)
ttm_bo_validate(VRAM_MAPPABLE | NO_EVICT);ttm_bo_unreserve()
io_mem_unpin:ttm_bo_reserve()
if (--pin_count == 0)
ttm_bo_validate(VRAM_MAPPABLE);ttm_bo_unreserve()This simple mapping manager would need a struct
ttm_buffer_objectas an argument. Not just the mem argument.
Quoted 7 lines
Quoted 3 lines
/Thomas
I didn't go the splitted way to avoid having a frontier btw mappable & unmappable vram, i think it's better to avoid this
Agreed. This was just a simple case to demonstrate. However, even with io_mem_reseve() we'd need to pass a bo. What's the reason for passing a mem here?
Quoted 6 lines
Hope being that not much buffer in vram need to be mapped (best case being buffer never mapped ;))
Cheers,
Jerome
Thanks,
Thomas
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--
Re: [PATCH] drm/ttm: ttm_fault callback to allow driver to handle bo placement V3
Quoted 167 lines · Thomas Hellstrom
Quoted 62 lines · Jerome Glisse
Quoted 61 lines · Thomas Hellstrom
Quoted 21 lines · Jerome Glisse
On fault the driver is given the opportunity to perform any operation it sees fit in order to place the buffer into a CPU visible area of memory. This patch doesn't break TTM users, nouveau, vmwgfx and radeon should keep working properly. Future patch will take advantage of this infrastructure and remove the old path from TTM once driver are converted.
V2 return
VM_FAULT_NOPAGEif callback return-EBUSYor-ERESTARTSYSV3 balanceio_mem_reserveandio_mem_freecall,fault_reserve_notify
is responsible to perform any necessary task for mapping to succeedSigned-off-by Jerome Glisse <[email protected]>---
drivers/gpu/drm/ttm/ttm_bo.c | 7 ++- drivers/gpu/drm/ttm/ttm_bo_util.c | 95 ++++++++++++++++++------------------- drivers/gpu/drm/ttm/ttm_bo_vm.c | 46 ++++++++---------- include/drm/ttm/ttm_bo_api.h | 21 ++++++++ include/drm/ttm/ttm_bo_driver.h | 16 ++++++- 5 files changed, 108 insertions(+), 77 deletions(-)Review void ttm_bo_unmap_virtual(struct ttm_buffer_object *bo) · line 1590
Quoted 3 lines
(quoted diff) +0
-1@@ -1588,8 +1591,8 @@ void ttm_bo_unmap_virtual(struct ttm_buffer_object *bo) if (!bdev->dev_mapping) return; -Still a lot of these. Please remove.
Quoted 13 lines
(quoted diff) +13
-0+int ttm_mem_io_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem) +{ + int ret; + + if (bdev->driver->io_mem_reserve) { + if (!atomic_xchg(&mem->bus.use_count, 1)) { + ret = bdev->driver->io_mem_reserve(bdev, mem); + if (unlikely(ret != 0)) + return ret; + } + } else { + ret = ttm_bo_pci_offset(bdev, mem, &mem->bus.base, &mem->bus.offset, &mem->bus.size); + if (unlikely(ret != 0))Review void ttm_bo_unmap_virtual(struct ttm_buffer_object *bo)
Quoted 10 lines
(quoted diff) +10
-0+ return ret; + mem->bus.is_iomem = (mem->bus.size > 0) ? 1 : 0; + } + return 0; +} + +void ttm_mem_io_free(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem) +{ + if (bdev->driver->io_mem_reserve) { + atomic_set(&mem->bus.use_count, 0);Shouldn't there be a test for zero before calling this?
Review
Quoted 4 lines
(quoted diff) +4
-0+ bdev->driver->io_mem_free(bdev, mem); + } +} +Hmm. I don't get the logic of the above refcounting. First, the kernel can preempt between refcounting and driver calls:
Thread a sets
use_countto 1 and preempts.
Thread b seesuse_count1 and callsttm_bo_pci_offset(), but we haven't yet done anio_mem_reserve??Quoted 7 lines
Quoted 4 lines
Otoh, from the last section it seems we always will hold
bo::reservedaround these calls, so instead we could makeuse_counta non-atomic variable.
use_countcould become boolio_reservedit's atomic for patch historical reason, will respawn a patch without atomic and blank line removal.Great. Please also consider the test for 0 on unreserve.
Quoted 43 lines
Quoted 39 lines
Then, for the rest please consider the following use cases:
1) We want to temporarily map a bo within the kernel. We do:
reserve_bo().make_mappable().kmap().kunmap().free_mappable_resources(). // This is just a hint. When the bo is unreserved, the manager is free to evict the mappable region.unreserve_bo().2) We want to permanently map a bo within the kernel (kernel map for fbdev). We do (bo is not reserved).
pin_mappable().kmap().
accesskunmap().unpin_mappable().3) Fault.
reserve_bo().make_mappable().set_upuser_space_map().unreserve_bo()./// Here the manager is free to evict the mappable range by reserving and then calling
ttm_bo_unmap_virtual().4) Unmap Virtual. (Called reserved).
unmap_user_space_mappings().free_mappable_resources().It looks to me like you've implemented
make_mappable()=ttm_mem_io_reserve()andfree_mappable_resources()=ttm_mem_io_free(), and from the above use cases we can see that they always will be called when the bo is reserved. Hence no need for an atomic variable and we can ignore the race scenarios above.Quoted 3 lines
but what about
pin_mappable()andunpin_mappable()? A general mapping manager must be able to perform these operations. PerhapsQuoted 5 lines
Idea is that buffer that will be mapped the whole time will also be set with no evict so unmap virtual is never call on them (at least that is my feeling from the code). So
iomeme_reserveworks also for pinned buffer and i don't separate the pined/not pinned case from the driver io manager (if driver has any).Yes, That's the case for simple io managers, where the mappable range is simply a (sub)TTM region. Then TTM
NO_EVICTis equivalent to io managerNO_EVICT. However, if the IO manager is not a TTM region manager but something the driver implements with its own LRU list, the IO manager must be informed about this. Admitted, we have no driver like this yet, and the common code won't be using that API, so I'm OK with leaving it for now. I might add a comment about this close to the io manager hooks later on.Quoted 23 lines
Quoted 23 lines
Finally, consider a very simple mapping manager that uses the two ttm regions VRAM and
VRAM_MAPPABLE. We'd implement the driver operations as follows, assuming we addio_mem_pinandio_mem_unpin:
io_mem_reserve:ttm_bo_validate(VRAM_MAPPABLE); (Evicting as needed).
io_mem_unreserve:noop().
io_mem_pin:ttm_bo_reserve()
if (pin_count++ == 0)
ttm_bo_validate(VRAM_MAPPABLE | NO_EVICT);ttm_bo_unreserve()
io_mem_unpin:ttm_bo_reserve()
if (--pin_count == 0)
ttm_bo_validate(VRAM_MAPPABLE);ttm_bo_unreserve()Quoted 8 lines
Quoted 5 lines
This simple mapping manager would need a struct
ttm_buffer_objectas an argument. Not just the mem argument./Thomas
I didn't go the splitted way to avoid having a frontier btw mappable & unmappable vram, i think it's better to avoid this
Agreed. This was just a simple case to demonstrate. However, even with
io_mem_reseve()we'd need to pass a bo. What's the reason for passing a mem here?
Quoted 9 lines
Quoted 5 lines
Hope being that not much buffer in vram need to be mapped (best case being buffer never mapped ;))
Cheers,
JeromeThanks,
Thomas
Reason for passing ttm_mem is ttm_bo_move_memcpy which might need to map 2 different io mem associated to the same bo. Otherwise i would have use bo as argument, thought maybe i can still pass bo & mem so driver manager can retrieve bo information like NO_EVICT and take approriate choice for its io management.
Thomas thanks a lot for reviewing, commenting & feedback.
Cheers,
Jerome
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--