Skip to contentSkip to conversation

Merge OF dynamic patches

PATCH In review Nathan Fontenot 4 participants 9 messages Nov 20, 2009 – Nov 23, 2009 2 messages not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v2 cover Merge OF dynamic patches

This set of patches merges the common dynamic device tree updating routines of_attach_node() and of_detach_node() to drivers/of/of_dynamic.c.

Built and tested on powerpc, I have no access to build/test this on microblaze.

-Nathan Fontenot
---

1/4 - Merge of_attach_node
2/4 - Merge of_detach_node
3/4 - Makefile/Kconfig updates
4/4 - Update powerpc/pseries to include of_dynamic.h

arch/microblaze/Kconfig                   |    1 arch/microblaze/include/asm/prom.h        |    4 -
arch/microblaze/kernel/prom.c             |   59 -----------------------
arch/powerpc/Kconfig                      |    1 arch/powerpc/include/asm/prom.h           |    4 -
arch/powerpc/kernel/prom.c                |   59 -----------------------
arch/powerpc/platforms/pseries/reconfig.c |    1 drivers/of/Kconfig                        |    4 +
drivers/of/Makefile                       |    1 drivers/of/of_dynamic.c                   |   75 ++++++++++++++++++++++++++++++
include/linux/of_dynamic.h                |   27 ++++++++++
11 files changed, 110 insertions(+), 126 deletions(-)
#2 lore raw

PATCH v2 1/4 Merge of_attach_node

In reply to a message not in the archive

Merge the common of_attach_node() routine from powerpc and microblaze to drivers/of/of_dynamic.c

---

arch/microblaze/include/asm/prom.h |    1 -
arch/microblaze/kernel/prom.c      |   15 ---------------
arch/powerpc/include/asm/prom.h    |    1 -
arch/powerpc/kernel/prom.c         |   15 ---------------
drivers/of/of_dynamic.c            |   32 ++++++++++++++++++++++++++++++++
include/linux/of_dynamic.h         |   26 ++++++++++++++++++++++++++
6 files changed, 58 insertions(+), 32 deletions(-)
arch/microblaze/kernel/prom.c +0 -0
Index: test-devicetree/arch/microblaze/kernel/prom.c
===================================================================
@@ -483,21 +483,6 @@

EXPORT_SYMBOL(of_node_put);

/*
- * Plug a device node into the tree and global list.
- */
-void of_attach_node(struct device_node *np)
-{
- unsigned long flags;
-
- write_lock_irqsave(&devtree_lock, flags);
- np->sibling = np->parent->child;
- np->allnext = allnodes;
- np->parent->child = np;
- allnodes = np;
- write_unlock_irqrestore(&devtree_lock, flags);
-}
-
-/*
* "Unplug" a node from the device tree. The caller must hold
* a reference to the node. The memory associated with the node
* is not freed until its refcount goes to zero.

arch/powerpc/kernel/prom.c +0 -0
Index: test-devicetree/arch/powerpc/kernel/prom.c
===================================================================
@@ -936,21 +936,6 @@

EXPORT_SYMBOL(of_node_put);

/*
- * Plug a device node into the tree and global list.
- */
-void of_attach_node(struct device_node *np)
-{
- unsigned long flags;
-
- write_lock_irqsave(&devtree_lock, flags);
- np->sibling = np->parent->child;
- np->allnext = allnodes;
- np->parent->child = np;
- allnodes = np;
- write_unlock_irqrestore(&devtree_lock, flags);
-}
-
-/*
* "Unplug" a node from the device tree. The caller must hold
* a reference to the node. The memory associated with the node
* is not freed until its refcount goes to zero.

drivers/of/of_dynamic.c new file +32 -0
Index: test-devicetree/drivers/of/of_dynamic.c
===================================================================
@@ -0,0 +1,32 @@
+/*
+ * Procedures for dynamically updating the device tree.
+ *
+ * Paul Mackerras	August 1996.
+ * Copyright (C) 1996-2005 Paul Mackerras.
+ *
+ *  Adapted for 64bit PowerPC by Dave Engebretsen and Peter Bergner.
+ *    {engebret|bergner}@us.ibm.com
+ *
+ *      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.
+ */
+
+#include <linux/of_dynamic.h>
+
+/*
+ * Plug a device node into the tree and global list.
+ */
+void of_attach_node(struct device_node *np)
+{
+	unsigned long flags;
+
+	write_lock_irqsave(&devtree_lock, flags);
+	np->sibling = np->parent->child;
+	np->allnext = allnodes;
+	np->parent->child = np;
+	allnodes = np;
+	write_unlock_irqrestore(&devtree_lock, flags);
+}
+
include/linux/of_dynamic.h new file +26 -0
Index: test-devicetree/include/linux/of_dynamic.h
===================================================================
@@ -0,0 +1,26 @@
+/*
+ * Definitions for dynamically updating the device tree.
+ *
+ * Paul Mackerras	August 1996.
+ * Copyright (C) 1996-2005 Paul Mackerras.
+ *
+ *  Adapted for 64bit PowerPC by Dave Engebretsen and Peter Bergner.
+ *    {engebret|bergner}@us.ibm.com
+ *
+ *      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.
+ */
+
+#ifndef _LINUX_OF_DYNAMIC_H
+#define _LINUX_OF_DYNAMIC_H
+
+#include <linux/of.h>
+
+/* temporary while merging */
+extern struct device_node *allnodes;
+extern rwlock_t devtree_lock;
+
+extern void of_attach_node(struct device_node *);
+#endif
arch/microblaze/include/asm/prom.h +0 -0
Index: test-devicetree/arch/microblaze/include/asm/prom.h
===================================================================
@@ -40,7 +40,6 @@

extern rwlock_t devtree_lock; /* temporary while merging */

/* For updating the device tree at runtime */ -extern void of_attach_node(struct device_node *); extern void of_detach_node(struct device_node *);

/* Other Prototypes */

arch/powerpc/include/asm/prom.h +0 -0
Index: test-devicetree/arch/powerpc/include/asm/prom.h
===================================================================
@@ -35,7 +35,6 @@

#define HAVE_ARCH_DEVTREE_FIXUPS

/* For updating the device tree at runtime */ -extern void of_attach_node(struct device_node *); extern void of_detach_node(struct device_node *);

#ifdef CONFIG_PPC32

#3 lore raw

PATCH v2 2/4 Merge of_detach_node

In reply to a message not in the archive

Merge the common of_detach_node() from powerpc and microblaze into the common drivers/of/of_dynamic.c

---

arch/microblaze/include/asm/prom.h |    3 --
arch/microblaze/kernel/prom.c      |   44 -------------------------------------
arch/powerpc/include/asm/prom.h    |    3 --
arch/powerpc/kernel/prom.c         |   44 -------------------------------------
drivers/of/of_dynamic.c            |   43 ++++++++++++++++++++++++++++++++++++
include/linux/of_dynamic.h         |    1 6 files changed, 44 insertions(+), 94 deletions(-)
arch/microblaze/kernel/prom.c +0 -0
Index: test-devicetree/arch/microblaze/kernel/prom.c
===================================================================
@@ -482,50 +482,6 @@

}
EXPORT_SYMBOL(of_node_put);

-/*
- * "Unplug" a node from the device tree. The caller must hold
- * a reference to the node. The memory associated with the node
- * is not freed until its refcount goes to zero.
- */
-void of_detach_node(struct device_node *np)
-{
- struct device_node *parent;
- unsigned long flags;
-
- write_lock_irqsave(&devtree_lock, flags);
-
- parent = np->parent;
- if (!parent)
- goto out_unlock;
-
- if (allnodes == np)
- allnodes = np->allnext;
- else {
- struct device_node *prev;
- for (prev = allnodes;
- prev->allnext != np;
- prev = prev->allnext)
- ;
- prev->allnext = np->allnext;
- }
-
- if (parent->child == np)
- parent->child = np->sibling;
- else {
- struct device_node *prevsib;
- for (prevsib = np->parent->child;
- prevsib->sibling != np;
- prevsib = prevsib->sibling)
- ;
- prevsib->sibling = np->sibling;
- }
-
- of_node_set_flag(np, OF_DETACHED);
-
-out_unlock:
- write_unlock_irqrestore(&devtree_lock, flags);
-}
-
#if defined(CONFIG_DEBUG_FS) && defined(DEBUG)
static struct debugfs_blob_wrapper flat_dt_blob;

arch/powerpc/kernel/prom.c +0 -0
Index: test-devicetree/arch/powerpc/kernel/prom.c
===================================================================
@@ -935,50 +935,6 @@

}
EXPORT_SYMBOL(of_node_put);

-/*
- * "Unplug" a node from the device tree. The caller must hold
- * a reference to the node. The memory associated with the node
- * is not freed until its refcount goes to zero.
- */
-void of_detach_node(struct device_node *np)
-{
- struct device_node *parent;
- unsigned long flags;
-
- write_lock_irqsave(&devtree_lock, flags);
-
- parent = np->parent;
- if (!parent)
- goto out_unlock;
-
- if (allnodes == np)
- allnodes = np->allnext;
- else {
- struct device_node *prev;
- for (prev = allnodes;
- prev->allnext != np;
- prev = prev->allnext)
- ;
- prev->allnext = np->allnext;
- }
-
- if (parent->child == np)
- parent->child = np->sibling;
- else {
- struct device_node *prevsib;
- for (prevsib = np->parent->child;
- prevsib->sibling != np;
- prevsib = prevsib->sibling)
- ;
- prevsib->sibling = np->sibling;
- }
-
- of_node_set_flag(np, OF_DETACHED);
-
-out_unlock:
- write_unlock_irqrestore(&devtree_lock, flags);
-}
-
#ifdef CONFIG_PPC_PSERIES
/*
* Fix up the uninitialized fields in a new device node:

drivers/of/of_dynamic.c +0 -0
Index: test-devicetree/drivers/of/of_dynamic.c
===================================================================
@@ -30,3 +30,46 @@
	write_unlock_irqrestore(&devtree_lock, flags);
}

+/*
+ * "Unplug" a node from the device tree. The caller must hold
+ * a reference to the node. The memory associated with the node
+ * is not freed until its refcount goes to zero.
+ */
+void of_detach_node(struct device_node *np)
+{
+ struct device_node *parent;
+ unsigned long flags;
+
+ write_lock_irqsave(&devtree_lock, flags);
+
+ parent = np->parent;
+ if (!parent)
+ goto out_unlock;
+
+ if (allnodes == np)
+ allnodes = np->allnext;
+ else {
+ struct device_node *prev;
+ for (prev = allnodes;
+ prev->allnext != np;
+ prev = prev->allnext)
+ ;
+ prev->allnext = np->allnext;
+ }
+
+ if (parent->child == np)
+ parent->child = np->sibling;
+ else {
+ struct device_node *prevsib;
+ for (prevsib = np->parent->child;
+ prevsib->sibling != np;
+ prevsib = prevsib->sibling)
+ ;
+ prevsib->sibling = np->sibling;
+ }
+
+ of_node_set_flag(np, OF_DETACHED);
+
+out_unlock:
+ write_unlock_irqrestore(&devtree_lock, flags);
+}

arch/microblaze/include/asm/prom.h +0 -0
Index: test-devicetree/arch/microblaze/include/asm/prom.h
===================================================================
@@ -39,9 +39,6 @@
 

extern rwlock_t devtree_lock; /* temporary while merging */

-/* For updating the device tree at runtime */ -extern void of_detach_node(struct device_node *); -
/* Other Prototypes */
extern int early_uartlite_console(void);

arch/powerpc/include/asm/prom.h +0 -0
Index: test-devicetree/arch/powerpc/include/asm/prom.h
===================================================================
@@ -34,9 +34,6 @@
 

#define HAVE_ARCH_DEVTREE_FIXUPS

-/* For updating the device tree at runtime */ -extern void of_detach_node(struct device_node *); -
#ifdef CONFIG_PPC32
/*
* PCI <-> OF matching functions

include/linux/of_dynamic.h +0 -0
Index: test-devicetree/include/linux/of_dynamic.h
===================================================================
@@ -23,4 +23,5 @@

extern rwlock_t devtree_lock;

extern void of_attach_node(struct device_node *); +extern void of_detach_node(struct device_node *); #endif

#4 lore raw

PATCH v2 3/4 Makefile and Kconfig updates

In reply to a message not in the archive

Update the Kconfig and Makefile files for drivers/of, powerpc and microblaze to properly configure for CONFIG_OF_DYNAMIC to build the of_dynamic code.

---

arch/microblaze/Kconfig |    1 +
arch/powerpc/Kconfig    |    1 +
drivers/of/Kconfig      |    4 ++++
drivers/of/Makefile     |    1 +
4 files changed, 7 insertions(+)
arch/microblaze/Kconfig +0 -0
Index: test-devicetree/arch/microblaze/Kconfig
===================================================================
@@ -112,6 +112,7 @@

config OF
def_bool y
select OF_FLATTREE
+ select OF_DYNAMIC

config PROC_DEVICETREE
bool "Support for device tree in /proc"

arch/powerpc/Kconfig +0 -0
Index: test-devicetree/arch/powerpc/Kconfig
===================================================================
@@ -164,6 +164,7 @@

config OF
def_bool y
select OF_FLATTREE
+ select OF_DYNAMIC

config PPC_UDBG_16550
bool

drivers/of/Kconfig +0 -0
Index: test-devicetree/drivers/of/Kconfig
===================================================================
@@ -2,6 +2,10 @@

bool
depends on OF

+config OF_DYNAMIC
+ bool
+ depends on OF
+
config OF_DEVICE

	def_bool y
	depends on OF && (SPARC || PPC_OF || MICROBLAZE)
drivers/of/Makefile +0 -0
Index: test-devicetree/drivers/of/Makefile
===================================================================
@@ -1,5 +1,6 @@

obj-y = base.o
obj-$(CONFIG_OF_FLATTREE) += fdt.o
+obj-$(CONFIG_OF_DYNAMIC) += of_dynamic.o
obj-$(CONFIG_OF_DEVICE) += device.o platform.o
obj-$(CONFIG_OF_GPIO) += gpio.o
obj-$(CONFIG_OF_I2C) += of_i2c.o

#5 lore raw

PATCH v2 4/4 Include of_dynamic.h in pseries/reconfig.c

In reply to a message not in the archive

Include the newly created linux/of_dynamic.h to pick up the of_[attach,detach]_node declarations.

---
arch/powerpc/platforms/pseries/reconfig.c | 1 +

1 file changed, 1 insertion(+)
arch/powerpc/platforms/pseries/reconfig.c +0 -0
Index: test-devicetree/arch/powerpc/platforms/pseries/reconfig.c
===================================================================
@@ -15,6 +15,7 @@

#include <linux/kref.h>
#include <linux/notifier.h>
#include <linux/proc_fs.h>
+#include <linux/of_dynamic.h>

#include <asm/prom.h>
#include <asm/machdep.h>

#6 lore raw
In reply to a message not in the archive
Quoted 6 lines · Nathan Fontenot

This set of patches merges the common dynamic device tree updating routines of_attach_node() and of_detach_node() to drivers/of/of_dynamic.c.

Built and tested on powerpc, I have no access to build/test this on microblaze.

Heh. Actually, I've got a patch in my tree that does the same thing (except to a different location). I could pick up your version and drop mine, but you need to rework it to be bi-sectable. As the series exists right now, the build will fail if only part of the series is applied. This change is simple enough that you can do the whole thing in a single patch. Or, fix the Kconfig and include stuff in the first patch with the merge of of_attach_node, and then move of_detach_node in the second.

But I'm really close to posting my 3rd series, so it may be better to wait until that is published and build a patch on top of that to move them into of_dynamic.c

Cheers,
g.

Quoted 20 lines

---

1/4 - Merge of_attach_node
2/4 - Merge of_detach_node
3/4 - Makefile/Kconfig updates
4/4 - Update powerpc/pseries to include of_dynamic.h

arch/microblaze/Kconfig                   |    1 arch/microblaze/include/asm/prom.h        |    4 - arch/microblaze/kernel/prom.c             |   59 ----------------------- arch/powerpc/Kconfig                      |    1 arch/powerpc/include/asm/prom.h           |    4 - arch/powerpc/kernel/prom.c                |   59 ----------------------- arch/powerpc/platforms/pseries/reconfig.c |    1 drivers/of/Kconfig |    4 +
drivers/of/Makefile                       |    1 drivers/of/of_dynamic.c |   75 ++++++++++++++++++++++++++++++ include/linux/of_dynamic.h                |   27 ++++++++++

11 files changed, 110 insertions(+), 126 deletions(-)
Signature · 2 lines
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
#8 lore raw
In reply to a message not in the archive

On Fri, 20 Nov 2009 14:40:22 -0700
Grant Likely <grant.likely-s3s/[email protected]> wrote:

[...]

Quoted 5 lines

But I'm really close to posting my 3rd series, so it may be better to wait until that is published and build a patch on top of that to move them into of_dynamic.c

Do you have any plans to deal w/ creation of the fdt (specifically for sparc)? I'd like to get OLPC's devtree code upstream, which will require the same type of thing as the firmware doesn't hand a binary blob off to the kernel (afaik).

#9 lore raw
In reply to a message not in the archive
Quoted 17 lines · Grant Likely
Quoted 6 lines · Nathan Fontenot

This set of patches merges the common dynamic device tree updating routines of_attach_node() and of_detach_node() to drivers/of/of_dynamic.c.

Built and tested on powerpc, I have no access to build/test this on microblaze.

Heh. Actually, I've got a patch in my tree that does the same thing (except to a different location). I could pick up your version and drop mine, but you need to rework it to be bi-sectable. As the series exists right now, the build will fail if only part of the series is applied. This change is simple enough that you can do the whole thing in a single patch. Or, fix the Kconfig and include stuff in the first patch with the merge of of_attach_node, and then move of_detach_node in the second.

Quoted 3 lines

But I'm really close to posting my 3rd series, so it may be better to wait until that is published and build a patch on top of that to move them into of_dynamic.c

ACK.
Michal

Quoted 27 lines

Cheers,
g.

Quoted 20 lines

---

1/4 - Merge of_attach_node
2/4 - Merge of_detach_node
3/4 - Makefile/Kconfig updates
4/4 - Update powerpc/pseries to include of_dynamic.h

arch/microblaze/Kconfig                   |    1
arch/microblaze/include/asm/prom.h        |    4 -
arch/microblaze/kernel/prom.c             |   59 -----------------------
arch/powerpc/Kconfig                      |    1
arch/powerpc/include/asm/prom.h           |    4 -
arch/powerpc/kernel/prom.c                |   59 -----------------------
arch/powerpc/platforms/pseries/reconfig.c |    1 drivers/of/Kconfig
               |    4 +
drivers/of/Makefile                       |    1 drivers/of/of_dynamic.c
              |   75 ++++++++++++++++++++++++++++++
include/linux/of_dynamic.h                |   27 ++++++++++
11 files changed, 110 insertions(+), 126 deletions(-)
Signature · 3 lines
Michal Simek, Ing. (M.Eng)
PetaLogix - Linux Solutions for a Reconfigurable World
w: www.petalogix.com p: +61-7-30090663,+42-0-721842854 f: +61-7-30090663