drm/ttm: callback move_notify any time bo placement change v3
Subsystems (4)
PATCH 1/1 drm/ttm: callback move_notify any time bo placement change v3
From: Jerome Glisse <[email protected]>
Previously we were calling back move_notify in error path when the bo is returned to it's original position or when destroy the bo. When destroying the bo set the new mem placement as NULL when calling back in the driver.
Updating nouveau to deal with NULL placement properly.
v2: reserve the object before calling move_notify in bo destroy path
at that point ttm should be the only piece of code interacting with the object so atomic_set is safe here.
v3: callback move notify only once the bo is in its new position
call move notify want swaping out the buffer
--- drivers/gpu/drm/nouveau/nouveau_bo.c | 4 ++-- drivers/gpu/drm/ttm/ttm_bo.c | 17 +++++++++++++---- 2 files changed, 15 insertions(+), 6 deletions(-)
drivers/gpu/drm/nouveau/nouveau_bo.c +2 -2
@@ -815,10 +815,10 @@ nouveau_bo_move_ntfy(struct ttm_buffer_object *bo, struct ttm_mem_reg *new_mem)struct nouveau_vma *vma;list_for_each_entry (vma, &nvbo->vma_list, head) { -if (new_mem->mem_type ==TTM_PL_VRAM ) { +if (new_mem && new_mem->mem_type ==TTM_PL_VRAM ) {nouveau_vm_map (vma, new_mem->mm_node); }else -if (new_mem->mem_type ==TTM_PL_TT && +if (new_mem && new_mem->mem_type ==TTM_PL_TT && nvbo->page_shift == vma->vm->spg_shift) { nouveau_vm_map_sg(vma, 0, new_mem-> num_pages << PAGE_SHIFT,
drivers/gpu/drm/ttm/ttm_bo.c +13 -4
@@ -147,6 +147,12 @@ static void ttm_bo_release_list(struct kref *list_kref)BUG_ON (!list_empty (&bo->lru));BUG_ON (!list_empty (&bo->ddestroy)); +/* force bo to reserved, at this point we should be the only owner */ +atomic_set (&bo->reserved,1 ); +if (bdev->driver->move_notify) + bdev->driver->move_notify (bo,NULL ); +atomic_set (&bo->reserved,0 ); +if (bo->ttm)ttm_tt_destroy (bo->ttm);atomic_dec (&bo->glob->bo_count);
@@ -404,9 +410,6 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo, } } -if (bdev->driver->move_notify) - bdev->driver->move_notify (bo, mem); -if (!(old_man->flags &TTM_MEMTYPE_FLAG_FIXED ) && !(new_man->flags &TTM_MEMTYPE_FLAG_FIXED )) ret =ttm_bo_move_ttm (bo, evict, no_wait_reserve, no_wait_gpu, mem);
@@ -419,6 +422,9 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,if (ret) goto out_err; +if (bdev->driver->move_notify) + bdev->driver->move_notify (bo, mem); + moved:if (bo->evicted) { ret = bdev->driver->invalidate_caches (bdev, bo->mem.placement);
@@ -1872,9 +1878,12 @@ static int ttm_bo_swapout(struct ttm_mem_shrink *shrink)if (bo->bdev->driver->swap_notify) bo->bdev->driver->swap_notify (bo); +if (bo->bdev->driver->move_notify) + bo->bdev->driver->move_notify (bo,NULL ); + ret =ttm_tt_swapout (bo->ttm, bo->persistent_swap_storage); -out: +out:/** * * Unreserve without putting on LRU to avoid swapping out an
Signature · 1 line
1.7.7.1
Quoted 43 lines · On 11/19/2011 12:32 AM, [email protected] wrote:
From: Jerome Glisse<[email protected]>
Previously we were calling back
move_notifyin error path when the bo is returned to it's original position or when destroy the bo. When destroying the bo set the new mem placement as NULL when calling back in the driver.Updating nouveau to deal with NULL placement properly.
v2: reserve the object before calling
move_notifyin bo destroy path
at that point ttm should be the only piece of code interacting with the object soatomic_setis safe here.
v3: callback move notify only once the bo is in its new position
call move notify want swaping out the bufferReviewed-by Jerome Glisse<[email protected]>--- drivers/gpu/drm/nouveau/nouveau_bo.c | 4 ++-- drivers/gpu/drm/ttm/ttm_bo.c | 17 +++++++++++++---- 2 files changed, 15 insertions(+), 6 deletions(-)drivers/gpu/drm/nouveau/nouveau_bo.c +2
-2@@ -815,10 +815,10 @@ nouveau_bo_move_ntfy(struct ttm_buffer_object *bo, struct ttm_mem_reg *new_mem)struct nouveau_vma *vma;list_for_each_entry (vma,&nvbo->vma_list, head) { -if (new_mem->mem_type ==TTM_PL_VRAM ) { +if (new_mem&& new_mem->mem_type ==TTM_PL_VRAM ) {nouveau_vm_map (vma, new_mem->mm_node); }else -if (new_mem->mem_type ==TTM_PL_TT && +if (new_mem&& new_mem->mem_type ==TTM_PL_TT && nvbo->page_shift == vma->vm->spg_shift) { nouveau_vm_map_sg(vma, 0, new_mem-> num_pages<< PAGE_SHIFT,drivers/gpu/drm/ttm/ttm_bo.c +0
-0
drivers/gpu/drm/ttm/ttm_bo.c static void ttm_bo_release_list(struct kref *list_kref) · line 155
Quoted 9 lines
drivers/gpu/drm/ttm/ttm_bo.c +5
-0@@ -147,6 +147,12 @@ static void ttm_bo_release_list(struct kref *list_kref)BUG_ON (!list_empty (&bo->lru));BUG_ON (!list_empty (&bo->ddestroy)); +/* force bo to reserved, at this point we should be the only owner */ +atomic_set (&bo->reserved,1 ); +if (bdev->driver->move_notify) + bdev->driver->move_notify (bo,NULL ); +atomic_set (&bo->reserved,0 );
We can actually do this from the top of ttm_bo_cleanup_memtype_use(). Then we should catch all current and future use-cases and you wouldn't need the fake reserving, because at that point, we're already reserved.
Quoted 27 lines
drivers/gpu/drm/ttm/ttm_bo.c +1
-0+if (bo->ttm)ttm_tt_destroy (bo->ttm);atomic_dec(&bo->glob->bo_count);drivers/gpu/drm/ttm/ttm_bo.c +3
-3@@ -404,9 +410,6 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo, } } -if (bdev->driver->move_notify) - bdev->driver->move_notify (bo, mem); -if (!(old_man->flags&TTM_MEMTYPE_FLAG_FIXED )&& !(new_man->flags&TTM_MEMTYPE_FLAG_FIXED )) ret =ttm_bo_move_ttm (bo, evict, no_wait_reserve, no_wait_gpu, mem);@@ -419,6 +422,9 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,if (ret) goto out_err; +if (bdev->driver->move_notify) + bdev->driver->move_notify (bo, mem); + moved:if (bo->evicted) { ret = bdev->driver->invalidate_caches(bdev, bo->mem.placement);
drivers/gpu/drm/ttm/ttm_bo.c static int ttm_bo_swapout(struct ttm_mem_shrink *shrink) · line 1884
Quoted 7 lines
drivers/gpu/drm/ttm/ttm_bo.c +3
-0@@ -1872,9 +1878,12 @@ static int ttm_bo_swapout(struct ttm_mem_shrink *shrink)if (bo->bdev->driver->swap_notify) bo->bdev->driver->swap_notify (bo); +if (bo->bdev->driver->move_notify) + bo->bdev->driver->move_notify (bo,NULL ); +
Hmm. On second thought, we could use swap_notify() for this, I missed we already had that and that's what vmwgfx once used for exactly the same purpose.
drivers/gpu/drm/ttm/ttm_bo.c static int ttm_bo_swapout(struct ttm_mem_shrink *shrink)
Quoted 5 lines
drivers/gpu/drm/ttm/ttm_bo.c +1
-1ret =ttm_tt_swapout (bo->ttm, bo->persistent_swap_storage); -out: +out:
Whitespace.
/Thomas
Jerome Glisse
Reviewed-byQuoted 111 lines · Thomas Hellstrom
Quoted 47 lines · On 11/19/2011 12:32 AM, [email protected] wrote:
From: Jerome Glisse<[email protected]>
Previously we were calling back
move_notifyin error path when the bo is returned to it's original position or when destroy the bo. When destroying the bo set the new mem placement as NULL when calling back in the driver.Updating nouveau to deal with NULL placement properly.
v2: reserve the object before calling
move_notifyin bo destroy path at that point ttm should be the only piece of code interacting with the object soatomic_setis safe here.
v3: callback move notify only once the bo is in its new position call move notify want swaping out the bufferReviewed-by Jerome Glisse<[email protected]>---
drivers/gpu/drm/nouveau/nouveau_bo.c | 4 ++--drivers/gpu/drm/ttm/ttm_bo.c| 17 +++++++++++++----2 files changed, 15 insertions(+), 6 deletions(-)drivers/gpu/drm/nouveau/nouveau_bo.c +2
-2@@ -815,10 +815,10 @@ nouveau_bo_move_ntfy(struct ttm_buffer_object *bo, struct ttm_mem_reg *new_mem) struct nouveau_vma *vma; list_for_each_entry(vma,&nvbo->vma_list, head) { - if (new_mem->mem_type == TTM_PL_VRAM) { + if (new_mem&& new_mem->mem_type == TTM_PL_VRAM) { nouveau_vm_map(vma, new_mem->mm_node); } else - if (new_mem->mem_type == TTM_PL_TT&& + if (new_mem&& new_mem->mem_type == TTM_PL_TT&& nvbo->page_shift == vma->vm->spg_shift) {nouveau_vm_map_sg(vma, 0, new_mem-> num_pages<< PAGE_SHIFT,
drivers/gpu/drm/ttm/ttm_bo.c +0
-0@@ -147,6 +147,12 @@ static void ttm_bo_release_list(struct kref *list_kref)drivers/gpu/drm/ttm/ttm_bo.c static void ttm_bo_release_list(struct kref · line 157
Quoted 10 lines
drivers/gpu/drm/ttm/ttm_bo.c +5
-0BUG_ON(!list_empty(&bo->lru)); BUG_ON(!list_empty(&bo->ddestroy)); + /* force bo to reserved, at this point we should be the only owner */ + atomic_set(&bo->reserved, 1); + if (bdev->driver->move_notify) + bdev->driver->move_notify(bo, NULL); + atomic_set(&bo->reserved, 0);We can actually do this from the top of
ttm_bo_cleanup_memtype_use(). Then we should catch all current and future use-cases and you wouldn't need the fake reserving, because at that point, we're already reserved.Quoted 31 lines
drivers/gpu/drm/ttm/ttm_bo.c +1
-0+if (
bo->ttm)
ttm_tt_destroy(bo->ttm);
atomic_dec(&bo->glob->bo_count);drivers/gpu/drm/ttm/ttm_bo.c +0
-3@@ -404,9 +410,6 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo, } } - if (bdev->driver->move_notify) - bdev->driver->move_notify(bo, mem); -if (!(old_man->flags& TTM_MEMTYPE_FLAG_FIXED)&& !(new_man->flags& TTM_MEMTYPE_FLAG_FIXED))
ret =ttm_bo_move_ttm(bo, evict, no_wait_reserve, no_wait_gpu, mem);drivers/gpu/drm/ttm/ttm_bo.c +3
-0@@ -419,6 +422,9 @@ static int ttm_bo_handle_move_mem(structttm_buffer_object *bo, if (ret) goto out_err; + if (bdev->driver->move_notify) + bdev->driver->move_notify(bo, mem); +moved:
if (bo->evicted) {
ret =bdev->driver->invalidate_caches(bdev, bo->mem.placement);drivers/gpu/drm/ttm/ttm_bo.c static int ttm_bo_swapout(struct ttm_mem_shrink · line 1885
Quoted 8 lines
drivers/gpu/drm/ttm/ttm_bo.c +3
-0@@ -1872,9 +1878,12 @@ static int ttm_bo_swapout(struct ttm_mem_shrink *shrink) if (bo->bdev->driver->swap_notify) bo->bdev->driver->swap_notify(bo); + if (bo->bdev->driver->move_notify) + bo->bdev->driver->move_notify(bo, NULL); +Hmm. On second thought, we could use
swap_notify()for this, I missed we already had that and that's what vmwgfx once used for exactly the same purpose.Quoted 3 lines
drivers/gpu/drm/ttm/ttm_bo.c +0
-1ret = ttm_tt_swapout(bo->ttm, bo->persistent_swap_storage); -out:
Quoted 8 lines
drivers/gpu/drm/ttm/ttm_bo.c static int ttm_bo_swapout(struct ttm_mem_shrink · line 1889
Quoted 2 lines
drivers/gpu/drm/ttm/ttm_bo.c +1
-0+out:Whitespace.
/Thomas
Attached updated patch
Cheers,
Jerome
From 2bd2641180ed79974e72974266140cf88d06b18a Mon Sep 17 00:00:00 2001
From: Jerome Glisse <[email protected]>
Date: Fri, 18 Nov 2011 11:47:03 -0500
Subject: [PATCH] drm/ttm: callback move_notify any time bo placement change
v4
Previously we were calling back move_notify in error path when the bo is returned to it's original position or when destroy the bo. When destroying the bo set the new mem placement as NULL when calling back in the driver.
Updating nouveau to deal with NULL placement properly.
v2: reserve the object before calling move_notify in bo destroy path
at that point ttm should be the only piece of code interacting with the object so atomic_set is safe here.
v3: callback move notify only once the bo is in its new position
call move notify want swaping out the buffer
v4:- don't call move_notify when swapin out bo, assume driver should
do what is appropriate in swap notify
- move move_notify call back to ttm_bo_cleanup_memtype_use for destroy path
--- drivers/gpu/drm/nouveau/nouveau_bo.c | 4 ++-- drivers/gpu/drm/ttm/ttm_bo.c | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-)
drivers/gpu/drm/nouveau/nouveau_bo.c +2 -2
@@ -815,10 +815,10 @@ nouveau_bo_move_ntfy(struct ttm_buffer_object *bo, struct ttm_mem_reg *new_mem)struct nouveau_vma *vma;list_for_each_entry (vma, &nvbo->vma_list, head) { -if (new_mem->mem_type ==TTM_PL_VRAM ) { +if (new_mem && new_mem->mem_type ==TTM_PL_VRAM ) {nouveau_vm_map (vma, new_mem->mm_node); }else -if (new_mem->mem_type ==TTM_PL_TT && +if (new_mem && new_mem->mem_type ==TTM_PL_TT && nvbo->page_shift == vma->vm->spg_shift) { nouveau_vm_map_sg(vma, 0, new_mem-> num_pages << PAGE_SHIFT,
drivers/gpu/drm/ttm/ttm_bo.c +6 -3
@@ -404,9 +404,6 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo, } } -if (bdev->driver->move_notify) - bdev->driver->move_notify (bo, mem); -if (!(old_man->flags &TTM_MEMTYPE_FLAG_FIXED ) && !(new_man->flags &TTM_MEMTYPE_FLAG_FIXED )) ret =ttm_bo_move_ttm (bo, evict, no_wait_reserve, no_wait_gpu, mem);
@@ -419,6 +416,9 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,if (ret) goto out_err; +if (bdev->driver->move_notify) + bdev->driver->move_notify (bo, mem); + moved:if (bo->evicted) { ret = bdev->driver->invalidate_caches (bdev, bo->mem.placement);
@@ -457,6 +457,9 @@ out_err:static void ttm_bo_cleanup_memtype_use (struct ttm_buffer_object *bo) { +if (bo->bdev->driver->move_notify) + bo->bdev->driver->move_notify (bo,NULL ); +if (bo->ttm) {ttm_tt_unbind (bo->ttm);ttm_tt_destroy (bo->ttm);
Signature · 1 line
1.7.7.1
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Thomas Hellstrom
Reviewed-byUpdated patch
Quoted 137 lines · Jerome Glisse
Quoted 114 lines · Thomas Hellstrom
Quoted 47 lines · On 11/19/2011 12:32 AM, [email protected] wrote:
From: Jerome Glisse<[email protected]>
Previously we were calling back
move_notifyin error path when the bo is returned to it's original position or when destroy the bo. When destroying the bo set the new mem placement as NULL when calling back in the driver.Updating nouveau to deal with NULL placement properly.
v2: reserve the object before calling
move_notifyin bo destroy path
at that point ttm should be the only piece of code interacting with the object soatomic_setis safe here.
v3: callback move notify only once the bo is in its new position
call move notify want swaping out the bufferReviewed-by Jerome Glisse<[email protected]>--- drivers/gpu/drm/nouveau/nouveau_bo.c | 4 ++-- drivers/gpu/drm/ttm/ttm_bo.c | 17 +++++++++++++---- 2 files changed, 15 insertions(+), 6 deletions(-)drivers/gpu/drm/nouveau/nouveau_bo.c +2
-2@@ -815,10 +815,10 @@ nouveau_bo_move_ntfy(struct ttm_buffer_object *bo, struct ttm_mem_reg *new_mem)struct nouveau_vma *vma;list_for_each_entry (vma,&nvbo->vma_list, head) { -if (new_mem->mem_type ==TTM_PL_VRAM ) { +if (new_mem&& new_mem->mem_type ==TTM_PL_VRAM ) {nouveau_vm_map (vma, new_mem->mm_node); }else -if (new_mem->mem_type ==TTM_PL_TT && +if (new_mem&& new_mem->mem_type ==TTM_PL_TT && nvbo->page_shift == vma->vm->spg_shift) { nouveau_vm_map_sg(vma, 0, new_mem->num_pages<<
PAGE_SHIFT,drivers/gpu/drm/ttm/ttm_bo.c +0
-0@@ -147,6 +147,12 @@ static void ttm_bo_release_list(struct kref *list_kref)drivers/gpu/drm/ttm/ttm_bo.c static void ttm_bo_release_list(struct kref · line 157
Quoted 10 lines
drivers/gpu/drm/ttm/ttm_bo.c +5
-0BUG_ON (!list_empty (&bo->lru));BUG_ON (!list_empty (&bo->ddestroy)); +/* force bo to reserved, at this point we should be the only owner */ +atomic_set (&bo->reserved,1 ); +if (bdev->driver->move_notify) + bdev->driver->move_notify (bo,NULL ); +atomic_set (&bo->reserved,0 );We can actually do this from the top of
ttm_bo_cleanup_memtype_use(). Then we should catch all current and future use-cases and you wouldn't need the fake reserving, because at that point, we're already reserved.Quoted 32 lines
drivers/gpu/drm/ttm/ttm_bo.c +1
-0+if (bo->ttm) ttm_tt_destroy(bo->ttm); atomic_dec(&bo->glob->bo_count);drivers/gpu/drm/ttm/ttm_bo.c +0
-3@@ -404,9 +410,6 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo, } } -if (bdev->driver->move_notify) - bdev->driver->move_notify (bo, mem); -if (!(old_man->flags&TTM_MEMTYPE_FLAG_FIXED )&& !(new_man->flags&TTM_MEMTYPE_FLAG_FIXED ))ret = ttm_bo_move_ttm(bo, evict,
no_wait_reserve,no_wait_gpu, mem);drivers/gpu/drm/ttm/ttm_bo.c +3
-0@@ -419,6 +422,9 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo, if (ret) goto out_err; +if (bdev->driver->move_notify) + bdev->driver->move_notify (bo, mem); +moved:
if (bo->evicted) { ret = bdev->driver->invalidate_caches(bdev,
bo->mem.placement);drivers/gpu/drm/ttm/ttm_bo.c static int ttm_bo_swapout(struct ttm_mem_shrink · line 1886
Quoted 9 lines
drivers/gpu/drm/ttm/ttm_bo.c +3
-0@@ -1872,9 +1878,12 @@ static int ttm_bo_swapout(struct ttm_mem_shrink *shrink)if (bo->bdev->driver->swap_notify) bo->bdev->driver->swap_notify (bo); +if (bo->bdev->driver->move_notify) + bo->bdev->driver->move_notify (bo,NULL ); +Hmm. On second thought, we could use
swap_notify()for this, I missed we already had that and that's what vmwgfx once used for exactly the same purpose.Quoted 3 lines
drivers/gpu/drm/ttm/ttm_bo.c +0
-1ret =ttm_tt_swapout (bo->ttm, bo->persistent_swap_storage); -out:Quoted 9 lines
drivers/gpu/drm/ttm/ttm_bo.c static int ttm_bo_swapout(struct ttm_mem_shrink · line 1889
Quoted 3 lines
drivers/gpu/drm/ttm/ttm_bo.c +1
-0+out:Whitespace.
/Thomas
Attached updated patch
Cheers,
Jerome_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel