drm/ttm: add the missed global memory count update
Subsystems (3)
PATCH 1/1 drm/ttm: add the missed global memory count update
when ttm_mem_global_alloc_page fails, we should call ttm_mem_global_free_page to update memory count for the ttm pages which already run ttm_mem_global_alloc_page successfully
Signed-off-by Roger He <[email protected]>
--- drivers/gpu/drm/ttm/ttm_page_alloc.c | 41 ++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 16 deletions(-)
drivers/gpu/drm/ttm/ttm_page_alloc.c +25 -16
@@ -1063,6 +1063,28 @@ void ttm_page_alloc_fini(void) _manager =NULL ; } +static void +ttm_pool_unpopulate_helper (struct ttm_tt *ttm,unsigned mem_count_update) +{ +unsigned i; + +if (mem_count_update ==0 ) + goto put_pages; + +for (i =0 ; i < mem_count_update; ++i) { +if (!ttm->pages[i]) +continue ; + +ttm_mem_global_free_page (ttm->glob->mem_glob, ttm->pages[i], +PAGE_SIZE ); + } + +put_pages: +ttm_put_pages (ttm->pages, ttm->num_pages, ttm->page_flags, + ttm->caching_state); + ttm->state = tt_unpopulated; +} +int ttm_pool_populate (struct ttm_tt *ttm,struct ttm_operation_ctx *ctx) {struct ttm_mem_global *mem_glob = ttm->glob->mem_glob;
@@ -1075,8 +1097,7 @@ 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_put_pages (ttm->pages, ttm->num_pages, ttm->page_flags, - ttm->caching_state); +ttm_pool_unpopulate_helper (ttm,0 );return ret; }
@@ -1084,8 +1105,7 @@ 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_put_pages (ttm->pages, ttm->num_pages, - ttm->page_flags, ttm->caching_state); +ttm_pool_unpopulate_helper (ttm, i);return -ENOMEM ; } }
@@ -1105,18 +1125,7 @@ EXPORT_SYMBOL(ttm_pool_populate);void ttm_pool_unpopulate (struct ttm_tt *ttm) { -unsigned i; - -for (i =0 ; i < ttm->num_pages; ++i) { -if (!ttm->pages[i]) -continue ; - -ttm_mem_global_free_page (ttm->glob->mem_glob, ttm->pages[i], -PAGE_SIZE ); - } -ttm_put_pages (ttm->pages, ttm->num_pages, ttm->page_flags, - ttm->caching_state); - ttm->state = tt_unpopulated; +ttm_pool_unpopulate_helper (ttm, ttm->num_pages); }EXPORT_SYMBOL (ttm_pool_unpopulate);
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Am 19.01.2018 um 09:11 schrieb Roger He:
Quoted 6 lines
when
ttm_mem_global_alloc_pagefails, we should callttm_mem_global_free_pageto update memory count for the ttm pages which already runttm_mem_global_alloc_pagesuccessfullySigned-off-by Roger He <[email protected]>
Reviewed-by Christian König <[email protected]>
Quoted 67 lines
--- drivers/gpu/drm/ttm/ttm_page_alloc.c | 41 ++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 16 deletions(-)drivers/gpu/drm/ttm/ttm_page_alloc.c +24
-10@@ -1063,6 +1063,28 @@ void ttm_page_alloc_fini(void) _manager =NULL ; } +static void +ttm_pool_unpopulate_helper (struct ttm_tt *ttm,unsigned mem_count_update) +{ +unsigned i; + +if (mem_count_update ==0 ) + goto put_pages; + +for (i =0 ; i < mem_count_update; ++i) { +if (!ttm->pages[i]) +continue ; + +ttm_mem_global_free_page (ttm->glob->mem_glob, ttm->pages[i], +PAGE_SIZE ); + } + +put_pages: +ttm_put_pages (ttm->pages, ttm->num_pages, ttm->page_flags, + ttm->caching_state); + ttm->state = tt_unpopulated; +} +int ttm_pool_populate (struct ttm_tt *ttm,struct ttm_operation_ctx *ctx) {struct ttm_mem_global *mem_glob = ttm->glob->mem_glob;@@ -1075,8 +1097,7 @@ 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_put_pages (ttm->pages, ttm->num_pages, ttm->page_flags, - ttm->caching_state); +ttm_pool_unpopulate_helper (ttm,0 );return ret; }@@ -1084,8 +1105,7 @@ 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_put_pages (ttm->pages, ttm->num_pages, - ttm->page_flags, ttm->caching_state); +ttm_pool_unpopulate_helper (ttm, i);return -ENOMEM ; } }@@ -1105,18 +1125,7 @@ EXPORT_SYMBOL(ttm_pool_populate);void ttm_pool_unpopulate (struct ttm_tt *ttm) { -unsigned i; - -for (i =0 ; i < ttm->num_pages; ++i) { -if (!ttm->pages[i]) -continue ; -
drivers/gpu/drm/ttm/ttm_page_alloc.c EXPORT_SYMBOL(ttm_pool_populate); · line 1131
Quoted 10 lines
drivers/gpu/drm/ttm/ttm_page_alloc.c +1
-6-ttm_mem_global_free_page (ttm->glob->mem_glob, ttm->pages[i], -PAGE_SIZE ); - } -ttm_put_pages (ttm->pages, ttm->num_pages, ttm->page_flags, - ttm->caching_state); - ttm->state = tt_unpopulated; +ttm_pool_unpopulate_helper (ttm, ttm->num_pages); }EXPORT_SYMBOL (ttm_pool_unpopulate);
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel