Re: Sequoia kernel crash workaround.

2007-09-23 Thread Benjamin Herrenschmidt

On Thu, 2007-09-20 at 12:29 -0500, Josh Boyer wrote:
> On Thu, 20 Sep 2007 12:25:06 -0500
> Olof Johansson <[EMAIL PROTECTED]> wrote:
> 
> > On Thu, Sep 20, 2007 at 08:56:32PM +0400, Valentine Barshak wrote:
> > >
> > > I was thinking about it. Looks like it's the best place, but the code 
> > > that 
> > > actually calls setup_cpu is under ifdef CONFIG_PPC64, while lots of 
> > > cpu_setup functions are defined for ppc32 processors.
> > > Is it OK to remove this ifdef, or should I do CONFIG_PPC64 || CONFIG_44x?
> > 
> > Sounds like something that went wrong at the merge of ppc and ppc64.
> > 
> > Take out the ifdef, even if there's fallout we should deal with it
> > instead of adding more complex ifdefs.
> 
> Yeah.  Looks like BenH did this in commit:
> 
> 42c4aaadb737e0e672b3fb86b2c41ff59f0fb8bc
> 
> Ben, any reason you ifdef'd it for ppc64?

I'll have to check on monday what's up there, but isn't setup_cpu called
from a different place on 32 bits? There are some subtle difference with
the way the cpu feature stuff is initialized /done between 32 and 64
bits that we haven't fully reconciled yet. 

Ben.


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


Downtime

2007-09-23 Thread Stephen Rothwell
Hi all,

Just letting you all know that ozlabs.org will be down for about 5 hours from 
1:54 am Canberra time (UTC+10) Monday morning (i.e. about 2 hours 40 minutes 
from now) due to electrical work in our hosting data centre.

-- 
Cheers,
Stephen Rothwell[EMAIL PROTECTED]
http://www.canb.auug.org.au/~sfr/


pgp0OGCF4NHQ9.pgp
Description: PGP signature
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev

[patch v3] Cell: Wrap master run control bit

2007-09-23 Thread Geoff Levand
Subject: Cell: Wrap master run control bit

From: Masato Noguchi <[EMAIL PROTECTED]>

Add platform specific SPU run control routines to the spufs.  The current
spufs implementation uses the SPU master run control bit (MFC_SR1[S]) to
control SPE execution, but the PS3 hypervisor does not support the use of
this feature.

This change adds the run control wrapper routies spu_enable_spu() and
spu_disable_spu().  The bare metal routines use the master run control
bit, and the PS3 specific routines use the priv2 run control register.

An outstanding enhancement for the PS3 would be to add a guard to check
for incorrect access to the spu problem state when the spu context is
disabled.  This check could be implemented with a flag added to the spu
context that would inhibit mapping problem state pages, and a routine
to unmap spu problem state pages.  When the spu is enabled with
ps3_enable_spu() the flag would be set allowing pages to be mapped,
and when the spu is disabled with ps3_disable_spu() the flag would be
cleared and mapped problem state pages would be unmapped.

Signed-off-by: Masato Noguchi <[EMAIL PROTECTED]>
Signed-off-by: Geoff Levand <[EMAIL PROTECTED]>
---

Jeremy,

Here is an updated version for 2.6.24.  Noguchi-san will
work on the LS unmapping feature for 2.6.25.

-Geoff

v2:
 o Added comments about unmapping PS pages when disabled.
v3:
 o Changed routines to return void instead of int.
 o Rebased to apply to Jeremy's 2.6.23-rc work-around.

 arch/powerpc/platforms/cell/spu_manage.c|   13 +++
 arch/powerpc/platforms/cell/spufs/backing_ops.c |6 +
 arch/powerpc/platforms/cell/spufs/hw_ops.c  |   10 
 arch/powerpc/platforms/cell/spufs/run.c |4 +--
 arch/powerpc/platforms/cell/spufs/spufs.h   |1 
 arch/powerpc/platforms/ps3/spu.c|   27 ++--
 include/asm-powerpc/spu_priv1.h |   15 +
 7 files changed, 72 insertions(+), 4 deletions(-)

--- a/arch/powerpc/platforms/cell/spu_manage.c
+++ b/arch/powerpc/platforms/cell/spu_manage.c
@@ -35,6 +35,7 @@
 #include 
 #include 
 
+#include "spufs/spufs.h"
 #include "interrupt.h"
 
 struct device_node *spu_devnode(struct spu *spu)
@@ -369,6 +370,16 @@ static int of_destroy_spu(struct spu *sp
return 0;
 }
 
+static void enable_spu_by_master_run(struct spu_context *ctx)
+{
+   ctx->ops->master_start(ctx);
+}
+
+static void disable_spu_by_master_run(struct spu_context *ctx)
+{
+   ctx->ops->master_stop(ctx);
+}
+
 /* Hardcoded affinity idxs for qs20 */
 #define QS20_SPES_PER_BE 8
 static int qs20_reg_idxs[QS20_SPES_PER_BE] =   { 0, 2, 4, 6, 7, 5, 3, 1 };
@@ -535,5 +546,7 @@ const struct spu_management_ops spu_mana
.enumerate_spus = of_enumerate_spus,
.create_spu = of_create_spu,
.destroy_spu = of_destroy_spu,
+   .enable_spu = enable_spu_by_master_run,
+   .disable_spu = disable_spu_by_master_run,
.init_affinity = init_affinity,
 };
--- a/arch/powerpc/platforms/cell/spufs/backing_ops.c
+++ b/arch/powerpc/platforms/cell/spufs/backing_ops.c
@@ -285,6 +285,11 @@ static void spu_backing_runcntl_write(st
spin_unlock(&ctx->csa.register_lock);
 }
 
+static void spu_backing_runcntl_stop(struct spu_context *ctx)
+{
+   spu_backing_runcntl_write(ctx, SPU_RUNCNTL_STOP);
+}
+
 static void spu_backing_master_start(struct spu_context *ctx)
 {
struct spu_state *csa = &ctx->csa;
@@ -381,6 +386,7 @@ struct spu_context_ops spu_backing_ops =
.get_ls = spu_backing_get_ls,
.runcntl_read = spu_backing_runcntl_read,
.runcntl_write = spu_backing_runcntl_write,
+   .runcntl_stop = spu_backing_runcntl_stop,
.master_start = spu_backing_master_start,
.master_stop = spu_backing_master_stop,
.set_mfc_query = spu_backing_set_mfc_query,
--- a/arch/powerpc/platforms/cell/spufs/hw_ops.c
+++ b/arch/powerpc/platforms/cell/spufs/hw_ops.c
@@ -220,6 +220,15 @@ static void spu_hw_runcntl_write(struct 
spin_unlock_irq(&ctx->spu->register_lock);
 }
 
+static void spu_hw_runcntl_stop(struct spu_context *ctx)
+{
+   spin_lock_irq(&ctx->spu->register_lock);
+   out_be32(&ctx->spu->problem->spu_runcntl_RW, SPU_RUNCNTL_STOP);
+   while (in_be32(&ctx->spu->problem->spu_status_R) & SPU_STATUS_RUNNING)
+   cpu_relax();
+   spin_unlock_irq(&ctx->spu->register_lock);
+}
+
 static void spu_hw_master_start(struct spu_context *ctx)
 {
struct spu *spu = ctx->spu;
@@ -321,6 +330,7 @@ struct spu_context_ops spu_hw_ops = {
.get_ls = spu_hw_get_ls,
.runcntl_read = spu_hw_runcntl_read,
.runcntl_write = spu_hw_runcntl_write,
+   .runcntl_stop = spu_hw_runcntl_stop,
.master_start = spu_hw_master_start,
.master_stop = spu_hw_master_stop,
.set_mfc_query = spu_hw_set_mfc_query,
--- a/arch/powerpc/platforms/cell/spufs/run.c
+++ b/arch/powerpc/platforms/cell/spufs/run.c
@@ -302,7 +302,7 @@ long sp

FDT for Microblaze and PPC405

2007-09-23 Thread Michal Simek
Hi,
I made EDK tcl script for generation DTS test scructure for FDT. Script
support Microblaze and PowerPC 405.
Script was primary built for generation U-BOOT configs files for Microblaze.
For Microblaze can you generate both files (FDT and U-BOOT).
For PowerPC can you generate only DTS file. Generation U-BOOT configs files
aren't supported yet. Script ends after generation DTS.
Script has 2.00.a mark.
It is available at www.monstr.eu.

Cheers,
Michal Simek

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


Re: [PATCH 1/2] qemu platform, v2

2007-09-23 Thread Rob Landley
On Saturday 22 September 2007 11:27:05 pm Paul Mackerras wrote:
> Rob Landley writes:
>
> Just to correct a few misconceptions:
> > 2) PowerPC uses a device tree supplied by the hardware to identify the
> > available hardware, even for stuff living on PCI busses which it could
> > theoretically probe for but doesn't.
>
> The device tree doesn't have to include anything that can be probed
> for.  On some platforms (e.g. pSeries) we choose to use the device
> tree rather than probing, but on most other platforms we probe.
>
> > I'd be following this more closely if compiling a device tree didn't
> > currently require an external utility (dtc or some such) that doesn't
> > come with the Linux kernel.  No other target platform I've built kernels
> > for requires such an environmental dependency.
>
> No?  You haven't built kernels for other platforms that have external
> dependencies such as perl, gcc, make, binutils, etc.? :)

Lemme clarify.

1) All of the other platforms have the _same_ requirements.  I never had to 
install anything to build "for arm", "for mips", "for sparc", or 
for "x86_64".

The minimal requirements are:  A compiler (gcc/binutils although I'm working 
on extending tcc to replace these), make, linux kernel, C library (uClibc), 
busybox, and bash.  That's it.  You can rebuild it under itself from source 
with that, on x86, x86-64, arm, mips...  Presumably sparc and m68k too (still 
debugging there).

2) Perl isn't needed to build any target platform I've tried.  (I even sent in 
some patches way back to turn a perl script into a sed script for User Mode 
Linux to _make_ this the case.)  Yes you need perl to build glibc, but not to 
build uClibc. :)

3) What I'm pointing out is that ppc needs an external dependency none of the 
other platforms I've tried need.  I consider this a bug.  I didn't start 
using "make headers_install" until it stopped needing an external unifdef.

> >  (This is a problem both for hardwiring the
> > device tree into the kernel and for building a new boot rom from the
> > linux kernel's ppc boot wrapper that would contain such a device tree to
> > feed to the kernel.)
>
> It's only really been a problem for ps3 so far, since the embedded
> guys don't seem to have any difficulty with installing dtc.

If the only target that interested me was ppc, then I'd happily install dtc 
for it.  But focusing on cross-platform support as I am, I notice when a 
platform has different requirements from any of the others.

> We are 
> looking at what to do for ps3 and prep, and the answer may well
> involve bundling dtc in the kernel source (it's not too big, around
> 3400 lines).

Sounds good to me...

> Paul.

Rob
-- 
"One of my most productive days was throwing away 1000 lines of code."
  - Ken Thompson.
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCH 08/11] [POWERPC] iSeries: move detection of virtual cdroms

2007-09-23 Thread Stephen Rothwell
Now we will only have entries in the device tree for the actual existing
devices (including their OS/400 properties).  This way viocd.c gets all
the information about the devices from the device tree.

Signed-off-by: Stephen Rothwell <[EMAIL PROTECTED]>
---
 arch/powerpc/kernel/vio.c   |3 -
 arch/powerpc/platforms/iseries/Makefile |2 +-
 arch/powerpc/platforms/iseries/dt.c |4 -
 arch/powerpc/platforms/iseries/vio.c|  317 +++
 drivers/cdrom/viocd.c   |  116 ++--
 include/asm-powerpc/iseries/vio.h   |   24 +++
 6 files changed, 361 insertions(+), 105 deletions(-)
 create mode 100644 arch/powerpc/platforms/iseries/vio.c

This version creates the device tree entries unconditionally.
-- 
Cheers,
Stephen Rothwell[EMAIL PROTECTED]

diff --git a/arch/powerpc/kernel/vio.c b/arch/powerpc/kernel/vio.c
index 9e1ff21..aec5fff 100644
--- a/arch/powerpc/kernel/vio.c
+++ b/arch/powerpc/kernel/vio.c
@@ -257,9 +257,6 @@ static int __init vio_bus_init(void)
int err;
struct device_node *node_vroot;
 
-   if (firmware_has_feature(FW_FEATURE_ISERIES))
-   iommu_vio_init();
-
err = bus_register(&vio_bus_type);
if (err) {
printk(KERN_ERR "failed to register VIO bus\n");
diff --git a/arch/powerpc/platforms/iseries/Makefile 
b/arch/powerpc/platforms/iseries/Makefile
index 60db509..a65f1b4 100644
--- a/arch/powerpc/platforms/iseries/Makefile
+++ b/arch/powerpc/platforms/iseries/Makefile
@@ -7,7 +7,7 @@ obj-y += hvlog.o hvlpconfig.o lpardata.o setup.o dt_mod.o mf.o 
lpevents.o \
hvcall.o proc.o htab.o iommu.o misc.o irq.o
 obj-$(CONFIG_PCI) += pci.o vpdinfo.o
 obj-$(CONFIG_SMP) += smp.o
-obj-$(CONFIG_VIOPATH) += viopath.o
+obj-$(CONFIG_VIOPATH) += viopath.o vio.o
 obj-$(CONFIG_MODULES) += ksyms.o
 
 quiet_cmd_dt_strings = DT_STR  $@
diff --git a/arch/powerpc/platforms/iseries/dt.c 
b/arch/powerpc/platforms/iseries/dt.c
index 9e8a334..84fcee1 100644
--- a/arch/powerpc/platforms/iseries/dt.c
+++ b/arch/powerpc/platforms/iseries/dt.c
@@ -381,10 +381,6 @@ static void __init dt_vdevices(struct iseries_flat_dt *dt)
dt_do_vdevice(dt, "viodasd", reg, i, device_type_block,
"IBM,iSeries-viodasd", 1);
reg += HVMAXARCHITECTEDVIRTUALDISKS;
-
-   for (i = 0; i < HVMAXARCHITECTEDVIRTUALCDROMS; i++)
-   dt_do_vdevice(dt, "viocd", reg, i, device_type_block,
-   "IBM,iSeries-viocd", 1);
reg += HVMAXARCHITECTEDVIRTUALCDROMS;
 
for (i = 0; i < HVMAXARCHITECTEDVIRTUALTAPES; i++)
diff --git a/arch/powerpc/platforms/iseries/vio.c 
b/arch/powerpc/platforms/iseries/vio.c
new file mode 100644
index 000..08f6884
--- /dev/null
+++ b/arch/powerpc/platforms/iseries/vio.c
@@ -0,0 +1,317 @@
+/*
+ * Legacy iSeries specific vio initialisation
+ * that needs to be built in (not a module).
+ *
+ * © Copyright 2007 IBM Corporation
+ * Author: Stephen Rothwell
+ * Some parts collected from various other files
+ *
+ * This program is free software;  you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define FIRST_VTY  0
+#define NUM_VTYS   1
+#define FIRST_VSCSI(FIRST_VTY + NUM_VTYS)
+#define NUM_VSCSIS 1
+#define FIRST_VLAN (FIRST_VSCSI + NUM_VSCSIS)
+#define NUM_VLANS  HVMAXARCHITECTEDVIRTUALLANS
+#define FIRST_VIODASD  (FIRST_VLAN + NUM_VLANS)
+#define NUM_VIODASDS   HVMAXARCHITECTEDVIRTUALDISKS
+#define FIRST_VIOCD(FIRST_VIODASD + NUM_VIODASDS)
+#define NUM_VIOCDS HVMAXARCHITECTEDVIRTUALCDROMS
+#define FIRST_VIOTAPE  (FIRST_VIOCD + NUM_VIOCDS)
+#define NUM_VIOTAPES   HVMAXARCHITECTEDVIRTUALTAPES
+
+static struct property * __init new_property(const char *name, int length,
+   const void *value)
+{
+   struct property *np = kzalloc(sizeof(*np) + strlen(name) + 1 + length,
+   GFP_KERNEL);
+
+   if (!np)
+   return NULL;
+   np->name = (char *)(np + 1);
+   np->value = np->name + strlen(name) + 1;
+   strcpy(np->name, name);
+   memcpy(np->value, value, length);
+   np->length = length;
+   return np;
+}
+
+static void

[PATCH 09/11] [POWERPC] iSeries: move detection of virtual tapes

2007-09-23 Thread Stephen Rothwell
Now we will only have entries in the device tree for the actual existing
devices (including their OS/400 properties).  This way viotape.c gets
all the information about the devices from the device tree.

Signed-off-by: Stephen Rothwell <[EMAIL PROTECTED]>
---
 arch/powerpc/platforms/iseries/dt.c  |7 --
 arch/powerpc/platforms/iseries/vio.c |  149 ++
 drivers/char/viotape.c   |  124 
 include/asm-powerpc/iseries/vio.h|   41 +
 4 files changed, 192 insertions(+), 129 deletions(-)

This version creates the device tree entries unconditionally.
-- 
Cheers,
Stephen Rothwell[EMAIL PROTECTED]

diff --git a/arch/powerpc/platforms/iseries/dt.c 
b/arch/powerpc/platforms/iseries/dt.c
index 84fcee1..2e4ad6b 100644
--- a/arch/powerpc/platforms/iseries/dt.c
+++ b/arch/powerpc/platforms/iseries/dt.c
@@ -73,7 +73,6 @@ static char __initdata device_type_memory[] = "memory";
 static char __initdata device_type_serial[] = "serial";
 static char __initdata device_type_network[] = "network";
 static char __initdata device_type_block[] = "block";
-static char __initdata device_type_byte[] = "byte";
 static char __initdata device_type_pci[] = "pci";
 static char __initdata device_type_vdevice[] = "vdevice";
 static char __initdata device_type_vscsi[] = "vscsi";
@@ -380,12 +379,6 @@ static void __init dt_vdevices(struct iseries_flat_dt *dt)
for (i = 0; i < HVMAXARCHITECTEDVIRTUALDISKS; i++)
dt_do_vdevice(dt, "viodasd", reg, i, device_type_block,
"IBM,iSeries-viodasd", 1);
-   reg += HVMAXARCHITECTEDVIRTUALDISKS;
-   reg += HVMAXARCHITECTEDVIRTUALCDROMS;
-
-   for (i = 0; i < HVMAXARCHITECTEDVIRTUALTAPES; i++)
-   dt_do_vdevice(dt, "viotape", reg, i, device_type_byte,
-   "IBM,iSeries-viotape", 1);
 
dt_end_node(dt);
 }
diff --git a/arch/powerpc/platforms/iseries/vio.c 
b/arch/powerpc/platforms/iseries/vio.c
index 08f6884..b4f7433 100644
--- a/arch/powerpc/platforms/iseries/vio.c
+++ b/arch/powerpc/platforms/iseries/vio.c
@@ -45,6 +45,18 @@
 #define FIRST_VIOTAPE  (FIRST_VIOCD + NUM_VIOCDS)
 #define NUM_VIOTAPES   HVMAXARCHITECTEDVIRTUALTAPES
 
+struct vio_waitevent {
+   struct completion   com;
+   int rc;
+   u16 sub_result;
+};
+
+struct vio_resource {
+   charrsrcname[10];
+   chartype[4];
+   charmodel[3];
+};
+
 static struct property * __init new_property(const char *name, int length,
const void *value)
 {
@@ -123,22 +135,10 @@ static int __init add_raw_property(struct device_node 
*np, const char *name,
return 1;
 }
 
-struct viocd_waitevent {
-   struct completion   com;
-   int rc;
-   u16 sub_result;
-};
-
-struct cdrom_info {
-   charrsrcname[10];
-   chartype[4];
-   charmodel[3];
-};
-
 static void __init handle_cd_event(struct HvLpEvent *event)
 {
struct viocdlpevent *bevent;
-   struct viocd_waitevent *pwe;
+   struct vio_waitevent *pwe;
 
if (!event)
/* Notification that a partition went away! */
@@ -158,7 +158,7 @@ static void __init handle_cd_event(struct HvLpEvent *event)
 
switch (event->xSubtype & VIOMINOR_SUBTYPE_MASK) {
case viocdgetinfo:
-   pwe = (struct viocd_waitevent *)event->xCorrelationToken;
+   pwe = (struct vio_waitevent *)event->xCorrelationToken;
pwe->rc = event->xRc;
pwe->sub_result = bevent->sub_result;
complete(&pwe->com);
@@ -179,8 +179,8 @@ static void __init get_viocd_info(struct device_node 
*vio_root)
 {
HvLpEvent_Rc hvrc;
u32 unit;
-   struct viocd_waitevent we;
-   struct cdrom_info *unitinfo;
+   struct vio_waitevent we;
+   struct vio_resource *unitinfo;
dma_addr_t unitinfo_dmaaddr;
int ret;
 
@@ -286,6 +286,122 @@ static void __init get_viocd_info(struct device_node 
*vio_root)
viopath_close(viopath_hostLp, viomajorsubtype_cdio, 2);
 }
 
+/* Handle interrupt events for tape */
+static void __init handle_tape_event(struct HvLpEvent *event)
+{
+   struct vio_waitevent *we;
+   struct viotapelpevent *tevent = (struct viotapelpevent *)event;
+
+   if (event == NULL)
+   /* Notification that a partition went away! */
+   return;
+
+   we = (struct vio_waitevent *)event->xCorrelationToken;
+   switch (event->xSubtype & VIOMINOR_SUBTYPE_MASK) {
+   case viotapegetinfo:
+   we->rc = tevent->sub_type_result;
+   complete(&we->com);
+   break;
+   default:
+   printk(KERN_WARNING "handle_tape_event: weird ack\n");
+   }
+}
+
+static void __init get_viotape_info(struct device_node *vio_root)
+{
+   HvLpEven

[PATCH 11/11] [POWERPC] iSeries: move viodasd probing

2007-09-23 Thread Stephen Rothwell
This way we only have entries in the device tree for disks that actually
exist.  A slight complication is that disks may be attached to LPARs
at runtime.

Signed-off-by: Stephen Rothwell <[EMAIL PROTECTED]>
---
 arch/powerpc/platforms/iseries/dt.c  |6 -
 arch/powerpc/platforms/iseries/vio.c |  301 +++--
 drivers/block/viodasd.c  |   77 +++--
 include/asm-powerpc/iseries/vio.h|   47 ++
 4 files changed, 282 insertions(+), 149 deletions(-)

This version creates the device tree entries unconditionally.
-- 
Cheers,
Stephen Rothwell[EMAIL PROTECTED]

diff --git a/arch/powerpc/platforms/iseries/dt.c 
b/arch/powerpc/platforms/iseries/dt.c
index 2e4ad6b..4543c4b 100644
--- a/arch/powerpc/platforms/iseries/dt.c
+++ b/arch/powerpc/platforms/iseries/dt.c
@@ -72,7 +72,6 @@ static char __initdata device_type_cpu[] = "cpu";
 static char __initdata device_type_memory[] = "memory";
 static char __initdata device_type_serial[] = "serial";
 static char __initdata device_type_network[] = "network";
-static char __initdata device_type_block[] = "block";
 static char __initdata device_type_pci[] = "pci";
 static char __initdata device_type_vdevice[] = "vdevice";
 static char __initdata device_type_vscsi[] = "vscsi";
@@ -374,11 +373,6 @@ static void __init dt_vdevices(struct iseries_flat_dt *dt)
 
dt_end_node(dt);
}
-   reg += HVMAXARCHITECTEDVIRTUALLANS;
-
-   for (i = 0; i < HVMAXARCHITECTEDVIRTUALDISKS; i++)
-   dt_do_vdevice(dt, "viodasd", reg, i, device_type_block,
-   "IBM,iSeries-viodasd", 1);
 
dt_end_node(dt);
 }
diff --git a/arch/powerpc/platforms/iseries/vio.c 
b/arch/powerpc/platforms/iseries/vio.c
index b4f7433..d6435b0 100644
--- a/arch/powerpc/platforms/iseries/vio.c
+++ b/arch/powerpc/platforms/iseries/vio.c
@@ -25,8 +25,10 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -57,7 +59,7 @@ struct vio_resource {
charmodel[3];
 };
 
-static struct property * __init new_property(const char *name, int length,
+static struct property *new_property(const char *name, int length,
const void *value)
 {
struct property *np = kzalloc(sizeof(*np) + strlen(name) + 1 + length,
@@ -78,7 +80,7 @@ static void __init free_property(struct property *np)
kfree(np);
 }
 
-static struct device_node * __init new_node(const char *path,
+static struct device_node *new_node(const char *path,
struct device_node *parent)
 {
struct device_node *np = kzalloc(sizeof(*np), GFP_KERNEL);
@@ -97,7 +99,7 @@ static struct device_node * __init new_node(const char *path,
return np;
 }
 
-static void __init free_node(struct device_node *np)
+static void free_node(struct device_node *np)
 {
struct property *next;
struct property *prop;
@@ -113,7 +115,7 @@ static void __init free_node(struct device_node *np)
kfree(np);
 }
 
-static int __init add_string_property(struct device_node *np, const char *name,
+static int add_string_property(struct device_node *np, const char *name,
const char *value)
 {
struct property *nprop = new_property(name, strlen(value) + 1, value);
@@ -124,7 +126,7 @@ static int __init add_string_property(struct device_node 
*np, const char *name,
return 1;
 }
 
-static int __init add_raw_property(struct device_node *np, const char *name,
+static int add_raw_property(struct device_node *np, const char *name,
int length, const void *value)
 {
struct property *nprop = new_property(name, length, value);
@@ -135,6 +137,201 @@ static int __init add_raw_property(struct device_node 
*np, const char *name,
return 1;
 }
 
+static struct device_node *do_device_node(struct device_node *parent,
+   const char *name, u32 reg, u32 unit, const char *type,
+   const char *compat, struct vio_resource *res)
+{
+   struct device_node *np;
+   char path[32];
+
+   snprintf(path, sizeof(path), "/vdevice/[EMAIL PROTECTED]", name, reg);
+   np = new_node(path, parent);
+   if (!np)
+   return NULL;
+   if (!add_string_property(np, "name", name) ||
+   !add_string_property(np, "device_type", type) ||
+   !add_string_property(np, "compatible", compat) ||
+   !add_raw_property(np, "reg", sizeof(reg), ®) ||
+   !add_raw_property(np, "linux,unit_address",
+   sizeof(unit), &unit)) {
+   goto node_free;
+   }
+   if (res) {
+   if (!add_raw_property(np, "linux,vio_rsrcname",
+   sizeof(res->rsrcname), res->rsrcname) ||
+   !add_raw_property(np, "linux,vio_type",
+   sizeof(res->type), res->type) ||
+   !add_raw_property(np, "linux,vio_model",
+ 

Re: [PATCH 1/15] boot: find initrd location from device-tree

2007-09-23 Thread David Gibson
On Fri, Sep 21, 2007 at 06:03:24PM -0500, Milton Miller wrote:
> Some platforms have a boot agent that can create or modify properties in
> the device-tree and load images into memory.  Provide a helper to set
> loader_info used by prep_initrd().
> 
> Signed-off-by: Milton Miller <[EMAIL PROTECTED]>
> Acked-by: David Gibson <[EMAIL PROTECTED]>

Hrm, despite my earlier ack, I'm going to whinge about a few nits
here.

> --- 
> re 12168
> rediffed types.h, offset in ops.h
> 
> Index: kernel/arch/powerpc/boot/ops.h
> ===
> --- kernel.orig/arch/powerpc/boot/ops.h   2007-09-17 22:12:47.0 
> -0500
> +++ kernel/arch/powerpc/boot/ops.h2007-09-17 22:12:51.0 -0500
> @@ -163,6 +163,7 @@ void dt_fixup_clock(const char *path, u3
>  void __dt_fixup_mac_addresses(u32 startindex, ...);
>  #define dt_fixup_mac_addresses(...) \
>   __dt_fixup_mac_addresses(0, __VA_ARGS__, NULL)
> +void dt_find_initrd(void);
>  
>  
>  static inline void *find_node_by_linuxphandle(const u32 linuxphandle)
> Index: kernel/arch/powerpc/boot/types.h
> ===
> --- kernel.orig/arch/powerpc/boot/types.h 2007-09-17 22:12:47.0 
> -0500
> +++ kernel/arch/powerpc/boot/types.h  2007-09-17 22:12:51.0 -0500
> @@ -12,6 +12,8 @@ typedef short   s16;
>  typedef int  s32;
>  typedef long longs64;
>  
> +#define UINT_MAX 0x

I actually don't like this constant - at the point you compare you
care, explicitly, about the value not being over 32-bits, rather than
whether it fits a uint, so the named constant is more misleading than
helpful.

> +
>  #define min(x,y) ({ \
>   typeof(x) _x = (x); \
>   typeof(y) _y = (y); \
> Index: kernel/arch/powerpc/boot/devtree.c
> ===
> --- kernel.orig/arch/powerpc/boot/devtree.c   2007-09-17 22:12:47.0 
> -0500
> +++ kernel/arch/powerpc/boot/devtree.c2007-09-17 22:12:51.0 
> -0500
> @@ -1,6 +1,7 @@
>  /*
>   * devtree.c - convenience functions for device tree manipulation
>   * Copyright 2007 David Gibson, IBM Corporation.
> + * Copyright 2007 Milton Miller, IBM Corporation.
>   * Copyright (c) 2007 Freescale Semiconductor, Inc.
>   *
>   * Authors: David Gibson <[EMAIL PROTECTED]>
> @@ -333,3 +334,68 @@ int dt_is_compatible(void *node, const c
>  
>   return 0;
>  }
> +
> +/**
> + * dt_find_initrd - set loader initrd location based on existing properties
> + *
> + * finds the linux,initrd-start and linux,initrd-end properties in
> + * the /chosen node and sets the loader initrd fields accordingly.
> + *
> + * Use this if your loader sets the properties to allow other code to
> + * relocate the tree and/or cause r3 and r4 to be set on true OF
> + * platforms.

I am unable to make sense of the paragraph above.

> + */
> +void dt_find_initrd(void)
> +{
> + int rc;
> + unsigned long long initrd_start, initrd_end;
> + void *devp;
> + static const char start_prop[] = "linux,initrd-start";
> + static const char end_prop[] = "linux,initrd-end";

I think these constants are more obscuring than useful.

> +
> + devp = finddevice("/chosen");
> + if (! devp) {
> + return;
> + }

CodingStyle would not put { } here.

> +
> + rc = getprop(devp, start_prop, &initrd_start, sizeof(initrd_start));
> + if (rc < 0)
> + return; /* not found */
> + /* The properties had to be 8 bytes until 2.6.22 */
> + if (rc == sizeof(unsigned long)) {
> + unsigned long tmp;
> + memcpy(&tmp, &initrd_start, rc);
> + initrd_start = tmp;
> + } else if (rc != sizeof(initrd_start)) {/* now they
> can be 4 */

Right.  8 bytes and 4 bytes, so you should be using explicit length
types instead of long and long long.

> + printf("unexpected length of %s in /chosen!\n\r", start_prop);
> + return;

All these printf() / return stanzas add a lot of verbosity to this
function.  Any way they can be consolidated a bit, maybe a single
error path that just prints the property values, so the user can
figure out what was wrong with them.

> + }
> +
> + rc = getprop(devp, end_prop, &initrd_end, sizeof(initrd_end));
> + if (rc < 0) {
> + printf("chosen has %s but no %s!\n\r", start_prop, end_prop);
> + return;
> + }
> + if (rc == sizeof(unsigned long)) {
> + unsigned long tmp;
> + memcpy(&tmp, &initrd_end, rc);
> + initrd_end = tmp;
> + } else if (rc != sizeof(initrd_end)) {
> + printf("unexpected length of %s in /chosen!\n\r", end_prop);
> + return;
> + }
> +
> + /* Check for presence, ignore if (partially) loaded above 32 bits */
> + if (initrd_start == initrd_end) {

Re: [PATCH 2/15] boot: record header bytes in gunzip_start

2007-09-23 Thread David Gibson
On Fri, Sep 21, 2007 at 06:03:34PM -0500, Milton Miller wrote:
> 
> Record the number of header bytes skipped in the total bytes read field.
> 
> This is needed for the initramfs parsing code to find the end of the
> zip file.
> 
> Signed-off-by: Milton Miller <[EMAIL PROTECTED]>
Acked-by: David Gibson <[EMAIL PROTECTED]>

-- 
David Gibson| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au  | minimalist, thank you.  NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH 5/15] bootwrapper: occuppied memory ranges

2007-09-23 Thread David Gibson
On Fri, Sep 21, 2007 at 06:04:18PM -0500, Milton Miller wrote:
> Add a set of library routines to manage gross memory allocations.
> 
> This code uses an array in bss to store upto 32 entrys with merging
> representing a range of memory below rma_end (aka end of real mode
> memory at 0).
> 
> To use this code, a platform would set rma_end (find_rma_end), mark
> memory ranges occupied (add_known_ranges et al), initialize malloc in
> the spaces between (ranges_init_malloc), and optionally use the supplied
> vmlinux_alloc may be used.
> 
> Signed-off-by: Milton Miller <[EMAIL PROTECTED]>
> --- 
> vs 12172
> rename rmo_end to rma_end (real mode area, as used in papr)
> removed section labels (now in ops.h)
> rediff ops.h, Makefile
> moved find_rma_end here (from kexec.c in a later patch)
> find_rma_end searches by node type for "memory", checks that
>   the parent is the root node, then looks for a reg property
>   with the first address/size pair starting at 0.

Urg.  It's an awful lot of code for the bootwrapper.  Am I right in
understanding that the only reason to use the ranges code is for the
ranges based malloc() and vmlinux_alloc() you get out of it?

-- 
David Gibson| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au  | minimalist, thank you.  NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH 6/15] bootwrapper: help for 64 bit cpus

2007-09-23 Thread David Gibson
On Fri, Sep 21, 2007 at 06:04:37PM -0500, Milton Miller wrote:
> Add code to check if the processor is in 64 or 32 bit mode using
> only instructions from the 32 bit subset.  If the processor is in
> 64 bit mode, switch to 32 bit mode by clearing MSR[SF].
> 
> Also add a 64 bit procedure descriptor to use as a elf64 entry
> point.
> 
> Signed-off-by: Milton Miller <[EMAIL PROTECTED]>
> --- 
> vs 12173
> correct comment (equal vs not-equal)
> 
> Index: kernel/arch/powerpc/boot/crt0.S
> ===
> --- kernel.orig/arch/powerpc/boot/crt0.S  2007-07-10 03:33:36.0 
> -0500
> +++ kernel/arch/powerpc/boot/crt0.S   2007-07-10 03:39:08.0 -0500
> @@ -17,11 +17,47 @@
>  _zimage_start_opd:
>   .long   _zimage_start, 0, 0, 0
>  
> + /* a procedure descriptor used when pretending to be elf64_powerpc */
> + .balign 8
> + .globl  _zimage_start_64
> +_zimage_start_64:

Hrm, I'd prefer _zimage_start_opd64 in analogy with the COFF opd entry
above.

> + .long   0, _zimage_start/* big endian, supported reloc ppc32 */
> + .long   0, 0, 0, 0, 0, 0
> +
> +
>   .weak   _zimage_start
>   .globl  _zimage_start
>  _zimage_start:
>   .globl  _zimage_start_lib
>  _zimage_start_lib:
> + /* Check if the processor is running in 32 bit mode, using
> +  * only 32 bit instructions which should be safe on 32 and
> +  * 64 bit processors.
> +  *
> +  * Subtract bottom 32 bits of MSR from full value recording
> +  * the result.  Since MSR[SF] is in the high word, we will
> +  * be equal iff in 32 bit mode (either the processor is
> +  * a 32 bit processor or MSR[SF] = 0).
> +  */
> + mfmsr   r0  /* grab whole msr   */
> + rlwinm  r8,r0,0,0,31/* extract bottom word  */
> + subf.   r8,r8,r0/* subtract, same?  */
> + beq 0f  /* yes: we are 32 bit mode  */
> +
> + /* We are in 64-bit mode.  This program must run in 32 bit
> +  * mode.  Assume we are actually running somewhere in the
> +  * low 32 bits of the address space, so we can just turn
> +  * off MSR[SF] which is bit 0.
> +  */
> + .machine push
> + .machine "ppc64"
> + rldicl  r0,r0,0,1
> + sync
> + mtmsrd  r0
> + isync
> + .machine pop
> +0:   /* We are now in 32-bit mode */
> +
>   /* Work out the offset between the address we were linked at
>  and the address where we're running. */
>   bl  1f
> ___
> Linuxppc-dev mailing list
> Linuxppc-dev@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-dev
> 

-- 
David Gibson| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au  | minimalist, thank you.  NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH 7/15] bootwrapper: Add kexec callable zImage wrapper

2007-09-23 Thread David Gibson
On Fri, Sep 21, 2007 at 06:04:58PM -0500, Milton Miller wrote:
> 
> This code creates a 32 bit zImage wrapper for a 32 or 64 bit PowerPC
> Linux kernel.  This allows you to kexec a zImage with its compressed
> vmlinux instead of the uncompressed vmlinux elf.  The code is also
> packaged as a 64 bit elf for use by kexec-tools on 64 bit kernels.
> 
> Limitations:
> Note: the device-tree generated by kexec-tools is currently version 2,
> not the version 16 supported by the boot code base.
> 
> Signed-off-by: Milton Miller <[EMAIL PROTECTED]>
> ---
> find_rmo_end moved to memranges as find_rma_end.
> early_scan_flat_tree replaced with calls to its pieces in
> kexec_platform_init
> rediff wrapper, Makefile, ops.h
> 
> Index: kernel/arch/powerpc/boot/kexec.c
> ===
> --- /dev/null 1970-01-01 00:00:00.0 +
> +++ kernel/arch/powerpc/boot/kexec.c  2007-09-21 04:52:46.0 -0500
> @@ -0,0 +1,122 @@
> +/*
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
> + *
> + * Copyright IBM Corporation 2007
> + *
> + * Authors: Milton Miller <[EMAIL PROTECTED]>
> + */
> +
> +#include "ops.h"
> +#include "stdio.h"
> +#include "flatdevtree.h"
> +#include "page.h"
> +#include "types.h"
> +
> +extern char _start[];
> +extern char _end[];

Don't need these externs any more, they're in the headers.

> +
> +BSS_STACK(16*1024);
> +
> +static void find_console_from_tree(void)
> +{
> + int rc = -1;
> +
> + if (rc) {
> + /* no console, oh well */
> + }

Um... pointless function...?

> +}
> +
> +/**
> + * setup_initial_heap - setup a small heap in the bss
> + * Using a preallocated heap, setup for scanning the device tree.
> + * Intended for the initial read while the tree will remain read-only so
> + * a minimal malloc and search limit can be used.  This way we don't have
> + * lots of data or bss to clear.
> + */
> +static void setup_initial_heap(void)
> +{
> + static char initial_heap[8*1024];
> + void *heap_end;
> +
> + heap_end = simple_alloc_init(initial_heap,
> + sizeof(initial_heap) * 7 / 8,
> + sizeof(long), 64);
> +
> + if (heap_end - sizeof(initial_heap) > (void *)&initial_heap[0])
> + fatal("Initial heap too big\n\r");
> +}
> +
> +static void init_flat_tree(struct boot_param_header *dt_blob)
> +{
> + int rc;
> +
> + rc = ft_init(dt_blob, dt_blob->totalsize, /* max_finddevice */ 1024);
> + if (rc)
> + fatal("Unable to initialize device_tree library!\n\r");
> +}
> +
> +static void *saved_vmlinux_addr;
> +
> +static void *kexec_vmlinux_alloc(unsigned long size)
> +{
> + void *addr;
> +
> + addr = ranges_vmlinux_alloc(size);
> +
> + saved_vmlinux_addr = addr;
> + return addr;
> +}
> +
> +static void kexec_fixups(void)
> +{
> + wait_slaves_moved();
> +}
> +
> +static unsigned long (*finalize_chain)(void);
> +
> +static unsigned long kexec_finalize(void)
> +{
> + send_slaves_to_kernel(saved_vmlinux_addr);

Ow, yuck, no.  The finalize callback is for finalizing the device
tree, don't abuse it for SMP entry.  It's a new thing that needs to be
done, so create a new callback for it.

> +
> + return finalize_chain();
> +}
> +
> +void kexec_platform_init(struct boot_param_header *dt_blob)
> +{
> + slaves_are_low();
> + move_slaves_up();
> +
> + setup_initial_heap();
> + init_flat_tree(dt_blob);
> + /*
> +  * drivers can malloc and read the tree, but not realloc later
> +  * or modify the tree now.
> +  */
> + if (!console_ops.write)
> + find_console_from_tree();
> +
> + find_rma_end();
> + dt_find_initrd();
> + add_known_ranges(dt_blob);
> + ranges_init_malloc();
> +
> + /* now that we have a malloc region, start over from the flat tree */
> + init_flat_tree(dt_blob);
> +
> + platform_ops.vmlinux_alloc = kexec_vmlinux_alloc;
> + platform_ops.fixups = kexec_fixups;
> + finalize_chain = dt_ops.finalize;
> + dt_ops.finalize = kexec_finalize;
> +}
> Index: kernel/arch/powerpc/boot/crt0_kexec.S
> ===
> --- /dev/null 1970-01-01 00:00:00.0 +
> +++ kernel/arch/powerpc/boot/crt0_k

Re: [PATCH 8/15] bootwrapper: convert flatdevtree to version 16

2007-09-23 Thread David Gibson
On Fri, Sep 21, 2007 at 06:05:06PM -0500, Milton Miller wrote:
> kexec-tools still produces a version 2 device tree, while the
> libraries in the wrapper only support version 16 and later.
> 
> Add a routine to convert a v2 flat device tree to a v16 one inplace
> by inserting OF_DT_NOP and chomping full path.  Make space for new
> headers by moving and then chomping the OF_DT_NOPs.
> 
> Signed-off-by: Milton Miller <[EMAIL PROTECTED]>
> ---
> vs 12175
> Rediffed Makefile, ops, kexec.c
> 
> Index: kernel/arch/powerpc/boot/flatdevtree_conv.c
> ===
> --- /dev/null 1970-01-01 00:00:00.0 +
> +++ kernel/arch/powerpc/boot/flatdevtree_conv.c   2007-09-20 
> 17:49:04.0 -0500
> @@ -0,0 +1,280 @@
> +/*
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
> + *
> + * Copyright IBM Corporation 2007
> + *
> + * Authors: Milton Miller <[EMAIL PROTECTED]>
> + */
> +#include "flatdevtree.h"
> +#include "stdio.h"
> +#include "ops.h"
> +
> +#define MIN_VERSION 2
> +#define OUT_VERSION 16

Should output version 17.  In any case, don't try to be so general -
just convert v123 (all basically the same) to latest (i.e. v17)
without all the #if nonsense.

> +#define OUT_COMPAT 16
> +
> +#ifdef NO_CHECK
> +static int check_v123_tree(u32 *start, u32 *limit)
> +{
> + return 0;
> +}
> +#else
> +/**
> + * check_v123_tree - check integrety of a version 1, 2, or 3 tree
> + * @start: the start of the device tree struct
> + * @limit: the end of the region for the struct
> + * structural checks on device_tree
> + */
> +static int check_v123_tree(u32 *start, u32 *limit)

What is the point of this check?  If the device tree is corrupt, we're
stuffed anyway, so why bother?

> +{
> + u32 len;
> + int depth = 0;
> + u32 *dtp = start;
> +
> + while (dtp < limit)
> + switch (*dtp) {
> + case OF_DT_END:
> + if (depth)
> + return -1;
> + return ++dtp - start;
> + case OF_DT_NOP:
> + dtp++;
> + break;
> + case OF_DT_END_NODE:
> + dtp++;
> + depth--;
> + break;
> + case OF_DT_BEGIN_NODE:
> + len = strlen((char *)(++dtp));
> + /* check path is suffix to previous? */
> + dtp += 1 + (len / 4);
> + depth++;
> + break;
> + case OF_DT_PROP:
> + len = dtp[1];
> + dtp += 3;
> + if ((len >= 8) && ((long)dtp & 4))
> + dtp++;
> + dtp += (len + 3) / 4;
> + break;
> + default:
> + return -1;
> + }
> + return -1;  /* no OF_DT_END */
> +}
> +#endif
> +
> +/**
> + * nop_to_v16 - add %OF_DT_NOP to hide alignment differences
> + * @dtp: pointer to the beginning of the struct area to modify
> + * insert %OF_DT_NOP into the dt_struct @dtp to make it v16 from v1, 2, or 3.
> + */
> +static int nop_to_v16(u32 *dtp)
> +{
> + int nops = 0;
> + char *p, *s;
> + int len;
> + u32 *next;
> +
> + while (*dtp != OF_DT_END)
> + switch (*dtp) {
> + case OF_DT_BEGIN_NODE:
> + /* v2 & v3 names are full path, v16+ is relative */
> + p = (char *)(++dtp);
> + len = strlen(p);
> + next = dtp + 1 + len / 4;
> +
> + for (s = p + len; *s != '/'; s--)
> + if (s == p)
> + fatal("name %s has no '/'", p);
> +
> + len -= s++ - p; /* not the slash but the nul */
> + memmove(p, s, len);
> + while (len % 4)
> + p[len++] = '\0';
> + dtp += len / 4;
> + while (dtp != next) {
> + *dtp++ = OF_DT_NOP;
> + nops++;
> + }
> + break;
> + case OF_DT_PROP:
> +   

Re: [PATCH 9/15] bootwrapper: rtas support

2007-09-23 Thread David Gibson
On Fri, Sep 21, 2007 at 06:05:30PM -0500, Milton Miller wrote:
> This code provides a console write that calls put-term-char.
> 
> To avoid PIC relocation of the absolute rtas addresses, hide the
> actual call to rtas in assembly and declare all variables as int.
> 
> An instantiated rtas will be protected by a reserved range in the
> device tree, so no explicit call to add_occupied_range is needed
> here.
> 
> Signed-off-by: Milton Miller <[EMAIL PROTECTED]>
> --- 
> vs 12176
> rtas_put_term_write now takes const char *buf
> rediff ops.h, Makefile
> 
> Index: kernel/arch/powerpc/boot/rtas.c
> ===
> --- /dev/null 1970-01-01 00:00:00.0 +
> +++ kernel/arch/powerpc/boot/rtas.c   2007-09-21 01:43:08.0 -0500
> @@ -0,0 +1,146 @@
> +/*
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
> + *
> + * Copyright 2007 IBM Corporation.
> + *
> + * Authors: Milton Miller <[EMAIL PROTECTED]>
> + *
> + */
> +
> +#include "ops.h"
> +#include "stdio.h"
> +#include "flatdevtree.h"
> +
> +static int rtas_entry;
> +static int rtas_base;
> +static int rtas_size;
> +
> +static void find_rtas(void)
> +{
> + int rc;
> + void *devp;
> + char *str;
> +
> + devp = finddevice("/rtas");
> + if (! devp)
> + return;
> +
> + str = "linux,rtas-entry";

wtf?  Just use the literals in the getprop() calls, this is pure
obfuscation.

> + rc = getprop(devp, str, &rtas_entry, sizeof(rtas_entry));
> + if (rc < 0)
> + return;
> + if (rc != sizeof(rtas_entry))
> + goto fail;
> +
> + str = "rtas-size";
> + rc = getprop(devp, str, &rtas_size, sizeof(rtas_size));
> + if (rc < 0)
> + return;
> + if (rc != sizeof(rtas_size))
> + goto fail;
> +
> + str = "linux,rtas-base";
> + rc = getprop(devp, str, &rtas_base, sizeof(rtas_base));
> + if (rc < 0) {
> + printf("rtas-size but no linux,rtas-base in /rtas.  "
> + "disabling wrapper rtas interface\n\r");
> + rtas_entry = 0;
> + return;
> + }
> +
> + if (rc != sizeof(rtas_base))
> + goto fail;
> +
> + return;
> +
> +
> +fail:
> + printf("Unexpected length %d of %s property in /rtas.\n\r"
> + "disabling wrapper rtas interface\n\r", rc, str);
> + rtas_entry = 0;
> + return;
> +}
> +
> +/*
> + * PIC relocation of function pointers happens at call time.
> + * We have an absolute out-of-image address.   So tell C they
> + * are just integers, and hide the call as an out-of-file
> + * function.
> + */

I don't get this.  If we can call into the kernel using a function
pointer, you should be able to call into rtas without this weirdness.

> +__asm__ (
> + "   .globl call_rtas\n"
> + "   call_rtas: mtctr 5\n"
> + "   bctr\n"
> + );
> +
> +void call_rtas(int args[], int base, int entry);
> +
> +
> +static int put_term_char;
> +
> +static void rtas_put_term_write(const char *buf, int len)
> +{
> + int i, args[5];
> +
> + args[0] = put_term_char;
> + args[1] = 1;/* num inputs */
> + args[2] = 1;/* num outputs */
> +
> + for (i=0; i < len; ) {
> + args[3] = buf[i];
> + args[4] = 0;
> +
> + call_rtas(args, rtas_base, rtas_entry);
> + if (args[4] == 0)   /* SUCCESS */
> + i++;
> + else if (args[4] == -1) /* HARDWARE_ERROR */
> + break;
> + /* else retry */
> + }
> +}
> +
> +int rtas_console_init(void)
> +{
> + void *devp;
> + int rc;
> +
> +
> + devp = finddevice("/rtas");
> + if (!devp)
> + return -1;
> +
> + if (!rtas_entry)
> + find_rtas();
> + if (!rtas_entry)
> + return -1;
> +
> + rc = getprop(devp, "put-term-char", &put_term_char,
> + sizeof(put_term_char));
> + if (rc == sizeof(put_term_char))
> + console_ops.write = rtas_put_term_write;
> + else
> + put_term_char = -1;
> +
> + return put_term_char == -1 ? -1 : 0;
> +}
> +
> +/* for debug, hard code */
> +void use_rtas_console(

Re: [PATCH 1/2] qemu platform, v2

2007-09-23 Thread David Gibson
On Sat, Sep 22, 2007 at 11:55:46AM +0200, Christoph Hellwig wrote:
> On Fri, Sep 21, 2007 at 06:08:31PM -0500, Milton Miller wrote:
> > Here is the second rev of patches to boot a arch powerpc kernel on
> > qemu with the prep architecture.
> 
> So if this is supposed to be prep why do you need additional kernel
> support?  And if you really needed why isn't it under
> platforms/prep?

Basically because PReP support doesn't work under arch/powerpc.
Getting it working properly is something that should happen, but will
take a while.  In the meantime, getting something that's sufficient to
get working under just qemu's version of prep, without using the
abominable openhackware is a quicker path to a usable arch/powerpc
kernel under qemu.

-- 
David Gibson| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au  | minimalist, thank you.  NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH 13/15] bootwrapper: attach an empty vmlinux

2007-09-23 Thread David Gibson
On Fri, Sep 21, 2007 at 06:06:38PM -0500, Milton Miller wrote:
> Allow the boot wrapper code to be linked without an attached vmlinux.
> 
> Rather than invent a new syntax to invoke the wrapper, attach the
> stripped version of empty.o, which produces the same result.

Aiee.  Please don't do that.  Add a new wrapper option so the vmlinux
is optional instead.  

Particularly since...
> Index: kernel/arch/powerpc/boot/wrapper
> ===
> --- kernel.orig/arch/powerpc/boot/wrapper 2007-09-17 22:11:51.0 
> -0500
> +++ kernel/arch/powerpc/boot/wrapper  2007-09-17 22:12:05.0 -0500
> @@ -161,6 +161,13 @@ ps3)
>  ;;
>  esac
>  
> +if [ "$kernel" = $object/empty.o ] ; then
> +ext=bin
> +objflags="-O binary"
> +gzip=
> +fi

Making the vmlinux empty.o *isn't* just a matter of doing that but
also has other side effects as above.

-- 
David Gibson| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au  | minimalist, thank you.  NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [patch 3/3] mpc8349emitx.dts: Add ds1339 RTC

2007-09-23 Thread David Gibson
On Fri, Sep 21, 2007 at 09:35:03AM +0200, Peter Korsgaard wrote:
> > "Scott" == Scott Wood <[EMAIL PROTECTED]> writes:
> 
> Hi,
> 
>  Scott> #size-cells is zero on i2c, so it should just be reg = <68>.
> 
>  Scott> You'll probably need to add #address-cells and #size-cells to the
>  Scott> controller node, as well.

Uh.. yes.. i2c interfaces should really always have #a and #s.

> Ahh - Thanks. This should be better.
> ---
> 
> [PATCH] mpc8349emitx.dts: Add ds1339 RTC
> 
> Add ds1339 I2C RTC chip as child of 2nd I2C controller.
> 
> Signed-off-by: Peter Korsgaard <[EMAIL PROTECTED]>
> ---
>  arch/powerpc/boot/dts/mpc8349emitx.dts |9 +
>  1 file changed, 9 insertions(+)
> 
> Index: linux/arch/powerpc/boot/dts/mpc8349emitx.dts
> ===
> --- linux.orig/arch/powerpc/boot/dts/mpc8349emitx.dts
> +++ linux/arch/powerpc/boot/dts/mpc8349emitx.dts
> @@ -62,12 +62,21 @@
>   };
>  
>   [EMAIL PROTECTED] {
> + #address-cells = <1>;
> + #size-cells = <0>;
>   device_type = "i2c";

Hrm... we probably want an "i2c" device_type class, but I don't think
we've actually defined one, which is a problem

>   compatible = "fsl-i2c";
>   reg = <3100 100>;
>   interrupts = ;
>   interrupt-parent = < &ipic >;
>   dfsrr;
> +
> + [EMAIL PROTECTED] {
> + device_type = "rtc";
> + compatible = "dallas,ds1339";
> + reg = <68>;
> + };

I think we want to think a bit more carefully about how to do bindings
for RTC devices.  No "rtc" device_type is defined, but again we might
want to.

I did find one real OF binding for a different Dallas RTC (and NVRAM),
see:

http://playground.sun.com/1275/proposals/Closed/Remanded/Accepted/346-it.txt

It's a little different from the example above.

The fact that NVRAM+RTC chips are so common is a bit of an issue from
the point of view of defining a device class binding - a device can't
have type "rtc" and "nvram".

> +
>   };
>  
>   [EMAIL PROTECTED] {
> 

-- 
David Gibson| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au  | minimalist, thank you.  NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH 1/15] boot: find initrd location from device-tree

2007-09-23 Thread Rob Landley
On Sunday 23 September 2007 9:58:24 pm David Gibson wrote:
> On Fri, Sep 21, 2007 at 06:03:24PM -0500, Milton Miller wrote:
> > Some platforms have a boot agent that can create or modify properties in
> > the device-tree and load images into memory.  Provide a helper to set
> > loader_info used by prep_initrd().
> >
> > Signed-off-by: Milton Miller <[EMAIL PROTECTED]>
> > Acked-by: David Gibson <[EMAIL PROTECTED]>
>
> Hrm, despite my earlier ack, I'm going to whinge about a few nits
> here.
>
> > ---
> > re 12168
> > rediffed types.h, offset in ops.h
> >
> > Index: kernel/arch/powerpc/boot/ops.h
> > ===
> > --- kernel.orig/arch/powerpc/boot/ops.h 2007-09-17 22:12:47.0
> > -0500 +++ kernel/arch/powerpc/boot/ops.h2007-09-17 22:12:51.0
> > -0500 @@ -163,6 +163,7 @@ void dt_fixup_clock(const char *path, u3
> >  void __dt_fixup_mac_addresses(u32 startindex, ...);
> >  #define dt_fixup_mac_addresses(...) \
> > __dt_fixup_mac_addresses(0, __VA_ARGS__, NULL)
> > +void dt_find_initrd(void);
> >
> >
> >  static inline void *find_node_by_linuxphandle(const u32 linuxphandle)
> > Index: kernel/arch/powerpc/boot/types.h
> > ===
> > --- kernel.orig/arch/powerpc/boot/types.h   2007-09-17 22:12:47.0
> > -0500 +++ kernel/arch/powerpc/boot/types.h  2007-09-17 22:12:51.0
> > -0500 @@ -12,6 +12,8 @@ typedef short   s16;
> >  typedef ints32;
> >  typedef long long  s64;
> >
> > +#define UINT_MAX   0x
>
> I actually don't like this constant - at the point you compare you
> care, explicitly, about the value not being over 32-bits, rather than
> whether it fits a uint, so the named constant is more misleading than
> helpful.

Except int and uint are 32 bits on all targets, due to unix standardizing on 
LP64:

http://www.unix.org/whitepapers/64bit.html
http://www.unix.org/version2/whatsnew/lp64_wp.html

> > +/**
> > + * dt_find_initrd - set loader initrd location based on existing
> > properties + *
> > + * finds the linux,initrd-start and linux,initrd-end properties in
> > + * the /chosen node and sets the loader initrd fields accordingly.
> > + *
> > + * Use this if your loader sets the properties to allow other code to
> > + * relocate the tree and/or cause r3 and r4 to be set on true OF
> > + * platforms.
>
> I am unable to make sense of the paragraph above.

I think this means it finds the initrd location from the device tree (supplied 
by your firmware or bootloader) rather than from the kernel command line the 
way all the other platforms do.

Rob
-- 
"One of my most productive days was throwing away 1000 lines of code."
  - Ken Thompson.
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [patch 3/3] mpc8349emitx.dts: Add ds1339 RTC

2007-09-23 Thread Peter Korsgaard
> "David" == David Gibson <[EMAIL PROTECTED]> writes:

Hi

 >> compatible = "fsl-i2c";
 >> reg = <3100 100>;
 >> interrupts = ;
 >> interrupt-parent = < &ipic >;
 >> dfsrr;
 >> +
 >> +   [EMAIL PROTECTED] {
 >> +   device_type = "rtc";
 >> +   compatible = "dallas,ds1339";
 >> +   reg = <68>;
 >> +   };

 David> I think we want to think a bit more carefully about how to do bindings
 David> for RTC devices.  No "rtc" device_type is defined, but again we might
 David> want to.

Could be. I've simply done it like kuroboxHD.dts already does and
fsl_soc.c expects.

 David> I did find one real OF binding for a different Dallas RTC (and NVRAM),
 David> see:

 David> 
http://playground.sun.com/1275/proposals/Closed/Remanded/Accepted/346-it.txt

 David> It's a little different from the example above.

 David> The fact that NVRAM+RTC chips are so common is a bit of an issue from
 David> the point of view of defining a device class binding - a device can't
 David> have type "rtc" and "nvram".

True. I think we should primarily focus on the RTC part rather than
NVRAM as that's the "main" functionality and leave a NVRAM class for
I2C EEPROMs.

The Linux driver for the chip (rtc-1307.c) doesn't expose the NVRAM
bytes either.

But I'm open for suggestions.

-- 
Bye, Peter Korsgaard
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [patch 3/3] mpc8349emitx.dts: Add ds1339 RTC

2007-09-23 Thread Kumar Gala

On Sep 24, 2007, at 12:07 AM, David Gibson wrote:

> On Fri, Sep 21, 2007 at 09:35:03AM +0200, Peter Korsgaard wrote:
>>> "Scott" == Scott Wood <[EMAIL PROTECTED]> writes:
>>
>> Hi,
>>
>>  Scott> #size-cells is zero on i2c, so it should just be reg = <68>.
>>
>>  Scott> You'll probably need to add #address-cells and #size-cells  
>> to the
>>  Scott> controller node, as well.
>
> Uh.. yes.. i2c interfaces should really always have #a and #s.
>
>> Ahh - Thanks. This should be better.
>> ---
>>
>> [PATCH] mpc8349emitx.dts: Add ds1339 RTC
>>
>> Add ds1339 I2C RTC chip as child of 2nd I2C controller.
>>
>> Signed-off-by: Peter Korsgaard <[EMAIL PROTECTED]>
>> ---
>>  arch/powerpc/boot/dts/mpc8349emitx.dts |9 +
>>  1 file changed, 9 insertions(+)
>>
>> Index: linux/arch/powerpc/boot/dts/mpc8349emitx.dts
>> ===
>> --- linux.orig/arch/powerpc/boot/dts/mpc8349emitx.dts
>> +++ linux/arch/powerpc/boot/dts/mpc8349emitx.dts
>> @@ -62,12 +62,21 @@
>>  };
>>
>>  [EMAIL PROTECTED] {
>> +#address-cells = <1>;
>> +#size-cells = <0>;
>>  device_type = "i2c";
>
> Hrm... we probably want an "i2c" device_type class, but I don't think
> we've actually defined one, which is a prob

suggestions on how to handle this?  We've described that fsl-i2c  
nodes in booting-without-of.txt should have it. (which may have been  
wrong at the time).

- k

>
>>  compatible = "fsl-i2c";
>>  reg = <3100 100>;
>>  interrupts = ;
>>  interrupt-parent = < &ipic >;
>>  dfsrr;


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


Re: [PATCH 8/15] bootwrapper: convert flatdevtree to version 16

2007-09-23 Thread Milton Miller

On Sep 23, 2007, at 10:36 PM, David Gibson wrote:

> On Fri, Sep 21, 2007 at 06:05:06PM -0500, Milton Miller wrote:
>> kexec-tools still produces a version 2 device tree, while the
>> libraries in the wrapper only support version 16 and later.
>>
>> Add a routine to convert a v2 flat device tree to a v16 one inplace
>> by inserting OF_DT_NOP and chomping full path.  Make space for new
>> headers by moving and then chomping the OF_DT_NOPs.
>>
>> Signed-off-by: Milton Miller <[EMAIL PROTECTED]>
>> ---
>> vs 12175
>> Rediffed Makefile, ops, kexec.c
>>
>> Index: kernel/arch/powerpc/boot/flatdevtree_conv.c
>> ===
>> --- /dev/null1970-01-01 00:00:00.0 +
>> +++ kernel/arch/powerpc/boot/flatdevtree_conv.c  2007-09-20 
>> 17:49:04.0 -0500
>> @@ -0,0 +1,280 @@
>> +/*
>> + * This program is free software; you can redistribute it and/or 
>> modify
>> + * it under the terms of the GNU General Public License as published 
>> by
>> + * the Free Software Foundation; either version 2 of the License, or
>> + * (at your option) any later version.
>> + *
>> + * This program is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>> + * GNU General Public License for more details.
>> + *
>> + * You should have received a copy of the GNU General Public License
>> + * along with this program; if not, write to the Free Software
>> + * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  
>> 02110-1301, USA.
>> + *
>> + * Copyright IBM Corporation 2007
>> + *
>> + * Authors: Milton Miller <[EMAIL PROTECTED]>
>> + */
>> +#include "flatdevtree.h"
>> +#include "stdio.h"
>> +#include "ops.h"
>> +
>> +#define MIN_VERSION 2
>> +#define OUT_VERSION 16
>
> Should output version 17.  In any case, don't try to be so general -
> just convert v123 (all basically the same) to latest (i.e. v17)
> without all the #if nonsense.

Outputing v17 instead of 16 requires more words to be added to the 
header, and the library does fine with v16.  Actually the v1 trees has 
some other differences such as initrd addresses were kernel linear not 
real, cpus were assigned logical numbers  ... so while the structure 
didn't change except for the header field, the contents did.  Actually, 
when converting v3 to v16 some of the code issn't needed, the ifs allow 
the code size to be reduced.

>
>> +#define OUT_COMPAT 16
>> +
>> +#ifdef NO_CHECK
>> +static int check_v123_tree(u32 *start, u32 *limit)
>> +{
>> +return 0;
>> +}
>> +#else
>> +/**
>> + * check_v123_tree - check integrety of a version 1, 2, or 3 tree
>> + * @start: the start of the device tree struct
>> + * @limit: the end of the region for the struct
>> + * structural checks on device_tree
>> + */
>> +static int check_v123_tree(u32 *start, u32 *limit)
>
> What is the point of this check?  If the device tree is corrupt, we're
> stuffed anyway, so why bother?

Hence the ifdef NO_CHECK.   When developing, sometimes its nice to know 
if its your input or your program.  These functions are destructive to 
an improperlly formed tree, and in non-obvious ways.  When debugging, 
it's not hard to hardcode console write or read the printf string 
buffer with a hardware debugger to see error messages.  That said, it 
could be removed.

>
>> +{
>> +u32 len;
>> +int depth = 0;
>> +u32 *dtp = start;
>> +
>> +while (dtp < limit)
>> +switch (*dtp) {
>> +case OF_DT_END:
>> +if (depth)
>> +return -1;
>> +return ++dtp - start;
>> +case OF_DT_NOP:
>> +dtp++;
>> +break;
>> +case OF_DT_END_NODE:
>> +dtp++;
>> +depth--;
>> +break;
>> +case OF_DT_BEGIN_NODE:
>> +len = strlen((char *)(++dtp));
>> +/* check path is suffix to previous? */
>> +dtp += 1 + (len / 4);
>> +depth++;
>> +break;
>> +case OF_DT_PROP:
>> +len = dtp[1];
>> +dtp += 3;
>> +if ((len >= 8) && ((long)dtp & 4))
>> +dtp++;
>> +dtp += (len + 3) / 4;
>> +break;
>> +default:
>> +return -1;
>> +}
>> +return -1;  /* no OF_DT_END */
>> +}
>> +#endif
>> +
>> +/**
>> + * nop_to_v16 - add %OF_DT_NOP to hide alignment differences
>> + * @dtp: pointer to the beginning of the struct area to modify
>> + * insert %OF_DT_NOP into the dt_struct @dtp to make it v16 from v1, 
>> 2, or 3.
>> + */
>> +static int nop_to_v16(u32 *dtp)
>> +{
>> +int nops = 0;
>> +char *p, *s;
>> +int len;
>> +u32 *next;
>> +