diff options
author | Patrick Daly <pdaly@codeaurora.org> | 2016-01-21 18:46:43 -0800 |
---|---|---|
committer | David Keitel <dkeitel@codeaurora.org> | 2016-03-25 16:04:19 -0700 |
commit | e0eb556f01254d99cfa3d28b76eef9a94332b14b (patch) | |
tree | ce2874cfc632aad1a9f3d8705f2c7308ebd10e5a | |
parent | d95f3040650ab89f62b9db5f3a4c83299f1a5da7 (diff) |
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.
Change-Id: Ie746362a19a22dceb6e47148d67901d483778a85
Signed-off-by: Patrick Daly <pdaly@codeaurora.org>
-rw-r--r-- | drivers/staging/android/ion/ion.c | 10 | ||||
-rw-r--r-- | drivers/staging/android/ion/ion_priv.h | 3 | ||||
-rw-r--r-- | drivers/staging/android/ion/msm/msm_ion.c | 16 |
3 files changed, 22 insertions, 7 deletions
diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c index 3409ecace582..e1de0064d424 100644 --- a/drivers/staging/android/ion/ion.c +++ b/drivers/staging/android/ion/ion.c @@ -3,7 +3,7 @@ * drivers/staging/android/ion/ion.c * * Copyright (C) 2011 Google, Inc. - * Copyright (c) 2011-2015, The Linux Foundation. All rights reserved. + * Copyright (c) 2011-2016, 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 @@ -1897,10 +1897,11 @@ void ion_device_add_heap(struct ion_device *dev, struct ion_heap *heap) } EXPORT_SYMBOL(ion_device_add_heap); -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; /* @@ -1909,7 +1910,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; diff --git a/drivers/staging/android/ion/ion_priv.h b/drivers/staging/android/ion/ion_priv.h index d665ab9dcc08..bae53350f7df 100644 --- a/drivers/staging/android/ion/ion_priv.h +++ b/drivers/staging/android/ion/ion_priv.h @@ -488,7 +488,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, diff --git a/drivers/staging/android/ion/msm/msm_ion.c b/drivers/staging/android/ion/msm/msm_ion.c index da43a7334949..952edb7c9163 100644 --- a/drivers/staging/android/ion/msm/msm_ion.c +++ b/drivers/staging/android/ion/msm/msm_ion.c @@ -725,16 +725,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; } |