From 524fcca39b72bf4f6a32fcbf051dd0a8b0e67634 Mon Sep 17 00:00:00 2001 From: Lecopzer Chen Date: Fri, 12 Jul 2019 16:47:17 +0800 Subject: [PATCH] staging: android: ion: Remove unused rbtree for ion_buffer Re-apply commit 3e6998b17f36 ("staging: android: ion: Remove unused rbtree for ion_buffer") which has been inadvertently and partly reverted by merge commit bfa0399bc856 ("Merge Linus's 5.4-rc1-prerelease branch into android-mainline"). Later, the following two commits completed the incomplete revert: commit c8e152bc7d05 ("ANDROID: staging: ion: Fix missing entry in kerneldoc header") commit f9aa2c60711d ("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 Cc: YJ Chiang Cc: Lecopzer Chen Acked-by: Laura Abbott Link: https://lore.kernel.org/r/20190712084717.12441-1-lecopzer.chen@mediatek.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/ion/ion.c | 1 - drivers/staging/android/ion/ion_buffer.c | 32 ----------------------- drivers/staging/android/ion/ion_private.h | 4 --- include/linux/ion.h | 6 +---- 4 files changed, 1 insertion(+), 42 deletions(-) diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c index a1d42cc95227..b43655da4d7c 100644 --- a/drivers/staging/android/ion/ion.c +++ b/drivers/staging/android/ion/ion.c @@ -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; diff --git a/drivers/staging/android/ion/ion_buffer.c b/drivers/staging/android/ion/ion_buffer.c index eaca61f1663c..12f180a84ea8 100644 --- a/drivers/staging/android/ion/ion_buffer.c +++ b/drivers/staging/android/ion/ion_buffer.c @@ -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); diff --git a/drivers/staging/android/ion/ion_private.h b/drivers/staging/android/ion/ion_private.h index 2f5376e131c3..ca4ca2389397 100644 --- a/drivers/staging/android/ion/ion_private.h +++ b/drivers/staging/android/ion/ion_private.h @@ -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; diff --git a/include/linux/ion.h b/include/linux/ion.h index 0fdc1e1d4c29..dbcbe0cb7b08 100644 --- a/include/linux/ion.h +++ b/include/linux/ion.h @@ -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;