drm/ttm: don't update global memory count for some special cases
Subsystems (6)
PATCH 1/2 drm/ttm: don't update global memory count for some special cases
add input parameter for ttm_dma_unpopulate.
when ttm_dma_pool_get_pages or ttm_mem_global_alloc_page fail, don't call ttm_mem_global_free_page to update global memory count.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 2 +- drivers/gpu/drm/nouveau/nouveau_bo.c | 2 +- drivers/gpu/drm/radeon/radeon_ttm.c | 2 +- drivers/gpu/drm/ttm/ttm_page_alloc_dma.c | 19 +++++++++++-------- drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c | 2 +- include/drm/ttm/ttm_page_alloc.h | 5 +++-- 6 files changed, 18 insertions(+), 14 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -1
@@ -1046,7 +1046,7 @@ static void amdgpu_ttm_tt_unpopulate(struct ttm_tt *ttm)#ifdef CONFIG_SWIOTLB if (swiotlb_nr_tbl ()) { -ttm_dma_unpopulate (>t->ttm, adev->dev); +ttm_dma_unpopulate (>t->ttm, adev->dev, true);return ; }#endif
drivers/gpu/drm/nouveau/nouveau_bo.c +1 -1
@@ -1632,7 +1632,7 @@ nouveau_ttm_tt_unpopulate(struct ttm_tt *ttm)#if IS_ENABLED (CONFIG_SWIOTLB ) &&IS_ENABLED (CONFIG_X86 )if (swiotlb_nr_tbl ()) { -ttm_dma_unpopulate ((void *)ttm, dev); +ttm_dma_unpopulate ((void *)ttm, dev, true);return ; }#endif
drivers/gpu/drm/radeon/radeon_ttm.c +1 -1
@@ -789,7 +789,7 @@ static void radeon_ttm_tt_unpopulate(struct ttm_tt *ttm)#ifdef CONFIG_SWIOTLB if (swiotlb_nr_tbl ()) { -ttm_dma_unpopulate (>t->ttm, rdev->dev); +ttm_dma_unpopulate (>t->ttm, rdev->dev, true);return ; }#endif
drivers/gpu/drm/ttm/ttm_page_alloc_dma.c +11 -8
@@ -969,7 +969,7 @@ int ttm_dma_populate(struct ttm_dma_tt *ttm_dma, struct device *dev, ret =ttm_mem_global_alloc_page (mem_glob, ttm->pages[i], pool->size, ctx);if (unlikely (ret !=0 )) { -ttm_dma_unpopulate (ttm_dma, dev); +ttm_dma_unpopulate (ttm_dma, dev, false);return -ENOMEM ; }
@@ -998,14 +998,14 @@ int ttm_dma_populate(struct ttm_dma_tt *ttm_dma, struct device *dev,while (num_pages) { ret =ttm_dma_pool_get_pages (pool, ttm_dma, i);if (ret !=0 ) { -ttm_dma_unpopulate (ttm_dma, dev); +ttm_dma_unpopulate (ttm_dma, dev, false);return -ENOMEM ; } ret =ttm_mem_global_alloc_page (mem_glob, ttm->pages[i], pool->size, ctx);if (unlikely (ret !=0 )) { -ttm_dma_unpopulate (ttm_dma, dev); +ttm_dma_unpopulate (ttm_dma, dev, false);return -ENOMEM ; }
@@ -1016,7 +1016,7 @@ int ttm_dma_populate(struct ttm_dma_tt *ttm_dma, struct device *dev,if (unlikely (ttm->page_flags &TTM_PAGE_FLAG_SWAPPED )) { ret =ttm_tt_swapin (ttm);if (unlikely (ret !=0 )) { -ttm_dma_unpopulate (ttm_dma, dev); +ttm_dma_unpopulate (ttm_dma, dev, true);return ret; } }
@@ -1027,7 +1027,8 @@ int ttm_dma_populate(struct ttm_dma_tt *ttm_dma, struct device *dev,EXPORT_SYMBOL_GPL (ttm_dma_populate);/* Put all pages in pages list to correct pool to wait for reuse */ -void ttm_dma_unpopulate (struct ttm_dma_tt *ttm_dma,struct device *dev) +void ttm_dma_unpopulate (struct ttm_dma_tt *ttm_dma,struct device *dev, +bool update_glob_count) {struct ttm_tt *ttm = &ttm_dma->ttm;struct dma_pool *pool;
@@ -1049,7 +1050,8 @@ void ttm_dma_unpopulate(struct ttm_dma_tt *ttm_dma, struct device *dev)continue ; count++; -ttm_mem_global_free_page (ttm->glob->mem_glob, +if (update_glob_count) +ttm_mem_global_free_page (ttm->glob->mem_glob, d_page->p, pool->size);ttm_dma_page_put (pool, d_page); }
@@ -1094,11 +1096,12 @@ void ttm_dma_unpopulate(struct ttm_dma_tt *ttm_dma, struct device *dev)if (is_cached) {list_for_each_entry_safe (d_page, next, &ttm_dma->pages_list, page_list) { -ttm_mem_global_free_page (ttm->glob->mem_glob, +if (update_glob_count) +ttm_mem_global_free_page (ttm->glob->mem_glob, d_page->p, pool->size);ttm_dma_page_put (pool, d_page); } - }else { + }else if (update_glob_count) {for (i =0 ; i < count; i++) {ttm_mem_global_free_page (ttm->glob->mem_glob, ttm->pages[i], pool->size);
drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c +1 -1
@@ -681,7 +681,7 @@ static void vmw_ttm_unpopulate(struct ttm_tt *ttm)size_t size =ttm_round_pot (ttm->num_pages *sizeof (dma_addr_t)); -ttm_dma_unpopulate (&vmw_tt->dma_ttm, dev_priv->dev->dev); +ttm_dma_unpopulate (&vmw_tt->dma_ttm, dev_priv->dev->dev, true);ttm_mem_global_free (glob, size); }else ttm_pool_unpopulate (ttm);
include/drm/ttm/ttm_page_alloc.h +3 -2
@@ -92,7 +92,8 @@ int ttm_dma_page_alloc_debugfs(struct seq_file *m, void *data);int ttm_dma_populate (struct ttm_dma_tt *ttm_dma,struct device *dev,struct ttm_operation_ctx *ctx); -void ttm_dma_unpopulate (struct ttm_dma_tt *ttm_dma,struct device *dev); +void ttm_dma_unpopulate (struct ttm_dma_tt *ttm_dma,struct device *dev, +bool update_glob_count);#else static inline int ttm_dma_page_alloc_init(struct ttm_mem_global *glob,
@@ -114,7 +115,7 @@ static inline int ttm_dma_populate(struct ttm_dma_tt *ttm_dma, return -ENOMEM; }static inline void ttm_dma_unpopulate (struct ttm_dma_tt *ttm_dma, -struct device *dev) +struct device *dev,bool update_glob_count); { }#endif
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 2/2 drm/ttm: only free pages rather than update global memory count together
if ttm_get_pages or ttm_mem_global_alloc_page fail, should not update global memory count.
--- drivers/gpu/drm/ttm/ttm_page_alloc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/ttm/ttm_page_alloc.c +4 -2
@@ -1075,7 +1075,8 @@ int ttm_pool_populate(struct ttm_tt *ttm, struct ttm_operation_ctx *ctx) ret =ttm_get_pages (ttm->pages, ttm->num_pages, ttm->page_flags, ttm->caching_state);if (unlikely (ret !=0 )) { -ttm_pool_unpopulate (ttm); +ttm_put_pages (ttm->pages, ttm->num_pages, ttm->page_flags, + ttm->caching_state);return ret; }
@@ -1083,7 +1084,8 @@ int ttm_pool_populate(struct ttm_tt *ttm, struct ttm_operation_ctx *ctx) ret =ttm_mem_global_alloc_page (mem_glob, ttm->pages[i],PAGE_SIZE , ctx);if (unlikely (ret !=0 )) { -ttm_pool_unpopulate (ttm); +ttm_put_pages (ttm->pages, ttm->num_pages, + ttm->page_flags, ttm->caching_state);return -ENOMEM ; } }
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Can this fix GTT size issue or not?
Regards,
David Zhou
Quoted 155 lines · Roger He
add input parameter for
ttm_dma_unpopulate.
whenttm_dma_pool_get_pagesorttm_mem_global_alloc_pagefail, don't callttm_mem_global_free_pageto update global memory count.Signed-off-by Roger He <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 2 +- drivers/gpu/drm/nouveau/nouveau_bo.c | 2 +- drivers/gpu/drm/radeon/radeon_ttm.c | 2 +- drivers/gpu/drm/ttm/ttm_page_alloc_dma.c | 19 +++++++++++-------- drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c | 2 +- include/drm/ttm/ttm_page_alloc.h | 5 +++-- 6 files changed, 18 insertions(+), 14 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1
-1@@ -1046,7 +1046,7 @@ static void amdgpu_ttm_tt_unpopulate(struct ttm_tt *ttm)#ifdef CONFIG_SWIOTLB if (swiotlb_nr_tbl ()) { -ttm_dma_unpopulate (>t->ttm, adev->dev); +ttm_dma_unpopulate (>t->ttm, adev->dev, true);return ; }#endif drivers/gpu/drm/nouveau/nouveau_bo.c +1
-1@@ -1632,7 +1632,7 @@ nouveau_ttm_tt_unpopulate(struct ttm_tt *ttm)#if IS_ENABLED (CONFIG_SWIOTLB ) &&IS_ENABLED (CONFIG_X86 )if (swiotlb_nr_tbl ()) { -ttm_dma_unpopulate ((void *)ttm, dev); +ttm_dma_unpopulate ((void *)ttm, dev, true);return ; }#endif drivers/gpu/drm/radeon/radeon_ttm.c +1
-1@@ -789,7 +789,7 @@ static void radeon_ttm_tt_unpopulate(struct ttm_tt *ttm)#ifdef CONFIG_SWIOTLB if (swiotlb_nr_tbl ()) { -ttm_dma_unpopulate (>t->ttm, rdev->dev); +ttm_dma_unpopulate (>t->ttm, rdev->dev, true);return ; }#endif drivers/gpu/drm/ttm/ttm_page_alloc_dma.c +11
-8@@ -969,7 +969,7 @@ int ttm_dma_populate(struct ttm_dma_tt *ttm_dma, struct device *dev, ret =ttm_mem_global_alloc_page (mem_glob, ttm->pages[i], pool->size, ctx);if (unlikely (ret !=0 )) { -ttm_dma_unpopulate (ttm_dma, dev); +ttm_dma_unpopulate (ttm_dma, dev, false);return -ENOMEM ; }@@ -998,14 +998,14 @@ int ttm_dma_populate(struct ttm_dma_tt *ttm_dma, struct device *dev,while (num_pages) { ret =ttm_dma_pool_get_pages (pool, ttm_dma, i);if (ret !=0 ) { -ttm_dma_unpopulate (ttm_dma, dev); +ttm_dma_unpopulate (ttm_dma, dev, false);return -ENOMEM ; } ret =ttm_mem_global_alloc_page (mem_glob, ttm->pages[i], pool->size, ctx);if (unlikely (ret !=0 )) { -ttm_dma_unpopulate (ttm_dma, dev); +ttm_dma_unpopulate (ttm_dma, dev, false);return -ENOMEM ; }@@ -1016,7 +1016,7 @@ int ttm_dma_populate(struct ttm_dma_tt *ttm_dma, struct device *dev,if (unlikely (ttm->page_flags &TTM_PAGE_FLAG_SWAPPED )) { ret =ttm_tt_swapin (ttm);if (unlikely (ret !=0 )) { -ttm_dma_unpopulate (ttm_dma, dev); +ttm_dma_unpopulate (ttm_dma, dev, true);return ret; } }@@ -1027,7 +1027,8 @@ int ttm_dma_populate(struct ttm_dma_tt *ttm_dma, struct device *dev,EXPORT_SYMBOL_GPL (ttm_dma_populate);/* Put all pages in pages list to correct pool to wait for reuse */ -void ttm_dma_unpopulate (struct ttm_dma_tt *ttm_dma,struct device *dev) +void ttm_dma_unpopulate (struct ttm_dma_tt *ttm_dma,struct device *dev, +bool update_glob_count) {struct ttm_tt *ttm = &ttm_dma->ttm;struct dma_pool *pool;@@ -1049,7 +1050,8 @@ void ttm_dma_unpopulate(struct ttm_dma_tt *ttm_dma, struct device *dev)continue ; count++; -ttm_mem_global_free_page (ttm->glob->mem_glob, +if (update_glob_count) +ttm_mem_global_free_page (ttm->glob->mem_glob, d_page->p, pool->size);ttm_dma_page_put (pool, d_page); }@@ -1094,11 +1096,12 @@ void ttm_dma_unpopulate(struct ttm_dma_tt *ttm_dma, struct device *dev)if (is_cached) {list_for_each_entry_safe (d_page, next, &ttm_dma->pages_list, page_list) { -ttm_mem_global_free_page (ttm->glob->mem_glob, +if (update_glob_count) +ttm_mem_global_free_page (ttm->glob->mem_glob, d_page->p, pool->size);ttm_dma_page_put (pool, d_page); } - }else { + }else if (update_glob_count) {for (i =0 ; i < count; i++) {ttm_mem_global_free_page (ttm->glob->mem_glob, ttm->pages[i], pool->size);drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c +1
-1@@ -681,7 +681,7 @@ static void vmw_ttm_unpopulate(struct ttm_tt *ttm)size_t size =ttm_round_pot (ttm->num_pages *sizeof (dma_addr_t)); -ttm_dma_unpopulate (&vmw_tt->dma_ttm, dev_priv->dev->dev); +ttm_dma_unpopulate (&vmw_tt->dma_ttm, dev_priv->dev->dev, true);ttm_mem_global_free (glob, size); }else ttm_pool_unpopulate (ttm);include/drm/ttm/ttm_page_alloc.h +2
-1@@ -92,7 +92,8 @@ int ttm_dma_page_alloc_debugfs(struct seq_file *m, void *data);int ttm_dma_populate (struct ttm_dma_tt *ttm_dma,struct device *dev,struct ttm_operation_ctx *ctx); -void ttm_dma_unpopulate (struct ttm_dma_tt *ttm_dma,struct device *dev); +void ttm_dma_unpopulate (struct ttm_dma_tt *ttm_dma,struct device *dev, +bool update_glob_count);#else static inline int ttm_dma_page_alloc_init(struct ttm_mem_global *glob,
include/drm/ttm/ttm_page_alloc.h static inline int ttm_dma_populate(struct ttm_dma_tt *ttm_dma, · line 121
Quoted 8 lines
include/drm/ttm/ttm_page_alloc.h +1
-1@@ -114,7 +115,7 @@ static inline int ttm_dma_populate(struct ttm_dma_tt *ttm_dma, return -ENOMEM; }static inline void ttm_dma_unpopulate (struct ttm_dma_tt *ttm_dma, -struct device *dev) +struct device *dev,bool update_glob_count); { }#endif
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
It is the first step for the GTT size issue.
Need other patches I am working on it.
Thanks
Roger(Hongbo.He)
-----Original Message-----
From: Zhou, David(ChunMing)
Sent: Friday, January 12, 2018 2:46 PM
To: He, Roger <[email protected]>; [email protected]
Cc: Koenig, Christian <[email protected]>
Subject: Re: [PATCH 1/2] drm/ttm: don't update global memory count for some special cases
Can this fix GTT size issue or not?
Regards,
David Zhou
Quoted 170 lines · Roger He
add input parameter for
ttm_dma_unpopulate.
whenttm_dma_pool_get_pagesorttm_mem_global_alloc_pagefail, don't callttm_mem_global_free_pageto update global memory count.Signed-off-by Roger He <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 2 +- drivers/gpu/drm/nouveau/nouveau_bo.c | 2 +- drivers/gpu/drm/radeon/radeon_ttm.c | 2 +- drivers/gpu/drm/ttm/ttm_page_alloc_dma.c | 19 +++++++++++-------- drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c | 2 +- include/drm/ttm/ttm_page_alloc.h | 5 +++-- 6 files changed, 18 insertions(+), 14 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1
-1@@ -1046,7 +1046,7 @@ static void amdgpu_ttm_tt_unpopulate(struct ttm_tt *ttm)#ifdef CONFIG_SWIOTLB if (swiotlb_nr_tbl ()) { -ttm_dma_unpopulate (>t->ttm, adev->dev); +ttm_dma_unpopulate (>t->ttm, adev->dev, true);return ; }#endifdrivers/gpu/drm/nouveau/nouveau_bo.c +1
-1@@ -1632,7 +1632,7 @@ nouveau_ttm_tt_unpopulate(struct ttm_tt *ttm)#if IS_ENABLED (CONFIG_SWIOTLB ) &&IS_ENABLED (CONFIG_X86 )if (swiotlb_nr_tbl ()) { -ttm_dma_unpopulate ((void *)ttm, dev); +ttm_dma_unpopulate ((void *)ttm, dev, true);return ; }#endif drivers/gpu/drm/radeon/radeon_ttm.c +1
-1@@ -789,7 +789,7 @@ static void radeon_ttm_tt_unpopulate(struct ttm_tt *ttm)#ifdef CONFIG_SWIOTLB if (swiotlb_nr_tbl ()) { -ttm_dma_unpopulate (>t->ttm, rdev->dev); +ttm_dma_unpopulate (>t->ttm, rdev->dev, true);return ; }#endifdrivers/gpu/drm/ttm/ttm_page_alloc_dma.c +6
-5@@ -969,7 +969,7 @@ int ttm_dma_populate(struct ttm_dma_tt *ttm_dma, struct device *dev, ret =ttm_mem_global_alloc_page (mem_glob, ttm->pages[i], pool->size, ctx);if (unlikely (ret !=0 )) { -ttm_dma_unpopulate (ttm_dma, dev); +ttm_dma_unpopulate (ttm_dma, dev, false);return -ENOMEM ; }@@ -998,14 +998,14 @@ int ttm_dma_populate(struct ttm_dma_tt *ttm_dma, struct device *dev,while (num_pages) { ret =ttm_dma_pool_get_pages (pool, ttm_dma, i);if (ret !=0 ) { -ttm_dma_unpopulate (ttm_dma, dev); +ttm_dma_unpopulate (ttm_dma, dev, false);return -ENOMEM ; } ret =ttm_mem_global_alloc_page (mem_glob, ttm->pages[i], pool->size, ctx);if (unlikely (ret !=0 )) { -ttm_dma_unpopulate (ttm_dma, dev); +ttm_dma_unpopulate (ttm_dma, dev, false);return -ENOMEM ; }@@ -1016,7 +1016,7 @@ int ttm_dma_populate(struct ttm_dma_tt *ttm_dma, struct device *dev,if (unlikely (ttm->page_flags &TTM_PAGE_FLAG_SWAPPED )) { ret =ttm_tt_swapin (ttm);if (unlikely (ret !=0 )) { -ttm_dma_unpopulate (ttm_dma, dev); +ttm_dma_unpopulate (ttm_dma, dev, true);return ret; } }@@ -1027,7 +1027,8 @@ int ttm_dma_populate(struct ttm_dma_tt *ttm_dma, struct device *dev,EXPORT_SYMBOL_GPL (ttm_dma_populate);/* Put all pages in pages list to correct pool to wait for reuse */ -void ttm_dma_unpopulate (struct ttm_dma_tt *ttm_dma,struct device *dev) +void ttm_dma_unpopulate (struct ttm_dma_tt *ttm_dma,struct device *dev, +bool update_glob_count) {struct ttm_tt *ttm = &ttm_dma->ttm;struct
dma_pool*pool;drivers/gpu/drm/ttm/ttm_page_alloc_dma.c +5
-3@@ -1049,7 +1050,8 @@ void ttm_dma_unpopulate(struct ttm_dma_tt *ttm_dma, struct device *dev)continue ; count++; -ttm_mem_global_free_page (ttm->glob->mem_glob, +if (update_glob_count) +ttm_mem_global_free_page (ttm->glob->mem_glob, d_page->p, pool->size);ttm_dma_page_put (pool, d_page); }@@ -1094,11 +1096,12 @@ void ttm_dma_unpopulate(struct ttm_dma_tt *ttm_dma, struct device *dev)if (is_cached) {list_for_each_entry_safe (d_page, next, &ttm_dma->pages_list, page_list) { -ttm_mem_global_free_page (ttm->glob->mem_glob, +if (update_glob_count) +ttm_mem_global_free_page (ttm->glob->mem_glob, d_page->p, pool->size);ttm_dma_page_put (pool, d_page); } - }else { + }else if (update_glob_count) {for (i =0 ; i < count; i++) { ttm_mem_global_free_page(ttm->glob->mem_glob,ttm->pages[i], pool->size);drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c +1
-1@@ -681,7 +681,7 @@ static void vmw_ttm_unpopulate(struct ttm_tt *ttm)size_t size =ttm_round_pot (ttm->num_pages *sizeof (dma_addr_t)); -ttm_dma_unpopulate (&vmw_tt->dma_ttm, dev_priv->dev->dev); +ttm_dma_unpopulate (&vmw_tt->dma_ttm, dev_priv->dev->dev, true);ttm_mem_global_free (glob, size); }else ttm_pool_unpopulate (ttm);include/drm/ttm/ttm_page_alloc.h +2
-1@@ -92,7 +92,8 @@ int ttm_dma_page_alloc_debugfs(struct seq_file *m, void *data);int ttm_dma_populate (struct ttm_dma_tt *ttm_dma,struct device *dev,struct ttm_operation_ctx *ctx); -void ttm_dma_unpopulate (struct ttm_dma_tt *ttm_dma,struct device *dev); +void ttm_dma_unpopulate (struct ttm_dma_tt *ttm_dma,struct device *dev, +bool update_glob_count);#else
static inline int ttm_dma_page_alloc_init(structttm_mem_global
*glob, @@ -114,7 +115,7 @@ static inline int ttm_dma_populate(structttm_dma_tt*ttm_dma,
return-ENOMEM;
}
static inline void ttm_dma_unpopulate(structttm_dma_tt*ttm_dma,
include/drm/ttm/ttm_page_alloc.h static inline int ttm_dma_populate(struct ttm_dma_tt *ttm_dma, · line 121
Quoted 5 lines
include/drm/ttm/ttm_page_alloc.h +1
-1- struct device *dev) + struct device *dev, bool update_glob_count); { }#endif
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 2/2] drm/ttm: only free pages rather than update global memory count together
In reply to Roger HeBoth patches
Andrey
Quoted 23 lines · Roger He
if
ttm_get_pagesorttm_mem_global_alloc_pagefail, should not update global memory count.Signed-off-by Roger He <[email protected]>--- drivers/gpu/drm/ttm/ttm_page_alloc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/gpu/drm/ttm/ttm_page_alloc.c +2
-1@@ -1075,7 +1075,8 @@ int ttm_pool_populate(struct ttm_tt *ttm, struct ttm_operation_ctx *ctx) ret =ttm_get_pages (ttm->pages, ttm->num_pages, ttm->page_flags, ttm->caching_state);if (unlikely (ret !=0 )) { -ttm_pool_unpopulate (ttm); +ttm_put_pages (ttm->pages, ttm->num_pages, ttm->page_flags, + ttm->caching_state);return ret; }
drivers/gpu/drm/ttm/ttm_page_alloc.c int ttm_pool_populate(struct ttm_tt *ttm, struct ttm_operation_ctx *ctx) · line 1091
Quoted 9 lines
drivers/gpu/drm/ttm/ttm_page_alloc.c +2
-1@@ -1083,7 +1084,8 @@ int ttm_pool_populate(struct ttm_tt *ttm, struct ttm_operation_ctx *ctx) ret =ttm_mem_global_alloc_page (mem_glob, ttm->pages[i],PAGE_SIZE , ctx);if (unlikely (ret !=0 )) { -ttm_pool_unpopulate (ttm); +ttm_put_pages (ttm->pages, ttm->num_pages, + ttm->page_flags, ttm->caching_state);return -ENOMEM ; } }
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 2/2] drm/ttm: only free pages rather than update global memory count together
In reply to Roger HeAm 12.01.2018 um 07:14 schrieb Roger He:
Quoted 13 lines
if
ttm_get_pagesorttm_mem_global_alloc_pagefail, should not update global memory count.Signed-off-by Roger He <[email protected]>--- drivers/gpu/drm/ttm/ttm_page_alloc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/gpu/drm/ttm/ttm_page_alloc.c +0
-0
drivers/gpu/drm/ttm/ttm_page_alloc.c int ttm_pool_populate(struct ttm_tt *ttm, struct ttm_operation_ctx *ctx) · line 1079
Quoted 6 lines
drivers/gpu/drm/ttm/ttm_page_alloc.c +2
-1@@ -1075,7 +1075,8 @@ int ttm_pool_populate(struct ttm_tt *ttm, struct ttm_operation_ctx *ctx) ret =ttm_get_pages (ttm->pages, ttm->num_pages, ttm->page_flags, ttm->caching_state);if (unlikely (ret !=0 )) { -ttm_pool_unpopulate (ttm); +ttm_put_pages (ttm->pages, ttm->num_pages, ttm->page_flags, + ttm->caching_state);
That is not correctly indented. The "ttm->caching_state" should be one the same column as the "ttm->pages" above. It looks like your editor only inserts tabs, not spaces.
Apart from that the patch is Reviewed-by: Christian König <[email protected]>.
Regards,
Christian.
drivers/gpu/drm/ttm/ttm_page_alloc.c int ttm_pool_populate(struct ttm_tt *ttm, struct ttm_operation_ctx *ctx) · line 1091
Quoted 13 lines
drivers/gpu/drm/ttm/ttm_page_alloc.c +2
-1return ret; }@@ -1083,7 +1084,8 @@ int ttm_pool_populate(struct ttm_tt *ttm, struct ttm_operation_ctx *ctx) ret =ttm_mem_global_alloc_page (mem_glob, ttm->pages[i],PAGE_SIZE , ctx);if (unlikely (ret !=0 )) { -ttm_pool_unpopulate (ttm); +ttm_put_pages (ttm->pages, ttm->num_pages, + ttm->page_flags, ttm->caching_state);return -ENOMEM ; } }
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Am 12.01.2018 um 07:14 schrieb Roger He:
Quoted 5 lines
add input parameter for
ttm_dma_unpopulate.
whenttm_dma_pool_get_pagesorttm_mem_global_alloc_pagefail, don't callttm_mem_global_free_pageto update global memory count.Signed-off-by Roger He <[email protected]>
Good catch, but that doesn't looks correct to me.
See the handling in ttm_dma_populate():
Quoted 11 lines
ret =
ttm_dma_pool_get_pages(pool, ttm_dma, i); if (ret != 0)
break;ret =
ttm_mem_global_alloc_page(mem_glob, ttm->pages[i], pool->size, ctx); if (unlikely(ret != 0)) {ttm_dma_unpopulate(ttm_dma, dev); return-ENOMEM;
}
When ttm_mem_global_alloc_page() fails we only missed to account the last allocated page, not all of them.
Additional to that I really don't like adding the new parameter to the drivers.
Regards,
Christian.
Quoted 150 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 2 +- drivers/gpu/drm/nouveau/nouveau_bo.c | 2 +- drivers/gpu/drm/radeon/radeon_ttm.c | 2 +- drivers/gpu/drm/ttm/ttm_page_alloc_dma.c | 19 +++++++++++-------- drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c | 2 +- include/drm/ttm/ttm_page_alloc.h | 5 +++-- 6 files changed, 18 insertions(+), 14 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1
-1@@ -1046,7 +1046,7 @@ static void amdgpu_ttm_tt_unpopulate(struct ttm_tt *ttm)#ifdef CONFIG_SWIOTLB if (swiotlb_nr_tbl ()) { -ttm_dma_unpopulate (>t->ttm, adev->dev); +ttm_dma_unpopulate (>t->ttm, adev->dev, true);return ; }#endif drivers/gpu/drm/nouveau/nouveau_bo.c +1
-1@@ -1632,7 +1632,7 @@ nouveau_ttm_tt_unpopulate(struct ttm_tt *ttm)#if IS_ENABLED (CONFIG_SWIOTLB ) &&IS_ENABLED (CONFIG_X86 )if (swiotlb_nr_tbl ()) { -ttm_dma_unpopulate ((void *)ttm, dev); +ttm_dma_unpopulate ((void *)ttm, dev, true);return ; }#endif drivers/gpu/drm/radeon/radeon_ttm.c +1
-1@@ -789,7 +789,7 @@ static void radeon_ttm_tt_unpopulate(struct ttm_tt *ttm)#ifdef CONFIG_SWIOTLB if (swiotlb_nr_tbl ()) { -ttm_dma_unpopulate (>t->ttm, rdev->dev); +ttm_dma_unpopulate (>t->ttm, rdev->dev, true);return ; }#endif drivers/gpu/drm/ttm/ttm_page_alloc_dma.c +11
-8@@ -969,7 +969,7 @@ int ttm_dma_populate(struct ttm_dma_tt *ttm_dma, struct device *dev, ret =ttm_mem_global_alloc_page (mem_glob, ttm->pages[i], pool->size, ctx);if (unlikely (ret !=0 )) { -ttm_dma_unpopulate (ttm_dma, dev); +ttm_dma_unpopulate (ttm_dma, dev, false);return -ENOMEM ; }@@ -998,14 +998,14 @@ int ttm_dma_populate(struct ttm_dma_tt *ttm_dma, struct device *dev,while (num_pages) { ret =ttm_dma_pool_get_pages (pool, ttm_dma, i);if (ret !=0 ) { -ttm_dma_unpopulate (ttm_dma, dev); +ttm_dma_unpopulate (ttm_dma, dev, false);return -ENOMEM ; } ret =ttm_mem_global_alloc_page (mem_glob, ttm->pages[i], pool->size, ctx);if (unlikely (ret !=0 )) { -ttm_dma_unpopulate (ttm_dma, dev); +ttm_dma_unpopulate (ttm_dma, dev, false);return -ENOMEM ; }@@ -1016,7 +1016,7 @@ int ttm_dma_populate(struct ttm_dma_tt *ttm_dma, struct device *dev,if (unlikely (ttm->page_flags &TTM_PAGE_FLAG_SWAPPED )) { ret =ttm_tt_swapin (ttm);if (unlikely (ret !=0 )) { -ttm_dma_unpopulate (ttm_dma, dev); +ttm_dma_unpopulate (ttm_dma, dev, true);return ret; } }@@ -1027,7 +1027,8 @@ int ttm_dma_populate(struct ttm_dma_tt *ttm_dma, struct device *dev,EXPORT_SYMBOL_GPL (ttm_dma_populate);/* Put all pages in pages list to correct pool to wait for reuse */ -void ttm_dma_unpopulate (struct ttm_dma_tt *ttm_dma,struct device *dev) +void ttm_dma_unpopulate (struct ttm_dma_tt *ttm_dma,struct device *dev, +bool update_glob_count) {struct ttm_tt *ttm = &ttm_dma->ttm;struct dma_pool *pool;@@ -1049,7 +1050,8 @@ void ttm_dma_unpopulate(struct ttm_dma_tt *ttm_dma, struct device *dev)continue ; count++; -ttm_mem_global_free_page (ttm->glob->mem_glob, +if (update_glob_count) +ttm_mem_global_free_page (ttm->glob->mem_glob, d_page->p, pool->size);ttm_dma_page_put (pool, d_page); }@@ -1094,11 +1096,12 @@ void ttm_dma_unpopulate(struct ttm_dma_tt *ttm_dma, struct device *dev)if (is_cached) {list_for_each_entry_safe (d_page, next, &ttm_dma->pages_list, page_list) { -ttm_mem_global_free_page (ttm->glob->mem_glob, +if (update_glob_count) +ttm_mem_global_free_page (ttm->glob->mem_glob, d_page->p, pool->size);ttm_dma_page_put (pool, d_page); } - }else { + }else if (update_glob_count) {for (i =0 ; i < count; i++) {ttm_mem_global_free_page (ttm->glob->mem_glob, ttm->pages[i], pool->size);drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c +1
-1@@ -681,7 +681,7 @@ static void vmw_ttm_unpopulate(struct ttm_tt *ttm)size_t size =ttm_round_pot (ttm->num_pages *sizeof (dma_addr_t)); -ttm_dma_unpopulate (&vmw_tt->dma_ttm, dev_priv->dev->dev); +ttm_dma_unpopulate (&vmw_tt->dma_ttm, dev_priv->dev->dev, true);ttm_mem_global_free (glob, size); }else ttm_pool_unpopulate (ttm);include/drm/ttm/ttm_page_alloc.h +2
-1@@ -92,7 +92,8 @@ int ttm_dma_page_alloc_debugfs(struct seq_file *m, void *data);int ttm_dma_populate (struct ttm_dma_tt *ttm_dma,struct device *dev,struct ttm_operation_ctx *ctx); -void ttm_dma_unpopulate (struct ttm_dma_tt *ttm_dma,struct device *dev); +void ttm_dma_unpopulate (struct ttm_dma_tt *ttm_dma,struct device *dev, +bool update_glob_count);#else static inline int ttm_dma_page_alloc_init(struct ttm_mem_global *glob,
include/drm/ttm/ttm_page_alloc.h static inline int ttm_dma_populate(struct ttm_dma_tt *ttm_dma, · line 121
Quoted 8 lines
include/drm/ttm/ttm_page_alloc.h +1
-1@@ -114,7 +115,7 @@ static inline int ttm_dma_populate(struct ttm_dma_tt *ttm_dma, return -ENOMEM; }static inline void ttm_dma_unpopulate (struct ttm_dma_tt *ttm_dma, -struct device *dev) +struct device *dev,bool update_glob_count); { }#endif
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel