linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v7 0/4] Add generic driver for on-chip SRAM
@ 2012-11-23 14:24 Philipp Zabel
  2012-11-23 14:24 ` [PATCH v7 1/4] genalloc: add a global pool list, allow to find pools by phys address Philipp Zabel
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Philipp Zabel @ 2012-11-23 14:24 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnd Bergmann, Greg Kroah-Hartman, Grant Likely, Rob Herring,
	Paul Gortmaker, Shawn Guo, Richard Zhao, Huang Shijie,
	Dong Aisheng, Matt Porter, Fabio Estevam, Javier Martin, kernel,
	devicetree-discuss

These patches add support to configure on-chip SRAM via device-tree
node or platform data and to obtain the resulting genalloc pool from
the physical address or a phandle pointing at the device tree node.
This allows drivers to allocate SRAM with the genalloc API without
hard-coding the genalloc pool pointer.

The on-chip SRAM on i.MX53 and i.MX6q can be registered via device tree
and changed to use the simple generic SRAM driver:

                ocram: ocram@00900000 {
                        compatible = "fsl,imx-ocram", "sram";
                        reg = <0x00900000 0x3f000>;
                };

A driver that needs to allocate SRAM buffers, like the video processing
unit on i.MX53, can retrieve the genalloc pool from a phandle in the
device tree using of_get_named_gen_pool(node, "iram", 0) from patch 1:

                vpu@63ff4000 {
                        /* ... */
                        iram = <&ocram>;
                };

The allocation granularity is hard-coded to 32 bytes for now,
until a way to configure it can be agreed upon. There is overhead
for bigger SRAMs, where only a much coarser allocation granularity
is needed: At 32 bytes minimum allocation size, a 256 KiB SRAM
needs a 1 KiB bitmap to track allocations.

Once everybody is ok with it, could the first two patches be merged
through the char-misc tree? I'll resend the i.MX and coda patches to
the respective lists afterwards.

Changes since v6:
 - Reduced the hard coded allocation granularity to 32 bytes.

regards
Philipp

---
 Documentation/devicetree/bindings/misc/sram.txt |   17 ++++
 arch/arm/boot/dts/imx53.dtsi                    |    5 +
 arch/arm/boot/dts/imx6q.dtsi                    |    6 ++
 drivers/media/platform/Kconfig                  |    3 +-
 drivers/media/platform/coda.c                   |   47 ++++++---
 drivers/misc/Kconfig                            |    9 ++
 drivers/misc/Makefile                           |    1 +
 drivers/misc/sram.c                             |  121 +++++++++++++++++++++++
 include/linux/genalloc.h                        |   14 +++
 lib/genalloc.c                                  |   67 +++++++++++++
 10 files changed, 274 insertions(+), 16 deletions(-)


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v7 1/4] genalloc: add a global pool list, allow to find pools by phys address
  2012-11-23 14:24 [PATCH v7 0/4] Add generic driver for on-chip SRAM Philipp Zabel
@ 2012-11-23 14:24 ` Philipp Zabel
  2012-11-23 14:24 ` [PATCH v7 2/4] misc: Generic on-chip SRAM allocation driver Philipp Zabel
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Philipp Zabel @ 2012-11-23 14:24 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnd Bergmann, Greg Kroah-Hartman, Grant Likely, Rob Herring,
	Paul Gortmaker, Shawn Guo, Richard Zhao, Huang Shijie,
	Dong Aisheng, Matt Porter, Fabio Estevam, Javier Martin, kernel,
	devicetree-discuss, Philipp Zabel

This patch keeps all created pools in a global list and adds two
functions that allow to retrieve the gen_pool pointer from a known
physical address and from a device tree node.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Reviewed-by: Shawn Guo <shawn.guo@linaro.org>
---
 include/linux/genalloc.h |   14 ++++++++++
 lib/genalloc.c           |   67 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 81 insertions(+)

diff --git a/include/linux/genalloc.h b/include/linux/genalloc.h
index dd7c569..91d606e 100644
--- a/include/linux/genalloc.h
+++ b/include/linux/genalloc.h
@@ -47,6 +47,7 @@ typedef unsigned long (*genpool_algo_t)(unsigned long *map,
  *  General purpose special memory pool descriptor.
  */
 struct gen_pool {
+	struct list_head next_pool;	/* pool in global list */
 	spinlock_t lock;
 	struct list_head chunks;	/* list of chunks in this pool */
 	int min_alloc_order;		/* minimum allocation order */
@@ -105,4 +106,17 @@ extern unsigned long gen_pool_first_fit(unsigned long *map, unsigned long size,
 extern unsigned long gen_pool_best_fit(unsigned long *map, unsigned long size,
 		unsigned long start, unsigned int nr, void *data);
 
+extern struct gen_pool *gen_pool_find_by_phys(phys_addr_t phys);
+
+struct device_node;
+#ifdef CONFIG_OF
+extern struct gen_pool *of_get_named_gen_pool(struct device_node *np,
+	const char *propname, int index);
+#else
+inline struct gen_pool *of_get_named_gen_pool(struct device_node *np,
+	const char *propname, int index)
+{
+	return NULL;
+}
+#endif
 #endif /* __GENALLOC_H__ */
diff --git a/lib/genalloc.c b/lib/genalloc.c
index 5492043..edf4bf3 100644
--- a/lib/genalloc.c
+++ b/lib/genalloc.c
@@ -34,6 +34,11 @@
 #include <linux/rculist.h>
 #include <linux/interrupt.h>
 #include <linux/genalloc.h>
+#include <linux/of_address.h>
+#include <linux/of_device.h>
+
+static LIST_HEAD(pools);
+static DEFINE_SPINLOCK(list_lock);
 
 static int set_bits_ll(unsigned long *addr, unsigned long mask_to_set)
 {
@@ -154,6 +159,9 @@ struct gen_pool *gen_pool_create(int min_alloc_order, int nid)
 		pool->min_alloc_order = min_alloc_order;
 		pool->algo = gen_pool_first_fit;
 		pool->data = NULL;
+		spin_lock(&list_lock);
+		list_add_rcu(&pool->next_pool, &pools);
+		spin_unlock(&list_lock);
 	}
 	return pool;
 }
@@ -236,6 +244,9 @@ void gen_pool_destroy(struct gen_pool *pool)
 	int order = pool->min_alloc_order;
 	int bit, end_bit;
 
+	spin_lock(&list_lock);
+	list_del_rcu(&pool->next_pool);
+	spin_unlock(&list_lock);
 	list_for_each_safe(_chunk, _next_chunk, &pool->chunks) {
 		chunk = list_entry(_chunk, struct gen_pool_chunk, next_chunk);
 		list_del(&chunk->next_chunk);
@@ -480,3 +491,59 @@ unsigned long gen_pool_best_fit(unsigned long *map, unsigned long size,
 	return start_bit;
 }
 EXPORT_SYMBOL(gen_pool_best_fit);
+
+/*
+ * gen_pool_find_by_phys - find a pool by physical start address
+ * @phys: physical address as added with gen_pool_add_virt
+ *
+ * Returns the pool that contains the chunk starting at phys,
+ * or NULL if not found.
+ */
+struct gen_pool *gen_pool_find_by_phys(phys_addr_t phys)
+{
+	struct gen_pool *pool, *found = NULL;
+	struct gen_pool_chunk *chunk;
+
+	rcu_read_lock();
+	list_for_each_entry_rcu(pool, &pools, next_pool) {
+		list_for_each_entry_rcu(chunk, &pool->chunks, next_chunk) {
+			if (phys == chunk->phys_addr) {
+				found = pool;
+				break;
+			}
+		}
+	}
+	rcu_read_unlock();
+
+	return found;
+}
+EXPORT_SYMBOL_GPL(gen_pool_find_by_phys);
+
+#ifdef CONFIG_OF
+/**
+ * of_get_named_gen_pool - find a pool by phandle property
+ * @np: device node
+ * @propname: property name containing phandle(s)
+ * @index: index into the phandle array
+ *
+ * Returns the pool that contains the chunk starting at the physical
+ * address of the device tree node pointed at by the phandle property,
+ * or NULL if not found.
+ */
+struct gen_pool *of_get_named_gen_pool(struct device_node *np,
+	const char *propname, int index)
+{
+	struct device_node *np_pool;
+	struct resource res;
+	int ret;
+
+	np_pool = of_parse_phandle(np, propname, index);
+	if (!np_pool)
+		return NULL;
+	ret = of_address_to_resource(np_pool, 0, &res);
+	if (ret < 0)
+		return NULL;
+	return gen_pool_find_by_phys((phys_addr_t) res.start);
+}
+EXPORT_SYMBOL_GPL(of_get_named_gen_pool);
+#endif /* CONFIG_OF */
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v7 2/4] misc: Generic on-chip SRAM allocation driver
  2012-11-23 14:24 [PATCH v7 0/4] Add generic driver for on-chip SRAM Philipp Zabel
  2012-11-23 14:24 ` [PATCH v7 1/4] genalloc: add a global pool list, allow to find pools by phys address Philipp Zabel
@ 2012-11-23 14:24 ` Philipp Zabel
  2012-11-23 14:24 ` [PATCH v7 3/4] media: coda: use genalloc API Philipp Zabel
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Philipp Zabel @ 2012-11-23 14:24 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnd Bergmann, Greg Kroah-Hartman, Grant Likely, Rob Herring,
	Paul Gortmaker, Shawn Guo, Richard Zhao, Huang Shijie,
	Dong Aisheng, Matt Porter, Fabio Estevam, Javier Martin, kernel,
	devicetree-discuss, Philipp Zabel

This driver requests and remaps a memory region as configured in the
device tree. It serves memory from this region via the genalloc API.
It optionally enables the SRAM clock.

Other drivers can retrieve the genalloc pool from a phandle pointing
to this drivers' device node in the device tree.

The allocation granularity is hard-coded to 32 bytes for now,
to make the SRAM driver useful for the 6502 remoteproc driver.
There is overhead for bigger SRAMs, where only a much coarser
allocation granularity is needed: At 32 bytes minimum allocation
size, a 256 KiB SRAM needs a 1 KiB bitmap to track allocations.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Reviewed-by: Shawn Guo <shawn.guo@linaro.org>
---
 Documentation/devicetree/bindings/misc/sram.txt |   17 ++++
 drivers/misc/Kconfig                            |    9 ++
 drivers/misc/Makefile                           |    1 +
 drivers/misc/sram.c                             |  121 +++++++++++++++++++++++
 4 files changed, 148 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/misc/sram.txt
 create mode 100644 drivers/misc/sram.c

diff --git a/Documentation/devicetree/bindings/misc/sram.txt b/Documentation/devicetree/bindings/misc/sram.txt
new file mode 100644
index 0000000..b64136c
--- /dev/null
+++ b/Documentation/devicetree/bindings/misc/sram.txt
@@ -0,0 +1,17 @@
+Generic on-chip SRAM
+
+Simple IO memory regions to be managed by the genalloc API.
+
+Required properties:
+
+- compatible : sram
+
+- reg : SRAM iomem address range
+
+Example:
+
+sram: sram@5c000000 {
+	compatible = "sram";
+	reg = <0x5c000000 0x40000>; /* 256 KiB SRAM at address 0x5c000000 */
+};
+
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index b151b7c..211468c 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -499,6 +499,15 @@ config USB_SWITCH_FSA9480
 	  stereo and mono audio, video, microphone and UART data to use
 	  a common connector port.
 
+config SRAM
+	bool "Generic on-chip SRAM driver"
+	depends on HAS_IOMEM
+	select GENERIC_ALLOCATOR
+	help
+	  This driver allows to declare a memory region to be managed
+	  by the genalloc API. It is supposed to be used for small
+	  on-chip SRAM areas found on many SoCs.
+
 source "drivers/misc/c2port/Kconfig"
 source "drivers/misc/eeprom/Kconfig"
 source "drivers/misc/cb710/Kconfig"
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index 2129377..d845690 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -49,3 +49,4 @@ obj-y				+= carma/
 obj-$(CONFIG_USB_SWITCH_FSA9480) += fsa9480.o
 obj-$(CONFIG_ALTERA_STAPL)	+=altera-stapl/
 obj-$(CONFIG_INTEL_MEI)		+= mei/
+obj-$(CONFIG_SRAM)		+= sram.o
diff --git a/drivers/misc/sram.c b/drivers/misc/sram.c
new file mode 100644
index 0000000..0d91964
--- /dev/null
+++ b/drivers/misc/sram.c
@@ -0,0 +1,121 @@
+/*
+ * Generic on-chip SRAM allocation driver
+ *
+ * Copyright (C) 2012 Philipp Zabel, Pengutronix
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/clk.h>
+#include <linux/err.h>
+#include <linux/io.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+#include <linux/spinlock.h>
+#include <linux/genalloc.h>
+
+#define SRAM_GRANULARITY	32
+
+struct sram_dev {
+	struct gen_pool *pool;
+	struct clk *clk;
+};
+
+static int __devinit sram_probe(struct platform_device *pdev)
+{
+	void __iomem *virt_base;
+	struct sram_dev *sram;
+	struct resource *res;
+	unsigned long size;
+	int ret;
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!res)
+		return -EINVAL;
+
+	size = resource_size(res);
+
+	virt_base = devm_request_and_ioremap(&pdev->dev, res);
+	if (!virt_base)
+		return -EADDRNOTAVAIL;
+
+	sram = devm_kzalloc(&pdev->dev, sizeof(*sram), GFP_KERNEL);
+	if (!sram)
+		return -ENOMEM;
+
+	sram->clk = devm_clk_get(&pdev->dev, NULL);
+	if (IS_ERR(sram->clk))
+		sram->clk = NULL;
+	else
+		clk_prepare_enable(sram->clk);
+
+	sram->pool = gen_pool_create(ilog2(SRAM_GRANULARITY), -1);
+	if (!sram->pool)
+		return -ENOMEM;
+
+	ret = gen_pool_add_virt(sram->pool, (unsigned long)virt_base,
+				res->start, size, -1);
+	if (ret < 0) {
+		gen_pool_destroy(sram->pool);
+		return ret;
+	}
+
+	platform_set_drvdata(pdev, sram);
+
+	dev_dbg(&pdev->dev, "SRAM pool: %ld KiB @ 0x%p\n", size / 1024, virt_base);
+
+	return 0;
+}
+
+static int __devexit sram_remove(struct platform_device *pdev)
+{
+	struct sram_dev *sram = platform_get_drvdata(pdev);
+
+	if (gen_pool_avail(sram->pool) < gen_pool_size(sram->pool))
+		dev_dbg(&pdev->dev, "removed while SRAM allocated\n");
+
+	gen_pool_destroy(sram->pool);
+
+	if (sram->clk)
+		clk_disable_unprepare(sram->clk);
+
+	return 0;
+}
+
+#ifdef CONFIG_OF
+static struct of_device_id sram_dt_ids[] = {
+	{ .compatible = "sram" },
+	{}
+};
+#endif
+
+static struct platform_driver sram_driver = {
+	.driver = {
+		.name = "sram",
+		.of_match_table = of_match_ptr(sram_dt_ids),
+	},
+	.probe = sram_probe,
+	.remove = __devexit_p(sram_remove),
+};
+
+int __init sram_init(void)
+{
+	return platform_driver_register(&sram_driver);
+}
+
+postcore_initcall(sram_init);
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v7 3/4] media: coda: use genalloc API
  2012-11-23 14:24 [PATCH v7 0/4] Add generic driver for on-chip SRAM Philipp Zabel
  2012-11-23 14:24 ` [PATCH v7 1/4] genalloc: add a global pool list, allow to find pools by phys address Philipp Zabel
  2012-11-23 14:24 ` [PATCH v7 2/4] misc: Generic on-chip SRAM allocation driver Philipp Zabel
@ 2012-11-23 14:24 ` Philipp Zabel
  2012-11-23 14:24 ` [PATCH v7 4/4] ARM: dts: add sram for imx53 and imx6q Philipp Zabel
  2012-12-04  8:53 ` [PATCH v7 0/4] Add generic driver for on-chip SRAM Philipp Zabel
  4 siblings, 0 replies; 8+ messages in thread
From: Philipp Zabel @ 2012-11-23 14:24 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnd Bergmann, Greg Kroah-Hartman, Grant Likely, Rob Herring,
	Paul Gortmaker, Shawn Guo, Richard Zhao, Huang Shijie,
	Dong Aisheng, Matt Porter, Fabio Estevam, Javier Martin, kernel,
	devicetree-discuss, Philipp Zabel

This patch depends on "genalloc: add a global pool list,
allow to find pools by phys address", which provides the
of_get_named_gen_pool function.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
 drivers/media/platform/Kconfig |    3 +--
 drivers/media/platform/coda.c  |   47 ++++++++++++++++++++++++++++------------
 2 files changed, 34 insertions(+), 16 deletions(-)

diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index 181c768..09d45c6 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -130,10 +130,9 @@ if V4L_MEM2MEM_DRIVERS
 
 config VIDEO_CODA
 	tristate "Chips&Media Coda multi-standard codec IP"
-	depends on VIDEO_DEV && VIDEO_V4L2 && ARCH_MXC
+	depends on VIDEO_DEV && VIDEO_V4L2
 	select VIDEOBUF2_DMA_CONTIG
 	select V4L2_MEM2MEM_DEV
-	select IRAM_ALLOC if SOC_IMX53
 	---help---
 	   Coda is a range of video codec IPs that supports
 	   H.264, MPEG-4, and other video formats.
diff --git a/drivers/media/platform/coda.c b/drivers/media/platform/coda.c
index cd04ae2..f17b659 100644
--- a/drivers/media/platform/coda.c
+++ b/drivers/media/platform/coda.c
@@ -14,6 +14,7 @@
 #include <linux/clk.h>
 #include <linux/delay.h>
 #include <linux/firmware.h>
+#include <linux/genalloc.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
 #include <linux/irq.h>
@@ -24,7 +25,6 @@
 #include <linux/videodev2.h>
 #include <linux/of.h>
 
-#include <mach/iram.h>
 #include <media/v4l2-ctrls.h>
 #include <media/v4l2-device.h>
 #include <media/v4l2-ioctl.h>
@@ -43,6 +43,7 @@
 #define CODA7_WORK_BUF_SIZE	(512 * 1024 + CODA_FMO_BUF_SIZE * 8 * 1024)
 #define CODA_PARA_BUF_SIZE	(10 * 1024)
 #define CODA_ISRAM_SIZE	(2048 * 2)
+#define CODADX6_IRAM_SIZE	0xb000
 #define CODA7_IRAM_SIZE		0x14000 /* 81920 bytes */
 
 #define CODA_MAX_FRAMEBUFFERS	2
@@ -128,7 +129,10 @@ struct coda_dev {
 
 	struct coda_aux_buf	codebuf;
 	struct coda_aux_buf	workbuf;
+	struct gen_pool		*iram_pool;
+	long unsigned int	iram_vaddr;
 	long unsigned int	iram_paddr;
+	unsigned long		iram_size;
 
 	spinlock_t		irqlock;
 	struct mutex		dev_mutex;
@@ -1958,6 +1962,22 @@ static int __devinit coda_probe(struct platform_device *pdev)
 		return -ENOENT;
 	}
 
+	/* Without device tree, get SRAM paddr from second memory resource */
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+	if (res != NULL)
+		dev->iram_pool = gen_pool_find_by_phys(res->start);
+#ifdef CONFIG_OF
+	if (!dev->iram_pool) {
+		struct device_node *np = pdev->dev.of_node;
+
+		dev->iram_pool = of_get_named_gen_pool(np, "iram", 0);
+	}
+#endif
+	if (!dev->iram_pool) {
+		dev_err(&pdev->dev, "iram pool not available\n");
+		return -ENOMEM;
+	}
+
 	ret = v4l2_device_register(&pdev->dev, &dev->v4l2_dev);
 	if (ret)
 		return ret;
@@ -1992,18 +2012,17 @@ static int __devinit coda_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	}
 
-	if (dev->devtype->product == CODA_DX6) {
-		dev->iram_paddr = 0xffff4c00;
-	} else {
-		void __iomem *iram_vaddr;
-
-		iram_vaddr = iram_alloc(CODA7_IRAM_SIZE,
-					&dev->iram_paddr);
-		if (!iram_vaddr) {
-			dev_err(&pdev->dev, "unable to alloc iram\n");
-			return -ENOMEM;
-		}
+	if (dev->devtype->product == CODA_DX6)
+		dev->iram_size = CODADX6_IRAM_SIZE;
+	else
+		dev->iram_size = CODA7_IRAM_SIZE;
+	dev->iram_vaddr = gen_pool_alloc(dev->iram_pool, dev->iram_size);
+	if (!dev->iram_vaddr) {
+		dev_err(&pdev->dev, "unable to alloc iram\n");
+		return -ENOMEM;
 	}
+	dev->iram_paddr = gen_pool_virt_to_phys(dev->iram_pool,
+						dev->iram_vaddr);
 
 	platform_set_drvdata(pdev, dev);
 
@@ -2020,8 +2039,8 @@ static int coda_remove(struct platform_device *pdev)
 	if (dev->alloc_ctx)
 		vb2_dma_contig_cleanup_ctx(dev->alloc_ctx);
 	v4l2_device_unregister(&dev->v4l2_dev);
-	if (dev->iram_paddr)
-		iram_free(dev->iram_paddr, CODA7_IRAM_SIZE);
+	if (dev->iram_vaddr)
+		gen_pool_free(dev->iram_pool, dev->iram_vaddr, dev->iram_size);
 	if (dev->codebuf.vaddr)
 		dma_free_coherent(&pdev->dev, dev->codebuf.size,
 				  &dev->codebuf.vaddr, dev->codebuf.paddr);
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v7 4/4] ARM: dts: add sram for imx53 and imx6q
  2012-11-23 14:24 [PATCH v7 0/4] Add generic driver for on-chip SRAM Philipp Zabel
                   ` (2 preceding siblings ...)
  2012-11-23 14:24 ` [PATCH v7 3/4] media: coda: use genalloc API Philipp Zabel
@ 2012-11-23 14:24 ` Philipp Zabel
  2012-12-04  8:53 ` [PATCH v7 0/4] Add generic driver for on-chip SRAM Philipp Zabel
  4 siblings, 0 replies; 8+ messages in thread
From: Philipp Zabel @ 2012-11-23 14:24 UTC (permalink / raw)
  To: linux-kernel
  Cc: Arnd Bergmann, Greg Kroah-Hartman, Grant Likely, Rob Herring,
	Paul Gortmaker, Shawn Guo, Richard Zhao, Huang Shijie,
	Dong Aisheng, Matt Porter, Fabio Estevam, Javier Martin, kernel,
	devicetree-discuss, Philipp Zabel

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Reviewed-by: Shawn Guo <shawn.guo@linaro.org>
---
 arch/arm/boot/dts/imx53.dtsi |    5 +++++
 arch/arm/boot/dts/imx6q.dtsi |    6 ++++++
 2 files changed, 11 insertions(+)

diff --git a/arch/arm/boot/dts/imx53.dtsi b/arch/arm/boot/dts/imx53.dtsi
index 76ebb1a..7677218 100644
--- a/arch/arm/boot/dts/imx53.dtsi
+++ b/arch/arm/boot/dts/imx53.dtsi
@@ -541,5 +541,10 @@
 				status = "disabled";
 			};
 		};
+
+		ocram: ocram@f8000000 {
+			compatible = "fsl,imx-ocram", "sram";
+			reg = <0xf8000000 0x20000>;
+		};
 	};
 };
diff --git a/arch/arm/boot/dts/imx6q.dtsi b/arch/arm/boot/dts/imx6q.dtsi
index f3990b0..855ac25 100644
--- a/arch/arm/boot/dts/imx6q.dtsi
+++ b/arch/arm/boot/dts/imx6q.dtsi
@@ -116,6 +116,12 @@
 			status = "disabled";
 		};
 
+		ocram: ocram@00900000 {
+			compatible = "fsl,imx-ocram", "sram";
+			reg = <0x00900000 0x3f000>;
+			clocks = <&clks 142>;
+		};
+
 		timer@00a00600 {
 			compatible = "arm,cortex-a9-twd-timer";
 			reg = <0x00a00600 0x20>;
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v7 0/4] Add generic driver for on-chip SRAM
  2012-11-23 14:24 [PATCH v7 0/4] Add generic driver for on-chip SRAM Philipp Zabel
                   ` (3 preceding siblings ...)
  2012-11-23 14:24 ` [PATCH v7 4/4] ARM: dts: add sram for imx53 and imx6q Philipp Zabel
@ 2012-12-04  8:53 ` Philipp Zabel
  2012-12-04 16:19   ` Greg Kroah-Hartman
  4 siblings, 1 reply; 8+ messages in thread
From: Philipp Zabel @ 2012-12-04  8:53 UTC (permalink / raw)
  To: linux-kernel, Arnd Bergmann, Greg Kroah-Hartman
  Cc: Grant Likely, Rob Herring, Paul Gortmaker, Shawn Guo,
	Richard Zhao, Huang Shijie, Dong Aisheng, Matt Porter,
	Fabio Estevam, Javier Martin, kernel, devicetree-discuss

Hi,

On Fri, 2012-11-23 at 15:24 +0100, Philipp Zabel wrote:
> These patches add support to configure on-chip SRAM via device-tree
> node or platform data and to obtain the resulting genalloc pool from
> the physical address or a phandle pointing at the device tree node.
> This allows drivers to allocate SRAM with the genalloc API without
> hard-coding the genalloc pool pointer.

are there any further comments on this series?

> The on-chip SRAM on i.MX53 and i.MX6q can be registered via device tree
> and changed to use the simple generic SRAM driver:
> 
>                 ocram: ocram@00900000 {
>                         compatible = "fsl,imx-ocram", "sram";
>                         reg = <0x00900000 0x3f000>;
>                 };
> 
> A driver that needs to allocate SRAM buffers, like the video processing
> unit on i.MX53, can retrieve the genalloc pool from a phandle in the
> device tree using of_get_named_gen_pool(node, "iram", 0) from patch 1:
> 
>                 vpu@63ff4000 {
>                         /* ... */
>                         iram = <&ocram>;
>                 };
> 
> The allocation granularity is hard-coded to 32 bytes for now,
> until a way to configure it can be agreed upon. There is overhead
> for bigger SRAMs, where only a much coarser allocation granularity
> is needed: At 32 bytes minimum allocation size, a 256 KiB SRAM
> needs a 1 KiB bitmap to track allocations.
> 
> Once everybody is ok with it, could the first two patches be merged
> through the char-misc tree? I'll resend the i.MX and coda patches to
> the respective lists afterwards.

Arnd, Greg, would you take the first patch "genalloc: add a global pool
list, allow to find pools by phys address" into the char-misc tree if
there are no vetoes? Or should I try and get it merged separately,
first?

regards
Philipp

> Changes since v6:
>  - Reduced the hard coded allocation granularity to 32 bytes.
> 
> regards
> Philipp
> 
> ---
>  Documentation/devicetree/bindings/misc/sram.txt |   17 ++++
>  arch/arm/boot/dts/imx53.dtsi                    |    5 +
>  arch/arm/boot/dts/imx6q.dtsi                    |    6 ++
>  drivers/media/platform/Kconfig                  |    3 +-
>  drivers/media/platform/coda.c                   |   47 ++++++---
>  drivers/misc/Kconfig                            |    9 ++
>  drivers/misc/Makefile                           |    1 +
>  drivers/misc/sram.c                             |  121 +++++++++++++++++++++++
>  include/linux/genalloc.h                        |   14 +++
>  lib/genalloc.c                                  |   67 +++++++++++++
>  10 files changed, 274 insertions(+), 16 deletions(-)



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v7 0/4] Add generic driver for on-chip SRAM
  2012-12-04  8:53 ` [PATCH v7 0/4] Add generic driver for on-chip SRAM Philipp Zabel
@ 2012-12-04 16:19   ` Greg Kroah-Hartman
  2012-12-04 16:55     ` Philipp Zabel
  0 siblings, 1 reply; 8+ messages in thread
From: Greg Kroah-Hartman @ 2012-12-04 16:19 UTC (permalink / raw)
  To: Philipp Zabel
  Cc: linux-kernel, Arnd Bergmann, Grant Likely, Rob Herring,
	Paul Gortmaker, Shawn Guo, Richard Zhao, Huang Shijie,
	Dong Aisheng, Matt Porter, Fabio Estevam, Javier Martin, kernel,
	devicetree-discuss

On Tue, Dec 04, 2012 at 09:53:38AM +0100, Philipp Zabel wrote:
> Hi,
> 
> On Fri, 2012-11-23 at 15:24 +0100, Philipp Zabel wrote:
> > These patches add support to configure on-chip SRAM via device-tree
> > node or platform data and to obtain the resulting genalloc pool from
> > the physical address or a phandle pointing at the device tree node.
> > This allows drivers to allocate SRAM with the genalloc API without
> > hard-coding the genalloc pool pointer.
> 
> are there any further comments on this series?
> 
> > The on-chip SRAM on i.MX53 and i.MX6q can be registered via device tree
> > and changed to use the simple generic SRAM driver:
> > 
> >                 ocram: ocram@00900000 {
> >                         compatible = "fsl,imx-ocram", "sram";
> >                         reg = <0x00900000 0x3f000>;
> >                 };
> > 
> > A driver that needs to allocate SRAM buffers, like the video processing
> > unit on i.MX53, can retrieve the genalloc pool from a phandle in the
> > device tree using of_get_named_gen_pool(node, "iram", 0) from patch 1:
> > 
> >                 vpu@63ff4000 {
> >                         /* ... */
> >                         iram = <&ocram>;
> >                 };
> > 
> > The allocation granularity is hard-coded to 32 bytes for now,
> > until a way to configure it can be agreed upon. There is overhead
> > for bigger SRAMs, where only a much coarser allocation granularity
> > is needed: At 32 bytes minimum allocation size, a 256 KiB SRAM
> > needs a 1 KiB bitmap to track allocations.
> > 
> > Once everybody is ok with it, could the first two patches be merged
> > through the char-misc tree? I'll resend the i.MX and coda patches to
> > the respective lists afterwards.
> 
> Arnd, Greg, would you take the first patch "genalloc: add a global pool
> list, allow to find pools by phys address" into the char-misc tree if
> there are no vetoes? Or should I try and get it merged separately,
> first?

It's too late for anything new for 3.8, so how about resending this all
after 3.8-rc1 is out and we can take it from there?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v7 0/4] Add generic driver for on-chip SRAM
  2012-12-04 16:19   ` Greg Kroah-Hartman
@ 2012-12-04 16:55     ` Philipp Zabel
  0 siblings, 0 replies; 8+ messages in thread
From: Philipp Zabel @ 2012-12-04 16:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-kernel, Arnd Bergmann, Grant Likely, Rob Herring,
	Paul Gortmaker, Shawn Guo, Richard Zhao, Huang Shijie,
	Dong Aisheng, Matt Porter, Fabio Estevam, Javier Martin, kernel,
	devicetree-discuss

On Tue, 2012-12-04 at 08:19 -0800, Greg Kroah-Hartman wrote:
> On Tue, Dec 04, 2012 at 09:53:38AM +0100, Philipp Zabel wrote:
> > Hi,
> > 
> > On Fri, 2012-11-23 at 15:24 +0100, Philipp Zabel wrote:
> > > These patches add support to configure on-chip SRAM via device-tree
> > > node or platform data and to obtain the resulting genalloc pool from
> > > the physical address or a phandle pointing at the device tree node.
> > > This allows drivers to allocate SRAM with the genalloc API without
> > > hard-coding the genalloc pool pointer.
> > 
> > are there any further comments on this series?
> > 
> > > The on-chip SRAM on i.MX53 and i.MX6q can be registered via device tree
> > > and changed to use the simple generic SRAM driver:
> > > 
> > >                 ocram: ocram@00900000 {
> > >                         compatible = "fsl,imx-ocram", "sram";
> > >                         reg = <0x00900000 0x3f000>;
> > >                 };
> > > 
> > > A driver that needs to allocate SRAM buffers, like the video processing
> > > unit on i.MX53, can retrieve the genalloc pool from a phandle in the
> > > device tree using of_get_named_gen_pool(node, "iram", 0) from patch 1:
> > > 
> > >                 vpu@63ff4000 {
> > >                         /* ... */
> > >                         iram = <&ocram>;
> > >                 };
> > > 
> > > The allocation granularity is hard-coded to 32 bytes for now,
> > > until a way to configure it can be agreed upon. There is overhead
> > > for bigger SRAMs, where only a much coarser allocation granularity
> > > is needed: At 32 bytes minimum allocation size, a 256 KiB SRAM
> > > needs a 1 KiB bitmap to track allocations.
> > > 
> > > Once everybody is ok with it, could the first two patches be merged
> > > through the char-misc tree? I'll resend the i.MX and coda patches to
> > > the respective lists afterwards.
> > 
> > Arnd, Greg, would you take the first patch "genalloc: add a global pool
> > list, allow to find pools by phys address" into the char-misc tree if
> > there are no vetoes? Or should I try and get it merged separately,
> > first?
> 
> It's too late for anything new for 3.8, so how about resending this all
> after 3.8-rc1 is out and we can take it from there?

Ok, I'll do that.

thanks
Philipp


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-12-04 16:55 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-23 14:24 [PATCH v7 0/4] Add generic driver for on-chip SRAM Philipp Zabel
2012-11-23 14:24 ` [PATCH v7 1/4] genalloc: add a global pool list, allow to find pools by phys address Philipp Zabel
2012-11-23 14:24 ` [PATCH v7 2/4] misc: Generic on-chip SRAM allocation driver Philipp Zabel
2012-11-23 14:24 ` [PATCH v7 3/4] media: coda: use genalloc API Philipp Zabel
2012-11-23 14:24 ` [PATCH v7 4/4] ARM: dts: add sram for imx53 and imx6q Philipp Zabel
2012-12-04  8:53 ` [PATCH v7 0/4] Add generic driver for on-chip SRAM Philipp Zabel
2012-12-04 16:19   ` Greg Kroah-Hartman
2012-12-04 16:55     ` Philipp Zabel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).