Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1240985 > unrolled thread

[RFC][PATCH 0/2] Devicetree bindings for Ion

Started byLaura Abbott <labbott@fedoraproject.org>
First post2015-10-06 22:50 +0200
Last post2015-10-06 23:40 +0200
Articles 5 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [RFC][PATCH 0/2] Devicetree bindings for Ion Laura Abbott <labbott@fedoraproject.org> - 2015-10-06 22:50 +0200
    [RFC][PATCH 2/2] staging: ion: Add files for parsing the devicetree (WIP) Laura Abbott <labbott@fedoraproject.org> - 2015-10-06 22:50 +0200
      Re: [RFC][PATCH 2/2] staging: ion: Add files for parsing the  devicetree (WIP) kbuild test robot <lkp@intel.com> - 2015-10-06 23:40 +0200
      [RFC PATCH] staging: ion: ion_parse_dt_heap_common() can be static kbuild test robot <lkp@intel.com> - 2015-10-06 23:40 +0200
      Re: [RFC][PATCH 2/2] staging: ion: Add files for parsing the  devicetree (WIP) Andrew <andrew@ncrmnt.org> - 2015-10-06 23:40 +0200

#1240985 — [RFC][PATCH 0/2] Devicetree bindings for Ion

FromLaura Abbott <labbott@fedoraproject.org>
Date2015-10-06 22:50 +0200
Subject[RFC][PATCH 0/2] Devicetree bindings for Ion
Message-ID<qgHlo-p0-5@gated-at.bofh.it>
From: Laura Abbott <laura@labbott.name>


Hi,

At the last Plumbers and Linaro Connect, there was some discussion
related to Ion. One of the items that came up towards eventually
getting Ion out of staging was some concept of stable devicetree
bindings. This is a proof of concept for bindings.

Most of this is based on previously submitted work
(https://lkml.org/lkml/2015/6/30/425 thank you Andrew Andrianov for
getting this started!) and also the
out of tree qcom bindings (available somewhere on codeaurora.org).
As the title indicates, this is an RFC and the purpose here is to
get feedback on if these bindings would potentially work. If there
are platforms out there that don't use devicetree, the bindings
would hopefully also serve as a guide for how to setup the platform
data for heaps like CMA.

One of the big things this series improves on is giving a standard
mechanism for defining and allocating memory for all heap types.
DMA/CMA is handled as well as memory for carveout and chunk heaps.

Further TODO:
- Need to fixup include paths so heap types can be cleanly included
  in DTS files
- Figure out callbacks or similar for support custom platform heaps

Laura Abbott (2):
  WIP: Devicetree bindings for Ion
  staging: ion: Add files for parsing the devicetree (WIP)

 drivers/staging/android/ion/Kconfig        |  10 ++
 drivers/staging/android/ion/Makefile       |   7 +-
 drivers/staging/android/ion/devicetree.txt |  53 +++++++++
 drivers/staging/android/ion/ion_of.c       | 185 +++++++++++++++++++++++++++++
 drivers/staging/android/ion/ion_of.h       |   3 +
 5 files changed, 255 insertions(+), 3 deletions(-)
 create mode 100644 drivers/staging/android/ion/devicetree.txt
 create mode 100644 drivers/staging/android/ion/ion_of.c
 create mode 100644 drivers/staging/android/ion/ion_of.h

-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1240986 — [RFC][PATCH 2/2] staging: ion: Add files for parsing the devicetree (WIP)

FromLaura Abbott <labbott@fedoraproject.org>
Date2015-10-06 22:50 +0200
Subject[RFC][PATCH 2/2] staging: ion: Add files for parsing the devicetree (WIP)
Message-ID<qgHlo-p0-17@gated-at.bofh.it>
In reply to#1240985
From: Laura Abbott <laura@labbott.name>


Devicetree is the preferred mechanism for platform definition
these days. Add a set of files for supporting Ion with devicetree.
This includes a set of bindings for heaps common across all
devices and parsing methods. Clients may use the standard
bindings or they can call the parsing functions along with
their own parsing for platform specific heaps.

Signed-off-by: Laura Abbott <laura@labbott.name>
Signed-off-by: Andrew Andrianov <andrew@ncrmnt.org>
---
 drivers/staging/android/ion/Kconfig  |  10 ++
 drivers/staging/android/ion/Makefile |   7 +-
 drivers/staging/android/ion/ion_of.c | 185 +++++++++++++++++++++++++++++++++++
 drivers/staging/android/ion/ion_of.h |   3 +
 4 files changed, 202 insertions(+), 3 deletions(-)
 create mode 100644 drivers/staging/android/ion/ion_of.c
 create mode 100644 drivers/staging/android/ion/ion_of.h

diff --git a/drivers/staging/android/ion/Kconfig b/drivers/staging/android/ion/Kconfig
index 3452346..9b6d65d 100644
--- a/drivers/staging/android/ion/Kconfig
+++ b/drivers/staging/android/ion/Kconfig
@@ -33,3 +33,13 @@ config ION_TEGRA
 	help
 	  Choose this option if you wish to use ion on an nVidia Tegra.
 
+config ION_OF
+	bool "Devicetree support for Ion"
+	depends on ION && OF
+	help
+	  Provides base support for defining Ion heaps in devicetree
+	  and setting them up. Also includes functions for platforms
+	  to parse the devicetree and expand for their own custom
+	  extensions
+
+	  If using Ion and devicetree, you should say Y here
diff --git a/drivers/staging/android/ion/Makefile b/drivers/staging/android/ion/Makefile
index b56fd2b..6602512 100644
--- a/drivers/staging/android/ion/Makefile
+++ b/drivers/staging/android/ion/Makefile
@@ -5,6 +5,7 @@ ifdef CONFIG_COMPAT
 obj-$(CONFIG_ION) += compat_ion.o
 endif
 
-obj-$(CONFIG_ION_DUMMY) += ion_dummy_driver.o
-obj-$(CONFIG_ION_TEGRA) += tegra/
-
+obj-$(CONFIG_ION_DUMMY)   += ion_dummy_driver.o
+obj-$(CONFIG_ION_PHYSMEM) += ion_physmem.o
+obj-$(CONFIG_ION_TEGRA)   += tegra/
+obj-$(CONFIG_ION_OF) +=	ion_of.o ion_physmem.o
diff --git a/drivers/staging/android/ion/ion_of.c b/drivers/staging/android/ion/ion_of.c
new file mode 100644
index 0000000..3c9b1e5
--- /dev/null
+++ b/drivers/staging/android/ion/ion_of.c
@@ -0,0 +1,185 @@
+/*
+ * Based on work from:
+ *   Andrew Andrianov <andrew@ncrmnt.org>
+ *   Google
+ *   The Linux Foundation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/init.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+#include <linux/of.h>
+#include <linux/of_platform.h>
+#include <linux/of_address.h>
+#include <linux/clk.h>
+#include <linux/dma-mapping.h>
+#include <linux/cma.h>
+#include <linux/dma-contiguous.h>
+#include <linux/io.h>
+#include <linux/of_reserved_mem.h>
+#include "ion.h"
+#include "ion_priv.h"
+
+/*
+ * Future work: allow callback function for each heap?
+ */
+
+int ion_parse_dt_heap_common(struct device_node *heap_node,
+			struct ion_platform_heap *heap)
+{
+	u32 ion_heap_id, ion_heap_align, ion_heap_type;
+	const char *ion_heap_name;
+	int ret;
+
+	ret =  of_property_read_string(heap_node, "linux,ion-heap-name",
+					&ion_heap_name);
+	if (ret)
+		return ret;
+
+	ret = of_property_read_u32(heap_node, "linux,ion-heap-id",
+					&ion_heap_id);
+	if (ret)
+		return ret;
+
+	ret = of_property_read_u32(heap_node, "linux,ion-heap-type",
+					&ion_heap_type);
+	if (ret)
+		return ret;
+
+	ret = of_property_read_u32(heap_node, "linux,ion-heap-align",
+					&ion_heap_align);
+	if (ret)
+		/* align is optional so make the alignemnt page size */
+		ion_heap_align = PAGE_SIZE;
+
+	heap->id = ion_heap_id;
+	heap->type = ion_heap_type;
+	heap->name = ion_heap_name;
+	heap->align = ion_heap_align;
+	pr_info("%s: id %d type %d name %s align %x\n",
+			__func__,
+			ion_heap_id, ion_heap_type,
+			ion_heap_name, ion_heap_align);
+	return 0;
+}
+
+int ion_setup_heap_common(struct platform_device *parent,
+			struct device_node *heap_node,
+			struct ion_platform_heap *heap)
+{
+	int ret = 0;
+
+	switch (heap->type) {
+		case ION_HEAP_TYPE_CARVEOUT:
+		case ION_HEAP_TYPE_CHUNK:
+			if (heap->base && heap->size)
+				return 0;
+
+			ret = of_reserved_mem_device_init(heap->priv);
+			break;
+		default:
+			break;
+	}
+
+	return ret;
+}
+
+struct ion_platform_data *ion_parse_dt(struct platform_device *pdev)
+{
+	int num_heaps, ret;
+	const struct device_node *dt_node = pdev->dev.of_node;
+	struct device_node *node;
+	struct ion_platform_heap *heaps;
+	struct ion_platform_data *data;
+	int i = 0;
+
+	num_heaps = of_get_available_child_count(dt_node);
+
+	if (!num_heaps)
+		return ERR_PTR(-EINVAL);
+
+	heaps = devm_kzalloc(&pdev->dev,
+				sizeof(struct ion_platform_heap)*num_heaps,
+				GFP_KERNEL);
+	if (!heaps)
+		return ERR_PTR(-ENOMEM);
+
+	data = devm_kzalloc(&pdev->dev, sizeof(struct ion_platform_data),
+				GFP_KERNEL);
+	if (!data)
+		return ERR_PTR(-ENOMEM);
+
+	for_each_available_child_of_node(dt_node, node) {
+		struct platform_device *heap_pdev;
+
+		ret = ion_parse_dt_heap_common(node, &heaps[i]);
+		if (ret)
+			return ERR_PTR(ret);
+
+		heap_pdev = of_platform_device_create(node, heaps[i].name,
+							&pdev->dev);
+		if (!pdev)
+			return ERR_PTR(-ENOMEM);
+		heap_pdev->dev.platform_data = &heaps[i];
+
+		heaps[i].priv = &heap_pdev->dev;
+
+		ret = ion_setup_heap_common(pdev, node, &heaps[i]);
+		if (ret)
+			return ERR_PTR(ret);
+		i++;
+
+		/* TODO custom callback */
+	}
+
+
+	data->heaps = heaps;
+	data->nr = num_heaps;
+	return data;
+}
+
+#ifdef CONFIG_OF_RESERVED_MEM
+#include <linux/of.h>
+#include <linux/of_fdt.h>
+#include <linux/of_reserved_mem.h>
+
+static int rmem_ion_device_init(struct reserved_mem *rmem, struct device *dev)
+{
+	struct platform_device *pdev = to_platform_device(dev);
+	struct ion_platform_heap *heap = pdev->dev.platform_data;
+
+	heap->base = rmem->base;
+	heap->base = rmem->size;
+	pr_debug("%s: heap %s base %pa size %pa dev %p\n", __func__,
+			heap->name, &rmem->base, &rmem->size, dev);
+	return 0;
+}
+
+static void rmem_ion_device_release(struct reserved_mem *rmem,
+					struct device *dev)
+{
+	return;
+}
+
+static const struct reserved_mem_ops rmem_dma_ops = {
+	.device_init	= rmem_ion_device_init,
+	.device_release	= rmem_ion_device_release,
+};
+
+static int __init rmem_ion_setup(struct reserved_mem *rmem)
+{
+	phys_addr_t size = rmem->size;
+
+	size = size / 1024;
+
+	pr_info("Ion memory setup at %pa size %pa MiB\n",
+		&rmem->base, &size);
+	rmem->ops = &rmem_dma_ops;
+	return 0;
+}
+RESERVEDMEM_OF_DECLARE(ion, "ion-region", rmem_ion_setup);
+#endif
diff --git a/drivers/staging/android/ion/ion_of.h b/drivers/staging/android/ion/ion_of.h
new file mode 100644
index 0000000..b4d1b6d
--- /dev/null
+++ b/drivers/staging/android/ion/ion_of.h
@@ -0,0 +1,3 @@
+/* YES I NEED HEADER */
+
+struct ion_platform_data *ion_parse_dt(struct platform_device *pdev);
-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1241008 — Re: [RFC][PATCH 2/2] staging: ion: Add files for parsing the devicetree (WIP)

Fromkbuild test robot <lkp@intel.com>
Date2015-10-06 23:40 +0200
SubjectRe: [RFC][PATCH 2/2] staging: ion: Add files for parsing the devicetree (WIP)
Message-ID<qgI7L-1zn-1@gated-at.bofh.it>
In reply to#1240986
Hi Laura,

[auto build test WARNING on v4.3-rc4 -- if it's inappropriate base, please ignore]

reproduce:
        # apt-get install sparse
        make ARCH=x86_64 allmodconfig
        make C=1 CF=-D__CHECK_ENDIAN__


sparse warnings: (new ones prefixed by >>)

>> drivers/staging/android/ion/ion_of.c:31:5: sparse: symbol 'ion_parse_dt_heap_common' was not declared. Should it be static?
>> drivers/staging/android/ion/ion_of.c:70:5: sparse: symbol 'ion_setup_heap_common' was not declared. Should it be static?

Please review and possibly fold the followup patch.

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1241010 — [RFC PATCH] staging: ion: ion_parse_dt_heap_common() can be static

Fromkbuild test robot <lkp@intel.com>
Date2015-10-06 23:40 +0200
Subject[RFC PATCH] staging: ion: ion_parse_dt_heap_common() can be static
Message-ID<qgI7M-1zn-11@gated-at.bofh.it>
In reply to#1240986
Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
---
 ion_of.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/android/ion/ion_of.c b/drivers/staging/android/ion/ion_of.c
index 3c9b1e5..daded0c 100644
--- a/drivers/staging/android/ion/ion_of.c
+++ b/drivers/staging/android/ion/ion_of.c
@@ -28,7 +28,7 @@
  * Future work: allow callback function for each heap?
  */
 
-int ion_parse_dt_heap_common(struct device_node *heap_node,
+static int ion_parse_dt_heap_common(struct device_node *heap_node,
 			struct ion_platform_heap *heap)
 {
 	u32 ion_heap_id, ion_heap_align, ion_heap_type;
@@ -67,7 +67,7 @@ int ion_parse_dt_heap_common(struct device_node *heap_node,
 	return 0;
 }
 
-int ion_setup_heap_common(struct platform_device *parent,
+static int ion_setup_heap_common(struct platform_device *parent,
 			struct device_node *heap_node,
 			struct ion_platform_heap *heap)
 {
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1241015 — Re: [RFC][PATCH 2/2] staging: ion: Add files for parsing the devicetree (WIP)

FromAndrew <andrew@ncrmnt.org>
Date2015-10-06 23:40 +0200
SubjectRe: [RFC][PATCH 2/2] staging: ion: Add files for parsing the devicetree (WIP)
Message-ID<qgI7N-1zn-31@gated-at.bofh.it>
In reply to#1240986
Thanks a lot for starting again with dt bindings discussion.
I got carried away by work and never had a chance for a respin of my 
ion-physmem.

I'll try to test these on actual hardware next week and provide more 
detailed
feedback. For now just a small pick:

> -
> +obj-$(CONFIG_ION_DUMMY)   += ion_dummy_driver.o
> +obj-$(CONFIG_ION_PHYSMEM) += ion_physmem.o
> +obj-$(CONFIG_ION_TEGRA)   += tegra/
> +obj-$(CONFIG_ION_OF) +=	ion_of.o ion_physmem.o

ion_physmem.o looks like the one that shouldn't be here, right?

P.S. Anyone interested in a non-android port of libion with
a few helper utils? I had to call it liblinuxion, since libion is 
something
already present in repositories.

-- 
Regards,
Andrew
RC Module
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web