Commit 7eb88bff authored by Heesub Shin's avatar Heesub Shin Committed by Greg Kroah-Hartman

staging: ion: remove struct page_info

ION system heap creates a temporary list of pages to build
scatter/gather table, introducing an internal data type, page_info. Now
that the order field has been removed from it, we do not need to depend
on such data type anymore.
Signed-off-by: default avatarHeesub Shin <heesub.shin@samsung.com>
Reviewed-by: default avatarMitchel Humpherys <mitchelh@codeaurora.org>
Tested-by: default avatarJohn Stultz <john.stultz@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent d10e4ffd
...@@ -52,11 +52,6 @@ struct ion_system_heap { ...@@ -52,11 +52,6 @@ struct ion_system_heap {
struct ion_page_pool **pools; struct ion_page_pool **pools;
}; };
struct page_info {
struct page *page;
struct list_head list;
};
static struct page *alloc_buffer_page(struct ion_system_heap *heap, static struct page *alloc_buffer_page(struct ion_system_heap *heap,
struct ion_buffer *buffer, struct ion_buffer *buffer,
unsigned long order) unsigned long order)
...@@ -98,19 +93,14 @@ static void free_buffer_page(struct ion_system_heap *heap, ...@@ -98,19 +93,14 @@ static void free_buffer_page(struct ion_system_heap *heap,
} }
static struct page_info *alloc_largest_available(struct ion_system_heap *heap, static struct page *alloc_largest_available(struct ion_system_heap *heap,
struct ion_buffer *buffer, struct ion_buffer *buffer,
unsigned long size, unsigned long size,
unsigned int max_order) unsigned int max_order)
{ {
struct page *page; struct page *page;
struct page_info *info;
int i; int i;
info = kmalloc(sizeof(struct page_info), GFP_KERNEL);
if (!info)
return NULL;
for (i = 0; i < num_orders; i++) { for (i = 0; i < num_orders; i++) {
if (size < order_to_size(orders[i])) if (size < order_to_size(orders[i]))
continue; continue;
...@@ -121,10 +111,8 @@ static struct page_info *alloc_largest_available(struct ion_system_heap *heap, ...@@ -121,10 +111,8 @@ static struct page_info *alloc_largest_available(struct ion_system_heap *heap,
if (!page) if (!page)
continue; continue;
info->page = page; return page;
return info;
} }
kfree(info);
return NULL; return NULL;
} }
...@@ -140,7 +128,7 @@ static int ion_system_heap_allocate(struct ion_heap *heap, ...@@ -140,7 +128,7 @@ static int ion_system_heap_allocate(struct ion_heap *heap,
struct sg_table *table; struct sg_table *table;
struct scatterlist *sg; struct scatterlist *sg;
struct list_head pages; struct list_head pages;
struct page_info *info, *tmp_info; struct page *page, *tmp_page;
int i = 0; int i = 0;
unsigned long size_remaining = PAGE_ALIGN(size); unsigned long size_remaining = PAGE_ALIGN(size);
unsigned int max_order = orders[0]; unsigned int max_order = orders[0];
...@@ -153,13 +141,13 @@ static int ion_system_heap_allocate(struct ion_heap *heap, ...@@ -153,13 +141,13 @@ static int ion_system_heap_allocate(struct ion_heap *heap,
INIT_LIST_HEAD(&pages); INIT_LIST_HEAD(&pages);
while (size_remaining > 0) { while (size_remaining > 0) {
info = alloc_largest_available(sys_heap, buffer, size_remaining, page = alloc_largest_available(sys_heap, buffer, size_remaining,
max_order); max_order);
if (!info) if (!page)
goto free_pages; goto free_pages;
list_add_tail(&info->list, &pages); list_add_tail(&page->lru, &pages);
size_remaining -= PAGE_SIZE << compound_order(info->page); size_remaining -= PAGE_SIZE << compound_order(page);
max_order = compound_order(info->page); max_order = compound_order(page);
i++; i++;
} }
table = kmalloc(sizeof(struct sg_table), GFP_KERNEL); table = kmalloc(sizeof(struct sg_table), GFP_KERNEL);
...@@ -170,12 +158,10 @@ static int ion_system_heap_allocate(struct ion_heap *heap, ...@@ -170,12 +158,10 @@ static int ion_system_heap_allocate(struct ion_heap *heap,
goto free_table; goto free_table;
sg = table->sgl; sg = table->sgl;
list_for_each_entry_safe(info, tmp_info, &pages, list) { list_for_each_entry_safe(page, tmp_page, &pages, lru) {
struct page *page = info->page;
sg_set_page(sg, page, PAGE_SIZE << compound_order(page), 0); sg_set_page(sg, page, PAGE_SIZE << compound_order(page), 0);
sg = sg_next(sg); sg = sg_next(sg);
list_del(&info->list); list_del(&page->lru);
kfree(info);
} }
buffer->priv_virt = table; buffer->priv_virt = table;
...@@ -184,11 +170,8 @@ static int ion_system_heap_allocate(struct ion_heap *heap, ...@@ -184,11 +170,8 @@ static int ion_system_heap_allocate(struct ion_heap *heap,
free_table: free_table:
kfree(table); kfree(table);
free_pages: free_pages:
list_for_each_entry_safe(info, tmp_info, &pages, list) { list_for_each_entry_safe(page, tmp_page, &pages, lru)
free_buffer_page(sys_heap, buffer, info->page, free_buffer_page(sys_heap, buffer, page, compound_order(page));
compound_order(info->page));
kfree(info);
}
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