Skip to contentSkip to conversation

docs: dts: Add documentation for hi6220 SoC ION node

PATCH In review Chen Feng 2 participants 5 messages Oct 10, 2015 – Oct 12, 2015

Subsystems (3)
lore
Share & tools
lore

Chen Feng

author
#0 lore raw

PATCH 1/3 docs: dts: Add documentation for hi6220 SoC ION node

Documentation for hi6220 SoC ION node

---
 .../devicetree/bindings/staging/ion/hi6220-ion.txt | 31 ++++++++++++++++++++++
 1 file changed, 31 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/staging/ion/hi6220-ion.txt
Documentation/devicetree/bindings/staging/ion/hi6220-ion.txt new file +31 -0
new file mode 100644
index 0000000..97ba233
@@ -0,0 +1,31 @@
+Hi6220 SoC ION
+============================================================
+Required properties:
+- compatible : "hisilicon,hi6220-ion"
+- list of the ION heaps
+	- heap name : maybe heap_sys_user@0
+	- heap id   : id should be unique in the system.
+	- heap base : base ddr address of the heap,0 means that
+	it is dynamic.
+	- heap size : memory size and 0 means it is dynamic.
+	- heap type : the heap type of the heap, please also
+see the define in ion.h(drivers/staging/android/uapi/ion.h)
+------------------------------------------------------------
+Example:
+	hi6220-ion {
+		compatible = "hisilicon,hi6220-ion";
+		heap_sys_user@0 {
+			heap-name = "sys_user";
+			heap-id   = <0x0>;
+			heap-base = <0x0>;
+			heap-size = <0x0>;
+			heap-type = "ion_system";
+		};
+		heap_sys_contig@0 {
+			heap-name = "sys_contig";
+			heap-id   = <0x1>;
+			heap-base = <0x0>;
+			heap-size = <0x0>;
+			heap-type = "ion_system_contig";
+		};
+	};
Signature · 1 line
1.9.1
author
#1 lore raw

PATCH 2/3 taging: android: ion: Add ion driver for Hi6220 SoC platform

Add ion support for hi6220 SoC platform.

---
 drivers/staging/android/ion/Kconfig                |   7 +
 drivers/staging/android/ion/Makefile               |   1 +
 drivers/staging/android/ion/hisilicon/Kconfig      |   5 +
 drivers/staging/android/ion/hisilicon/Makefile     |   1 +
 drivers/staging/android/ion/hisilicon/hi6220_ion.c | 204 +++++++++++++++++++++
 5 files changed, 218 insertions(+)
 create mode 100644 drivers/staging/android/ion/hisilicon/Kconfig
 create mode 100644 drivers/staging/android/ion/hisilicon/Makefile
 create mode 100644 drivers/staging/android/ion/hisilicon/hi6220_ion.c
drivers/staging/android/ion/Kconfig +7 -0
index 3452346..19c1572 100644
@@ -33,3 +33,10 @@ config ION_TEGRA
 	help
 	  Choose this option if you wish to use ion on an nVidia Tegra.
 
+config ION_HISI
+	tristate "Ion for Hisilicon"
+	depends on ARCH_HISI && ION
+	help
+	  Choose this option if you wish to use ion on Hisilicon Platform.
+
+source "drivers/staging/android/ion/hisilicon/Kconfig"
drivers/staging/android/ion/Makefile +1 -0
index b56fd2b..18cc2aa 100644
@@ -7,4 +7,5 @@ endif
 
 obj-$(CONFIG_ION_DUMMY) += ion_dummy_driver.o
 obj-$(CONFIG_ION_TEGRA) += tegra/
+obj-$(CONFIG_ION_HISI) += hisilicon/
 
drivers/staging/android/ion/hisilicon/Kconfig new file +5 -0
new file mode 100644
index 0000000..2b4bd07
@@ -0,0 +1,5 @@
+config HI6220_ION
+        bool "Hi6220 ION Driver"
+        depends on ARCH_HISI && ION
+        help
+          Build the Hisilicon Hi6220 ion driver.
drivers/staging/android/ion/hisilicon/Makefile new file +1 -0
new file mode 100644
index 0000000..2a89414
@@ -0,0 +1 @@
+obj-$(CONFIG_HI6220_ION) += hi6220_ion.o
drivers/staging/android/ion/hisilicon/hi6220_ion.c new file +204 -0

204 lines not on this page · raw message

Signature · 1 line
1.9.1
#2 lore raw

Re: [PATCH V1 2/3] taging: android: ion: Add ion driver for Hi6220 SoC platform

Quoted 32 lines · Chen Feng
drivers/staging/android/ion/hisilicon/hi6220_ion.c new file +32 -0
+static int hi6220_ion_probe(struct platform_device *pdev)
+{
+	int i;
+	int err = 0;
+	static struct ion_platform_heap *p_heap;
+
+	idev = ion_device_create(NULL);
+	hi6220_set_platform_data(pdev);
+	heaps = devm_kzalloc(&pdev->dev,
+			     sizeof(struct ion_heap *) * num_heaps,
+			     GFP_KERNEL);
+	if (!heaps)
+		return -ENOMEM;
+
+	/*
+	 * create the heaps as specified in the dts file
+	 */
+	for (i = 0; i < num_heaps; i++) {
+		p_heap = heaps_data[i];
+		heaps[i] = ion_heap_create(p_heap);
+		if (IS_ERR_OR_NULL(heaps[i])) {
+			err = PTR_ERR(heaps[i]);
+			goto err_free_heaps;
+		}
+
+		ion_device_add_heap(idev, heaps[i]);
+
+		pr_info("%s: adding heap %s of type %d with %lx@%lx\n",
+			__func__, p_heap->name, p_heap->type,
+			p_heap->base, (unsigned long)p_heap->size);
+	}
+	return err;

drivers/staging/android/ion/hisilicon/hi6220_ion.c line 167

Quoted 10 lines
drivers/staging/android/ion/hisilicon/hi6220_ion.c new file +10 -0
+
+err_free_heaps:
+	ion_device_destroy(idev);
+	for (i = 0; i < num_heaps; ++i) {
+		ion_heap_destroy(heaps[i]);
+		heaps[i] = NULL;
+	}
+
+	return err;
+}

Thanks this is better but still not quite right. You have to unwind in the reverse order from how you allocated things.

err_free_heaps:

	for (i = 0; i < num_heaps; ++i) {
		ion_heap_destroy(heaps[i]);
		heaps[i] = NULL;
	}
err_destroy_idev:
	ion_device_destroy(idev);

	return err;

And earlier it should be:

idev = ion_device_create(NULL); hi6220_set_platform_data(pdev);
heaps = devm_kzalloc(&pdev->dev,
sizeof(struct ion_heap *) * num_heaps, GFP_KERNEL);
- if (!heaps)
- return -ENOMEM;
+ if (!heaps) {
+ err = -ENOMEM;
+ goto err_destroy_idev;
+ }

Otherwise we leak some resources if we can't allocate "heaps".

regards,
dan carpenter

author
#3 lore raw

Re: [PATCH V1 2/3] taging: android: ion: Add ion driver for Hi6220 SoC platform

Quoted 71 lines · Dan Carpenter
Quoted 32 lines · Chen Feng
drivers/staging/android/ion/hisilicon/hi6220_ion.c new file +32 -0
+static int hi6220_ion_probe(struct platform_device *pdev)
+{
+	int i;
+	int err = 0;
+	static struct ion_platform_heap *p_heap;
+
+	idev = ion_device_create(NULL);
+	hi6220_set_platform_data(pdev);
+	heaps = devm_kzalloc(&pdev->dev,
+			     sizeof(struct ion_heap *) * num_heaps,
+			     GFP_KERNEL);
+	if (!heaps)
+		return -ENOMEM;
+
+	/*
+	 * create the heaps as specified in the dts file
+	 */
+	for (i = 0; i < num_heaps; i++) {
+		p_heap = heaps_data[i];
+		heaps[i] = ion_heap_create(p_heap);
+		if (IS_ERR_OR_NULL(heaps[i])) {
+			err = PTR_ERR(heaps[i]);
+			goto err_free_heaps;
+		}
+
+		ion_device_add_heap(idev, heaps[i]);
+
+		pr_info("%s: adding heap %s of type %d with %lx@%lx\n",
+			__func__, p_heap->name, p_heap->type,
+			p_heap->base, (unsigned long)p_heap->size);
+	}
+	return err;

drivers/staging/android/ion/hisilicon/hi6220_ion.c line 167

Quoted 10 lines
drivers/staging/android/ion/hisilicon/hi6220_ion.c new file +10 -0
+
+err_free_heaps:
+	ion_device_destroy(idev);
+	for (i = 0; i < num_heaps; ++i) {
+		ion_heap_destroy(heaps[i]);
+		heaps[i] = NULL;
+	}
+
+	return err;
+}

Thanks this is better but still not quite right. You have to unwind in the reverse order from how you allocated things.

err_free_heaps:

	for (i = 0; i < num_heaps; ++i) {
		ion_heap_destroy(heaps[i]);
		heaps[i] = NULL;
	}
err_destroy_idev:
	ion_device_destroy(idev);

	return err;

And earlier it should be:

(quoted diff) +4 -2
 	idev = ion_device_create(NULL);
 	hi6220_set_platform_data(pdev);
 	heaps = devm_kzalloc(&pdev->dev,
 			     sizeof(struct ion_heap *) * num_heaps,
 			     GFP_KERNEL);
-	if (!heaps)
-		return -ENOMEM;
+	if (!heaps) {
+		err = -ENOMEM;
+		goto err_destroy_idev;
+	}
Quoted 2 lines

Otherwise we leak some resources if we can't allocate "heaps".

Yeah,it's right. I will fix this.

Quoted 6 lines

regards,
dan carpenter

.

author
#4 lore raw

PATCH 3/3 arm64: dts: Add dts files to enable ION on Hi6220 SoC.

In reply to Chen Feng

Add ION node to enable ION on hi6220 SoC platform

---
 arch/arm64/boot/dts/hisilicon/hi6220-hikey.dts |  1 +
 arch/arm64/boot/dts/hisilicon/hi6220-ion.dtsi  | 20 ++++++++++++++++++++
 2 files changed, 21 insertions(+)
 create mode 100644 arch/arm64/boot/dts/hisilicon/hi6220-ion.dtsi
arch/arm64/boot/dts/hisilicon/hi6220-hikey.dts +1 -0
index e36a539..44b75d2 100644
@@ -11,6 +11,7 @@
 /memreserve/ 0x05e00000 0x00100000;
 
 #include "hi6220.dtsi"
+#include "hi6220-ion.dtsi"
 
 / {
 	model = "HiKey Development Board";
arch/arm64/boot/dts/hisilicon/hi6220-ion.dtsi new file +20 -0
new file mode 100644
index 0000000..c79f2ce
@@ -0,0 +1,20 @@
+/ {
+	hi6220-ion {
+		compatible = "hisilicon,hi6220-ion";
+		heap_sys_user@0 {
+			heap-name = "sys_user";
+			heap-id   = <0x0>;
+			heap-base = <0x0>;
+			heap-size = <0x0>;
+			heap-type = "ion_system";
+		};
+		heap_sys_contig@0 {
+			heap-name = "sys_contig";
+			heap-id   = <0x1>;
+			heap-base = <0x0>;
+			heap-size = <0x0>;
+			heap-type = "ion_system_contig";
+		};
+	};
+
+};
Signature · 1 line
1.9.1