staging: android: ion: Remove unused rbtree for ion_buffer

Re-apply commit 3e6998b17f ("staging: android: ion: Remove unused
rbtree for ion_buffer") which has been inadvertently and partly reverted
by merge commit bfa0399bc8
("Merge Linus's 5.4-rc1-prerelease branch into android-mainline").
Later, the following two commits completed the incomplete revert:

commit c8e152bc7d ("ANDROID: staging: ion: Fix missing entry in
kerneldoc header")
commit f9aa2c6071 ("ANDROID: ion: Fix buffer_lock mutex
initialization")

This commit re-applies the original commit, i.e. it removes the unused
rbtree again.

ion_buffer_add() insert ion_buffer into rbtree every time creating
an ion_buffer but never use it after ION reworking.
Also, buffer_lock protects only rbtree operation, remove it together.

Change-Id: I56cc75fbc84d7412fb4d090f577b5d4a6980b879
Signed-off-by: Lecopzer Chen <lecopzer.chen@mediatek.com>
Cc: YJ Chiang <yj.chiang@mediatek.com>
Cc: Lecopzer Chen <lecopzer.chen@mediatek.com>
Acked-by: Laura Abbott <labbott@redhat.com>
Link: https://lore.kernel.org/r/20190712084717.12441-1-lecopzer.chen@mediatek.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Lecopzer Chen
2019-07-12 16:47:17 +08:00
committed by Daniel Mentz
parent ac049f22f1
commit 524fcca39b
4 changed files with 1 additions and 42 deletions

View File

@@ -422,7 +422,6 @@ static int ion_device_create(void)
idev->debug_root = debugfs_create_dir("ion", NULL);
init_rwsem(&idev->lock);
mutex_init(&idev->buffer_lock);
plist_head_init(&idev->heaps);
internal_dev = idev;
return 0;

View File

@@ -13,32 +13,6 @@
#include "ion_private.h"
/* this function should only be called while dev->lock is held */
static void ion_buffer_add(struct ion_device *dev,
struct ion_buffer *buffer)
{
struct rb_node **p = &dev->buffers.rb_node;
struct rb_node *parent = NULL;
struct ion_buffer *entry;
while (*p) {
parent = *p;
entry = rb_entry(parent, struct ion_buffer, node);
if (buffer < entry) {
p = &(*p)->rb_left;
} else if (buffer > entry) {
p = &(*p)->rb_right;
} else {
pr_err("%s: buffer already found.", __func__);
BUG();
}
}
rb_link_node(&buffer->node, parent, p);
rb_insert_color(&buffer->node, &dev->buffers);
}
/* this function should only be called while dev->lock is held */
static struct ion_buffer *ion_buffer_create(struct ion_heap *heap,
struct ion_device *dev,
@@ -91,9 +65,6 @@ static struct ion_buffer *ion_buffer_create(struct ion_heap *heap,
INIT_LIST_HEAD(&buffer->attachments);
mutex_init(&buffer->lock);
mutex_lock(&dev->buffer_lock);
ion_buffer_add(dev, buffer);
mutex_unlock(&dev->buffer_lock);
return buffer;
err1:
@@ -244,9 +215,6 @@ int ion_buffer_destroy(struct ion_device *dev, struct ion_buffer *buffer)
}
heap = buffer->heap;
mutex_lock(&dev->buffer_lock);
rb_erase(&buffer->node, &dev->buffers);
mutex_unlock(&dev->buffer_lock);
if (heap->flags & ION_HEAP_FLAG_DEFER_FREE)
ion_heap_freelist_add(heap, buffer);

View File

@@ -21,16 +21,12 @@
/**
* struct ion_device - the metadata of the ion device node
* @dev: the actual misc device
* @buffers: an rb tree of all the existing buffers
* @buffer_lock: lock protecting the tree of buffers
* @lock: rwsem protecting the tree of heaps, heap_bitmap and
* clients
* @heap_ids: bitmap of register heap ids
*/
struct ion_device {
struct miscdevice dev;
struct rb_root buffers;
struct mutex buffer_lock;
struct rw_semaphore lock;
DECLARE_BITMAP(heap_ids, ION_NUM_MAX_HEAPS);
struct plist_head heaps;

View File

@@ -22,7 +22,6 @@
/**
* struct ion_buffer - metadata for a particular buffer
* @node: node in the ion_device buffers tree
* @list: element in list of deferred freeable buffers
* @heap: back pointer to the heap the buffer came from
* @flags: buffer specific flags
@@ -37,10 +36,7 @@
* @attachments: list of devices attached to this buffer
*/
struct ion_buffer {
union {
struct rb_node node;
struct list_head list;
};
struct list_head list;
struct ion_heap *heap;
unsigned long flags;
unsigned long private_flags;