[PATCH 00/11] Yet another series of OF merge patches.

2009-11-24 Thread Grant Likely
Nothing much to say here other than mostly mechanical merging of OF
support code.  Some of it remains a little ugly, but I'm taking the
approach of merging the code first, and refactoring it second.

I've pushed this series out to my test-devicetree branch on my git
server if anyone wants to test.  That branch also includes the
previous 2 patch series that I've sent out.

git://git.secretlab.ca/git/linux-2.6 test-devicetree

Compile tested on: ppc64, ppc32, microblaze, sparc64, sparc32.
Boot tested on mpc5200 (ppc32) platform.

---

Grant Likely (11):
  of: unify phandle name in struct device_node
  microblaze: gut implementation of early_init_dt_scan_cpus()
  of: merge of_attach_node()  of_detach_node()
  of: Merge of_node_get() and of_node_put()
  of: merge machine_is_compatible()
  of/flattree: merge early_init_devtree() and early_init_move_devtree()
  of/flattree: merge early_init_dt_scan_chosen()
  of/flattree: eliminate cell_t typedef
  of/flattree: merge dt_mem_next_cell
  of/flattree: Merge earlyinit_dt_scan_root()
  of/flattree: Merge early_init_dt_check_for_initrd()


 arch/microblaze/include/asm/prom.h   |4 
 arch/microblaze/kernel/prom.c|  375 +-
 arch/powerpc/include/asm/prom.h  |4 
 arch/powerpc/kernel/prom.c   |  366 ++---
 arch/powerpc/platforms/powermac/pfunc_core.c |2 
 arch/sparc/kernel/devices.c  |2 
 arch/sparc/kernel/of_device_32.c |2 
 arch/sparc/kernel/of_device_64.c |2 
 arch/sparc/kernel/prom_common.c  |8 -
 arch/sparc/kernel/smp_64.c   |2 
 drivers/of/base.c|  153 +++
 drivers/of/fdt.c |  204 ++
 drivers/sbus/char/openprom.c |   10 -
 drivers/video/aty/atyfb_base.c   |2 
 include/linux/of.h   |7 
 include/linux/of_fdt.h   |   18 +
 16 files changed, 430 insertions(+), 731 deletions(-)

-- 
Signature
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH 01/11] of/flattree: Merge early_init_dt_check_for_initrd()

2009-11-24 Thread Grant Likely
Merge common code between PowerPC and Microblaze

Signed-off-by: Grant Likely grant.lik...@secretlab.ca
Reviewed-by: Wolfram Sang w.s...@pengutronix.de
Tested-by: Michal Simek mon...@monstr.eu
---

 arch/microblaze/kernel/prom.c |   32 
 arch/powerpc/kernel/prom.c|   30 --
 drivers/of/fdt.c  |   37 +
 include/linux/of_fdt.h|1 +
 4 files changed, 38 insertions(+), 62 deletions(-)

diff --git a/arch/microblaze/kernel/prom.c b/arch/microblaze/kernel/prom.c
index a38e373..7959495 100644
--- a/arch/microblaze/kernel/prom.c
+++ b/arch/microblaze/kernel/prom.c
@@ -113,38 +113,6 @@ static int __init early_init_dt_scan_cpus(unsigned long 
node,
return 0;
 }
 
-#ifdef CONFIG_BLK_DEV_INITRD
-static void __init early_init_dt_check_for_initrd(unsigned long node)
-{
-   unsigned long l;
-   u32 *prop;
-
-   pr_debug(Looking for initrd properties... );
-
-   prop = of_get_flat_dt_prop(node, linux,initrd-start, l);
-   if (prop) {
-   initrd_start = (unsigned long)
-   __va((u32)of_read_ulong(prop, l/4));
-
-   prop = of_get_flat_dt_prop(node, linux,initrd-end, l);
-   if (prop) {
-   initrd_end = (unsigned long)
-   __va((u32)of_read_ulong(prop, 1/4));
-   initrd_below_start_ok = 1;
-   } else {
-   initrd_start = 0;
-   }
-   }
-
-   pr_debug(initrd_start=0x%lx  initrd_end=0x%lx\n,
-   initrd_start, initrd_end);
-}
-#else
-static inline void early_init_dt_check_for_initrd(unsigned long node)
-{
-}
-#endif /* CONFIG_BLK_DEV_INITRD */
-
 static int __init early_init_dt_scan_chosen(unsigned long node,
const char *uname, int depth, void *data)
 {
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 7f88566..1ecd6c6 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -373,36 +373,6 @@ static int __init early_init_dt_scan_cpus(unsigned long 
node,
return 0;
 }
 
-#ifdef CONFIG_BLK_DEV_INITRD
-static void __init early_init_dt_check_for_initrd(unsigned long node)
-{
-   unsigned long l;
-   u32 *prop;
-
-   DBG(Looking for initrd properties... );
-
-   prop = of_get_flat_dt_prop(node, linux,initrd-start, l);
-   if (prop) {
-   initrd_start = (unsigned long)__va(of_read_ulong(prop, l/4));
-
-   prop = of_get_flat_dt_prop(node, linux,initrd-end, l);
-   if (prop) {
-   initrd_end = (unsigned long)
-   __va(of_read_ulong(prop, l/4));
-   initrd_below_start_ok = 1;
-   } else {
-   initrd_start = 0;
-   }
-   }
-
-   DBG(initrd_start=0x%lx  initrd_end=0x%lx\n, initrd_start, initrd_end);
-}
-#else
-static inline void early_init_dt_check_for_initrd(unsigned long node)
-{
-}
-#endif /* CONFIG_BLK_DEV_INITRD */
-
 static int __init early_init_dt_scan_chosen(unsigned long node,
const char *uname, int depth, void 
*data)
 {
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 43d236c..6ad98e8 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -11,6 +11,7 @@
 
 #include linux/kernel.h
 #include linux/lmb.h
+#include linux/initrd.h
 #include linux/of.h
 #include linux/of_fdt.h
 
@@ -369,6 +370,42 @@ unsigned long __init unflatten_dt_node(unsigned long mem,
return mem;
 }
 
+#ifdef CONFIG_BLK_DEV_INITRD
+/**
+ * early_init_dt_check_for_initrd - Decode initrd location from flat tree
+ * @node: reference to node containing initrd location ('chosen')
+ */
+void __init early_init_dt_check_for_initrd(unsigned long node)
+{
+   unsigned long len;
+   u32 *prop;
+
+   pr_debug(Looking for initrd properties... );
+
+   prop = of_get_flat_dt_prop(node, linux,initrd-start, len);
+   if (prop) {
+   initrd_start = (unsigned long)
+   __va(of_read_ulong(prop, len/4));
+
+   prop = of_get_flat_dt_prop(node, linux,initrd-end, len);
+   if (prop) {
+   initrd_end = (unsigned long)
+   __va(of_read_ulong(prop, len/4));
+   initrd_below_start_ok = 1;
+   } else {
+   initrd_start = 0;
+   }
+   }
+
+   pr_debug(initrd_start=0x%lx  initrd_end=0x%lx\n,
+initrd_start, initrd_end);
+}
+#else
+inline void early_init_dt_check_for_initrd(unsigned long node)
+{
+}
+#endif /* CONFIG_BLK_DEV_INITRD */
+
 /**
  * unflatten_device_tree - create tree of device_nodes from flat blob
  *
diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h

[PATCH 02/11] of/flattree: Merge earlyinit_dt_scan_root()

2009-11-24 Thread Grant Likely
Merge common code between PowerPC and Microblaze

Signed-off-by: Grant Likely grant.lik...@secretlab.ca
---

 arch/microblaze/kernel/prom.c |   23 ---
 arch/powerpc/kernel/prom.c|   24 
 drivers/of/fdt.c  |   26 ++
 include/linux/of_fdt.h|6 ++
 4 files changed, 32 insertions(+), 47 deletions(-)

diff --git a/arch/microblaze/kernel/prom.c b/arch/microblaze/kernel/prom.c
index 7959495..189179a 100644
--- a/arch/microblaze/kernel/prom.c
+++ b/arch/microblaze/kernel/prom.c
@@ -42,9 +42,6 @@
 #include asm/sections.h
 #include asm/pci-bridge.h
 
-static int __initdata dt_root_addr_cells;
-static int __initdata dt_root_size_cells;
-
 typedef u32 cell_t;
 
 /* export that to outside world */
@@ -158,26 +155,6 @@ static int __init early_init_dt_scan_chosen(unsigned long 
node,
return 1;
 }
 
-static int __init early_init_dt_scan_root(unsigned long node,
-   const char *uname, int depth, void *data)
-{
-   u32 *prop;
-
-   if (depth != 0)
-   return 0;
-
-   prop = of_get_flat_dt_prop(node, #size-cells, NULL);
-   dt_root_size_cells = (prop == NULL) ? 1 : *prop;
-   pr_debug(dt_root_size_cells = %x\n, dt_root_size_cells);
-
-   prop = of_get_flat_dt_prop(node, #address-cells, NULL);
-   dt_root_addr_cells = (prop == NULL) ? 2 : *prop;
-   pr_debug(dt_root_addr_cells = %x\n, dt_root_addr_cells);
-
-   /* break now */
-   return 1;
-}
-
 static u64 __init dt_mem_next_cell(int s, cell_t **cellp)
 {
cell_t *p = *cellp;
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 1ecd6c6..78f65a4 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -61,10 +61,6 @@
 #define DBG(fmt...)
 #endif
 
-
-static int __initdata dt_root_addr_cells;
-static int __initdata dt_root_size_cells;
-
 #ifdef CONFIG_PPC64
 int __initdata iommu_is_off;
 int __initdata iommu_force_on;
@@ -436,26 +432,6 @@ static int __init early_init_dt_scan_chosen(unsigned long 
node,
return 1;
 }
 
-static int __init early_init_dt_scan_root(unsigned long node,
- const char *uname, int depth, void 
*data)
-{
-   u32 *prop;
-
-   if (depth != 0)
-   return 0;
-
-   prop = of_get_flat_dt_prop(node, #size-cells, NULL);
-   dt_root_size_cells = (prop == NULL) ? 1 : *prop;
-   DBG(dt_root_size_cells = %x\n, dt_root_size_cells);
-
-   prop = of_get_flat_dt_prop(node, #address-cells, NULL);
-   dt_root_addr_cells = (prop == NULL) ? 2 : *prop;
-   DBG(dt_root_addr_cells = %x\n, dt_root_addr_cells);
-   
-   /* break now */
-   return 1;
-}
-
 static u64 __init dt_mem_next_cell(int s, cell_t **cellp)
 {
cell_t *p = *cellp;
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 6ad98e8..be200be 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -15,6 +15,9 @@
 #include linux/of.h
 #include linux/of_fdt.h
 
+int __initdata dt_root_addr_cells;
+int __initdata dt_root_size_cells;
+
 struct boot_param_header *initial_boot_params;
 
 char *find_flat_dt_string(u32 offset)
@@ -407,6 +410,29 @@ inline void early_init_dt_check_for_initrd(unsigned long 
node)
 #endif /* CONFIG_BLK_DEV_INITRD */
 
 /**
+ * early_init_dt_scan_root - fetch the top level address and size cells
+ */
+int __init early_init_dt_scan_root(unsigned long node, const char *uname,
+  int depth, void *data)
+{
+   u32 *prop;
+
+   if (depth != 0)
+   return 0;
+
+   prop = of_get_flat_dt_prop(node, #size-cells, NULL);
+   dt_root_size_cells = (prop == NULL) ? 1 : *prop;
+   pr_debug(dt_root_size_cells = %x\n, dt_root_size_cells);
+
+   prop = of_get_flat_dt_prop(node, #address-cells, NULL);
+   dt_root_addr_cells = (prop == NULL) ? 2 : *prop;
+   pr_debug(dt_root_addr_cells = %x\n, dt_root_addr_cells);
+
+   /* break now */
+   return 1;
+}
+
+/**
  * unflatten_device_tree - create tree of device_nodes from flat blob
  *
  * unflattens the device-tree passed by the firmware, creating the
diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h
index ec2db82..828c3cd 100644
--- a/include/linux/of_fdt.h
+++ b/include/linux/of_fdt.h
@@ -58,6 +58,8 @@ struct boot_param_header {
 };
 
 /* TBD: Temporary export of fdt globals - remove when code fully merged */
+extern int __initdata dt_root_addr_cells;
+extern int __initdata dt_root_size_cells;
 extern struct boot_param_header *initial_boot_params;
 
 /* For scanning the flat device-tree at boot time */
@@ -71,6 +73,10 @@ extern int of_flat_dt_is_compatible(unsigned long node, 
const char *name);
 extern unsigned long of_get_flat_dt_root(void);
 extern void early_init_dt_check_for_initrd(unsigned long node);
 
+/* Early flat tree scan hooks */
+extern int early_init_dt_scan_root(unsigned long node, const char *uname,
+   

[PATCH 03/11] of/flattree: merge dt_mem_next_cell

2009-11-24 Thread Grant Likely
Merge common code between PowerPC and Microblaze

Signed-off-by: Grant Likely grant.lik...@secretlab.ca
---

 arch/microblaze/kernel/prom.c |8 
 arch/powerpc/kernel/prom.c|8 
 drivers/of/fdt.c  |8 
 include/linux/of_fdt.h|1 +
 4 files changed, 9 insertions(+), 16 deletions(-)

diff --git a/arch/microblaze/kernel/prom.c b/arch/microblaze/kernel/prom.c
index 189179a..e0f4c34 100644
--- a/arch/microblaze/kernel/prom.c
+++ b/arch/microblaze/kernel/prom.c
@@ -155,14 +155,6 @@ static int __init early_init_dt_scan_chosen(unsigned long 
node,
return 1;
 }
 
-static u64 __init dt_mem_next_cell(int s, cell_t **cellp)
-{
-   cell_t *p = *cellp;
-
-   *cellp = p + s;
-   return of_read_number(p, s);
-}
-
 static int __init early_init_dt_scan_memory(unsigned long node,
const char *uname, int depth, void *data)
 {
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 78f65a4..048e3a3 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -432,14 +432,6 @@ static int __init early_init_dt_scan_chosen(unsigned long 
node,
return 1;
 }
 
-static u64 __init dt_mem_next_cell(int s, cell_t **cellp)
-{
-   cell_t *p = *cellp;
-
-   *cellp = p + s;
-   return of_read_number(p, s);
-}
-
 #ifdef CONFIG_PPC_PSERIES
 /*
  * Interpret the ibm,dynamic-memory property in the
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index be200be..ebce509 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -432,6 +432,14 @@ int __init early_init_dt_scan_root(unsigned long node, 
const char *uname,
return 1;
 }
 
+u64 __init dt_mem_next_cell(int s, u32 **cellp)
+{
+   u32 *p = *cellp;
+
+   *cellp = p + s;
+   return of_read_number(p, s);
+}
+
 /**
  * unflatten_device_tree - create tree of device_nodes from flat blob
  *
diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h
index 828c3cd..d1a37e5 100644
--- a/include/linux/of_fdt.h
+++ b/include/linux/of_fdt.h
@@ -72,6 +72,7 @@ extern void *of_get_flat_dt_prop(unsigned long node, const 
char *name,
 extern int of_flat_dt_is_compatible(unsigned long node, const char *name);
 extern unsigned long of_get_flat_dt_root(void);
 extern void early_init_dt_check_for_initrd(unsigned long node);
+extern u64 dt_mem_next_cell(int s, u32 **cellp);
 
 /* Early flat tree scan hooks */
 extern int early_init_dt_scan_root(unsigned long node, const char *uname,

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH 04/11] of/flattree: eliminate cell_t typedef

2009-11-24 Thread Grant Likely
A cell is firmly established as a u32.  No need to do an ugly typedef
to redefine it to cell_t.  Eliminate the unnecessary typedef so that
it doesn't have to be added to the of_fdt header file

Signed-off-by: Grant Likely grant.lik...@secretlab.ca
---

 arch/microblaze/kernel/prom.c |   10 --
 arch/powerpc/kernel/prom.c|   14 ++
 2 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/arch/microblaze/kernel/prom.c b/arch/microblaze/kernel/prom.c
index e0f4c34..7760186 100644
--- a/arch/microblaze/kernel/prom.c
+++ b/arch/microblaze/kernel/prom.c
@@ -42,8 +42,6 @@
 #include asm/sections.h
 #include asm/pci-bridge.h
 
-typedef u32 cell_t;
-
 /* export that to outside world */
 struct device_node *of_chosen;
 
@@ -159,7 +157,7 @@ static int __init early_init_dt_scan_memory(unsigned long 
node,
const char *uname, int depth, void *data)
 {
char *type = of_get_flat_dt_prop(node, device_type, NULL);
-   cell_t *reg, *endp;
+   u32 *reg, *endp;
unsigned long l;
 
/* Look for the ibm,dynamic-reconfiguration-memory node */
@@ -178,13 +176,13 @@ static int __init early_init_dt_scan_memory(unsigned long 
node,
} else if (strcmp(type, memory) != 0)
return 0;
 
-   reg = (cell_t *)of_get_flat_dt_prop(node, linux,usable-memory, l);
+   reg = (u32 *)of_get_flat_dt_prop(node, linux,usable-memory, l);
if (reg == NULL)
-   reg = (cell_t *)of_get_flat_dt_prop(node, reg, l);
+   reg = (u32 *)of_get_flat_dt_prop(node, reg, l);
if (reg == NULL)
return 0;
 
-   endp = reg + (l / sizeof(cell_t));
+   endp = reg + (l / sizeof(u32));
 
pr_debug(memory scan node %s, reg size %ld, data: %x %x %x %x,\n,
uname, l, reg[0], reg[1], reg[2], reg[3]);
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 048e3a3..43cdba2 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -67,8 +67,6 @@ int __initdata iommu_force_on;
 unsigned long tce_alloc_start, tce_alloc_end;
 #endif
 
-typedef u32 cell_t;
-
 extern rwlock_t devtree_lock;  /* temporary while merging */
 
 /* export that to outside world */
@@ -441,22 +439,22 @@ static int __init early_init_dt_scan_chosen(unsigned long 
node,
  */
 static int __init early_init_dt_scan_drconf_memory(unsigned long node)
 {
-   cell_t *dm, *ls, *usm;
+   u32 *dm, *ls, *usm;
unsigned long l, n, flags;
u64 base, size, lmb_size;
unsigned int is_kexec_kdump = 0, rngs;
 
ls = of_get_flat_dt_prop(node, ibm,lmb-size, l);
-   if (ls == NULL || l  dt_root_size_cells * sizeof(cell_t))
+   if (ls == NULL || l  dt_root_size_cells * sizeof(u32))
return 0;
lmb_size = dt_mem_next_cell(dt_root_size_cells, ls);
 
dm = of_get_flat_dt_prop(node, ibm,dynamic-memory, l);
-   if (dm == NULL || l  sizeof(cell_t))
+   if (dm == NULL || l  sizeof(u32))
return 0;
 
n = *dm++;  /* number of entries */
-   if (l  (n * (dt_root_addr_cells + 4) + 1) * sizeof(cell_t))
+   if (l  (n * (dt_root_addr_cells + 4) + 1) * sizeof(u32))
return 0;
 
/* check if this is a kexec/kdump kernel. */
@@ -515,7 +513,7 @@ static int __init early_init_dt_scan_memory(unsigned long 
node,
const char *uname, int depth, void 
*data)
 {
char *type = of_get_flat_dt_prop(node, device_type, NULL);
-   cell_t *reg, *endp;
+   u32 *reg, *endp;
unsigned long l;
 
/* Look for the ibm,dynamic-reconfiguration-memory node */
@@ -540,7 +538,7 @@ static int __init early_init_dt_scan_memory(unsigned long 
node,
if (reg == NULL)
return 0;
 
-   endp = reg + (l / sizeof(cell_t));
+   endp = reg + (l / sizeof(u32));
 
DBG(memory scan node %s, reg size %ld, data: %x %x %x %x,\n,
uname, l, reg[0], reg[1], reg[2], reg[3]);

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH 05/11] of/flattree: merge early_init_dt_scan_chosen()

2009-11-24 Thread Grant Likely
Merge common code between PowerPC and Microblaze.  This patch
splits the arch-specific stuff out into a new function,
early_init_dt_scan_chosen_arch().

Signed-off-by: Grant Likely grant.lik...@secretlab.ca
---

 arch/microblaze/kernel/prom.c |   44 ++-
 arch/powerpc/kernel/prom.c|   46 +
 drivers/of/fdt.c  |   38 ++
 include/linux/of_fdt.h|3 +++
 4 files changed, 53 insertions(+), 78 deletions(-)

diff --git a/arch/microblaze/kernel/prom.c b/arch/microblaze/kernel/prom.c
index 7760186..7ee021f 100644
--- a/arch/microblaze/kernel/prom.c
+++ b/arch/microblaze/kernel/prom.c
@@ -108,49 +108,9 @@ static int __init early_init_dt_scan_cpus(unsigned long 
node,
return 0;
 }
 
-static int __init early_init_dt_scan_chosen(unsigned long node,
-   const char *uname, int depth, void *data)
+void __init early_init_dt_scan_chosen_arch(unsigned long node)
 {
-   unsigned long l;
-   char *p;
-
-   pr_debug(search \chosen\, depth: %d, uname: %s\n, depth, uname);
-
-   if (depth != 1 ||
-   (strcmp(uname, chosen) != 0 
-   strcmp(uname, cho...@0) != 0))
-   return 0;
-
-#ifdef CONFIG_KEXEC
-   lprop = (u64 *)of_get_flat_dt_prop(node,
-   linux,crashkernel-base, NULL);
-   if (lprop)
-   crashk_res.start = *lprop;
-
-   lprop = (u64 *)of_get_flat_dt_prop(node,
-   linux,crashkernel-size, NULL);
-   if (lprop)
-   crashk_res.end = crashk_res.start + *lprop - 1;
-#endif
-
-   early_init_dt_check_for_initrd(node);
-
-   /* Retreive command line */
-   p = of_get_flat_dt_prop(node, bootargs, l);
-   if (p != NULL  l  0)
-   strlcpy(cmd_line, p, min((int)l, COMMAND_LINE_SIZE));
-
-#ifdef CONFIG_CMDLINE
-#ifndef CONFIG_CMDLINE_FORCE
-   if (p == NULL || l == 0 || (l == 1  (*p) == 0))
-#endif
-   strlcpy(cmd_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
-#endif /* CONFIG_CMDLINE */
-
-   pr_debug(Command line is: %s\n, cmd_line);
-
-   /* break now */
-   return 1;
+   /* No Microblaze specific code here */
 }
 
 static int __init early_init_dt_scan_memory(unsigned long node,
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 43cdba2..2c7d4a3 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -367,18 +367,9 @@ static int __init early_init_dt_scan_cpus(unsigned long 
node,
return 0;
 }
 
-static int __init early_init_dt_scan_chosen(unsigned long node,
-   const char *uname, int depth, void 
*data)
+void __init early_init_dt_scan_chosen_arch(unsigned long node)
 {
unsigned long *lprop;
-   unsigned long l;
-   char *p;
-
-   DBG(search \chosen\, depth: %d, uname: %s\n, depth, uname);
-
-   if (depth != 1 ||
-   (strcmp(uname, chosen) != 0  strcmp(uname, cho...@0) != 0))
-   return 0;
 
 #ifdef CONFIG_PPC64
/* check if iommu is forced on or off */
@@ -389,17 +380,17 @@ static int __init early_init_dt_scan_chosen(unsigned long 
node,
 #endif
 
/* mem=x on the command line is the preferred mechanism */
-   lprop = of_get_flat_dt_prop(node, linux,memory-limit, NULL);
-   if (lprop)
-   memory_limit = *lprop;
+   lprop = of_get_flat_dt_prop(node, linux,memory-limit, NULL);
+   if (lprop)
+   memory_limit = *lprop;
 
 #ifdef CONFIG_PPC64
-   lprop = of_get_flat_dt_prop(node, linux,tce-alloc-start, NULL);
-   if (lprop)
-   tce_alloc_start = *lprop;
-   lprop = of_get_flat_dt_prop(node, linux,tce-alloc-end, NULL);
-   if (lprop)
-   tce_alloc_end = *lprop;
+   lprop = of_get_flat_dt_prop(node, linux,tce-alloc-start, NULL);
+   if (lprop)
+   tce_alloc_start = *lprop;
+   lprop = of_get_flat_dt_prop(node, linux,tce-alloc-end, NULL);
+   if (lprop)
+   tce_alloc_end = *lprop;
 #endif
 
 #ifdef CONFIG_KEXEC
@@ -411,23 +402,6 @@ static int __init early_init_dt_scan_chosen(unsigned long 
node,
if (lprop)
crashk_res.end = crashk_res.start + *lprop - 1;
 #endif
-
-   early_init_dt_check_for_initrd(node);
-
-   /* Retreive command line */
-   p = of_get_flat_dt_prop(node, bootargs, l);
-   if (p != NULL  l  0)
-   strlcpy(cmd_line, p, min((int)l, COMMAND_LINE_SIZE));
-
-#ifdef CONFIG_CMDLINE
-   if (p == NULL || l == 0 || (l == 1  (*p) == 0))
-   strlcpy(cmd_line, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
-#endif /* CONFIG_CMDLINE */
-
-   DBG(Command line is: %s\n, cmd_line);
-
-   /* break now */
-   return 1;
 }
 
 #ifdef CONFIG_PPC_PSERIES
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index ebce509..616a476 

[PATCH 06/11] of/flattree: merge early_init_devtree() and early_init_move_devtree()

2009-11-24 Thread Grant Likely
Merge common code between Microblaze and PowerPC

Signed-off-by: Grant Likely grant.lik...@secretlab.ca
---

 arch/microblaze/kernel/prom.c |   53 +++
 arch/powerpc/kernel/prom.c|   94 +++--
 drivers/of/fdt.c  |   92 
 include/linux/of_fdt.h|7 +++
 4 files changed, 115 insertions(+), 131 deletions(-)

diff --git a/arch/microblaze/kernel/prom.c b/arch/microblaze/kernel/prom.c
index 7ee021f..543465a 100644
--- a/arch/microblaze/kernel/prom.c
+++ b/arch/microblaze/kernel/prom.c
@@ -47,9 +47,8 @@ struct device_node *of_chosen;
 
 #define early_init_dt_scan_drconf_memory(node) 0
 
-static int __init early_init_dt_scan_cpus(unsigned long node,
- const char *uname, int depth,
- void *data)
+int __init early_init_dt_scan_cpus(unsigned long node, const char *uname,
+  int depth, void *data)
 {
static int logical_cpuid;
char *type = of_get_flat_dt_prop(node, device_type, NULL);
@@ -113,8 +112,8 @@ void __init early_init_dt_scan_chosen_arch(unsigned long 
node)
/* No Microblaze specific code here */
 }
 
-static int __init early_init_dt_scan_memory(unsigned long node,
-   const char *uname, int depth, void *data)
+int __init early_init_dt_scan_memory(unsigned long node, const char *uname,
+int depth, void *data)
 {
char *type = of_get_flat_dt_prop(node, device_type, NULL);
u32 *reg, *endp;
@@ -201,7 +200,7 @@ static inline unsigned long 
phyp_dump_calculate_reserve_size(void)
  * without reserving anything. The memory in case of dump being
  * active is freed when the dump is collected (by userland tools).
  */
-static void __init phyp_dump_reserve_mem(void)
+void __init phyp_dump_reserve_mem(void)
 {
unsigned long base, size;
unsigned long variable_reserve_size;
@@ -240,7 +239,7 @@ static void __init phyp_dump_reserve_mem(void)
}
 }
 #else
-static inline void __init phyp_dump_reserve_mem(void) {}
+inline void __init phyp_dump_reserve_mem(void) {}
 #endif /* CONFIG_PHYP_DUMP   CONFIG_PPC_RTAS */
 
 #ifdef CONFIG_EARLY_PRINTK
@@ -277,45 +276,9 @@ int __init early_uartlite_console(void)
 }
 #endif
 
-void __init early_init_devtree(void *params)
+void __init early_init_devtree_arch(void)
 {
-   pr_debug( - early_init_devtree(%p)\n, params);
-
-   /* Setup flat device-tree pointer */
-   initial_boot_params = params;
-
-#ifdef CONFIG_PHYP_DUMP
-   /* scan tree to see if dump occured during last boot */
-   of_scan_flat_dt(early_init_dt_scan_phyp_dump, NULL);
-#endif
-
-   /* Retrieve various informations from the /chosen node of the
-* device-tree, including the platform type, initrd location and
-* size, TCE reserve, and more ...
-*/
-   of_scan_flat_dt(early_init_dt_scan_chosen, NULL);
-
-   /* Scan memory nodes and rebuild LMBs */
-   lmb_init();
-   of_scan_flat_dt(early_init_dt_scan_root, NULL);
-   of_scan_flat_dt(early_init_dt_scan_memory, NULL);
-
-   /* Save command line for /proc/cmdline and then parse parameters */
-   strlcpy(boot_command_line, cmd_line, COMMAND_LINE_SIZE);
-   parse_early_param();
-
-   lmb_analyze();
-
-   pr_debug(Phys. mem: %lx\n, (unsigned long) lmb_phys_mem_size());
-
-   pr_debug(Scanning CPUs ...\n);
-
-   /* Retreive CPU related informations from the flat tree
-* (altivec support, boot CPU ID, ...)
-*/
-   of_scan_flat_dt(early_init_dt_scan_cpus, NULL);
-
-   pr_debug( - early_init_devtree()\n);
+   /* No Microblaze specific code here */
 }
 
 /**
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 2c7d4a3..a5b3b9d 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -84,33 +84,6 @@ static int __init early_parse_mem(char *p)
 }
 early_param(mem, early_parse_mem);
 
-/**
- * move_device_tree - move tree to an unused area, if needed.
- *
- * The device tree may be allocated beyond our memory limit, or inside the
- * crash kernel region for kdump. If so, move it out of the way.
- */
-static void __init move_device_tree(void)
-{
-   unsigned long start, size;
-   void *p;
-
-   DBG(- move_device_tree\n);
-
-   start = __pa(initial_boot_params);
-   size = initial_boot_params-totalsize;
-
-   if ((memory_limit  (start + size)  memory_limit) ||
-   overlaps_crashkernel(start, size)) {
-   p = __va(lmb_alloc_base(size, PAGE_SIZE, lmb.rmo_size));
-   memcpy(p, initial_boot_params, size);
-   initial_boot_params = (struct boot_param_header *)p;
-   DBG(Moved device tree to 0x%p\n, p);
-   }
-
-   DBG(- move_device_tree\n);
-}
-
 /*
  * ibm,pa-features is a per-cpu 

[PATCH 07/11] of: merge machine_is_compatible()

2009-11-24 Thread Grant Likely
Merge common code between PowerPC and Microblaze

Signed-off-by: Grant Likely grant.lik...@secretlab.ca
---

 arch/microblaze/kernel/prom.c |   18 --
 arch/powerpc/kernel/prom.c|   18 --
 drivers/of/base.c |   18 ++
 3 files changed, 18 insertions(+), 36 deletions(-)

diff --git a/arch/microblaze/kernel/prom.c b/arch/microblaze/kernel/prom.c
index 543465a..c97192d 100644
--- a/arch/microblaze/kernel/prom.c
+++ b/arch/microblaze/kernel/prom.c
@@ -281,24 +281,6 @@ void __init early_init_devtree_arch(void)
/* No Microblaze specific code here */
 }
 
-/**
- * Indicates whether the root node has a given value in its
- * compatible property.
- */
-int machine_is_compatible(const char *compat)
-{
-   struct device_node *root;
-   int rc = 0;
-
-   root = of_find_node_by_path(/);
-   if (root) {
-   rc = of_device_is_compatible(root, compat);
-   of_node_put(root);
-   }
-   return rc;
-}
-EXPORT_SYMBOL(machine_is_compatible);
-
 /***
  *
  * New implementation of the OF find APIs, return a refcounted
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index a5b3b9d..65de093 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -677,24 +677,6 @@ void __init early_init_devtree_arch(void)
lmb_enforce_memory_limit(limit);
 }
 
-/**
- * Indicates whether the root node has a given value in its
- * compatible property.
- */
-int machine_is_compatible(const char *compat)
-{
-   struct device_node *root;
-   int rc = 0;
-
-   root = of_find_node_by_path(/);
-   if (root) {
-   rc = of_device_is_compatible(root, compat);
-   of_node_put(root);
-   }
-   return rc;
-}
-EXPORT_SYMBOL(machine_is_compatible);
-
 /***
  *
  * New implementation of the OF find APIs, return a refcounted
diff --git a/drivers/of/base.c b/drivers/of/base.c
index ec56739..e81558f 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -144,6 +144,24 @@ int of_device_is_compatible(const struct device_node 
*device,
 EXPORT_SYMBOL(of_device_is_compatible);
 
 /**
+ * Indicates whether the root node has a given value in its
+ * compatible property.
+ */
+int machine_is_compatible(const char *compat)
+{
+   struct device_node *root;
+   int rc = 0;
+
+   root = of_find_node_by_path(/);
+   if (root) {
+   rc = of_device_is_compatible(root, compat);
+   of_node_put(root);
+   }
+   return rc;
+}
+EXPORT_SYMBOL(machine_is_compatible);
+
+/**
  *  of_device_is_available - check if a device is available for use
  *
  *  @device: Node to check for availability

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH 08/11] of: Merge of_node_get() and of_node_put()

2009-11-24 Thread Grant Likely
Merge common code between PowerPC and MicroBlaze

Signed-off-by: Grant Likely grant.lik...@secretlab.ca
---

 arch/microblaze/kernel/prom.c |   74 
 arch/powerpc/kernel/prom.c|   73 
 drivers/of/base.c |   75 +
 3 files changed, 75 insertions(+), 147 deletions(-)

diff --git a/arch/microblaze/kernel/prom.c b/arch/microblaze/kernel/prom.c
index c97192d..c0d53b7 100644
--- a/arch/microblaze/kernel/prom.c
+++ b/arch/microblaze/kernel/prom.c
@@ -313,80 +313,6 @@ struct device_node *of_find_node_by_phandle(phandle handle)
 }
 EXPORT_SYMBOL(of_find_node_by_phandle);
 
-/**
- * of_node_get - Increment refcount of a node
- * @node:  Node to inc refcount, NULL is supported to
- * simplify writing of callers
- *
- * Returns node.
- */
-struct device_node *of_node_get(struct device_node *node)
-{
-   if (node)
-   kref_get(node-kref);
-   return node;
-}
-EXPORT_SYMBOL(of_node_get);
-
-static inline struct device_node *kref_to_device_node(struct kref *kref)
-{
-   return container_of(kref, struct device_node, kref);
-}
-
-/**
- * of_node_release - release a dynamically allocated node
- * @kref:  kref element of the node to be released
- *
- * In of_node_put() this function is passed to kref_put()
- * as the destructor.
- */
-static void of_node_release(struct kref *kref)
-{
-   struct device_node *node = kref_to_device_node(kref);
-   struct property *prop = node-properties;
-
-   /* We should never be releasing nodes that haven't been detached. */
-   if (!of_node_check_flag(node, OF_DETACHED)) {
-   printk(KERN_INFO WARNING: Bad of_node_put() on %s\n,
-   node-full_name);
-   dump_stack();
-   kref_init(node-kref);
-   return;
-   }
-
-   if (!of_node_check_flag(node, OF_DYNAMIC))
-   return;
-
-   while (prop) {
-   struct property *next = prop-next;
-   kfree(prop-name);
-   kfree(prop-value);
-   kfree(prop);
-   prop = next;
-
-   if (!prop) {
-   prop = node-deadprops;
-   node-deadprops = NULL;
-   }
-   }
-   kfree(node-full_name);
-   kfree(node-data);
-   kfree(node);
-}
-
-/**
- * of_node_put - Decrement refcount of a node
- * @node:  Node to dec refcount, NULL is supported to
- * simplify writing of callers
- *
- */
-void of_node_put(struct device_node *node)
-{
-   if (node)
-   kref_put(node-kref, of_node_release);
-}
-EXPORT_SYMBOL(of_node_put);
-
 /*
  * Plug a device node into the tree and global list.
  */
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 65de093..6873db9 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -740,79 +740,6 @@ struct device_node *of_find_next_cache_node(struct 
device_node *np)
return NULL;
 }
 
-/**
- * of_node_get - Increment refcount of a node
- * @node:  Node to inc refcount, NULL is supported to
- * simplify writing of callers
- *
- * Returns node.
- */
-struct device_node *of_node_get(struct device_node *node)
-{
-   if (node)
-   kref_get(node-kref);
-   return node;
-}
-EXPORT_SYMBOL(of_node_get);
-
-static inline struct device_node * kref_to_device_node(struct kref *kref)
-{
-   return container_of(kref, struct device_node, kref);
-}
-
-/**
- * of_node_release - release a dynamically allocated node
- * @kref:  kref element of the node to be released
- *
- * In of_node_put() this function is passed to kref_put()
- * as the destructor.
- */
-static void of_node_release(struct kref *kref)
-{
-   struct device_node *node = kref_to_device_node(kref);
-   struct property *prop = node-properties;
-
-   /* We should never be releasing nodes that haven't been detached. */
-   if (!of_node_check_flag(node, OF_DETACHED)) {
-   printk(WARNING: Bad of_node_put() on %s\n, node-full_name);
-   dump_stack();
-   kref_init(node-kref);
-   return;
-   }
-
-   if (!of_node_check_flag(node, OF_DYNAMIC))
-   return;
-
-   while (prop) {
-   struct property *next = prop-next;
-   kfree(prop-name);
-   kfree(prop-value);
-   kfree(prop);
-   prop = next;
-
-   if (!prop) {
-   prop = node-deadprops;
-   node-deadprops = NULL;
-   }
-   }
-   kfree(node-full_name);
-   kfree(node-data);
-   kfree(node);
-}
-
-/**
- * of_node_put - Decrement refcount of a node
- * @node:  Node to dec refcount, NULL is supported to
- * simplify writing of callers

[PATCH 09/11] of: merge of_attach_node() of_detach_node()

2009-11-24 Thread Grant Likely
Merge common code between PowerPC and Microblaze

Signed-off-by: Grant Likely grant.lik...@secretlab.ca
---

 arch/microblaze/include/asm/prom.h |4 --
 arch/microblaze/kernel/prom.c  |   59 ---
 arch/powerpc/include/asm/prom.h|4 --
 arch/powerpc/kernel/prom.c |   59 ---
 drivers/of/base.c  |   60 
 include/linux/of.h |4 ++
 6 files changed, 64 insertions(+), 126 deletions(-)

diff --git a/arch/microblaze/include/asm/prom.h 
b/arch/microblaze/include/asm/prom.h
index 07d1063..6c6b386 100644
--- a/arch/microblaze/include/asm/prom.h
+++ b/arch/microblaze/include/asm/prom.h
@@ -39,10 +39,6 @@ extern struct device_node *of_chosen;
 
 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 */
 extern int early_uartlite_console(void);
 
diff --git a/arch/microblaze/kernel/prom.c b/arch/microblaze/kernel/prom.c
index c0d53b7..8c00457 100644
--- a/arch/microblaze/kernel/prom.c
+++ b/arch/microblaze/kernel/prom.c
@@ -313,65 +313,6 @@ struct device_node *of_find_node_by_phandle(phandle handle)
 }
 EXPORT_SYMBOL(of_find_node_by_phandle);
 
-/*
- * 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.
- */
-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;
 
diff --git a/arch/powerpc/include/asm/prom.h b/arch/powerpc/include/asm/prom.h
index 2ab9cbd..f384db8 100644
--- a/arch/powerpc/include/asm/prom.h
+++ b/arch/powerpc/include/asm/prom.h
@@ -34,10 +34,6 @@ extern struct device_node *of_chosen;
 
 #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
 /*
  * PCI - OF matching functions
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 6873db9..7d0beeb 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -740,65 +740,6 @@ struct device_node *of_find_next_cache_node(struct 
device_node *np)
return NULL;
 }
 
-/*
- * 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.
- */
-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;
-   }
-
-  

[PATCH 10/11] microblaze: gut implementation of early_init_dt_scan_cpus()

2009-11-24 Thread Grant Likely
Microblaze only has one CPU, it isn't SMP at all.  This function is
effectively just a no-op, so remove it.

Signed-off-by: Grant Likely grant.lik...@secretlab.ca
---

 arch/microblaze/kernel/prom.c |   54 -
 1 files changed, 0 insertions(+), 54 deletions(-)

diff --git a/arch/microblaze/kernel/prom.c b/arch/microblaze/kernel/prom.c
index 8c00457..1f79e4d 100644
--- a/arch/microblaze/kernel/prom.c
+++ b/arch/microblaze/kernel/prom.c
@@ -50,60 +50,6 @@ struct device_node *of_chosen;
 int __init early_init_dt_scan_cpus(unsigned long node, const char *uname,
   int depth, void *data)
 {
-   static int logical_cpuid;
-   char *type = of_get_flat_dt_prop(node, device_type, NULL);
-   const u32 *intserv;
-   int i, nthreads;
-   int found = 0;
-
-   /* We are scanning cpu nodes only */
-   if (type == NULL || strcmp(type, cpu) != 0)
-   return 0;
-
-   /* Get physical cpuid */
-   intserv = of_get_flat_dt_prop(node, reg, NULL);
-   nthreads = 1;
-
-   /*
-* Now see if any of these threads match our boot cpu.
-* NOTE: This must match the parsing done in smp_setup_cpu_maps.
-*/
-   for (i = 0; i  nthreads; i++) {
-   /*
-* version 2 of the kexec param format adds the phys cpuid of
-* booted proc.
-*/
-   if (initial_boot_params  initial_boot_params-version = 2) {
-   if (intserv[i] ==
-   initial_boot_params-boot_cpuid_phys) {
-   found = 1;
-   break;
-   }
-   } else {
-   /*
-* Check if it's the boot-cpu, set it's hw index now,
-* unfortunately this format did not support booting
-* off secondary threads.
-*/
-   if (of_get_flat_dt_prop(node,
-   linux,boot-cpu, NULL) != NULL) {
-   found = 1;
-   break;
-   }
-   }
-
-#ifdef CONFIG_SMP
-   /* logical cpu id is always 0 on UP kernels */
-   logical_cpuid++;
-#endif
-   }
-
-   if (found) {
-   pr_debug(boot cpu: logical %d physical %d\n, logical_cpuid,
-   intserv[i]);
-   boot_cpuid = logical_cpuid;
-   }
-
return 0;
 }
 

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH 11/11] of: unify phandle name in struct device_node

2009-11-24 Thread Grant Likely
In struct device_node, the phandle is named 'linux_phandle' for PowerPC
and MicroBlaze, and 'node' for SPARC.  There is no good reason for the
difference, it is just an artifact of the code diverging over a couple
of years.  This patch renames .node to .linux_phandle for SPARC.

Note: the .node also existed in PowerPC/MicroBlaze, but the only user
seems to be arch/powerpc/platforms/powermac/pfunc_core.c.  It doesn't
look like the assignment between .linux_phandle and .node is
significantly different enough to warrant the separate code paths
unless ibm,phandle properties actually appear in Apple device trees.

I think it is safe to eliminate the old .node property and use
linux_phandle everywhere.

Signed-off-by: Grant Likely grant.lik...@secretlab.ca
---

 arch/powerpc/platforms/powermac/pfunc_core.c |2 +-
 arch/sparc/kernel/devices.c  |2 +-
 arch/sparc/kernel/of_device_32.c |2 +-
 arch/sparc/kernel/of_device_64.c |2 +-
 arch/sparc/kernel/prom_common.c  |8 
 arch/sparc/kernel/smp_64.c   |2 +-
 drivers/of/fdt.c |3 +--
 drivers/sbus/char/openprom.c |   10 +-
 drivers/video/aty/atyfb_base.c   |2 +-
 include/linux/of.h   |3 ---
 10 files changed, 16 insertions(+), 20 deletions(-)

diff --git a/arch/powerpc/platforms/powermac/pfunc_core.c 
b/arch/powerpc/platforms/powermac/pfunc_core.c
index 96d5ce5..2004b19 100644
--- a/arch/powerpc/platforms/powermac/pfunc_core.c
+++ b/arch/powerpc/platforms/powermac/pfunc_core.c
@@ -842,7 +842,7 @@ struct pmf_function *__pmf_find_function(struct device_node 
*target,
list_for_each_entry(func, dev-functions, link) {
if (name  strcmp(name, func-name))
continue;
-   if (func-phandle  target-node != func-phandle)
+   if (func-phandle  target-linux_phandle != func-phandle)
continue;
if ((func-flags  flags) == 0)
continue;
diff --git a/arch/sparc/kernel/devices.c b/arch/sparc/kernel/devices.c
index b171ae8..2196e71 100644
--- a/arch/sparc/kernel/devices.c
+++ b/arch/sparc/kernel/devices.c
@@ -59,7 +59,7 @@ static int __cpu_find_by(int (*compare)(int, int, void *), 
void *compare_arg,
 
cur_inst = 0;
for_each_node_by_type(dp, cpu) {
-   int err = check_cpu_node(dp-node, cur_inst,
+   int err = check_cpu_node(dp-linux_phandle, cur_inst,
 compare, compare_arg,
 prom_node, mid);
if (!err) {
diff --git a/arch/sparc/kernel/of_device_32.c b/arch/sparc/kernel/of_device_32.c
index 4c26eb5..27f4c2e 100644
--- a/arch/sparc/kernel/of_device_32.c
+++ b/arch/sparc/kernel/of_device_32.c
@@ -433,7 +433,7 @@ build_resources:
if (!parent)
dev_set_name(op-dev, root);
else
-   dev_set_name(op-dev, %08x, dp-node);
+   dev_set_name(op-dev, %08x, dp-linux_phandle);
 
if (of_device_register(op)) {
printk(%s: Could not register of device.\n,
diff --git a/arch/sparc/kernel/of_device_64.c b/arch/sparc/kernel/of_device_64.c
index 881947e..9a6245d 100644
--- a/arch/sparc/kernel/of_device_64.c
+++ b/arch/sparc/kernel/of_device_64.c
@@ -666,7 +666,7 @@ static struct of_device * __init scan_one_device(struct 
device_node *dp,
if (!parent)
dev_set_name(op-dev, root);
else
-   dev_set_name(op-dev, %08x, dp-node);
+   dev_set_name(op-dev, %08x, dp-linux_phandle);
 
if (of_device_register(op)) {
printk(%s: Could not register of device.\n,
diff --git a/arch/sparc/kernel/prom_common.c b/arch/sparc/kernel/prom_common.c
index d80a65d..2a3e302 100644
--- a/arch/sparc/kernel/prom_common.c
+++ b/arch/sparc/kernel/prom_common.c
@@ -42,7 +42,7 @@ struct device_node *of_find_node_by_phandle(phandle handle)
struct device_node *np;
 
for (np = allnodes; np; np = np-allnext)
-   if (np-node == handle)
+   if (np-linux_phandle == handle)
break;
 
return np;
@@ -89,7 +89,7 @@ int of_set_property(struct device_node *dp, const char *name, 
void *val, int len
void *old_val = prop-value;
int ret;
 
-   ret = prom_setprop(dp-node, name, val, len);
+   ret = prom_setprop(dp-linux_phandle, name, val, len);
 
err = -EINVAL;
if (ret = 0) {
@@ -236,7 +236,7 @@ static struct device_node * __init prom_create_node(phandle 
node,
 
dp-name = get_one_property(node, name);
dp-type = get_one_property(node, device_type);
-   dp-node = node;
+   dp-linux_phandle = node;
 
dp-properties = 

[PATCH] tty/of_serial: add missing ns16550a id

2009-11-24 Thread Arnd Bergmann
From: Michal Simek mon...@monstr.eu

Many boards have a bug-free ns16550 compatible serial port, which we should
register as PORT_16550A. This introduces a new value ns16550a for the
compatible property of of_serial to let a firmware choose that model instead
of using the crippled PORT_16550 mode.

Reported-by: Alon Ziv al...@nolaviz.org
Signed-off-by: Michal Simek mon...@monstr.eu
Signed-off-by: Arnd Bergmann a...@arndb.de

---
Please apply to the tty tree for 2.6.33

--- a/drivers/serial/of_serial.c
+++ b/drivers/serial/of_serial.c
@@ -161,6 +161,7 @@ static int of_platform_serial_remove(struct of_device 
*ofdev)
 static struct of_device_id __devinitdata of_platform_serial_table[] = {
{ .type = serial, .compatible = ns8250,   .data = (void 
*)PORT_8250, },
{ .type = serial, .compatible = ns16450,  .data = (void 
*)PORT_16450, },
+   { .type = serial, .compatible = ns16550a, .data = (void 
*)PORT_16550A, },
{ .type = serial, .compatible = ns16550,  .data = (void 
*)PORT_16550, },
{ .type = serial, .compatible = ns16750,  .data = (void 
*)PORT_16750, },
{ .type = serial, .compatible = ns16850,  .data = (void 
*)PORT_16850, },
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH] ppc64: re-enable kexec to allow module loads with CONFIG_MODVERSIONS and CONFIG_RELOCATABLE turned on

2009-11-24 Thread Neil Horman
On Thu, Nov 19, 2009 at 02:52:16PM -0500, Neil Horman wrote:
 Hey there-
   Before anyone flames me for what a oddball solution this is, let me just
 say I'm trying to get the ball rolling here.  I think there may be better
 solutions that can be impemented in reloc_64.S, but I've yet to make any of 
 the
 ones I've tried work successfully.  I'm open to suggestions, but this solution
 is the only one so far that I've been able to get to work. thanks :)
 
 
 Adjust crcs in __kcrctab_* sections if relocs are used with CONFIG_RELOCATABLE
 
 When CONFIG_MODVERSIONS and CONFIG_RELOCATABLE are enabled on powerpc 
 platforms,
 kdump has been failing in a rather odd way.  specifically modules will not
 install.  This is because when validating the crcs of symbols that the module
 needs, the crc of the module never matches the crc that is stored in the 
 kernel.
 
 The underlying cause of this is how CONFIG_MODVERSIONS is implemented, and how
 CONFIG_RELOCATABLE are implemented.  with CONFIG_MODVERSIONS enabled, for 
 every
 exported symbol in the kernel we emit 2 symbols, __crc_#sym which is declared
 extern and __kcrctab_##sym, which is placed in the __kcrctab section of the
 binary.  The latter has its value set equal to the address of the former
 (recalling it is declared extern).  After the object file is built, genksyms 
 is
 run on the processed source, and crcs are computed for each exported symbol.
 genksyms then emits a linker script which defines each of the needed 
 __crc_##sym
 symbols, and sets their addresses euqal to their respective crcs.  This script
 is then used in a secondary link to the previously build object file, so that
 the crcs of the missing symbol can be validated on module insert.
 
 The problem here is that because __kcrctab_sym is set equal to __crc_##sym, a
 relocation entry is emitted by the compiler for the __kcrctab__##sym.  
 Normally
 this is not a problem, since relocation on other arches is done without the 
 aid
 of .rel.dyn sections.  PPC however uses these relocations when
 CONFIG_RELOCATABLE is enabled.  nominally, since addressing starts at 0 for 
 ppc,
 its irrelevant, but if we start at a non-zero address (like we do when booting
 via kexec from reserved crashkernel memory), the ppc boot code iterates over 
 the
 relocation entries, and winds up adding that relocation offset to all symbols,
 including the symbols that are actually the aforementioned crc values in the
 __kcrctab_* sections.  This effectively corrupts the crcs and prevents any
 module loads from happening during a kdump.
 
 My solution is to 'undo' these relocations prior to boot up.  If
 ARCH_USES_RELOC_ENTRIES is defined, we add a symbol at address zero to the
 linker script for that arch (I call it reloc_start, so that reloc_start = 0).
 This symbol will then indicate the relocation offset for any given boot.  We
 also add an initcall to the module code that, during boot, scans the 
 __kcrctab_*
 sections and subtracts reloc_start from every entry in those sections,
 restoring the appropriate crc value.
 
 I've verified that this allows kexec to work properly on ppc64 systems myself.
 
 Signed-off-by: Neil Horman nhor...@tuxdriver.com
 
Ping, any thoughts here?  As I've been mulling this over, I'm beginning to like
this solution better than a completely arch-specific section, as this approach
makes common the bits that any arch is going to need if they implement
CONFIG_RELOCATABLE with a .rel[a].* section set.  The alternative is of course
to simply skip the appropriate relocations, but thats something that every arch
will need to discover on their own.  This makes it a bit more clear whats
happening I think.

Regards
Neil
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH] PPC: Sync guest visible MMU state

2009-11-24 Thread Avi Kivity

On 11/24/2009 09:50 AM, Alexander Graf wrote:

Currently userspace has no chance to find out which virtual address space we're
in and resolve addresses. While that is a big problem for migration, it's also
unpleasent when debugging, as gdb and the monitor don't work on virtual
addresses.
   



index 92045a9..1240fcb 100644
--- a/include/linux/kvm.h
+++ b/include/linux/kvm.h
@@ -492,6 +492,7 @@ struct kvm_ioeventfd {
  #ifdef __KVM_HAVE_VCPU_EVENTS
  #define KVM_CAP_VCPU_EVENTS 41
  #endif
+#define KVM_CAP_PPC_SEGSTATE 42

   


42 is already taken (s390 psw and D. Adams), please use 43.

--
error compiling committee.c: too many arguments to function

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH] PPC: Sync guest visible MMU state

2009-11-24 Thread Alexander Graf

On 24.11.2009, at 16:02, Avi Kivity wrote:

 On 11/24/2009 09:50 AM, Alexander Graf wrote:
 Currently userspace has no chance to find out which virtual address space 
 we're
 in and resolve addresses. While that is a big problem for migration, it's 
 also
 unpleasent when debugging, as gdb and the monitor don't work on virtual
 addresses.
   
 
 index 92045a9..1240fcb 100644
 --- a/include/linux/kvm.h
 +++ b/include/linux/kvm.h
 @@ -492,6 +492,7 @@ struct kvm_ioeventfd {
  #ifdef __KVM_HAVE_VCPU_EVENTS
  #define KVM_CAP_VCPU_EVENTS 41
  #endif
 +#define KVM_CAP_PPC_SEGSTATE 42
 
   
 
 42 is already taken (s390 psw and D. Adams), please use 43.

Aww. Any reason I didn't get the s390 patch in a git pull yet? (damn that 
Carsten - he got the cool number)

Alex

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH 7/8] spi_mpc8xxx: Turn qe_mode into flags

2009-11-24 Thread Anton Vorontsov
On Tue, Nov 24, 2009 at 04:03:36PM +1100, Benjamin Herrenschmidt wrote:
[...]
 This patch breaks my 6xx config:
 
 /home/benh/linux-powerpc-test/arch/powerpc/platforms/83xx/mpc832x_rdb.c: In 
 function ‘of_fsl_spi_probe’:
 /home/benh/linux-powerpc-test/arch/powerpc/platforms/83xx/mpc832x_rdb.c:77: 
 error: ‘struct fsl_spi_platform_data’ has no member named ‘qe_
 
 The reason is that the mpc832x_rdb.c code still uses the legacy probing
 method. The fix is not totally trivial as the new flags are defined inside
 spi_mpc8xxx.c

Thanks for noticing. I indeed forgot about the legacy stuff. :-/

 If you are going to keep the flags in the .c file you probably also want
 to remove the platform device definition from fsl_devices.h anyways as
 there's no point exposing to the world a structure with a flags member
 if the definition of those flags isn't also exposed.

Yep. Though, IIRC Joakim asked to keep the legacy bindings for some
time (until we implement SPI chip-select framework?)... so for now
we'll have to leave we the exposed flags.

Thanks again,

-- 
Anton Vorontsov
email: cbouatmai...@gmail.com
irc://irc.freenode.net/bd2
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH] PPC: Sync guest visible MMU state

2009-11-24 Thread Avi Kivity

On 11/24/2009 05:04 PM, Alexander Graf wrote:



index 92045a9..1240fcb 100644
--- a/include/linux/kvm.h
+++ b/include/linux/kvm.h
@@ -492,6 +492,7 @@ struct kvm_ioeventfd {
  #ifdef __KVM_HAVE_VCPU_EVENTS
  #define KVM_CAP_VCPU_EVENTS 41
  #endif
+#define KVM_CAP_PPC_SEGSTATE 42


   

42 is already taken (s390 psw and D. Adams), please use 43.
 

Aww. Any reason I didn't get the s390 patch in a git pull yet? (damn that 
Carsten - he got the cool number)

   


It's in the next branch only ('git fetch blah').

--
error compiling committee.c: too many arguments to function

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH 2/3] powerpc: Add support for creating FIT uImages

2009-11-24 Thread Peter Tyser
Hi Stefano,
Thanks for trying the patches out.

On Tue, 2009-11-24 at 11:32 +0100, Stefano Babic wrote:
 Peter Tyser ptyser wrote:
  +uboot.fit)
  +rm -f $ofile
  +${MKITS} -A ppc -C gzip -a $membase -e $membase -v $version \
  +   -d $srctree/$dtb -k $srctree/$vmz -o $object/uImage.its
  +${MKIMAGE} -f $object/uImage.its $ofile
 
 Hi,
 
 I have tested your patches against last mkimage utility provided with
 u-boot. The utility requires to pass the type of the image (flat_dt),
 even if this is not mentioned in the help output. Without the image type
 parameter, no image is generated, and no error is reported.
 It should be:
 
 ${MKIMAGE} -f $object/uImage.its - T flat_dt $ofile

Argh, I'm seeing the same behavior with the latest mkimage source too.
It looks like there was a regression in the mkimage utility - the -T
option shouldn't be necessary to create a FIT image.  I'll send a patch
to U-Boot to fix this behavior.

 I have tried to get an image for the lite5200b board, because I have the
 possibility to test the result on the target. However, dtc fails to
 compile the its generated by your script (Version: DTC 1.2.0-g0ef21055,
 cloned from jdt).

I did my testing using the dtc in the linux kernel source
(scripts/dtc/dtc, version 1.2.0) and version 1.2.0-rc1.  I see the same
error as you when using version 1.2.0-g0ef21055.

 DTC: dts-dtb  on file arch/powerpc/boot/uImage.its
 Error: arch/powerpc/boot/uImage.its 1:0 syntax error
 
 Do you test in different conditions ?

Applying the following change should resolve the dtc syntax error.

diff --git a/scripts/mkits.sh b/scripts/mkits.sh
index 88411dd..75edc27 100755
--- a/scripts/mkits.sh
+++ b/scripts/mkits.sh
@@ -64,7 +64,9 @@ ENTRY_ADDR=`echo $ENTRY_ADDR | sed 's/0x//'`
 RAMFS_ADDR=`echo $RAMFS_ADDR | sed 's/0x//'`
 
 # Create a default, fully populated DTS file
-DATA=/ {
+DATA=/dts-v1/;
+
+/ {
description = \Linux kernel ${VERSION}\;
#address-cells = 1;
 

I'll wait a few more days for feedback then resubmit with the dts syntax
fix

Thanks for testing,
Peter

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


PMP hot plug issue in kernel

2009-11-24 Thread Bhartiya Anju-B07263
Hi All,
 
Recently came across an issue which is decribed below.
 
Setup: Port Multiplier with 2 HDD's connected to it; Port multiplier is
connected to a SATA port of the Host Controller.
 
Test: HDD1 is mounted and using dd command a file of size 512MB is being
written on it.
Command: time sh -c dd if=/dev/zero of=/mnt/hd/ddfile bs=1k
count=512000  sync
 
While this command is running, if the second HDD on PMP is plugged out,
the R/W speed of the first HDD gets affected.
Please see the results of experiments on 2.6.31 kernel.
 
Plug Out Plug in Normal 
real0m34.433s
user0m0.932s
sys 0m21.352sreal0m23.726s
user0m0.908s
sys 0m21.388sreal0m23.329s
user0m1.132s
sys 0m20.968s   
 
The results are similiar with multiple Port Multipliers (Si3726, Si4726
and EXAR PMP) and multiple Host controllers (Si3132  and sata_fsl).
 
As the behaviour with multiple Host controllers and Port Multipliers is
the same so this seems to be an issue with libata stack.
Is there already a patch for this issue? Any pointers or help to fix
this will be greatly appreciated.
 
Best Regards,
Anju
Applications Engineer 
Freescale Semiconductor
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [RFC PATCH 14/19] powerpc: allow ioremap within reserved fake ram regions

2009-11-24 Thread Albert Herranz
Michael Ellerman wrote:
 Would it be acceptable to create a global var __allow_ioremap_normal_ram 
 that by default would have a value of 0 and would be set _only_ for those 
 platforms needing it?

 The other solutions I see is:
 - add support for discontiguous memory to powerpc 32-bits (which is not 
 something that I can look into now)
 - don't use the precious second 64MB area (which is a waste)
 
 - Implement your own ppc_md.ioremap(), see iseries  cell for example.
 
 Currently that's only called on 64-bit, but you could change that.
 
 If I'm reading your patch right, you should be able to do that check in
 your platform's ioremap() and then call the generic implementation to do
 the actual work.
 
 cheers

I could use ppc_md.ioremap to duplicate ioremap except for the ioremap ram 
check.
But calling the stock ioremap without modifying it is not possible because it 
checks and bails out when ioremapping a region marked as ram (even if it's not 
real ram and it's memreserved).

Is the list of memreserved areas preserved once the kernel is running?
If it is preserved another option would be to unban ioremapping ram if 
memreserved.

Thanks for your input,
Albert

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH 11/11] of: unify phandle name in struct device_node

2009-11-24 Thread David Miller
From: Grant Likely grant.lik...@secretlab.ca
Date: Tue, 24 Nov 2009 01:20:05 -0700

 In struct device_node, the phandle is named 'linux_phandle' for PowerPC
 and MicroBlaze, and 'node' for SPARC.  There is no good reason for the
 difference, it is just an artifact of the code diverging over a couple
 of years.  This patch renames .node to .linux_phandle for SPARC.

I know it's just a name, but there is no reason to put linux in the
member name.  It's the real device phandle value from OpenFirmware not
something invented by Linux's OF layer.

PowerPC uses this for something different, it records the information
here using the special linux,phandle and ibm,phandle properties.

See unflatten_dt_node() in arch/powerpc/kernel/prom.c before your
changes.
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [RFC PATCH 03/19] powerpc: gamecube: bootwrapper bits

2009-11-24 Thread Albert Herranz
Segher Boessenkool wrote:
 Hi Albert,
 
 +asm (\n\
 
 
 A file scope asm?!  Please don't.
 

So what's your proposal then? Placing it within a fake func?
That asm snippet is the entry point. I took as an example how prpmc2800.c deals 
with that, providing an own version of the (weak) _zImage_start.

 + * We enter with the cache enabled, the MMU enabled and some known
 legacy
 + * memory mappings active. xBAT3 is unused
 
 It would be good if you could depend as little as possible on these things;
 that makes writing another bootloader a lot easier.
 

Ok. I'll do a similar approach as done on the wii bootwrapper.

 +/* IBAT3,DBAT3 for first 16Mbytes */\n\
 +li8, 0x01ff/* 16MB */\n\
 +li  9, 0x0002/* rw */\n\
 +mtspr   0x216, 8/* IBAT3U */\n\
 +mtspr   0x217, 9/* IBAT3L */\n\
 +mtspr   0x21e, 8/* DBAT3U */\n\
 +mtspr   0x21f, 9/* DBAT3L */\n\
 
 WIMG=, are you sure?  Not M=1?
 

To be honest, I don't recall the details now.
But it was tested in the very early days, the result was not the expected one 
and, in the end, manual cache coherency management was still needed.

So everything is designed and working assuming M=0.
This can be re-checked again later if needed.

 +bcl-20,4*cr7+so,1f\n\
 
 Just write  bcl 20,31,1f .

Ok, I used two variants for this and I know which one you like now ;).

 
 
 Segher
 
 

Thanks,
Albert
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [RFC PATCH 05/19] powerpc: wii: bootwrapper bits

2009-11-24 Thread Albert Herranz
Segher Boessenkool wrote:
 + * We enter with an unknown cache, high BATs and MMU status.
 
 What does this mean?  You know the low four BATs on entry and
 nothing else?
 

That means that we do not make assumptions regarding:
- the state of the cache (enabled vs disabled)
- if the high BATs are enabled or not
- if the MMU is enabled or not

Is this clearer? I'm not a native english speaker as you may have noticed 
already :-P

 +asm (\n\
 
 Global asm() is evil.
 

Yes, you said. Still, I'd like a proper argument :)

 +mfmsr9\n\
 +andi.0, 9, (14)|(15) /* MSR_DR|MSR_IR */\n\
 
 +andc9, 9, 0\n\
 
 mfmsr 9 ; rlwinm 9,9,0,~0x30 ?
 

Yes. Maybe

mfmsr 9 ; rlwinm 9,9,0,~((14)|(15)) /* MSR_DR|MSR_IR */

 +mtspr0x01a, 8/* SRR0 */\n\
 +mtspr0x01b, 9/* SRR1 */\n\
 
 mtsrr0 and mtsrr1
 

Easier :)

 +sync\n\
 +rfi\n\
 
 No need for sync before rfi
 

Ok.

 +mtspr0x210, 8/* IBAT0U */\n\
 +mtspr0x211, 8/* IBAT0L */\n\
 
 You only need to set the upper BAT to zero, saves some code.
 

Great. Is this documented somewhere?

 +isync\n\
 
 isync here is cargo cult
 

I'll offer a dead chicken to compensate for this.

 +li8, 0x01ff/* first 16MiB */\n\
 +li9, 0x0002/* rw */\n\
 +mtspr0x210, 8/* IBAT0U */\n\
 +mtspr0x211, 9/* IBAT0L */\n\
 +mtspr0x218, 8/* DBAT0U */\n\
 +mtspr0x219, 9/* DBAT0L */\n\
 
 M=0 for RAM?
 

See analog question for gamecube bootwrapper bits.


 
 Also, you should normally write the lower BAT first.  Doesn't matter
 here because IR=DR=0 of course.
 

I can change that too if it's the general way to go.

 +lis8, 0xcc00/* I/O mem */\n\
 +ori8, 8, 0x3ff/* 32MiB */\n\
 +lis9, 0x0c00\n\
 +ori9, 9, 0x002a/* uncached, guarded, rw */\n\
 +mtspr0x21a, 8/* DBAT1U */\n\
 +mtspr0x21b, 9/* DBAT1L */\n\
 
 Is there any real reason you don't identity map this?
 

No. There's a bit of nostalgia there.
(On the other hand there's no real reason to identity map it).

 +sync\n\
 +isync\n\
 +\n\
 
 Don't need these
 

I'll get rid of them, then.

 +/* enable high BATs */\n\
 +lis8, 0x8200\n\
 +mtspr0x3f3, 8/* HID4 */\n\
 
 You need to use read-modify-write here.  Also, shouldn't you
 enable the extra BATs before setting them?
 

No. You should first set them up and then enable them.
The content of the HIGH BATs is undefined on boot, AFAIK.

 And you _do_ need isync here as far as I can see.
 
 +/* enable caches */\n\
 +mfspr8, 0x3f0\n\
 +ori8, 8, 0xc000\n\
 +mtspr0x3f0, 8/* HID0 */\n\
 +isync\n\
 
 You need to invalidate the L1 caches at the same time as you enable
 them.
 

Ok. I'll check if the caches are enabled. If they aren't I'll invalidate and 
enable them.

 +void platform_init(unsigned long r3, unsigned long r4, unsigned long r5)
 +{
 +u32 heapsize = 24*1024*1024 - (u32)_end;
 +
 +simple_alloc_init(_end, heapsize, 32, 64);
 +fdt_init(_dtb_start);
 +
 +if (!ug_grab_io_base()  ug_is_adapter_present())
 
 The ! reads weird.  Can you not make ug_is_adapter_present()
 call ug_grab_io_base(), anyway?
 

Calling ug_grab_io_base() from ug_is_adapter_present() can be misleading too 
(you are supposed to just check if the adapter is present in that function, 
according to the name).
If the ! is ugly I can use the following idiom, introducing an error variable.

  error = ug_grab_io_base();
  if (!error  ug_is_adapter_present())
 /* blah */

Thanks,
Albert

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [RFC PATCH 06/19] powerpc: gamecube/wii: introduce GAMECUBE_COMMON

2009-11-24 Thread Albert Herranz
Segher Boessenkool wrote:
 Add a config option GAMECUBE_COMMON to be used as a dependency for all
 options common to the Nintendo GameCube and Wii video game consoles.
 
 Maybe something like GAMECUBE_OR_WII instead?  COMMON is so
 common it's meaningless.
 

I don't like either GAMECUBE_OR_WII.
It looks as if it can be used to match options for the GAMECUBE _or_ WII. But 
that's not the meaning of it.

This option should be used only for options applicable to both the GAMECUBE and 
WII, i.e. basically those options in the WII which where inherited from the 
GAMECUBE to make it retro-compatible.

If GAMECUBE_COMMON is unacceptable, maybe GAMECUBE_LEGACY or GAMECUBE_COMPAT?

Thanks,
Albert

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [RFC PATCH 09/19] powerpc: gamecube/wii: udbg support for usbgecko

2009-11-24 Thread Albert Herranz
Segher Boessenkool wrote:
 +  If you say yes to this option, support will be included for the
 +  USB Gecko adapter as an udbg console.
 +  The USB Gecko is a EXI to USB Serial converter that can be plugged
 +  into a memcard slot in the Nintendo GameCube/Wii.
 
 Not a memcard slot, only the first one, you have it hardcoded.
 

No. It's not hardcoded in the code. It's specified in the device tree source.
The hardcoded one is just the early udbg, not the normal udbg.

 +#if 0
 +/*
 + * Trasmits a null terminated character string.
 + */
 +static void ug_puts(char *s)
 +{
 +while (*s)
 +ug_putc(*s++);
 +}
 +#endif
 
 Remove?
 

Ok :)

 +stdout = of_find_node_by_path(path);
 +if (!stdout) {
 +udbg_printf(%s: missing path %s, __func__, path);
 +goto done;
 +}
 +
 +for (np = NULL;
 +(np = of_find_compatible_node(np, NULL, usbgecko,usbgecko));)
 +if (np == stdout)
 +break;
 +
 +of_node_put(stdout);
 +if (!np) {
 +udbg_printf(%s: stdout is not an usbgecko, __func__);
 +goto done;
 +}
 
 Surely there is something called something like of_node_is_compatible()
 you can use here?  You already have the node pointer, there is no need
 to look at all other nodes.
 

I see the point.
I didn't find of_node_is_compatible() but I'll look what's available here.

Thanks,
Albert
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH] ppc64: re-enable kexec to allow module loads with CONFIG_MODVERSIONS and CONFIG_RELOCATABLE turned on

2009-11-24 Thread Neil Horman
Neil Horman writes:

   Before anyone flames me for what a oddball solution this is, let me just
 say I'm trying to get the ball rolling here.  I think there may be better
 solutions that can be impemented in reloc_64.S, but I've yet to make any of
the
 ones I've tried work successfully.  I'm open to suggestions, but this solution
 is the only one so far that I've been able to get to work. thanks :)

I had thought that the CRCs would be the only things with reloc
addends less than 4G, but it turns out that the toolchain folds
expressions like __pa(sym) into just a load from a doubleword (in the
TOC) containing the physical address of sym.  That needs to be
relocated and its reloc addend will be less than 4GB.  Hence the
crashes early in boot that you were seeing with my proposed patch to
reloc_64.S.

Given that, your solution seems as reasonable as any.  Should this go
via the modules maintainer, Rusty Russell, perhaps?

In any case,

Acked-by: Paul Mackerras paulus at samba.org


I'm not 100% sure, it does kind of split the middle in regards to what tree is
should come through.

Rusy, given the previous entries in this thread, do you have any thoughts on the
patch, or which tree it should go through?  I kind of think that the ppc tree is
just fine here since its currently the only user of this code, but I'll defer to
other opinions on the subject.

Thanks  Regards
Neil

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [RFC PATCH 10/19] powerpc: gamecube/wii: early debugging using usbgecko

2009-11-24 Thread Albert Herranz
Segher Boessenkool wrote:
 You set up DBAT1 here...
 
 +setup_usbgecko_bat:
 +/* prepare a BAT for early io */
 +lisr8, 0x0c00
 +orir8, r8, 0x002a/* uncached, guarded ,rw */
 +lisr11, 0xcc00
 +orir11, r11, 0x3/* 128K */
 +#ifdef CONFIG_WII
 +orisr8, r8, 0x0100
 +orisr11, r11, 0x0100
 +#endif
 +mtsprSPRN_DBAT1L, r8
 +mtsprSPRN_DBAT1U, r11
 +sync
 +isync
 +blr
 
 ... and again here:
 
 +void __init udbg_init_usbgecko(void)
 +{
 +unsigned long vaddr, paddr;
 +
 +#if defined(CONFIG_GAMECUBE)
 +paddr = 0x0c00;
 +#elif defined(CONFIG_WII)
 +paddr = 0x0d00;
 +#else
 +#error Invalid platform for USB Gecko based early debugging.
 +#endif
 +
 +vaddr = 0xc000 | paddr;
 +setbat(1, vaddr, paddr, 128*1024, PAGE_KERNEL_NCG);
 
 Do you need to do it twice?
 

Uhmm... I need to re-check it.
IIRC the BATs were re-initialized in between. But I'm not sure now :)

 +ug_io_base = (void __iomem *)(vaddr | 0x6814);
 
 Oh, hardcoded slot2, now i'm confused which one should be it :-)
 

early udbg  : hardcoded to mem2 slot
normal udbg : as specified in device tree

Clearer now ? ;)

Thanks for the review!
Albert
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH 11/11] of: unify phandle name in struct device_node

2009-11-24 Thread Grant Likely
On Tue, Nov 24, 2009 at 10:37 AM, David Miller da...@davemloft.net wrote:
 From: Grant Likely grant.lik...@secretlab.ca
 Date: Tue, 24 Nov 2009 01:20:05 -0700

 In struct device_node, the phandle is named 'linux_phandle' for PowerPC
 and MicroBlaze, and 'node' for SPARC.  There is no good reason for the
 difference, it is just an artifact of the code diverging over a couple
 of years.  This patch renames .node to .linux_phandle for SPARC.

 I know it's just a name, but there is no reason to put linux in the
 member name.  It's the real device phandle value from OpenFirmware not
 something invented by Linux's OF layer.

I agree, and I also considered renaming it to simply 'phandle' or to
change the powerpc code back to using .node everywhere (more on .node
usage in powerpc below).  I didn't want to use .node because .node is
pretty generic, and is used in other places for different things.
Basically I wanted to avoid confusion.  In particular, .node points to
a device_node, not a phandle, in struct of_device.  Changing all
references to simply 'phandle' seems to be the best, but it does
require changes to more locations in the code.  In the end I decided
on some constructive lazyness by settling for the already-used
.linux_phandle so that I would need to touch as many files, but still
retain a unique name that is easy to find.  If you prefer, I can
change it all to simply '.phandle'.

 PowerPC uses this for something different, it records the information
 here using the special linux,phandle and ibm,phandle properties.

Agreed, the phandle isn't a real phandle when using the flat tree.
However, though the source of the phandle value is different, the use
case is identical, so it make sense to stuff it into the same member.
Merging them lets me unify more code.  For example,
of_find_node_by_phandle().

 See unflatten_dt_node() in arch/powerpc/kernel/prom.c before your
 changes.

Yup, I looked at this.  The unflatten code stuffs both linux,phandle
and ibm,phandle into .linux_phandle, and linux,phandle also gets
stuffed into .node.  But all the users except one use the
.linux_phandle, not .node, and that remaining user *I think* can
safely use .linux_phandle too.

Thanks for the review,
g.

-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [RFC PATCH 03/19] powerpc: gamecube: bootwrapper bits

2009-11-24 Thread Segher Boessenkool

+asm (\n\



A file scope asm?!  Please don't.


So what's your proposal then? Placing it within a fake func?
That asm snippet is the entry point. I took as an example how  
prpmc2800.c deals with that, providing an own version of the (weak)  
_zImage_start.


Use an assembler source file.  You'll get much nicer syntax as well
(none of that \n stuff).


+/* IBAT3,DBAT3 for first 16Mbytes */\n\
+li8, 0x01ff/* 16MB */\n\
+li  9, 0x0002/* rw */\n\
+mtspr   0x216, 8/* IBAT3U */\n\
+mtspr   0x217, 9/* IBAT3L */\n\
+mtspr   0x21e, 8/* DBAT3U */\n\
+mtspr   0x21f, 9/* DBAT3L */\n\


WIMG=, are you sure?  Not M=1?


To be honest, I don't recall the details now.
But it was tested in the very early days, the result was not the  
expected one and, in the end, manual cache coherency management was  
still needed.


Sure, the memory controllers don't do coherency.  I'm slightly worried
about two things:
1) Will the generic code use M=0 as well?  Is it a problem if it  
doesn't?

2) Do lwarx. etc. work in M=0?

And a question: does M=0 actually give better performance (lower bus
utilisation, and maybe saves a few cycles)?


Segher

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [RFC PATCH 05/19] powerpc: wii: bootwrapper bits

2009-11-24 Thread Segher Boessenkool

+ * We enter with an unknown cache, high BATs and MMU status.


What does this mean?  You know the low four BATs on entry and
nothing else?



That means that we do not make assumptions regarding:
- the state of the cache (enabled vs disabled)
- if the high BATs are enabled or not
- if the MMU is enabled or not

Is this clearer?


Yeah it is.


+mfmsr9\n\
+andi.0, 9, (14)|(15) /* MSR_DR|MSR_IR */\n\



+andc9, 9, 0\n\


mfmsr 9 ; rlwinm 9,9,0,~0x30 ?



Yes. Maybe

mfmsr 9 ; rlwinm 9,9,0,~((14)|(15)) /* MSR_DR|MSR_IR */


Sure, or ~0x30 with that comment.  You can save an insn and make
the code clearer at the same time, how exactly you write it, I don't
care :-)


+mtspr0x210, 8/* IBAT0U */\n\
+mtspr0x211, 8/* IBAT0L */\n\


You only need to set the upper BAT to zero, saves some code.


Great. Is this documented somewhere?


Sure, it's all in the PEM.


+isync\n\


isync here is cargo cult


I'll offer a dead chicken to compensate for this.


Thanks, I needed some more of those :-)


Also, you should normally write the lower BAT first.  Doesn't matter
here because IR=DR=0 of course.


I can change that too if it's the general way to go.


Please do.


+lis8, 0xcc00/* I/O mem */\n\
+ori8, 8, 0x3ff/* 32MiB */\n\
+lis9, 0x0c00\n\
+ori9, 9, 0x002a/* uncached, guarded, rw */\n\
+mtspr0x21a, 8/* DBAT1U */\n\
+mtspr0x21b, 9/* DBAT1L */\n\


Is there any real reason you don't identity map this?



No. There's a bit of nostalgia there.
(On the other hand there's no real reason to identity map it).


It's a tiny bit cleaner and stops people from wondering why :-)


+/* enable high BATs */\n\
+lis8, 0x8200\n\
+mtspr0x3f3, 8/* HID4 */\n\


You need to use read-modify-write here.  Also, shouldn't you
enable the extra BATs before setting them?



No. You should first set them up and then enable them.
The content of the HIGH BATs is undefined on boot, AFAIK.


All BATs are undefined at boot; you need to clear them / set them
before enabling them (DR=1 or IR=1), so there is nothing special
about the high BATs.

What I am getting at is if the mfspr/mtspr to the high BATs does
work when the HID bit for them is off.

Please address the RMW thing (don't clear bits in HID4).


+/* enable caches */\n\
+mfspr8, 0x3f0\n\
+ori8, 8, 0xc000\n\
+mtspr0x3f0, 8/* HID0 */\n\
+isync\n\


You need to invalidate the L1 caches at the same time as you enable
them.



Ok. I'll check if the caches are enabled. If they aren't I'll  
invalidate and enable them.


Yeah, good point.

If the ! is ugly I can use the following idiom, introducing an  
error variable.


  error = ug_grab_io_base();
  if (!error  ug_is_adapter_present())
 /* blah */


Much clearer, thanks.


Segher

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH 11/11] of: unify phandle name in struct device_node

2009-11-24 Thread Benjamin Herrenschmidt
On Tue, 2009-11-24 at 09:37 -0800, David Miller wrote:
 From: Grant Likely grant.lik...@secretlab.ca
 Date: Tue, 24 Nov 2009 01:20:05 -0700
 
  In struct device_node, the phandle is named 'linux_phandle' for PowerPC
  and MicroBlaze, and 'node' for SPARC.  There is no good reason for the
  difference, it is just an artifact of the code diverging over a couple
  of years.  This patch renames .node to .linux_phandle for SPARC.
 
 I know it's just a name, but there is no reason to put linux in the
 member name.  It's the real device phandle value from OpenFirmware not
 something invented by Linux's OF layer.
 
 PowerPC uses this for something different, it records the information
 here using the special linux,phandle and ibm,phandle properties.
 
 See unflatten_dt_node() in arch/powerpc/kernel/prom.c before your
 changes.

Right, this comes from a subtle problem with our firmwares on pSeries.

We have a phandle from OF. But some devices, especially virtual devices,
also have an ibm,phandle which may or may not be the same afaik.

In addition, when the hypervisor hotplugs some devices, it sends us some
new device-tree bits to add. Those don't have a phandle in the formal
sense afaik, but -do- have an ibm,phandle property.

I think we can always just use ibm,phandle instead of the OF one when
the former is present, they should be non overlapping, but of course,
any chance in that area will require plenty of testing on some of those
machines.

Cheers,
Ben.

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [RFC PATCH 06/19] powerpc: gamecube/wii: introduce GAMECUBE_COMMON

2009-11-24 Thread Segher Boessenkool
Add a config option GAMECUBE_COMMON to be used as a dependency  
for all

options common to the Nintendo GameCube and Wii video game consoles.


Maybe something like GAMECUBE_OR_WII instead?  COMMON is so
common it's meaningless.



I don't like either GAMECUBE_OR_WII.
It looks as if it can be used to match options for the GAMECUBE  
_or_ WII. But that's not the meaning of it.


This option should be used only for options applicable to both the  
GAMECUBE and WII, i.e. basically those options in the WII which  
where inherited from the GAMECUBE to make it retro-compatible.


If GAMECUBE_COMMON is unacceptable, maybe GAMECUBE_LEGACY or  
GAMECUBE_COMPAT?


Maybe it's best to write GAMECUBE || WII in the places that use it,  
then?



Segher

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH 11/11] of: unify phandle name in struct device_node

2009-11-24 Thread David Miller
From: Grant Likely grant.lik...@secretlab.ca
Date: Tue, 24 Nov 2009 13:33:22 -0700

 If you prefer, I can change it all to simply '.phandle'.

Please do.
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [RFC PATCH 09/19] powerpc: gamecube/wii: udbg support for usbgecko

2009-11-24 Thread Segher Boessenkool
+  If you say yes to this option, support will be included  
for the

+  USB Gecko adapter as an udbg console.
+  The USB Gecko is a EXI to USB Serial converter that can be  
plugged

+  into a memcard slot in the Nintendo GameCube/Wii.


Not a memcard slot, only the first one, you have it hardcoded.



No. It's not hardcoded in the code. It's specified in the device  
tree source.

The hardcoded one is just the early udbg, not the normal udbg.


Ah I misread the code then.

Surely there is something called something like  
of_node_is_compatible()
you can use here?  You already have the node pointer, there is no  
need

to look at all other nodes.



I see the point.
I didn't find of_node_is_compatible() but I'll look what's  
available here.


int of_device_is_compatible(const struct device_node *device,
const char *compat)


Segher

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [RFC PATCH 11/19] powerpc: gamecube/wii: flipper interrupt controller support

2009-11-24 Thread Segher Boessenkool

 config GAMECUBE_COMMON
bool
select NOT_COHERENT_CACHE
+   select FLIPPER_PIC


Maybe using FLIPPER (or GAMECUBE_FLIPPER) instead of GAMECUBE_COMMON
is a good name?


+#define pr_fmt(fmt) DRV_MODULE_NAME :  fmt


Unused


+/*
+ * Each interrupt has a corresponding bit in both
+ * the Interrupt Cause (ICR) and Interrupt Mask (IMR) registers.
+ *
+ * Enabling/disabling an interrupt line involves asserting/clearing
+ * the corresponding bit in IMR. ACK'ing a request simply involves
+ * asserting the corresponding bit in ICR.
+ */



+static void flipper_pic_ack(unsigned int virq)
+{
+   int irq = virq_to_hw(virq);
+   void __iomem *io_base = get_irq_chip_data(virq);
+
+   set_bit(irq, io_base + FLIPPER_ICR);
+}


So it should be a simple write instead of an RMW here, right?
As it is you are ACKing _all_ IRQs as far as I can see.


+unsigned int flipper_pic_get_irq(void)
+{
+   void __iomem *io_base = flipper_irq_host-host_data;
+   int irq;
+   u32 irq_status;
+
+   irq_status = in_be32(io_base + FLIPPER_ICR) 
+in_be32(io_base + FLIPPER_IMR);
+   if (irq_status == 0)
+   return -1;  /* no more IRQs pending */
+
+   __asm__ __volatile__(cntlzw %0,%1 : =r(irq) : r(irq_status));
+   return irq_linear_revmap(flipper_irq_host, 31 - irq);
+}


There are generic macros for this kind of thing, no need for asm.  ffs()
or something.


Segher

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [RFC PATCH 12/19] powerpc: gamecube: platform support

2009-11-24 Thread Segher Boessenkool

+static struct of_device_id gamecube_of_bus[] = {
+   { .compatible = nintendo,flipper, },
+   { },
+};
+
+static int __init gamecube_device_probe(void)
+{
+   if (!machine_is(gamecube))
+   return 0;
+
+   of_platform_bus_probe(NULL, gamecube_of_bus, NULL);
+   return 0;
+}


You really do not need a platform bus as far as I can see?


Segher

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH 11/11] of: unify phandle name in struct device_node

2009-11-24 Thread Grant Likely
On Tue, Nov 24, 2009 at 2:06 PM, Benjamin Herrenschmidt
b...@kernel.crashing.org wrote:
 On Tue, 2009-11-24 at 09:37 -0800, David Miller wrote:
 From: Grant Likely grant.lik...@secretlab.ca
 Date: Tue, 24 Nov 2009 01:20:05 -0700

  In struct device_node, the phandle is named 'linux_phandle' for PowerPC
  and MicroBlaze, and 'node' for SPARC.  There is no good reason for the
  difference, it is just an artifact of the code diverging over a couple
  of years.  This patch renames .node to .linux_phandle for SPARC.

 I know it's just a name, but there is no reason to put linux in the
 member name.  It's the real device phandle value from OpenFirmware not
 something invented by Linux's OF layer.

 PowerPC uses this for something different, it records the information
 here using the special linux,phandle and ibm,phandle properties.

 See unflatten_dt_node() in arch/powerpc/kernel/prom.c before your
 changes.

 Right, this comes from a subtle problem with our firmwares on pSeries.

 We have a phandle from OF. But some devices, especially virtual devices,
 also have an ibm,phandle which may or may not be the same afaik.

 In addition, when the hypervisor hotplugs some devices, it sends us some
 new device-tree bits to add. Those don't have a phandle in the formal
 sense afaik, but -do- have an ibm,phandle property.

 I think we can always just use ibm,phandle instead of the OF one when
 the former is present, they should be non overlapping, but of course,
 any chance in that area will require plenty of testing on some of those
 machines.

If pseries is the troublesome platform, not powermac, then I'm pretty
confident this change is okay.  I cannot find any other users of .node
other than arch/powerpc/platforms/powermac/pfunc_core.c, but I'll
double check with an allmodconfig and an allyesconfig.  This patch
shouldn't change the behaviour of linux_phandle at all.

g.

-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [RFC PATCH 16/19] powerpc: wii: hollywood interrupt controller support

2009-11-24 Thread Segher Boessenkool

+config HLWD_PIC


Are vowels too expensive?  :-)


+static void hlwd_pic_ack(unsigned int virq)
+{
+   int irq = virq_to_hw(virq);
+   void __iomem *io_base = get_irq_chip_data(virq);
+
+   set_bit(irq, io_base + HW_BROADWAY_ICR);
+}


Same issue as with Flipper here.


+   __asm__ __volatile__(cntlzw %0,%1 : =r(irq) : r(irq_status));
+   return irq_linear_revmap(h, 31 - irq);


And here.


+static void __hlwd_quiesce(void __iomem *io_base)
+{
+   /* mask and ack all IRQs */
+   out_be32(io_base + HW_BROADWAY_IMR, 0);
+   out_be32(io_base + HW_BROADWAY_ICR, ~0);
+}


I would write 0x instead, it's clearer and slightly
more robust.


+void hlwd_pic_probe(void)
+{
+   struct irq_host *host;
+   struct device_node *np;
+   const u32 *interrupts;
+   int cascade_virq;
+
+   for_each_compatible_node(np, NULL, nintendo,hollywood-pic) {
+   interrupts = of_get_property(np, interrupts, NULL);
+   if (interrupts) {
+   host = hlwd_pic_init(np);
+   BUG_ON(!host);
+   cascade_virq = irq_of_parse_and_map(np, 0);
+   set_irq_data(cascade_virq, host);
+   set_irq_chained_handler(cascade_virq,
+   hlwd_pic_irq_cascade);


break;  here?  You do not handle more than one hollywood-pic elsewhere
(which of course is fine).


Segher

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH v2 11/11] of: unify phandle name in struct device_node

2009-11-24 Thread Grant Likely
In struct device_node, the phandle is named 'linux_phandle' for PowerPC
and MicroBlaze, and 'node' for SPARC.  There is no good reason for the
difference, it is just an artifact of the code diverging over a couple
of years.  This patch renames both to simply .phandle.

Note: the .node also existed in PowerPC/MicroBlaze, but the only user
seems to be arch/powerpc/platforms/powermac/pfunc_core.c.  It doesn't
look like the assignment between .linux_phandle and .node is
significantly different enough to warrant the separate code paths
unless ibm,phandle properties actually appear in Apple device trees.

I think it is safe to eliminate the old .node property and use
linux_phandle everywhere.

Signed-off-by: Grant Likely grant.lik...@secretlab.ca
---

 arch/microblaze/kernel/of_platform.c |2 +-
 arch/microblaze/kernel/prom.c|2 +-
 arch/powerpc/kernel/of_platform.c|2 +-
 arch/powerpc/kernel/prom.c   |6 +++---
 arch/powerpc/platforms/cell/spu_manage.c |6 +++---
 arch/powerpc/platforms/powermac/pfunc_core.c |2 +-
 arch/sparc/kernel/devices.c  |2 +-
 arch/sparc/kernel/of_device_32.c |2 +-
 arch/sparc/kernel/of_device_64.c |2 +-
 arch/sparc/kernel/prom_common.c  |8 
 arch/sparc/kernel/smp_64.c   |2 +-
 drivers/of/fdt.c |7 +++
 drivers/sbus/char/openprom.c |   10 +-
 drivers/video/aty/atyfb_base.c   |2 +-
 include/linux/of.h   |5 +
 sound/aoa/fabrics/layout.c   |2 +-
 16 files changed, 29 insertions(+), 33 deletions(-)

diff --git a/arch/microblaze/kernel/of_platform.c 
b/arch/microblaze/kernel/of_platform.c
index acf4574..1c6d684 100644
--- a/arch/microblaze/kernel/of_platform.c
+++ b/arch/microblaze/kernel/of_platform.c
@@ -185,7 +185,7 @@ EXPORT_SYMBOL(of_find_device_by_node);
 static int of_dev_phandle_match(struct device *dev, void *data)
 {
phandle *ph = data;
-   return to_of_device(dev)-node-linux_phandle == *ph;
+   return to_of_device(dev)-node-phandle == *ph;
 }
 
 struct of_device *of_find_device_by_phandle(phandle ph)
diff --git a/arch/microblaze/kernel/prom.c b/arch/microblaze/kernel/prom.c
index 1f79e4d..9b4a20b 100644
--- a/arch/microblaze/kernel/prom.c
+++ b/arch/microblaze/kernel/prom.c
@@ -251,7 +251,7 @@ struct device_node *of_find_node_by_phandle(phandle handle)
 
read_lock(devtree_lock);
for (np = allnodes; np != NULL; np = np-allnext)
-   if (np-linux_phandle == handle)
+   if (np-phandle == handle)
break;
of_node_get(np);
read_unlock(devtree_lock);
diff --git a/arch/powerpc/kernel/of_platform.c 
b/arch/powerpc/kernel/of_platform.c
index 1a4fc0d..666d08d 100644
--- a/arch/powerpc/kernel/of_platform.c
+++ b/arch/powerpc/kernel/of_platform.c
@@ -214,7 +214,7 @@ EXPORT_SYMBOL(of_find_device_by_node);
 static int of_dev_phandle_match(struct device *dev, void *data)
 {
phandle *ph = data;
-   return to_of_device(dev)-node-linux_phandle == *ph;
+   return to_of_device(dev)-node-phandle == *ph;
 }
 
 struct of_device *of_find_device_by_phandle(phandle ph)
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 7d0beeb..d3ce311 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -701,7 +701,7 @@ struct device_node *of_find_node_by_phandle(phandle handle)
 
read_lock(devtree_lock);
for (np = allnodes; np != 0; np = np-allnext)
-   if (np-linux_phandle == handle)
+   if (np-phandle == handle)
break;
of_node_get(np);
read_unlock(devtree_lock);
@@ -771,9 +771,9 @@ static int of_finish_dynamic_node(struct device_node *node)
if (machine_is(powermac))
return -ENODEV;
 
-   /* fix up new node's linux_phandle field */
+   /* fix up new node's phandle field */
if ((ibm_phandle = of_get_property(node, ibm,phandle, NULL)))
-   node-linux_phandle = *ibm_phandle;
+   node-phandle = *ibm_phandle;
 
 out:
of_node_put(parent);
diff --git a/arch/powerpc/platforms/cell/spu_manage.c 
b/arch/powerpc/platforms/cell/spu_manage.c
index 4c506c1..891f18e 100644
--- a/arch/powerpc/platforms/cell/spu_manage.c
+++ b/arch/powerpc/platforms/cell/spu_manage.c
@@ -457,7 +457,7 @@ neighbour_spu(int cbe, struct device_node *target, struct 
device_node *avoid)
continue;
vic_handles = of_get_property(spu_dn, vicinity, lenp);
for (i=0; i  (lenp / sizeof(phandle)); i++) {
-   if (vic_handles[i] == target-linux_phandle)
+   if (vic_handles[i] == target-phandle)
return spu;
}
}
@@ -499,7 +499,7 

Re: [RFC PATCH 17/19] powerpc: wii: bootmii starlet 'mini' firmware support

2009-11-24 Thread Segher Boessenkool

Add support for the BootMii 'mini' firmware replacement for the
Starlet processor.

'mini' is an open source IOS replacement written from scratch by
Team Twiizers.


It's not a replacement, it doesn't have any of the same functionality.


It grants full access to the hardware found on the
Nintendo Wii video game console via a custom IPC mechanism.


This is out of date, you get full register-level hardware access now.

Do you want to mainline any of the drivers that work via mini proxy?
If not, you can remove quite some bit of code here I think.


+enum starlet_ipc_flavour {
+   STARLET_IPC_IOS,
+   STARLET_IPC_MINI,
+};


I thought you don't support IOS at all anymore?


+config STARLET_MINI
+   bool BootMii Starlet 'mini' firmware support
+   depends on WII  EXPERIMENTAL


Given that this is the only supported starlet firmware interface,
does it make sense to expose the option to the user?

big snip, see my remove stuff comment above


+static void mipc_init_ahbprot(struct mipc_device *ipc_dev)
+{
+   void __iomem *hw_ahbprot;
+   u32 initial_ahbprot, ahbprot = 0;
+
+   hw_ahbprot = mipc_get_hw_reg(HW_AHBPROT_OF_COMPATIBLE);
+   if (!hw_ahbprot)
+   goto done;
+
+   initial_ahbprot = mipc_readl(hw_ahbprot);
+   if (initial_ahbprot != 0x) {
+   pr_debug(AHBPROT=%08X (before)\n, initial_ahbprot);
+   /* enable full access from the PowerPC side */
+   mipc_writel(0x, hw_ahbprot);
+   }
+
+   ahbprot = mipc_readl(hw_ahbprot);
+   if (initial_ahbprot != ahbprot)
+   pr_debug(AHBPROT=%08X (after)\n, ahbprot);
+done:
+   if (ahbprot != 0x)
+   pr_err(failed to set AHBPROT\n);
+}


Modern mini will always have AHBPROT set up to give you full access,
so this isn't needed either.


+#ifdef CONFIG_HLWD_PIC
+   /*
+* Setup the Hollywood interrupt controller as soon as
+* we detect that we are running under the mini firmware.
+*/
+   hlwd_pic_probe();
+#endif


Why?  The comment doesn't say.


Do you need this driver to boot?  If not, it might be best to leave it
out for now.


Segher

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [RFC PATCH 18/19] powerpc: wii: platform support

2009-11-24 Thread Segher Boessenkool
diff --git a/arch/powerpc/platforms/embedded6xx/wii.c b/arch/ 
powerpc/platforms/embedded6xx/wii.c



+#define DRV_MODULE_NAME rvl


Should this be wii?


+static enum starlet_ipc_flavour starlet_ipc_flavour;
+
+enum starlet_ipc_flavour starlet_get_ipc_flavour(void)
+{
+   return starlet_ipc_flavour;
+}


This can go I think, unless you plan on supporting something else  
than mini?



+#ifdef CONFIG_STARLET_MINI
+
+#define HW_RESETS_OF_COMPATIBLEnintendo,hollywood-resets
+#define HW_GPIO_ALIAS  hw_gpio


This should be unconditional now I think?  You access the hardware  
directly.



+   np = of_find_node_by_name(NULL, aliases);
+   if (!np) {
+   pr_err(unable to find node %s\n, aliases);
+   goto out;
+   }
+
+   path = of_get_property(np, HW_GPIO_ALIAS, NULL);
+   of_node_put(np);
+   if (!path) {
+   pr_err(alias %s unknown\n, HW_GPIO_ALIAS);
+   goto out;
+   }


Don't use an alias here, search for e.g. a matching compatible  
instead.



+static struct of_device_id wii_of_bus[] = {
+   { .compatible = nintendo,hollywood, },


Like with Flipper, why a platform bus?


+#ifdef CONFIG_STARLET_MINI
+   { .compatible = twiizers,starlet-mini-ipc, },
+#endif


This one should go completely, I will have more to say about it when  
I get

to review the device trees (saving those for last :-) ).


Segher

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH v2 11/11] of: unify phandle name in struct device_node

2009-11-24 Thread David Miller
From: Grant Likely grant.lik...@secretlab.ca
Date: Tue, 24 Nov 2009 15:01:14 -0700

 In struct device_node, the phandle is named 'linux_phandle' for PowerPC
 and MicroBlaze, and 'node' for SPARC.  There is no good reason for the
 difference, it is just an artifact of the code diverging over a couple
 of years.  This patch renames both to simply .phandle.
 
 Note: the .node also existed in PowerPC/MicroBlaze, but the only user
 seems to be arch/powerpc/platforms/powermac/pfunc_core.c.  It doesn't
 look like the assignment between .linux_phandle and .node is
 significantly different enough to warrant the separate code paths
 unless ibm,phandle properties actually appear in Apple device trees.
 
 I think it is safe to eliminate the old .node property and use
 linux_phandle everywhere.
 
 Signed-off-by: Grant Likely grant.lik...@secretlab.ca

Acked-by: David S. Miller da...@davemloft.net
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [RFC PATCH 02/19] powerpc: gamecube: device tree

2009-11-24 Thread Segher Boessenkool

+   model = NintendoGameCube;
+   compatible = nintendo,gamecube;


To date, we've been using the same form for both the model and
compatible properties.  Specifically the vendor,model form to
maintain the namespace.


That, however, is a) useless; and b) not totally correct.
The model property should show an exact model number if available.
You should use the vendor, thing indeed.

If you don't have any better model # to use, using the same thing
as compatible is okay I suppose.  But it's not the _best_ thing
to put here if you have the choice.  Maybe you should say  
nintendo,RVL-001

(well, that's Wii, you want the similar thing for NGC, but you get
the point I hope).


+   compatible = nintendo,flipper;
+   clock-frequency = 16200; /* 162MHz */
+   ranges = 0x0c00 0x0c00 0x0001;


Since you're only doing 1:1 mappings; you could replace this with an
empty ranges; property instead.


You could, but being explicit about the supported ranges isn't
bad either.


Hint:  If you move the interrupt-parent property up to the root node,
then you don't need to specify it in every single device node; it will
just inherit from the parent.


If you have only one interrupt controller, like here, you don't
need to refer to it _at all_ :-)


Segher

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [RFC PATCH 06/19] powerpc: gamecube/wii: introduce GAMECUBE_COMMON

2009-11-24 Thread Arnd Bergmann
On Tuesday 24 November 2009, Segher Boessenkool wrote:
  This option should be used only for options applicable to both the  
  GAMECUBE and WII, i.e. basically those options in the WII which  
  where inherited from the GAMECUBE to make it retro-compatible.
 
  If GAMECUBE_COMMON is unacceptable, maybe GAMECUBE_LEGACY or  
  GAMECUBE_COMPAT?
 
 Maybe it's best to write GAMECUBE || WII in the places that use it,  
 then?

Or just use CONFIG_NINTENDO? If we ever want to port to a future
Nintendo system that is not compatible, we can still change it.

Arnd 
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [RFC PATCH 02/19] powerpc: gamecube: device tree

2009-11-24 Thread Segher Boessenkool
The soc node here tries to represent the big multi-function chip  
that integrates most of the devices of the video game consoles  
(Flipper on the Nintendo GameCube and Hollywood on the Wii).


Right.  Much like many other SoCs.


It isn't a SoC, it's really just a memory bridge / I/O bridge
like e.g. MPC10x.

All the device addresses are fixed on the chip, there is no IMMR
or similar.

You can either group all devices under a flipper node, or just
put the devices directly in the root node, and have a separate
node for the generic control regs.  Both are a good description
of both the physical and logical structure, so it just comes down
to taste.

Good drivers can handle either structure btw, they should normally
only look at compatible to find their devices, so it doesn't
matter much anyway.


Segher

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [RFC PATCH 03/19] powerpc: gamecube: bootwrapper bits

2009-11-24 Thread Albert Herranz
Segher Boessenkool wrote:
 So what's your proposal then? Placing it within a fake func?
 That asm snippet is the entry point. I took as an example how
 prpmc2800.c deals with that, providing an own version of the (weak)
 _zImage_start.
 
 Use an assembler source file.  You'll get much nicer syntax as well
 (none of that \n stuff).
 

I found it cleaner to embed the entry point code in the .c file and avoid 
touching the wrapper script.
But I'm fine with that if it is the way to go (and I already finally touched 
the wrapper to increase the link address...).

 WIMG=, are you sure?  Not M=1?

 To be honest, I don't recall the details now.
 But it was tested in the very early days, the result was not the
 expected one and, in the end, manual cache coherency management was
 still needed.
 
 Sure, the memory controllers don't do coherency.  I'm slightly worried
 about two things:
 1) Will the generic code use M=0 as well?  Is it a problem if it doesn't?
 2) Do lwarx. etc. work in M=0?
 
 And a question: does M=0 actually give better performance (lower bus
 utilisation, and maybe saves a few cycles)?
 

I think that the generic code uses M=0 _except_ for SMP and some platforms (see 
comment in cputable.h).
And yes, the generic code works with these processors :)

M=0 should have a lower bus utilization, yes.
Also M=0 is a requirement if you use some Gekko/Broadway features like the 
locked (half-)cache.

Thanks,
Albert

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: spi_mpc8xxx.c: chip select polarity problem

2009-11-24 Thread Grant Likely
Thanks.  However, there needs to be a proper description of what this
patch does to go in the commit header.  Can you please write one?

Thanks,
g.

On Sat, Nov 21, 2009 at 9:08 AM, Torsten Fleischer
to-fleisc...@t-online.de wrote:
 On Sat, Nov 21, 2009 at 09:45:50 Grant Likely wrote:
 [...]
 Hey Torsten,  do you have an updated version of this change to address
 the comments?  I'm collecting the last few things for some linux-next
 exposure now.

 Hey Grant,

 here is the updated version of the patch containing the recommended
 changes.

 Best Regards
 Torsten


 Signed-off-by: Torsten Fleischer to-fleisc...@t-online.de
 ---

 diff -u -r -N linux-2.6.31.6_orig//drivers/spi/spi_mpc8xxx.c 
 linux-2.6.31.6/drivers/spi/spi_mpc8xxx.c
 --- linux-2.6.31.6_orig//drivers/spi/spi_mpc8xxx.c      2009-11-10 
 01:32:31.0 +0100
 +++ linux-2.6.31.6/drivers/spi/spi_mpc8xxx.c    2009-11-19 08:15:33.0 
 +0100
 @@ -114,6 +114,7 @@
        u32 rx_shift;           /* RX data reg shift when in qe mode */
        u32 tx_shift;           /* TX data reg shift when in qe mode */
        u32 hw_mode;            /* Holds HW mode register settings */
 +       int initialized;
  };

  static inline void mpc8xxx_spi_write_reg(__be32 __iomem *reg, u32 val)
 @@ -503,15 +504,52 @@

        return ret;
  }
 +
 +
 +struct mpc8xxx_spi_probe_info {
 +       struct fsl_spi_platform_data pdata;
 +       int *gpios;
 +       bool *alow_flags;
 +};
 +
 +static struct mpc8xxx_spi_probe_info *
 +to_of_pinfo(struct fsl_spi_platform_data *pdata)
 +{
 +       return container_of(pdata, struct mpc8xxx_spi_probe_info, pdata);
 +}
 +
 +static int mpc8xxx_spi_cs_init(struct spi_device *spi)
 +{
 +       struct device *dev = spi-dev.parent;
 +       struct mpc8xxx_spi_probe_info *pinfo = 
 to_of_pinfo(dev-platform_data);
 +       u16 cs = spi-chip_select;
 +       int gpio = pinfo-gpios[cs];
 +       bool on = pinfo-alow_flags[cs] ^ !(spi-mode  SPI_CS_HIGH);
 +
 +       return gpio_direction_output(gpio, on);
 +}
 +
  static int mpc8xxx_spi_transfer(struct spi_device *spi,
                                struct spi_message *m)
  {
        struct mpc8xxx_spi *mpc8xxx_spi = spi_master_get_devdata(spi-master);
 +       struct spi_mpc8xxx_cs *cs = spi-controller_state;
        unsigned long flags;

        m-actual_length = 0;
        m-status = -EINPROGRESS;

 +       if (cs  !cs-initialized) {
 +               int ret;
 +
 +               ret = mpc8xxx_spi_cs_init(spi);
 +               if (ret) {
 +                       dev_dbg(spi-dev, cs_init failed: %d\n, ret);
 +                       return ret;
 +               }
 +               cs-initialized = 1;
 +       }
 +
        spin_lock_irqsave(mpc8xxx_spi-lock, flags);
        list_add_tail(m-queue, mpc8xxx_spi-queue);
        queue_work(mpc8xxx_spi-workqueue, mpc8xxx_spi-work);
 @@ -648,18 +686,6 @@
        return 0;
  }

 -struct mpc8xxx_spi_probe_info {
 -       struct fsl_spi_platform_data pdata;
 -       int *gpios;
 -       bool *alow_flags;
 -};
 -
 -static struct mpc8xxx_spi_probe_info *
 -to_of_pinfo(struct fsl_spi_platform_data *pdata)
 -{
 -       return container_of(pdata, struct mpc8xxx_spi_probe_info, pdata);
 -}
 -
  static void mpc8xxx_spi_cs_control(struct spi_device *spi, bool on)
  {
        struct device *dev = spi-dev.parent;
 @@ -720,14 +746,6 @@

                pinfo-gpios[i] = gpio;
                pinfo-alow_flags[i] = flags  OF_GPIO_ACTIVE_LOW;
 -
 -               ret = gpio_direction_output(pinfo-gpios[i],
 -                                           pinfo-alow_flags[i]);
 -               if (ret) {
 -                       dev_err(dev, can't set output direction for gpio 
 -                               #%d: %d\n, i, ret);
 -                       goto err_loop;
 -               }
        }

        pdata-max_chipselect = ngpios;




-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [RFC PATCH 14/19] powerpc: allow ioremap within reserved fake ram regions

2009-11-24 Thread Michael Ellerman
On Tue, 2009-11-24 at 18:09 +0100, Albert Herranz wrote:
 Michael Ellerman wrote:
  Would it be acceptable to create a global var __allow_ioremap_normal_ram 
  that by default would have a value of 0 and would be set _only_ for those 
  platforms needing it?
 
  The other solutions I see is:
  - add support for discontiguous memory to powerpc 32-bits (which is not 
  something that I can look into now)
  - don't use the precious second 64MB area (which is a waste)
  
  - Implement your own ppc_md.ioremap(), see iseries  cell for example.
  
  Currently that's only called on 64-bit, but you could change that.
  
  If I'm reading your patch right, you should be able to do that check in
  your platform's ioremap() and then call the generic implementation to do
  the actual work.
  
  cheers
 
 I could use ppc_md.ioremap to duplicate ioremap except for the ioremap ram 
 check.
 But calling the stock ioremap without modifying it is not possible
 because it checks and bails out when ioremapping a region marked as
 ram (even if it's not real ram and it's memreserved).

OK, that wasn't clear in your patch. It looks like you're adding a check
(!__map_without_bats) - but whatever.

 Is the list of memreserved areas preserved once the kernel is running?
 If it is preserved another option would be to unban ioremapping ram if 
 memreserved.

Yeah it is, so that might work, though it's still a bit of a hack :)
But if that's just a stop-gap until sparse mem gets going on 32-bit
maybe that's OK.

cheers


signature.asc
Description: This is a digitally signed message part
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH v2 11/11] of: unify phandle name in struct device_node

2009-11-24 Thread Segher Boessenkool
In struct device_node, the phandle is named 'linux_phandle' for  
PowerPC

and MicroBlaze, and 'node' for SPARC.  There is no good reason for the
difference, it is just an artifact of the code diverging over a couple
of years.  This patch renames both to simply .phandle.

Note: the .node also existed in PowerPC/MicroBlaze, but the only user
seems to be arch/powerpc/platforms/powermac/pfunc_core.c.  It doesn't
look like the assignment between .linux_phandle and .node is
significantly different enough to warrant the separate code paths
unless ibm,phandle properties actually appear in Apple device trees.

I think it is safe to eliminate the old .node property and use
linux_phandle everywhere.


    You forgot to update one :-)





Segher

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH v2 11/11] of: unify phandle name in struct device_node

2009-11-24 Thread Grant Likely
On Tue, Nov 24, 2009 at 6:30 PM, Segher Boessenkool
seg...@kernel.crashing.org wrote:
 In struct device_node, the phandle is named 'linux_phandle' for PowerPC
 and MicroBlaze, and 'node' for SPARC.  There is no good reason for the
 difference, it is just an artifact of the code diverging over a couple
 of years.  This patch renames both to simply .phandle.

 Note: the .node also existed in PowerPC/MicroBlaze, but the only user
 seems to be arch/powerpc/platforms/powermac/pfunc_core.c.  It doesn't
 look like the assignment between .linux_phandle and .node is
 significantly different enough to warrant the separate code paths
 unless ibm,phandle properties actually appear in Apple device trees.

 I think it is safe to eliminate the old .node property and use
 linux_phandle everywhere.

    You forgot to update one :-)

Heeheehee.  oops.

g.

-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH 0/3] Kernel handling of Dynamic Logical Partitioning

2009-11-24 Thread Nathan Fontenot

The Dynamic Logical Partitioning (DLPAR) capabilities of the powerpc pseries
platform allows for the addition and removal of resources (i.e. cpus,
memory, pci devices) from a partition. The removal of a resource involves
removing the resource's node from the device tree and then returning the
resource to firmware via the rtas set-indicator call.  To add a resource, it
is first obtained from firmware via the rtas set-indicator call and then a
new device tree node is created using the ibm,configure-coinnector rtas call
and added to the device tree.

The following set of patches implements the needed infrastructure to have the
kernel handle the DLPAR addition and removal of cpus (other DLPAR'able items 
to follow in future patches).  The framework for this is to create a set of 
probe/release sysfs files that will facilitate arch-specific call-outs to 
handle addition and removal of cpus to the system.


-Nathan Fontenot

1/3 - powerpc/pseries kernel DLPAR infrastructure
2/3 - Create probe/release sysfs files and the powerpc handlers
3/3 - powerpc/pseries CPU DLPAR handling

arch/powerpc/Kconfig|4 
arch/powerpc/include/asm/machdep.h  |5 
arch/powerpc/include/asm/pSeries_reconfig.h |1 
arch/powerpc/kernel/sysfs.c |   19 +
arch/powerpc/platforms/pseries/Makefile |2 
arch/powerpc/platforms/pseries/dlpar.c  |  412 
arch/powerpc/platforms/pseries/reconfig.c   |2 
drivers/base/cpu.c  |   32 ++
include/linux/cpu.h |4 
9 files changed, 479 insertions(+), 2 deletions(-)

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH 1/3] Kernel DLPAR infrastructure

2009-11-24 Thread Nathan Fontenot

This patch provides the kernel DLPAR infrastructure in a new filed named
dlpar.c.  The functionality provided is for acquiring and releasing a resource
from firmware and the parsing of information returned from the
ibm,configure-connector rtas call.  Additionally this exports the pSeries
reconfiguration notifier chain so that it can be invoked when device tree 
updates are made.


Signed-off-by: Nathan Fontenot nf...@austin.ibm.com 
---


---
arch/powerpc/include/asm/pSeries_reconfig.h |1 
arch/powerpc/platforms/pseries/Makefile |2 
arch/powerpc/platforms/pseries/dlpar.c  |  324 
arch/powerpc/platforms/pseries/reconfig.c   |2 
4 files changed, 327 insertions(+), 2 deletions(-)


Index: powerpc/arch/powerpc/platforms/pseries/dlpar.c
===
--- /dev/null   1970-01-01 00:00:00.0 +
+++ powerpc/arch/powerpc/platforms/pseries/dlpar.c  2009-11-24 
23:31:28.0 -0600
@@ -0,0 +1,324 @@
+/*
+ * Support for dynamic reconfiguration for PCI, Memory, and CPU
+ * Hotplug and Dynamic Logical Partitioning on RPA platforms.
+ *
+ * Copyright (C) 2009 Nathan Fontenot
+ * Copyright (C) 2009 IBM Corporation
+ *
+ * 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/kernel.h
+#include linux/kref.h
+#include linux/notifier.h
+#include linux/proc_fs.h
+#include linux/spinlock.h
+#include linux/cpu.h
+
+#include asm/prom.h
+#include asm/machdep.h
+#include asm/uaccess.h
+#include asm/rtas.h
+#include asm/pSeries_reconfig.h
+
+struct cc_workarea {
+   u32 drc_index;
+   u32 zero;
+   u32 name_offset;
+   u32 prop_length;
+   u32 prop_offset;
+};
+
+static void dlpar_free_cc_property(struct property *prop)
+{
+   kfree(prop-name);
+   kfree(prop-value);
+   kfree(prop);
+}
+
+static struct property *dlpar_parse_cc_property(struct cc_workarea *ccwa)
+{
+   struct property *prop;
+   char *name;
+   char *value;
+
+   prop = kzalloc(sizeof(*prop), GFP_KERNEL);
+   if (!prop)
+   return NULL;
+
+   name = (char *)ccwa + ccwa-name_offset;
+   prop-name = kstrdup(name, GFP_KERNEL);
+
+   prop-length = ccwa-prop_length;
+   value = (char *)ccwa + ccwa-prop_offset;
+   prop-value = kzalloc(prop-length, GFP_KERNEL);
+   if (!prop-value) {
+   dlpar_free_cc_property(prop);
+   return NULL;
+   }
+
+   memcpy(prop-value, value, prop-length);
+   return prop;
+}
+
+static struct device_node *dlpar_parse_cc_node(struct cc_workarea *ccwa)
+{
+   struct device_node *dn;
+   char *name;
+
+   dn = kzalloc(sizeof(*dn), GFP_KERNEL);
+   if (!dn)
+   return NULL;
+
+   name = (char *)ccwa + ccwa-name_offset;
+   dn-full_name = kstrdup(name, GFP_KERNEL);
+
+   return dn;
+}
+
+static void dlpar_free_one_cc_node(struct device_node *dn)
+{
+   struct property *prop;
+
+   while (dn-properties) {
+   prop = dn-properties;
+   dn-properties = prop-next;
+   dlpar_free_cc_property(prop);
+   }
+
+   kfree(dn-full_name);
+   kfree(dn);
+}
+
+static void dlpar_free_cc_nodes(struct device_node *dn)
+{
+   if (dn-child)
+   dlpar_free_cc_nodes(dn-child);
+
+   if (dn-sibling)
+   dlpar_free_cc_nodes(dn-sibling);
+
+   dlpar_free_one_cc_node(dn);
+}
+
+#define NEXT_SIBLING1
+#define NEXT_CHILD  2
+#define NEXT_PROPERTY   3
+#define PREV_PARENT 4
+#define MORE_MEMORY 5
+#define CALL_AGAIN -2
+#define ERR_CFG_USE -9003
+
+struct device_node *dlpar_configure_connector(u32 drc_index)
+{
+   struct device_node *dn;
+   struct device_node *first_dn = NULL;
+   struct device_node *last_dn = NULL;
+   struct property *property;
+   struct property *last_property = NULL;
+   struct cc_workarea *ccwa;
+   int cc_token;
+   int rc;
+
+   cc_token = rtas_token(ibm,configure-connector);
+   if (cc_token == RTAS_UNKNOWN_SERVICE)
+   return NULL;
+
+   spin_lock(rtas_data_buf_lock);
+   ccwa = (struct cc_workarea *)rtas_data_buf[0];
+   ccwa-drc_index = drc_index;
+   ccwa-zero = 0;
+
+   rc = rtas_call(cc_token, 2, 1, NULL, rtas_data_buf, NULL);
+   while (rc) {
+   switch (rc) {
+   case NEXT_SIBLING:
+   dn = dlpar_parse_cc_node(ccwa);
+   if (!dn)
+   goto cc_error;
+
+   dn-parent = last_dn-parent;
+   last_dn-sibling = dn;
+   last_dn = dn;
+   break;
+
+   case NEXT_CHILD:
+   dn = dlpar_parse_cc_node(ccwa);
+  

[PATCH 2/3] sysfs cpu probe/release files

2009-11-24 Thread Nathan Fontenot

Create new probe and release sysfs files to facilitate adding and removing
cpus from the system.  This also creates the powerpc specific stubs to handle
the arch callouts from writes to the sysfs files.

The creation and use of these files is regulated by the 
CONFIG_ARCH_CPU_PROBE_RELEASE option so that only architectures that need the

capability will have the files created.

Signed-off-by: Nathan Fontenot nf...@austin.ibm.com
---
arch/powerpc/Kconfig   |4 
arch/powerpc/include/asm/machdep.h |5 +
arch/powerpc/kernel/sysfs.c|   19 +++
drivers/base/cpu.c |   32 
include/linux/cpu.h|4 
5 files changed, 64 insertions(+)

Index: powerpc/drivers/base/cpu.c
===
--- powerpc.orig/drivers/base/cpu.c 2009-11-23 18:19:23.0 -0600
+++ powerpc/drivers/base/cpu.c  2009-11-24 14:30:07.0 -0600
@@ -72,6 +72,38 @@
per_cpu(cpu_sys_devices, logical_cpu) = NULL;
return;
}
+
+#ifdef CONFIG_ARCH_CPU_PROBE_RELEASE
+static ssize_t cpu_probe_store(struct class *class, const char *buf,
+  size_t count)
+{
+   return arch_cpu_probe(buf, count);
+}
+
+static ssize_t cpu_release_store(struct class *class, const char *buf,
+size_t count)
+{
+   return arch_cpu_release(buf, count);
+}
+
+static CLASS_ATTR(probe, S_IWUSR, NULL, cpu_probe_store);
+static CLASS_ATTR(release, S_IWUSR, NULL, cpu_release_store);
+
+int __init cpu_probe_release_init(void)
+{
+   int rc;
+
+   rc = sysfs_create_file(cpu_sysdev_class.kset.kobj,
+  class_attr_probe.attr);
+   if (!rc)
+   rc = sysfs_create_file(cpu_sysdev_class.kset.kobj,
+  class_attr_release.attr);
+
+   return rc;
+}
+device_initcall(cpu_probe_release_init);
+#endif /* CONFIG_ARCH_CPU_PROBE_RELEASE */
+
#else /* ... !CONFIG_HOTPLUG_CPU */
static inline void register_cpu_control(struct cpu *cpu)
{
Index: powerpc/arch/powerpc/include/asm/machdep.h
===
--- powerpc.orig/arch/powerpc/include/asm/machdep.h 2009-11-23 
18:19:23.0 -0600
+++ powerpc/arch/powerpc/include/asm/machdep.h  2009-11-24 14:30:07.0 
-0600
@@ -266,6 +266,11 @@
void (*suspend_disable_irqs)(void);
void (*suspend_enable_irqs)(void);
#endif
+
+#ifdef CONFIG_ARCH_CPU_PROBE_RELEASE
+   ssize_t (*cpu_probe)(const char *, size_t);
+   ssize_t (*cpu_release)(const char *, size_t);
+#endif
};

extern void e500_idle(void);
Index: powerpc/arch/powerpc/kernel/sysfs.c
===
--- powerpc.orig/arch/powerpc/kernel/sysfs.c2009-11-23 18:19:23.0 
-0600
+++ powerpc/arch/powerpc/kernel/sysfs.c 2009-11-24 14:43:40.0 -0600
@@ -461,6 +461,25 @@

cacheinfo_cpu_offline(cpu);
}
+
+#ifdef CONFIG_ARCH_CPU_PROBE_RELEASE
+ssize_t arch_cpu_probe(const char *buf, size_t count)
+{
+   if (ppc_md.cpu_probe)
+   return ppc_md.cpu_probe(buf, count);
+
+   return -EINVAL;
+}
+
+ssize_t arch_cpu_release(const char *buf, size_t count)
+{
+   if (ppc_md.cpu_release)
+   return ppc_md.cpu_release(buf, count);
+
+   return -EINVAL;
+}
+#endif /* CONFIG_ARCH_CPU_PROBE_RELEASE */
+
#endif /* CONFIG_HOTPLUG_CPU */

static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
Index: powerpc/arch/powerpc/Kconfig
===
--- powerpc.orig/arch/powerpc/Kconfig   2009-11-23 18:19:23.0 -0600
+++ powerpc/arch/powerpc/Kconfig2009-11-24 14:30:07.0 -0600
@@ -320,6 +320,10 @@

  Say N if you are unsure.

+config ARCH_CPU_PROBE_RELEASE
+   def_bool y
+   depends on HOTPLUG_CPU
+
config ARCH_ENABLE_MEMORY_HOTPLUG
def_bool y

Index: powerpc/include/linux/cpu.h
===
--- powerpc.orig/include/linux/cpu.h2009-11-23 18:19:23.0 -0600
+++ powerpc/include/linux/cpu.h 2009-11-24 14:30:07.0 -0600
@@ -43,6 +43,10 @@

#ifdef CONFIG_HOTPLUG_CPU
extern void unregister_cpu(struct cpu *cpu);
+#ifdef CONFIG_ARCH_CPU_PROBE_RELEASE
+extern ssize_t arch_cpu_probe(const char *, size_t);
+extern ssize_t arch_cpu_release(const char *, size_t);
+#endif
#endif
struct notifier_block;

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH 3/3] CPU DLPAR handling

2009-11-24 Thread Nathan Fontenot

Register the pseries specific handlers for the powerpc architecture handlers
for the cpu probe and release files.  This also implements the cpu DLPAR
addition and removal of CPUS from the system.

Signed-off-by: Nathan Fontenot nf...@austin.ibm.com
---

arch/powerpc/platforms/pseries/dlpar.c |   88 +
1 file changed, 88 insertions(+)

Index: powerpc/arch/powerpc/platforms/pseries/dlpar.c
===
--- powerpc.orig/arch/powerpc/platforms/pseries/dlpar.c 2009-11-24 
23:29:12.0 -0600
+++ powerpc/arch/powerpc/platforms/pseries/dlpar.c  2009-11-24 
23:29:24.0 -0600
@@ -321,4 +321,92 @@
return 0;
}

+#ifdef CONFIG_ARCH_CPU_PROBE_RELEASE

+static ssize_t dlpar_cpu_probe(const char *buf, size_t count)
+{
+   struct device_node *dn;
+   unsigned long drc_index;
+   char *cpu_name;
+   int rc;
+
+   rc = strict_strtoul(buf, 0, drc_index);
+   if (rc)
+   return -EINVAL;
+
+   dn = dlpar_configure_connector(drc_index);
+   if (!dn)
+   return -EINVAL;
+
+   /* configure-connector reports cpus as living in the base
+* directory of the device tree.  CPUs actually live in the
+* cpus directory so we need to fixup the full_name.
+*/
+   cpu_name = kzalloc(strlen(dn-full_name) + strlen(/cpus/) + 1,
+  GFP_KERNEL);
+   if (!cpu_name) {
+   dlpar_free_cc_nodes(dn);
+   return -ENOMEM;
+   }
+
+   sprintf(cpu_name, /cpus/%s, dn-full_name);
+   kfree(dn-full_name);
+   dn-full_name = cpu_name;
+
+   rc = dlpar_acquire_drc(drc_index);
+   if (rc) {
+   dlpar_free_cc_nodes(dn);
+   return -EINVAL;
+   }
+
+   rc = dlpar_attach_node(dn);
+   if (rc) {
+   dlpar_release_drc(drc_index);
+   dlpar_free_cc_nodes(dn);
+   }
+
+   return rc ? rc : count;
+}
+
+static ssize_t dlpar_cpu_release(const char *buf, size_t count)
+{
+   struct device_node *dn;
+   const u32 *drc_index;
+   int rc;
+
+   dn = of_find_node_by_path(buf);
+   if (!dn)
+   return -EINVAL;
+
+   drc_index = of_get_property(dn, ibm,my-drc-index, NULL);
+   if (!drc_index) {
+   of_node_put(dn);
+   return -EINVAL;
+   }
+
+   rc = dlpar_release_drc(*drc_index);
+   if (rc) {
+   of_node_put(dn);
+   return -EINVAL;
+   }
+
+   rc = dlpar_detach_node(dn);
+   if (rc) {
+   dlpar_acquire_drc(*drc_index);
+   return rc;
+   }
+
+   of_node_put(dn);
+   return count;
+}
+
+static int __init pseries_dlpar_init(void)
+{
+   ppc_md.cpu_probe = dlpar_cpu_probe;
+   ppc_md.cpu_release = dlpar_cpu_release;
+
+   return 0;
+}
+machine_device_initcall(pseries, pseries_dlpar_init);
+
+#endif /* CONFIG_ARCH_CPU_PROBE_RELEASE */
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH 1/3] Kernel DLPAR infrastructure

2009-11-24 Thread Michael Neuling


In message 4b0c8ce3.4010...@austin.ibm.com you wrote:
 This patch provides the kernel DLPAR infrastructure in a new filed named
 dlpar.c.  The functionality provided is for acquiring and releasing a resourc
e
 from firmware and the parsing of information returned from the
 ibm,configure-connector rtas call.  Additionally this exports the pSeries
 reconfiguration notifier chain so that it can be invoked when device tree 
 updates are made.
 
 Signed-off-by: Nathan Fontenot nf...@austin.ibm.com 

These look like they got white space munged somewhere...

Mikey

 ---
 
 ---
  arch/powerpc/include/asm/pSeries_reconfig.h |1 
  arch/powerpc/platforms/pseries/Makefile |2 
  arch/powerpc/platforms/pseries/dlpar.c  |  324 +
+++
  arch/powerpc/platforms/pseries/reconfig.c   |2 
  4 files changed, 327 insertions(+), 2 deletions(-)
 
 Index: powerpc/arch/powerpc/platforms/pseries/dlpar.c
 ===
 --- /dev/null 1970-01-01 00:00:00.0 +
 +++ powerpc/arch/powerpc/platforms/pseries/dlpar.c2009-11-24 23:31:28.000
00 -0600
 @@ -0,0 +1,324 @@
 +/*
 + * Support for dynamic reconfiguration for PCI, Memory, and CPU
 + * Hotplug and Dynamic Logical Partitioning on RPA platforms.
 + *
 + * Copyright (C) 2009 Nathan Fontenot
 + * Copyright (C) 2009 IBM Corporation
 + *
 + * 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/kernel.h
 +#include linux/kref.h
 +#include linux/notifier.h
 +#include linux/proc_fs.h
 +#include linux/spinlock.h
 +#include linux/cpu.h
 +
 +#include asm/prom.h
 +#include asm/machdep.h
 +#include asm/uaccess.h
 +#include asm/rtas.h
 +#include asm/pSeries_reconfig.h
 +
 +struct cc_workarea {
 + u32 drc_index;
 + u32 zero;
 + u32 name_offset;
 + u32 prop_length;
 + u32 prop_offset;
 +};
 +
 +static void dlpar_free_cc_property(struct property *prop)
 +{
 + kfree(prop-name);
 + kfree(prop-value);
 + kfree(prop);
 +}
 +
 +static struct property *dlpar_parse_cc_property(struct cc_workarea *ccwa)
 +{
 + struct property *prop;
 + char *name;
 + char *value;
 +
 + prop = kzalloc(sizeof(*prop), GFP_KERNEL);
 + if (!prop)
 + return NULL;
 +
 + name = (char *)ccwa + ccwa-name_offset;
 + prop-name = kstrdup(name, GFP_KERNEL);
 +
 + prop-length = ccwa-prop_length;
 + value = (char *)ccwa + ccwa-prop_offset;
 + prop-value = kzalloc(prop-length, GFP_KERNEL);
 + if (!prop-value) {
 + dlpar_free_cc_property(prop);
 + return NULL;
 + }
 +
 + memcpy(prop-value, value, prop-length);
 + return prop;
 +}
 +
 +static struct device_node *dlpar_parse_cc_node(struct cc_workarea *ccwa)
 +{
 + struct device_node *dn;
 + char *name;
 +
 + dn = kzalloc(sizeof(*dn), GFP_KERNEL);
 + if (!dn)
 + return NULL;
 +
 + name = (char *)ccwa + ccwa-name_offset;
 + dn-full_name = kstrdup(name, GFP_KERNEL);
 +
 + return dn;
 +}
 +
 +static void dlpar_free_one_cc_node(struct device_node *dn)
 +{
 + struct property *prop;
 +
 + while (dn-properties) {
 + prop = dn-properties;
 + dn-properties = prop-next;
 + dlpar_free_cc_property(prop);
 + }
 +
 + kfree(dn-full_name);
 + kfree(dn);
 +}
 +
 +static void dlpar_free_cc_nodes(struct device_node *dn)
 +{
 + if (dn-child)
 + dlpar_free_cc_nodes(dn-child);
 +
 + if (dn-sibling)
 + dlpar_free_cc_nodes(dn-sibling);
 +
 + dlpar_free_one_cc_node(dn);
 +}
 +
 +#define NEXT_SIBLING1
 +#define NEXT_CHILD  2
 +#define NEXT_PROPERTY   3
 +#define PREV_PARENT 4
 +#define MORE_MEMORY 5
 +#define CALL_AGAIN   -2
 +#define ERR_CFG_USE -9003
 +
 +struct device_node *dlpar_configure_connector(u32 drc_index)
 +{
 + struct device_node *dn;
 + struct device_node *first_dn = NULL;
 + struct device_node *last_dn = NULL;
 + struct property *property;
 + struct property *last_property = NULL;
 + struct cc_workarea *ccwa;
 + int cc_token;
 + int rc;
 +
 + cc_token = rtas_token(ibm,configure-connector);
 + if (cc_token == RTAS_UNKNOWN_SERVICE)
 + return NULL;
 +
 + spin_lock(rtas_data_buf_lock);
 + ccwa = (struct cc_workarea *)rtas_data_buf[0];
 + ccwa-drc_index = drc_index;
 + ccwa-zero = 0;
 +
 + rc = rtas_call(cc_token, 2, 1, NULL, rtas_data_buf, NULL);
 + while (rc) {
 + switch (rc) {
 + case NEXT_SIBLING:
 + dn = dlpar_parse_cc_node(ccwa);
 + if (!dn)
 + goto cc_error;
 +
 + dn-parent = last_dn-parent;
 + last_dn-sibling = dn;
 + 

[PATCH] cpm2_pic: Allow correct flow_types for port C interrupts

2009-11-24 Thread Mark Ware
CPM2 Port C interrupts can be either falling edge, or either edge.
Other external interrupts are either falling edge or active low.

Signed-Off-By: Mark Ware mw...@elphinstone.net
---
 arch/powerpc/sysdev/cpm2_pic.c |   29 ++---
 1 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/arch/powerpc/sysdev/cpm2_pic.c b/arch/powerpc/sysdev/cpm2_pic.c
index 78f1f7c..179822c 100644
--- a/arch/powerpc/sysdev/cpm2_pic.c
+++ b/arch/powerpc/sysdev/cpm2_pic.c
@@ -141,13 +141,28 @@ static int cpm2_set_irq_type(unsigned int virq, unsigned 
int flow_type)
struct irq_desc *desc = get_irq_desc(virq);
unsigned int vold, vnew, edibit;
 
-   if (flow_type == IRQ_TYPE_NONE)
-   flow_type = IRQ_TYPE_LEVEL_LOW;
-
-   if (flow_type  IRQ_TYPE_EDGE_RISING) {
-   printk(KERN_ERR CPM2 PIC: sense type 0x%x not supported\n,
-   flow_type);
-   return -EINVAL;
+   /* Port C interrupts are either IRQ_TYPE_EDGE_FALLING or
+* IRQ_TYPE_EDGE_BOTH (default).  All others are IRQ_TYPE_EDGE_FALLING
+* or IRQ_TYPE_LEVEL_LOW (default)
+*/
+   if (src = CPM2_IRQ_PORTC15  src = CPM2_IRQ_PORTC0) {
+   if (flow_type == IRQ_TYPE_NONE)
+   flow_type = IRQ_TYPE_EDGE_BOTH;
+
+   if (flow_type  ~IRQ_TYPE_EDGE_BOTH) {
+   printk(KERN_ERR CPM2 PIC: sense type 0x%x not 
supported\n,
+   flow_type);
+   return -EINVAL;
+   }
+   } else {
+   if (flow_type == IRQ_TYPE_NONE)
+   flow_type = IRQ_TYPE_LEVEL_LOW;
+
+   if (flow_type  (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_LEVEL_HIGH)) {
+   printk(KERN_ERR CPM2 PIC: sense type 0x%x not 
supported\n,
+   flow_type);
+   return -EINVAL;
+   }
}
 
desc-status = ~(IRQ_TYPE_SENSE_MASK | IRQ_LEVEL);
-- 
1.5.6.5

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH 1/3] Kernel DLPAR infrastructure

2009-11-24 Thread Michael Neuling


In message 31581.1259115...@neuling.org you wrote:
 
 
 In message 4b0c8ce3.4010...@austin.ibm.com you wrote:
  This patch provides the kernel DLPAR infrastructure in a new filed named
  dlpar.c.  The functionality provided is for acquiring and releasing a resou
rc
 e
  from firmware and the parsing of information returned from the
  ibm,configure-connector rtas call.  Additionally this exports the pSeries
  reconfiguration notifier chain so that it can be invoked when device tree 
  updates are made.
  
  Signed-off-by: Nathan Fontenot nf...@austin.ibm.com 
 
 These look like they got white space munged somewhere...

Gah, sorry, they are fine

Mikey
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH 0/3] Kernel handling of Dynamic Logical Partitioning

2009-11-24 Thread Paul Mackerras
Nathan Fontenot writes:

 The Dynamic Logical Partitioning (DLPAR) capabilities of the powerpc pseries
 platform allows for the addition and removal of resources (i.e. cpus,
 memory, pci devices) from a partition. The removal of a resource involves
 removing the resource's node from the device tree and then returning the
 resource to firmware via the rtas set-indicator call.  To add a resource, it
 is first obtained from firmware via the rtas set-indicator call and then a
 new device tree node is created using the ibm,configure-coinnector rtas call
 and added to the device tree.
 
 The following set of patches implements the needed infrastructure to have the
 kernel handle the DLPAR addition and removal of cpus (other DLPAR'able items 
 to follow in future patches).  The framework for this is to create a set of 
 probe/release sysfs files that will facilitate arch-specific call-outs to 
 handle addition and removal of cpus to the system.

Nice explanation, but the 0/3 of the series doesn't go into git.
Could you rework some/all of this into the commit message for patch
1/3 so it gets stored permanently with these patches in git?

Thanks,
Paul.
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH 1/3] Kernel DLPAR infrastructure

2009-11-24 Thread Paul Mackerras
Nathan Fontenot writes:

 This patch provides the kernel DLPAR infrastructure in a new filed named
 dlpar.c.  The functionality provided is for acquiring and releasing a resource
 from firmware and the parsing of information returned from the
 ibm,configure-connector rtas call.  Additionally this exports the pSeries
 reconfiguration notifier chain so that it can be invoked when device tree 
 updates are made.

Mostly looks great.

 +static struct device_node *derive_parent(const char *path)
 +{
 + struct device_node *parent;
 + char parent_path[128];
 + int parent_path_len;
 +
 + parent_path_len = strrchr(path, '/') - path + 1;
 + strlcpy(parent_path, path, parent_path_len);

This looks a bit fragile if path could possibly not contain any '/' or
if the '/' is more than 128 characters from the start of path.  Please
fix this to check if strrchr returns NULL and to cope in some
reasonable fashion if the path happens to be very long.

 +#ifdef CONFIG_PROC_DEVICETREE
 + ent = proc_mkdir(strrchr(dn-full_name, '/') + 1, dn-parent-pde);
 + if (ent)
 + proc_device_tree_add_node(dn, ent);

Also assumes that dn-full_name contains a '/'.  If for some reason it
couldn't possibly not contain a '/', put in a comment explaining that.

Thanks,
Paul.
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH 3/3] CPU DLPAR handling

2009-11-24 Thread Paul Mackerras
Nathan Fontenot writes:

 Register the pseries specific handlers for the powerpc architecture handlers
 for the cpu probe and release files.  This also implements the cpu DLPAR
 addition and removal of CPUS from the system.

...

 + /* configure-connector reports cpus as living in the base
 +  * directory of the device tree.  CPUs actually live in the
 +  * cpus directory so we need to fixup the full_name.
 +  */
 + cpu_name = kzalloc(strlen(dn-full_name) + strlen(/cpus/) + 1,
 +GFP_KERNEL);
 + if (!cpu_name) {
 + dlpar_free_cc_nodes(dn);
 + return -ENOMEM;
 + }
 +
 + sprintf(cpu_name, /cpus/%s, dn-full_name);

I would have expected dn-full_name to start with a '/' already, in
which case this will end up with two consecutive slashes after
'cpus'.  I think that will probably cause problems.

Paul.
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH 2/3] sysfs cpu probe/release files

2009-11-24 Thread Paul Mackerras
Nathan Fontenot writes:

 Create new probe and release sysfs files to facilitate adding and removing
 cpus from the system.  This also creates the powerpc specific stubs to handle
 the arch callouts from writes to the sysfs files.
 
 The creation and use of these files is regulated by the 
 CONFIG_ARCH_CPU_PROBE_RELEASE option so that only architectures that need the
 capability will have the files created.
 
 Signed-off-by: Nathan Fontenot nf...@austin.ibm.com
 ---
  arch/powerpc/Kconfig   |4 
  arch/powerpc/include/asm/machdep.h |5 +
  arch/powerpc/kernel/sysfs.c|   19 +++
  drivers/base/cpu.c |   32 

Since this touches drivers/base/cpu.c, you should cc Greg KH on this
patch and get an ack from him, assuming these patches are going in
through the powerpc tree.

 --- powerpc.orig/include/linux/cpu.h  2009-11-23 18:19:23.0 -0600
 +++ powerpc/include/linux/cpu.h   2009-11-24 14:30:07.0 -0600
 @@ -43,6 +43,10 @@
  
  #ifdef CONFIG_HOTPLUG_CPU
  extern void unregister_cpu(struct cpu *cpu);
 +#ifdef CONFIG_ARCH_CPU_PROBE_RELEASE
 +extern ssize_t arch_cpu_probe(const char *, size_t);
 +extern ssize_t arch_cpu_release(const char *, size_t);
 +#endif

Since these are just declarations, they don't need the #ifdef around
them.

Paul.
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH v2 0/3] Kernel handling of Dynamic Logical Partitioning

2009-11-24 Thread Nathan Fontenot

version 2 of the patch set with updates from comments.

The Dynamic Logical Partitioning (DLPAR) capabilities of the powerpc pseries
platform allows for the addition and removal of resources (i.e. cpus,
memory, pci devices) from a partition. The removal of a resource involves
removing the resource's node from the device tree and then returning the
resource to firmware via the rtas set-indicator call.  To add a resource, it
is first obtained from firmware via the rtas set-indicator call and then a
new device tree node is created using the ibm,configure-coinnector rtas call
and added to the device tree.

The following set of patches implements the needed infrastructure to have the
kernel handle the DLPAR addition and removal of cpus (other DLPAR'able items to 
follow in future patches).  The framework for this is to create a set of probe/release 
sysfs files that will facilitate arch-specific call-outs to handle addition and 
removal of cpus to the system.


-Nathan Fontenot

1/3 - powerpc/pseries kernel DLPAR infrastructure
2/3 - Create probe/release sysfs files and the powerpc handlers
3/3 - powerpc/pseries CPU DLPAR handling 

arch/powerpc/Kconfig|4 
arch/powerpc/include/asm/machdep.h  |5 
arch/powerpc/include/asm/pSeries_reconfig.h |1 
arch/powerpc/kernel/smp.c   |   17 
arch/powerpc/kernel/sysfs.c |   19 +
arch/powerpc/platforms/pseries/Makefile |2 
arch/powerpc/platforms/pseries/dlpar.c  |  500 +++-
arch/powerpc/platforms/pseries/reconfig.c   |2 
drivers/base/cpu.c  |   33 +

include/linux/cpu.h |4
10 files changed, 581 insertions(+), 6 deletions(-)
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


Re: [PATCH 0/3] Kernel handling of Dynamic Logical Partitioning

2009-11-24 Thread Nathan Fontenot

Paul Mackerras wrote:

Nathan Fontenot writes:


The Dynamic Logical Partitioning (DLPAR) capabilities of the powerpc pseries
platform allows for the addition and removal of resources (i.e. cpus,
memory, pci devices) from a partition. The removal of a resource involves
removing the resource's node from the device tree and then returning the
resource to firmware via the rtas set-indicator call.  To add a resource, it
is first obtained from firmware via the rtas set-indicator call and then a
new device tree node is created using the ibm,configure-coinnector rtas call
and added to the device tree.

The following set of patches implements the needed infrastructure to have the
kernel handle the DLPAR addition and removal of cpus (other DLPAR'able items 
to follow in future patches).  The framework for this is to create a set of 
probe/release sysfs files that will facilitate arch-specific call-outs to 
handle addition and removal of cpus to the system.


Nice explanation, but the 0/3 of the series doesn't go into git.
Could you rework some/all of this into the commit message for patch
1/3 so it gets stored permanently with these patches in git?

Thanks,
Paul.


Thanks for all the feedback.

Version two of the patches are on their way based on your comments.

-Nathan Fontenot
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH v2 1/3] Kernel DLPAR Infrastructure

2009-11-24 Thread Nathan Fontenot

The Dynamic Logical Partitioning capabilities of the powerpc pseries platform
allows for the addition and removal of resources (i.e. CPU's, memory, and PCI
devices) from a partition. The removal of a resource involves
removing the resource's node from the device tree and then returning the
resource to firmware via the rtas set-indicator call.  To add a resource, it
is first obtained from firmware via the rtas set-indicator call and then a
new device tree node is created using the ibm,configure-coinnector rtas call
and added to the device tree. 


This patch provides the kernel DLPAR infrastructure in a new filed named
dlpar.c.  The functionality provided is for acquiring and releasing a resource
from firmware and the parsing of information returned from the
ibm,configure-connector rtas call.  Additionally this exports the pSeries
reconfiguration notifier chain so that it can be invoked when device tree 
updates are made.


Signed-off-by: Nathan Fontenot nf...@austin.ibm.com 
---
arch/powerpc/include/asm/pSeries_reconfig.h |1 
arch/powerpc/platforms/pseries/Makefile |2 
arch/powerpc/platforms/pseries/dlpar.c  |  344 
arch/powerpc/platforms/pseries/reconfig.c   |2 
4 files changed, 347 insertions(+), 2 deletions(-)


Index: powerpc/arch/powerpc/platforms/pseries/dlpar.c
===
--- /dev/null   1970-01-01 00:00:00.0 +
+++ powerpc/arch/powerpc/platforms/pseries/dlpar.c  2009-11-25 
04:54:13.0 -0600
@@ -0,0 +1,344 @@
+/*
+ * Support for dynamic reconfiguration for PCI, Memory, and CPU
+ * Hotplug and Dynamic Logical Partitioning on RPA platforms.
+ *
+ * Copyright (C) 2009 Nathan Fontenot
+ * Copyright (C) 2009 IBM Corporation
+ *
+ * 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/kernel.h
+#include linux/kref.h
+#include linux/notifier.h
+#include linux/proc_fs.h
+#include linux/spinlock.h
+#include linux/cpu.h
+
+#include asm/prom.h
+#include asm/machdep.h
+#include asm/uaccess.h
+#include asm/rtas.h
+#include asm/pSeries_reconfig.h
+
+struct cc_workarea {
+   u32 drc_index;
+   u32 zero;
+   u32 name_offset;
+   u32 prop_length;
+   u32 prop_offset;
+};
+
+static void dlpar_free_cc_property(struct property *prop)
+{
+   kfree(prop-name);
+   kfree(prop-value);
+   kfree(prop);
+}
+
+static struct property *dlpar_parse_cc_property(struct cc_workarea *ccwa)
+{
+   struct property *prop;
+   char *name;
+   char *value;
+
+   prop = kzalloc(sizeof(*prop), GFP_KERNEL);
+   if (!prop)
+   return NULL;
+
+   name = (char *)ccwa + ccwa-name_offset;
+   prop-name = kstrdup(name, GFP_KERNEL);
+
+   prop-length = ccwa-prop_length;
+   value = (char *)ccwa + ccwa-prop_offset;
+   prop-value = kzalloc(prop-length, GFP_KERNEL);
+   if (!prop-value) {
+   dlpar_free_cc_property(prop);
+   return NULL;
+   }
+
+   memcpy(prop-value, value, prop-length);
+   return prop;
+}
+
+static struct device_node *dlpar_parse_cc_node(struct cc_workarea *ccwa)
+{
+   struct device_node *dn;
+   char *name;
+
+   dn = kzalloc(sizeof(*dn), GFP_KERNEL);
+   if (!dn)
+   return NULL;
+
+   /* The configure connector reported name does not contain a
+* preceeding '/', so we allocate a buffer large enough to
+* prepend this to the full_name.
+*/
+   name = (char *)ccwa + ccwa-name_offset;
+   dn-full_name = kmalloc(strlen(name) + 2, GFP_KERNEL);
+   if (!dn-full_name) {
+   kfree(dn);
+   return NULL;
+   }
+
+   sprintf(dn-full_name, /%s, name);
+   return dn;
+}
+
+static void dlpar_free_one_cc_node(struct device_node *dn)
+{
+   struct property *prop;
+
+   while (dn-properties) {
+   prop = dn-properties;
+   dn-properties = prop-next;
+   dlpar_free_cc_property(prop);
+   }
+
+   kfree(dn-full_name);
+   kfree(dn);
+}
+
+static void dlpar_free_cc_nodes(struct device_node *dn)
+{
+   if (dn-child)
+   dlpar_free_cc_nodes(dn-child);
+
+   if (dn-sibling)
+   dlpar_free_cc_nodes(dn-sibling);
+
+   dlpar_free_one_cc_node(dn);
+}
+
+#define NEXT_SIBLING1
+#define NEXT_CHILD  2
+#define NEXT_PROPERTY   3
+#define PREV_PARENT 4
+#define MORE_MEMORY 5
+#define CALL_AGAIN -2
+#define ERR_CFG_USE -9003
+
+struct device_node *dlpar_configure_connector(u32 drc_index)
+{
+   struct device_node *dn;
+   struct device_node *first_dn = NULL;
+   struct device_node *last_dn = NULL;
+   struct property *property;
+   struct property *last_property = NULL;
+   struct cc_workarea 

[PATCH v2 2/3] sysfs cpu probe/release files

2009-11-24 Thread Nathan Fontenot

In order to support kernel DLPAR of CPU resources we need to provide an
interface to add (probe) and remove (release) the resource from the system.
This patch Creates new generic probe and release sysfs files to facilitate
cpu probe/release.  The probe/release interface provides for allowing each
arch to supply their own routines for implementing the backend of adding
and removing cpus to/from the system.

This also creates the powerpc specific stubs to handle the arch callouts 
from writes to the sysfs files.


The creation and use of these files is regulated by the 
CONFIG_ARCH_CPU_PROBE_RELEASE option so that only architectures that need the

capability will have the files created.

Signed-off-by: Nathan Fontenot nf...@austin.ibm.com
---

arch/powerpc/Kconfig   |4 
arch/powerpc/include/asm/machdep.h |5 +
arch/powerpc/kernel/sysfs.c|   19 +++
drivers/base/cpu.c |   32 
include/linux/cpu.h|2 ++
5 files changed, 62 insertions(+)

Index: powerpc/drivers/base/cpu.c
===
--- powerpc.orig/drivers/base/cpu.c 2009-11-25 04:06:10.0 -0600
+++ powerpc/drivers/base/cpu.c  2009-11-25 04:11:01.0 -0600
@@ -72,6 +72,38 @@
per_cpu(cpu_sys_devices, logical_cpu) = NULL;
return;
}
+
+#ifdef CONFIG_ARCH_CPU_PROBE_RELEASE
+static ssize_t cpu_probe_store(struct class *class, const char *buf,
+  size_t count)
+{
+   return arch_cpu_probe(buf, count);
+}
+
+static ssize_t cpu_release_store(struct class *class, const char *buf,
+size_t count)
+{
+   return arch_cpu_release(buf, count);
+}
+
+static CLASS_ATTR(probe, S_IWUSR, NULL, cpu_probe_store);
+static CLASS_ATTR(release, S_IWUSR, NULL, cpu_release_store);
+
+int __init cpu_probe_release_init(void)
+{
+   int rc;
+
+   rc = sysfs_create_file(cpu_sysdev_class.kset.kobj,
+  class_attr_probe.attr);
+   if (!rc)
+   rc = sysfs_create_file(cpu_sysdev_class.kset.kobj,
+  class_attr_release.attr);
+
+   return rc;
+}
+device_initcall(cpu_probe_release_init);
+#endif /* CONFIG_ARCH_CPU_PROBE_RELEASE */
+
#else /* ... !CONFIG_HOTPLUG_CPU */
static inline void register_cpu_control(struct cpu *cpu)
{
Index: powerpc/arch/powerpc/include/asm/machdep.h
===
--- powerpc.orig/arch/powerpc/include/asm/machdep.h 2009-11-25 
04:06:10.0 -0600
+++ powerpc/arch/powerpc/include/asm/machdep.h  2009-11-25 04:11:01.0 
-0600
@@ -266,6 +266,11 @@
void (*suspend_disable_irqs)(void);
void (*suspend_enable_irqs)(void);
#endif
+
+#ifdef CONFIG_ARCH_CPU_PROBE_RELEASE
+   ssize_t (*cpu_probe)(const char *, size_t);
+   ssize_t (*cpu_release)(const char *, size_t);
+#endif
};

extern void e500_idle(void);
Index: powerpc/arch/powerpc/kernel/sysfs.c
===
--- powerpc.orig/arch/powerpc/kernel/sysfs.c2009-11-25 04:06:10.0 
-0600
+++ powerpc/arch/powerpc/kernel/sysfs.c 2009-11-25 04:11:01.0 -0600
@@ -461,6 +461,25 @@

cacheinfo_cpu_offline(cpu);
}
+
+#ifdef CONFIG_ARCH_CPU_PROBE_RELEASE
+ssize_t arch_cpu_probe(const char *buf, size_t count)
+{
+   if (ppc_md.cpu_probe)
+   return ppc_md.cpu_probe(buf, count);
+
+   return -EINVAL;
+}
+
+ssize_t arch_cpu_release(const char *buf, size_t count)
+{
+   if (ppc_md.cpu_release)
+   return ppc_md.cpu_release(buf, count);
+
+   return -EINVAL;
+}
+#endif /* CONFIG_ARCH_CPU_PROBE_RELEASE */
+
#endif /* CONFIG_HOTPLUG_CPU */

static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
Index: powerpc/arch/powerpc/Kconfig
===
--- powerpc.orig/arch/powerpc/Kconfig   2009-11-25 04:06:10.0 -0600
+++ powerpc/arch/powerpc/Kconfig2009-11-25 04:11:01.0 -0600
@@ -320,6 +320,10 @@

  Say N if you are unsure.

+config ARCH_CPU_PROBE_RELEASE
+   def_bool y
+   depends on HOTPLUG_CPU
+
config ARCH_ENABLE_MEMORY_HOTPLUG
def_bool y

Index: powerpc/include/linux/cpu.h
===
--- powerpc.orig/include/linux/cpu.h2009-11-25 04:06:10.0 -0600
+++ powerpc/include/linux/cpu.h 2009-11-25 04:11:56.0 -0600
@@ -43,6 +43,8 @@

#ifdef CONFIG_HOTPLUG_CPU
extern void unregister_cpu(struct cpu *cpu);
+extern ssize_t arch_cpu_probe(const char *, size_t);
+extern ssize_t arch_cpu_release(const char *, size_t);
#endif
struct notifier_block;

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev


[PATCH v2 3/3]CPU DLPAR handling

2009-11-24 Thread Nathan Fontenot

This patch adds the specific routines to probe and release (add and remove)
cpu resource for the powerpc pseries platform and registers these handlers
with the ppc_md callout structure.

Signed-off-by: Nathan Fontenot nf...@austin.ibm.com
---
arch/powerpc/platforms/pseries/dlpar.c |   88 +
1 file changed, 88 insertions(+)

Index: powerpc/arch/powerpc/platforms/pseries/dlpar.c
===
--- powerpc.orig/arch/powerpc/platforms/pseries/dlpar.c 2009-11-25 
04:54:13.0 -0600
+++ powerpc/arch/powerpc/platforms/pseries/dlpar.c  2009-11-25 
04:55:00.0 -0600
@@ -341,4 +341,92 @@
return 0;
}

+#ifdef CONFIG_ARCH_CPU_PROBE_RELEASE

+static ssize_t dlpar_cpu_probe(const char *buf, size_t count)
+{
+   struct device_node *dn;
+   unsigned long drc_index;
+   char *cpu_name;
+   int rc;
+
+   rc = strict_strtoul(buf, 0, drc_index);
+   if (rc)
+   return -EINVAL;
+
+   dn = dlpar_configure_connector(drc_index);
+   if (!dn)
+   return -EINVAL;
+
+   /* configure-connector reports cpus as living in the base
+* directory of the device tree.  CPUs actually live in the
+* cpus directory so we need to fixup the full_name.
+*/
+   cpu_name = kzalloc(strlen(dn-full_name) + strlen(/cpus) + 1,
+  GFP_KERNEL);
+   if (!cpu_name) {
+   dlpar_free_cc_nodes(dn);
+   return -ENOMEM;
+   }
+
+   sprintf(cpu_name, /cpus%s, dn-full_name);
+   kfree(dn-full_name);
+   dn-full_name = cpu_name;
+
+   rc = dlpar_acquire_drc(drc_index);
+   if (rc) {
+   dlpar_free_cc_nodes(dn);
+   return -EINVAL;
+   }
+
+   rc = dlpar_attach_node(dn);
+   if (rc) {
+   dlpar_release_drc(drc_index);
+   dlpar_free_cc_nodes(dn);
+   }
+
+   return rc ? rc : count;
+}
+
+static ssize_t dlpar_cpu_release(const char *buf, size_t count)
+{
+   struct device_node *dn;
+   const u32 *drc_index;
+   int rc;
+
+   dn = of_find_node_by_path(buf);
+   if (!dn)
+   return -EINVAL;
+
+   drc_index = of_get_property(dn, ibm,my-drc-index, NULL);
+   if (!drc_index) {
+   of_node_put(dn);
+   return -EINVAL;
+   }
+
+   rc = dlpar_release_drc(*drc_index);
+   if (rc) {
+   of_node_put(dn);
+   return -EINVAL;
+   }
+
+   rc = dlpar_detach_node(dn);
+   if (rc) {
+   dlpar_acquire_drc(*drc_index);
+   return rc;
+   }
+
+   of_node_put(dn);
+   return count;
+}
+
+static int __init pseries_dlpar_init(void)
+{
+   ppc_md.cpu_probe = dlpar_cpu_probe;
+   ppc_md.cpu_release = dlpar_cpu_release;
+
+   return 0;
+}
+machine_device_initcall(pseries, pseries_dlpar_init);
+
+#endif /* CONFIG_ARCH_CPU_PROBE_RELEASE */
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev