Commit efee5a0c authored by Rebecca Schultz Zavin's avatar Rebecca Schultz Zavin Committed by Greg Kroah-Hartman

gpu: ion: Fix lockdep issue in ion_page_pool

Currently the mutex is held while kmalloc is called, under a low memory
condition this might trigger the shrinker which also takes this mutex.
Refactor so the mutex is not held during allocation.
Signed-off-by: default avatarRebecca Schultz Zavin <rebecca@android.com>
[jstultz: modified patch to apply to staging directory]
Signed-off-by: default avatarJohn Stultz <john.stultz@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 0fb9b815
...@@ -53,6 +53,8 @@ static int ion_page_pool_add(struct ion_page_pool *pool, struct page *page) ...@@ -53,6 +53,8 @@ static int ion_page_pool_add(struct ion_page_pool *pool, struct page *page)
item = kmalloc(sizeof(struct ion_page_pool_item), GFP_KERNEL); item = kmalloc(sizeof(struct ion_page_pool_item), GFP_KERNEL);
if (!item) if (!item)
return -ENOMEM; return -ENOMEM;
mutex_lock(&pool->mutex);
item->page = page; item->page = page;
if (PageHighMem(page)) { if (PageHighMem(page)) {
list_add_tail(&item->list, &pool->high_items); list_add_tail(&item->list, &pool->high_items);
...@@ -61,6 +63,7 @@ static int ion_page_pool_add(struct ion_page_pool *pool, struct page *page) ...@@ -61,6 +63,7 @@ static int ion_page_pool_add(struct ion_page_pool *pool, struct page *page)
list_add_tail(&item->list, &pool->low_items); list_add_tail(&item->list, &pool->low_items);
pool->low_count++; pool->low_count++;
} }
mutex_unlock(&pool->mutex);
return 0; return 0;
} }
...@@ -110,9 +113,7 @@ void ion_page_pool_free(struct ion_page_pool *pool, struct page* page) ...@@ -110,9 +113,7 @@ void ion_page_pool_free(struct ion_page_pool *pool, struct page* page)
{ {
int ret; int ret;
mutex_lock(&pool->mutex);
ret = ion_page_pool_add(pool, page); ret = ion_page_pool_add(pool, page);
mutex_unlock(&pool->mutex);
if (ret) if (ret)
ion_page_pool_free_pages(pool, page); ion_page_pool_free_pages(pool, page);
} }
......
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