Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp615582ybi; Fri, 12 Jul 2019 01:49:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqxwDycHR1z2tvNz3k7/GhtVtRxZBGcnzYilOBKsxmvEn3YmMDAZ5uDZgE5G/y+Ft8OrsVxN X-Received: by 2002:a63:e306:: with SMTP id f6mr9314066pgh.39.1562921341885; Fri, 12 Jul 2019 01:49:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562921341; cv=none; d=google.com; s=arc-20160816; b=x9YgX2zlWWArTocJIipf5fhppmwwqp0Kcpm46Dr7KV3xb9ngG4wsDdKJ3mDP40B0w4 fbg6ye2pDyZZ8RskHCNowrNc1APPyDGHqAaGbRP1Xt1X6y9e7JlXfj1lbV9L6uWqVhWu N4M039WdyF7K5BD8tCDsY9mvIAhoMzsJIVWXrmYJGZCmHVuCU2fpRelDEzvWHmtGUVNt EZpf3iVKt4CtZap2GDh3BL2DtIFX6eQmkScurpF3oeX05o+f19jk3+qjtwtA1TiTG/k/ yj83I15bV41aKATn6PuUdtgvf1vSd8ClqUgFKv0F1FsfMF0vQusYEWZSqOB5ubcN/mlh CzOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=xIEPwPSnFhwZlocHzZW3gimWq+8LpJCvvvI4TDKhMXs=; b=Cq224y5pu1ZwHsQMcfFbN7dPGd7gkwqnM2icMqSpwDvoHKb1Tm8LLK0bJ4WZp82p34 0ch3tiYgqNWfuWPjPhUCK4j7yDJrHFcSuEW8Ur9ipynreA4QbFpX7c6zQTxux77WUPW2 QGdmue82U3fWnDyHYpQtiwcCQJCL1QvVUJNIe+K8oWO84NbDwZbWNX1bCgB49+8sb6d9 WeBUOK5wScf+shqLNi+jAuGnmGDiOImYVGLi1CG/YlFuNat7Bzr4xRDIaRhR8M9GDrVa N4KLW84bhy1mLanSuNsMhS4QjVdmfwUHdR8TV6k84R/fdFHF5W6v9H3uzcpr0lpuDRiT JpEA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r19si7938767pfh.50.2019.07.12.01.48.46; Fri, 12 Jul 2019 01:49:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726411AbfGLIsD (ORCPT + 99 others); Fri, 12 Jul 2019 04:48:03 -0400 Received: from mailgw01.mediatek.com ([210.61.82.183]:35919 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1725877AbfGLIsD (ORCPT ); Fri, 12 Jul 2019 04:48:03 -0400 X-UUID: a6087602278f4ecba3588607e09d4a2c-20190712 X-UUID: a6087602278f4ecba3588607e09d4a2c-20190712 Received: from mtkcas06.mediatek.inc [(172.21.101.30)] by mailgw01.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 1209527918; Fri, 12 Jul 2019 16:47:48 +0800 Received: from mtkcas08.mediatek.inc (172.21.101.126) by mtkmbs01n2.mediatek.inc (172.21.101.79) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Fri, 12 Jul 2019 16:47:46 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas08.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Fri, 12 Jul 2019 16:47:47 +0800 From: Lecopzer Chen To: CC: , , , , , , , Lecopzer Chen , YJ Chiang Subject: [PATCH] staging: android: ion: Remove unused rbtree for ion_buffer Date: Fri, 12 Jul 2019 16:47:17 +0800 Message-ID: <20190712084717.12441-1-lecopzer.chen@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 Content-Type: text/plain X-TM-SNTS-SMTP: 92F56628C2D35BF0FDAA2809FBCCFE1AB61FCD8B124717D9CCEB10392A8CBEA92000:8 X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Signed-off-by: Lecopzer Chen Cc: YJ Chiang Cc: Lecopzer Chen --- drivers/staging/android/ion/ion.c | 36 ------------------------------- drivers/staging/android/ion/ion.h | 10 +-------- 2 files changed, 1 insertion(+), 45 deletions(-) diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c index 92c2914239e3..e6b1ca141b93 100644 --- a/drivers/staging/android/ion/ion.c +++ b/drivers/staging/android/ion/ion.c @@ -29,32 +29,6 @@ static struct ion_device *internal_dev; static int heap_id; -/* 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, @@ -100,9 +74,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: @@ -131,11 +102,6 @@ void ion_buffer_destroy(struct ion_buffer *buffer) static void _ion_buffer_destroy(struct ion_buffer *buffer) { struct ion_heap *heap = buffer->heap; - struct ion_device *dev = buffer->dev; - - 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); @@ -694,8 +660,6 @@ static int ion_device_create(void) } idev->debug_root = debugfs_create_dir("ion", NULL); - idev->buffers = RB_ROOT; - mutex_init(&idev->buffer_lock); init_rwsem(&idev->lock); plist_head_init(&idev->heaps); internal_dev = idev; diff --git a/drivers/staging/android/ion/ion.h b/drivers/staging/android/ion/ion.h index e291299fd35f..74914a266e25 100644 --- a/drivers/staging/android/ion/ion.h +++ b/drivers/staging/android/ion/ion.h @@ -23,7 +23,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 * @dev: back pointer to the ion_device * @heap: back pointer to the heap the buffer came from @@ -39,10 +38,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_device *dev; struct ion_heap *heap; unsigned long flags; @@ -61,14 +57,10 @@ void ion_buffer_destroy(struct ion_buffer *buffer); /** * 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 and clients */ struct ion_device { struct miscdevice dev; - struct rb_root buffers; - struct mutex buffer_lock; struct rw_semaphore lock; struct plist_head heaps; struct dentry *debug_root; -- 2.17.1