ion: Improve support for heap walking

Clients may wish to implement custom functions on a particular
heap ID. That function assumes that the heap ID has a specific heap
type. Make that requirement explicit by only calling the custom
function if both the ID and type match.

CRs-Fixed: 2078339
Change-Id: Ie746362a19a22dceb6e47148d67901d483778a85
Signed-off-by: Patrick Daly <pdaly@codeaurora.org>
Signed-off-by: Sudarshan Rajagopalan <sudaraja@codeaurora.org>
This commit is contained in:
Patrick Daly 2016-01-21 18:46:43 -08:00 committed by Gerrit - the friendly Code Review server
parent 931a70e8bf
commit 40a4bab422
3 changed files with 24 additions and 9 deletions

View File

@ -1,6 +1,6 @@
/*
* drivers/gpu/ion/ion.c
* drivers/staging/android/ion/ion.c
*
* Copyright (C) 2011 Google, Inc.
* Copyright (c) 2011-2017, The Linux Foundation. All rights reserved.
@ -2015,10 +2015,11 @@ void ion_device_add_heap(struct ion_device *dev, struct ion_heap *heap)
up_write(&dev->lock);
}
int ion_walk_heaps(struct ion_client *client, int heap_id, void *data,
int ion_walk_heaps(struct ion_client *client, int heap_id,
enum ion_heap_type type, void *data,
int (*f)(struct ion_heap *heap, void *data))
{
int ret_val = -EINVAL;
int ret_val = 0;
struct ion_heap *heap;
struct ion_device *dev = client->dev;
/*
@ -2027,7 +2028,8 @@ int ion_walk_heaps(struct ion_client *client, int heap_id, void *data,
*/
down_write(&dev->lock);
plist_for_each_entry(heap, &dev->heaps, node) {
if (ION_HEAP(heap->id) != heap_id)
if (ION_HEAP(heap->id) != heap_id ||
type != heap->type)
continue;
ret_val = f(heap, data);
break;

View File

@ -1,8 +1,8 @@
/*
* drivers/gpu/ion/ion_priv.h
* drivers/staging/android/ion/ion_priv.h
*
* Copyright (C) 2011 Google, Inc.
* Copyright (c) 2011-2015, The Linux Foundation. All rights reserved.
* Copyright (c) 2011-2017, The Linux Foundation. All rights reserved.
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
@ -441,7 +441,8 @@ int ion_page_pool_shrink(struct ion_page_pool *pool, gfp_t gfp_mask,
void ion_pages_sync_for_device(struct device *dev, struct page *page,
size_t size, enum dma_data_direction dir);
int ion_walk_heaps(struct ion_client *client, int heap_id, void *data,
int ion_walk_heaps(struct ion_client *client, int heap_id,
enum ion_heap_type type, void *data,
int (*f)(struct ion_heap *heap, void *data));
struct ion_handle *ion_handle_get_by_id(struct ion_client *client,

View File

@ -756,16 +756,28 @@ long msm_ion_custom_ioctl(struct ion_client *client,
}
case ION_IOC_PREFETCH:
{
ion_walk_heaps(client, data.prefetch_data.heap_id,
int ret;
ret = ion_walk_heaps(client, data.prefetch_data.heap_id,
ION_HEAP_TYPE_SECURE_DMA,
(void *)data.prefetch_data.len,
ion_secure_cma_prefetch);
if (ret)
return ret;
break;
}
case ION_IOC_DRAIN:
{
ion_walk_heaps(client, data.prefetch_data.heap_id,
int ret;
ret = ion_walk_heaps(client, data.prefetch_data.heap_id,
ION_HEAP_TYPE_SECURE_DMA,
(void *)data.prefetch_data.len,
ion_secure_cma_drain_pool);
if (ret)
return ret;
break;
}