Commit 5c42c64f authored by Christian König's avatar Christian König Committed by Alex Deucher

drm/ttm: fix the fix for huge compound pages

We don't use compound pages at the moment. Take this into account when
freeing them.
Signed-off-by: default avatarChristian König <christian.koenig@amd.comd>
Reviewed-and-Tested-by: default avatarMichel Dänzer <michel.daenzer@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent c057c114
...@@ -733,22 +733,33 @@ static void ttm_put_pages(struct page **pages, unsigned npages, int flags, ...@@ -733,22 +733,33 @@ static void ttm_put_pages(struct page **pages, unsigned npages, int flags,
/* No pool for this memory type so free the pages */ /* No pool for this memory type so free the pages */
i = 0; i = 0;
while (i < npages) { while (i < npages) {
unsigned order; #ifdef CONFIG_TRANSPARENT_HUGEPAGE
struct page *p = pages[i];
#endif
unsigned order = 0, j;
if (!pages[i]) { if (!pages[i]) {
++i; ++i;
continue; continue;
} }
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
for (j = 0; j < HPAGE_PMD_NR; ++j)
if (p++ != pages[i + j])
break;
if (j == HPAGE_PMD_NR)
order = HPAGE_PMD_ORDER;
#endif
if (page_count(pages[i]) != 1) if (page_count(pages[i]) != 1)
pr_err("Erroneous page count. Leaking pages.\n"); pr_err("Erroneous page count. Leaking pages.\n");
order = compound_order(pages[i]);
__free_pages(pages[i], order); __free_pages(pages[i], order);
order = 1 << order; j = 1 << order;
while (order) { while (j) {
pages[i++] = NULL; pages[i++] = NULL;
--order; --j;
} }
} }
return; return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment