All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nishka Dasgupta <nishkadg.linux@gmail.com>
To: labbott@redhat.com, sumit.semwal@linaro.org,
	gregkh@linuxfoundation.org, arve@android.com, tkjos@android.com,
	maco@android.com, joel@joelfernandes.org, christian@brauner.io,
	devel@driverdev.osuosl.org, dri-devel@lists.freedesktop.org,
	linaro-mm-sig@lists.linaro.org
Cc: Nishka Dasgupta <nishkadg.linux@gmail.com>
Subject: [PATCH 1/2] staging: android: ion: Remove file ion_carveout_heap.c
Date: Wed,  3 Jul 2019 13:48:41 +0530	[thread overview]
Message-ID: <20190703081842.22872-1-nishkadg.linux@gmail.com> (raw)

Remove file ion_carveout_heap.c as its functions and definitions are not
used anywhere.
Issue found with Coccinelle.

Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
Acked-by: Laura Abbott <labbott@redhat.com>
---
 drivers/staging/android/ion/Kconfig           |   9 --
 drivers/staging/android/ion/Makefile          |   1 -
 .../staging/android/ion/ion_carveout_heap.c   | 133 ------------------
 3 files changed, 143 deletions(-)
 delete mode 100644 drivers/staging/android/ion/ion_carveout_heap.c

diff --git a/drivers/staging/android/ion/Kconfig b/drivers/staging/android/ion/Kconfig
index 178df581a8fc..dff641451a89 100644
--- a/drivers/staging/android/ion/Kconfig
+++ b/drivers/staging/android/ion/Kconfig
@@ -18,15 +18,6 @@ config ION_SYSTEM_HEAP
 	  Choose this option to enable the Ion system heap. The system heap
 	  is backed by pages from the buddy allocator. If in doubt, say Y.
 
-config ION_CARVEOUT_HEAP
-	bool "Ion carveout heap support"
-	depends on ION
-	help
-	  Choose this option to enable carveout heaps with Ion. Carveout heaps
-	  are backed by memory reserved from the system. Allocation times are
-	  typically faster at the cost of memory not being used. Unless you
-	  know your system has these regions, you should say N here.
-
 config ION_CHUNK_HEAP
 	bool "Ion chunk heap support"
 	depends on ION
diff --git a/drivers/staging/android/ion/Makefile b/drivers/staging/android/ion/Makefile
index 17f3a7569e3d..0ac5465e2841 100644
--- a/drivers/staging/android/ion/Makefile
+++ b/drivers/staging/android/ion/Makefile
@@ -1,6 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0
 obj-$(CONFIG_ION) += ion.o ion_heap.o
 obj-$(CONFIG_ION_SYSTEM_HEAP) += ion_system_heap.o ion_page_pool.o
-obj-$(CONFIG_ION_CARVEOUT_HEAP) += ion_carveout_heap.o
 obj-$(CONFIG_ION_CHUNK_HEAP) += ion_chunk_heap.o
 obj-$(CONFIG_ION_CMA_HEAP) += ion_cma_heap.o
diff --git a/drivers/staging/android/ion/ion_carveout_heap.c b/drivers/staging/android/ion/ion_carveout_heap.c
deleted file mode 100644
index bb9d614767a2..000000000000
--- a/drivers/staging/android/ion/ion_carveout_heap.c
+++ /dev/null
@@ -1,133 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * ION Memory Allocator carveout heap helper
- *
- * Copyright (C) 2011 Google, Inc.
- */
-
-#include <linux/dma-mapping.h>
-#include <linux/err.h>
-#include <linux/genalloc.h>
-#include <linux/io.h>
-#include <linux/mm.h>
-#include <linux/scatterlist.h>
-#include <linux/slab.h>
-
-#include "ion.h"
-
-#define ION_CARVEOUT_ALLOCATE_FAIL	-1
-
-struct ion_carveout_heap {
-	struct ion_heap heap;
-	struct gen_pool *pool;
-};
-
-static phys_addr_t ion_carveout_allocate(struct ion_heap *heap,
-					 unsigned long size)
-{
-	struct ion_carveout_heap *carveout_heap =
-		container_of(heap, struct ion_carveout_heap, heap);
-	unsigned long offset = gen_pool_alloc(carveout_heap->pool, size);
-
-	if (!offset)
-		return ION_CARVEOUT_ALLOCATE_FAIL;
-
-	return offset;
-}
-
-static void ion_carveout_free(struct ion_heap *heap, phys_addr_t addr,
-			      unsigned long size)
-{
-	struct ion_carveout_heap *carveout_heap =
-		container_of(heap, struct ion_carveout_heap, heap);
-
-	if (addr == ION_CARVEOUT_ALLOCATE_FAIL)
-		return;
-
-	gen_pool_free(carveout_heap->pool, addr, size);
-}
-
-static int ion_carveout_heap_allocate(struct ion_heap *heap,
-				      struct ion_buffer *buffer,
-				      unsigned long size,
-				      unsigned long flags)
-{
-	struct sg_table *table;
-	phys_addr_t paddr;
-	int ret;
-
-	table = kmalloc(sizeof(*table), GFP_KERNEL);
-	if (!table)
-		return -ENOMEM;
-	ret = sg_alloc_table(table, 1, GFP_KERNEL);
-	if (ret)
-		goto err_free;
-
-	paddr = ion_carveout_allocate(heap, size);
-	if (paddr == ION_CARVEOUT_ALLOCATE_FAIL) {
-		ret = -ENOMEM;
-		goto err_free_table;
-	}
-
-	sg_set_page(table->sgl, pfn_to_page(PFN_DOWN(paddr)), size, 0);
-	buffer->sg_table = table;
-
-	return 0;
-
-err_free_table:
-	sg_free_table(table);
-err_free:
-	kfree(table);
-	return ret;
-}
-
-static void ion_carveout_heap_free(struct ion_buffer *buffer)
-{
-	struct ion_heap *heap = buffer->heap;
-	struct sg_table *table = buffer->sg_table;
-	struct page *page = sg_page(table->sgl);
-	phys_addr_t paddr = PFN_PHYS(page_to_pfn(page));
-
-	ion_heap_buffer_zero(buffer);
-
-	ion_carveout_free(heap, paddr, buffer->size);
-	sg_free_table(table);
-	kfree(table);
-}
-
-static struct ion_heap_ops carveout_heap_ops = {
-	.allocate = ion_carveout_heap_allocate,
-	.free = ion_carveout_heap_free,
-	.map_user = ion_heap_map_user,
-	.map_kernel = ion_heap_map_kernel,
-	.unmap_kernel = ion_heap_unmap_kernel,
-};
-
-struct ion_heap *ion_carveout_heap_create(phys_addr_t base, size_t size)
-{
-	struct ion_carveout_heap *carveout_heap;
-	int ret;
-
-	struct page *page;
-
-	page = pfn_to_page(PFN_DOWN(base));
-	ret = ion_heap_pages_zero(page, size, pgprot_writecombine(PAGE_KERNEL));
-	if (ret)
-		return ERR_PTR(ret);
-
-	carveout_heap = kzalloc(sizeof(*carveout_heap), GFP_KERNEL);
-	if (!carveout_heap)
-		return ERR_PTR(-ENOMEM);
-
-	carveout_heap->pool = gen_pool_create(PAGE_SHIFT, -1);
-	if (!carveout_heap->pool) {
-		kfree(carveout_heap);
-		return ERR_PTR(-ENOMEM);
-	}
-	gen_pool_add(carveout_heap->pool, base, size, -1);
-	carveout_heap->heap.ops = &carveout_heap_ops;
-	carveout_heap->heap.type = ION_HEAP_TYPE_CARVEOUT;
-	carveout_heap->heap.flags = ION_HEAP_FLAG_DEFER_FREE;
-
-	return &carveout_heap->heap;
-}
-- 
2.19.1

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

WARNING: multiple messages have this Message-ID (diff)
From: Nishka Dasgupta <nishkadg.linux@gmail.com>
To: labbott@redhat.com, sumit.semwal@linaro.org,
	gregkh@linuxfoundation.org, arve@android.com, tkjos@android.com,
	maco@android.com, joel@joelfernandes.org, christian@brauner.io,
	devel@driverdev.osuosl.org, dri-devel@lists.freedesktop.org,
	linaro-mm-sig@lists.linaro.org
Cc: Nishka Dasgupta <nishkadg.linux@gmail.com>
Subject: [PATCH 1/2] staging: android: ion: Remove file ion_carveout_heap.c
Date: Wed,  3 Jul 2019 13:48:41 +0530	[thread overview]
Message-ID: <20190703081842.22872-1-nishkadg.linux@gmail.com> (raw)

Remove file ion_carveout_heap.c as its functions and definitions are not
used anywhere.
Issue found with Coccinelle.

Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
---
 drivers/staging/android/ion/Kconfig           |   9 --
 drivers/staging/android/ion/Makefile          |   1 -
 .../staging/android/ion/ion_carveout_heap.c   | 133 ------------------
 3 files changed, 143 deletions(-)
 delete mode 100644 drivers/staging/android/ion/ion_carveout_heap.c

diff --git a/drivers/staging/android/ion/Kconfig b/drivers/staging/android/ion/Kconfig
index 178df581a8fc..dff641451a89 100644
--- a/drivers/staging/android/ion/Kconfig
+++ b/drivers/staging/android/ion/Kconfig
@@ -18,15 +18,6 @@ config ION_SYSTEM_HEAP
 	  Choose this option to enable the Ion system heap. The system heap
 	  is backed by pages from the buddy allocator. If in doubt, say Y.
 
-config ION_CARVEOUT_HEAP
-	bool "Ion carveout heap support"
-	depends on ION
-	help
-	  Choose this option to enable carveout heaps with Ion. Carveout heaps
-	  are backed by memory reserved from the system. Allocation times are
-	  typically faster at the cost of memory not being used. Unless you
-	  know your system has these regions, you should say N here.
-
 config ION_CHUNK_HEAP
 	bool "Ion chunk heap support"
 	depends on ION
diff --git a/drivers/staging/android/ion/Makefile b/drivers/staging/android/ion/Makefile
index 17f3a7569e3d..0ac5465e2841 100644
--- a/drivers/staging/android/ion/Makefile
+++ b/drivers/staging/android/ion/Makefile
@@ -1,6 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0
 obj-$(CONFIG_ION) += ion.o ion_heap.o
 obj-$(CONFIG_ION_SYSTEM_HEAP) += ion_system_heap.o ion_page_pool.o
-obj-$(CONFIG_ION_CARVEOUT_HEAP) += ion_carveout_heap.o
 obj-$(CONFIG_ION_CHUNK_HEAP) += ion_chunk_heap.o
 obj-$(CONFIG_ION_CMA_HEAP) += ion_cma_heap.o
diff --git a/drivers/staging/android/ion/ion_carveout_heap.c b/drivers/staging/android/ion/ion_carveout_heap.c
deleted file mode 100644
index bb9d614767a2..000000000000
--- a/drivers/staging/android/ion/ion_carveout_heap.c
+++ /dev/null
@@ -1,133 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * ION Memory Allocator carveout heap helper
- *
- * Copyright (C) 2011 Google, Inc.
- */
-
-#include <linux/dma-mapping.h>
-#include <linux/err.h>
-#include <linux/genalloc.h>
-#include <linux/io.h>
-#include <linux/mm.h>
-#include <linux/scatterlist.h>
-#include <linux/slab.h>
-
-#include "ion.h"
-
-#define ION_CARVEOUT_ALLOCATE_FAIL	-1
-
-struct ion_carveout_heap {
-	struct ion_heap heap;
-	struct gen_pool *pool;
-};
-
-static phys_addr_t ion_carveout_allocate(struct ion_heap *heap,
-					 unsigned long size)
-{
-	struct ion_carveout_heap *carveout_heap =
-		container_of(heap, struct ion_carveout_heap, heap);
-	unsigned long offset = gen_pool_alloc(carveout_heap->pool, size);
-
-	if (!offset)
-		return ION_CARVEOUT_ALLOCATE_FAIL;
-
-	return offset;
-}
-
-static void ion_carveout_free(struct ion_heap *heap, phys_addr_t addr,
-			      unsigned long size)
-{
-	struct ion_carveout_heap *carveout_heap =
-		container_of(heap, struct ion_carveout_heap, heap);
-
-	if (addr == ION_CARVEOUT_ALLOCATE_FAIL)
-		return;
-
-	gen_pool_free(carveout_heap->pool, addr, size);
-}
-
-static int ion_carveout_heap_allocate(struct ion_heap *heap,
-				      struct ion_buffer *buffer,
-				      unsigned long size,
-				      unsigned long flags)
-{
-	struct sg_table *table;
-	phys_addr_t paddr;
-	int ret;
-
-	table = kmalloc(sizeof(*table), GFP_KERNEL);
-	if (!table)
-		return -ENOMEM;
-	ret = sg_alloc_table(table, 1, GFP_KERNEL);
-	if (ret)
-		goto err_free;
-
-	paddr = ion_carveout_allocate(heap, size);
-	if (paddr == ION_CARVEOUT_ALLOCATE_FAIL) {
-		ret = -ENOMEM;
-		goto err_free_table;
-	}
-
-	sg_set_page(table->sgl, pfn_to_page(PFN_DOWN(paddr)), size, 0);
-	buffer->sg_table = table;
-
-	return 0;
-
-err_free_table:
-	sg_free_table(table);
-err_free:
-	kfree(table);
-	return ret;
-}
-
-static void ion_carveout_heap_free(struct ion_buffer *buffer)
-{
-	struct ion_heap *heap = buffer->heap;
-	struct sg_table *table = buffer->sg_table;
-	struct page *page = sg_page(table->sgl);
-	phys_addr_t paddr = PFN_PHYS(page_to_pfn(page));
-
-	ion_heap_buffer_zero(buffer);
-
-	ion_carveout_free(heap, paddr, buffer->size);
-	sg_free_table(table);
-	kfree(table);
-}
-
-static struct ion_heap_ops carveout_heap_ops = {
-	.allocate = ion_carveout_heap_allocate,
-	.free = ion_carveout_heap_free,
-	.map_user = ion_heap_map_user,
-	.map_kernel = ion_heap_map_kernel,
-	.unmap_kernel = ion_heap_unmap_kernel,
-};
-
-struct ion_heap *ion_carveout_heap_create(phys_addr_t base, size_t size)
-{
-	struct ion_carveout_heap *carveout_heap;
-	int ret;
-
-	struct page *page;
-
-	page = pfn_to_page(PFN_DOWN(base));
-	ret = ion_heap_pages_zero(page, size, pgprot_writecombine(PAGE_KERNEL));
-	if (ret)
-		return ERR_PTR(ret);
-
-	carveout_heap = kzalloc(sizeof(*carveout_heap), GFP_KERNEL);
-	if (!carveout_heap)
-		return ERR_PTR(-ENOMEM);
-
-	carveout_heap->pool = gen_pool_create(PAGE_SHIFT, -1);
-	if (!carveout_heap->pool) {
-		kfree(carveout_heap);
-		return ERR_PTR(-ENOMEM);
-	}
-	gen_pool_add(carveout_heap->pool, base, size, -1);
-	carveout_heap->heap.ops = &carveout_heap_ops;
-	carveout_heap->heap.type = ION_HEAP_TYPE_CARVEOUT;
-	carveout_heap->heap.flags = ION_HEAP_FLAG_DEFER_FREE;
-
-	return &carveout_heap->heap;
-}
-- 
2.19.1

             reply	other threads:[~2019-07-03  8:18 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-03  8:18 Nishka Dasgupta [this message]
2019-07-03  8:18 ` [PATCH 1/2] staging: android: ion: Remove file ion_carveout_heap.c Nishka Dasgupta
2019-07-03  8:18 ` [PATCH 2/2] staging: android: ion: Remove file ion_chunk_heap.c Nishka Dasgupta
2019-07-03  8:18   ` Nishka Dasgupta
2019-07-03 11:33   ` Laura Abbott
2019-07-03 11:33     ` Laura Abbott
2019-07-03  8:37 ` [PATCH 1/2] staging: android: ion: Remove file ion_carveout_heap.c Greg KH
2019-07-03  8:37   ` Greg KH
2019-07-03  8:44   ` Nishka Dasgupta
2019-07-03  8:44     ` Nishka Dasgupta
2019-07-03  9:10     ` Greg KH
2019-07-03  9:10       ` Greg KH
2019-07-03  9:50   ` Daniel Vetter
2019-07-03  9:50     ` Daniel Vetter
2019-07-03 11:32     ` Laura Abbott
2019-07-03 11:32       ` Laura Abbott
2019-07-03 16:24       ` Greg KH
2019-07-03 16:24         ` Greg KH
2019-07-03 19:36       ` John Stultz
2019-07-03 19:36         ` John Stultz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190703081842.22872-1-nishkadg.linux@gmail.com \
    --to=nishkadg.linux@gmail.com \
    --cc=arve@android.com \
    --cc=christian@brauner.io \
    --cc=devel@driverdev.osuosl.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=joel@joelfernandes.org \
    --cc=labbott@redhat.com \
    --cc=linaro-mm-sig@lists.linaro.org \
    --cc=maco@android.com \
    --cc=sumit.semwal@linaro.org \
    --cc=tkjos@android.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.