Commit fce48bf1 authored by Hans de Goede's avatar Hans de Goede Committed by Mauro Carvalho Chehab

media: atomisp: hmm_bo: Further simplify alloc_private_pages()

Further simplify alloc_private_pages().
Reviewed-by: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
parent 8519635c
...@@ -642,21 +642,11 @@ static void free_private_bo_pages(struct hmm_buffer_object *bo, ...@@ -642,21 +642,11 @@ static void free_private_bo_pages(struct hmm_buffer_object *bo,
/*Allocate pages which will be used only by ISP*/ /*Allocate pages which will be used only by ISP*/
static int alloc_private_pages(struct hmm_buffer_object *bo) static int alloc_private_pages(struct hmm_buffer_object *bo)
{ {
int ret; const gfp_t gfp = __GFP_NOWARN | __GFP_RECLAIM | __GFP_FS;
unsigned int pgnr, blk_pgnr, alloc_pgnr;
struct page *pages; struct page *pages;
gfp_t gfp = GFP_NOWAIT | __GFP_NOWARN; /* REVISIT: need __GFP_FS too? */ int i, ret;
int i, j;
pgnr = bo->pgnr;
i = 0;
alloc_pgnr = 0;
while (pgnr) {
gfp &= ~GFP_NOWAIT;
gfp |= __GFP_RECLAIM | __GFP_FS;
for (i = 0; i < bo->pgnr; i++) {
pages = alloc_pages(gfp, 0); // alloc 1 page pages = alloc_pages(gfp, 0); // alloc 1 page
if (unlikely(!pages)) { if (unlikely(!pages)) {
dev_err(atomisp_dev, dev_err(atomisp_dev,
...@@ -664,12 +654,10 @@ static int alloc_private_pages(struct hmm_buffer_object *bo) ...@@ -664,12 +654,10 @@ static int alloc_private_pages(struct hmm_buffer_object *bo)
__func__); __func__);
goto cleanup; goto cleanup;
} else { } else {
blk_pgnr = 1;
/* /*
* set memory to uncacheable -- UC_MINUS * set memory to uncacheable -- UC_MINUS
*/ */
ret = set_pages_uc(pages, blk_pgnr); ret = set_pages_uc(pages, 1);
if (ret) { if (ret) {
dev_err(atomisp_dev, dev_err(atomisp_dev,
"set page uncacheablefailed.\n"); "set page uncacheablefailed.\n");
...@@ -679,18 +667,13 @@ static int alloc_private_pages(struct hmm_buffer_object *bo) ...@@ -679,18 +667,13 @@ static int alloc_private_pages(struct hmm_buffer_object *bo)
goto cleanup; goto cleanup;
} }
for (j = 0; j < blk_pgnr; j++, i++) { bo->pages[i] = pages;
bo->pages[i] = pages + j;
}
pgnr -= blk_pgnr;
} }
} }
return 0; return 0;
cleanup: cleanup:
alloc_pgnr = i; free_private_bo_pages(bo, i);
free_private_bo_pages(bo, alloc_pgnr);
return -ENOMEM; return -ENOMEM;
} }
......
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