Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 919ca1a9 authored by Lecopzer Chen's avatar Lecopzer Chen Committed by Daniel Mentz
Browse files

staging: android: ion: Remove unused rbtree for ion_buffer



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

commit c8e152bc ("ANDROID: staging: ion: Fix missing entry in
kerneldoc header")
commit f9aa2c60 ("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: default avatarLecopzer Chen <lecopzer.chen@mediatek.com>
Cc: YJ Chiang <yj.chiang@mediatek.com>
Cc: Lecopzer Chen <lecopzer.chen@mediatek.com>
Acked-by: default avatarLaura Abbott <labbott@redhat.com>
Link: https://lore.kernel.org/r/20190712084717.12441-1-lecopzer.chen@mediatek.com


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 524fcca39b72bf4f6a32fcbf051dd0a8b0e67634)
parent 63dd580f
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -424,7 +424,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;
+0 −32
Original line number Diff line number Diff line
@@ -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);
+0 −4
Original line number Diff line number Diff line
@@ -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;
+1 −5
Original line number Diff line number Diff line
@@ -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 ion_heap *heap;
	unsigned long flags;
	unsigned long private_flags;