LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* Re: [BUG] powerpc does not save msi state [was Re: [PATCH 5/7] pci: Export the pci_restore_msi_state() function
From: Benjamin Herrenschmidt @ 2007-10-20  1:29 UTC (permalink / raw)
  To: Linas Vepstas
  Cc: Michael Ellerman, netdev, mcarlson, linuxppc-dev, mchan,
	linux-pci, David Miller
In-Reply-To: <20071020004610.GR29903@austin.ibm.com>


> I'm cc'ing the powerpc mailing list to point this out: 
> it looks like only cell/axon_msi.c and mpic_u3msi.c 
> bother do do anything.  I guess that there aren't any old 
> macintosh laptops that have msi on them? Because without
> this, suspend and resume breaks.

The only macs that can do any form of MSIs are the G5s using
mpic_u3msi.c

> Paul,
> On the off chance your reading this, I'll send a pseries
> patch on Monday, with luck (and some other patches too).
> I'm not touching any of the other plaforms, you and benh 
> would know those better.

Or rather Michael as he wrote the ppc MSI support. I'll check with him

Ben.

^ permalink raw reply

* Re: [PATCH] powerpc: mpic: minor optimization of ipi handler
From: Benjamin Herrenschmidt @ 2007-10-20  1:23 UTC (permalink / raw)
  To: Olof Johansson; +Cc: linuxppc-dev, paulus, jgarzik
In-Reply-To: <20071019234950.GA18112@lixom.net>


On Fri, 2007-10-19 at 18:49 -0500, Olof Johansson wrote:
> Optimize MPIC IPIs, by passing in the IPI number as the argument to the
> handler, since all we did was translate it back based on which mpic
> the interrupt came though on (and that was always the primary mpic).
> 
> 
> Signed-off-by: Olof Johansson <olof@lixom.net>

> Oh, I see what you mean. You didn't make it easy to parse. :)
> 
> This should actually do the work.
> 
> -Olof

Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

> 
> diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
> index e479388..a8d7c68 100644
> --- a/arch/powerpc/sysdev/mpic.c
> +++ b/arch/powerpc/sysdev/mpic.c
> @@ -614,10 +614,9 @@ static inline void mpic_eoi(struct mpic *mpic)
>  #ifdef CONFIG_SMP
>  static irqreturn_t mpic_ipi_action(int irq, void *data)
>  {
> -	struct mpic *mpic;
> +	long ipi = (long)data;
>  
> -	mpic = mpic_find(irq, NULL);
> -	smp_message_recv(mpic_irq_to_hw(irq) - mpic->ipi_vecs[0]);
> +	smp_message_recv(ipi);
>  
>  	return IRQ_HANDLED;
>  }
> @@ -1457,7 +1456,7 @@ unsigned int mpic_get_irq(void)
>  void mpic_request_ipis(void)
>  {
>  	struct mpic *mpic = mpic_primary;
> -	int i, err;
> +	long i, err;
>  	static char *ipi_names[] = {
>  		"IPI0 (call function)",
>  		"IPI1 (reschedule)",
> @@ -1472,14 +1471,14 @@ void mpic_request_ipis(void)
>  		unsigned int vipi = irq_create_mapping(mpic->irqhost,
>  						       mpic->ipi_vecs[0] + i);
>  		if (vipi == NO_IRQ) {
> -			printk(KERN_ERR "Failed to map IPI %d\n", i);
> +			printk(KERN_ERR "Failed to map IPI %ld\n", i);
>  			break;
>  		}
>  		err = request_irq(vipi, mpic_ipi_action,
>  				  IRQF_DISABLED|IRQF_PERCPU,
> -				  ipi_names[i], mpic);
> +				  ipi_names[i], (void *)i);
>  		if (err) {
> -			printk(KERN_ERR "Request of irq %d for IPI %d failed\n",
> +			printk(KERN_ERR "Request of irq %d for IPI %ld failed\n",
>  			       vipi, i);
>  			break;
>  		}

^ permalink raw reply

* Re: [BUG] powerpc does not save msi state [was Re: [PATCH 5/7] pci: Export the pci_restore_msi_state() function
From: David Miller @ 2007-10-20  0:53 UTC (permalink / raw)
  To: linas; +Cc: netdev, mcarlson, linuxppc-dev, mchan, linux-pci
In-Reply-To: <20071020004610.GR29903@austin.ibm.com>

From: linas@austin.ibm.com (Linas Vepstas)
Date: Fri, 19 Oct 2007 19:46:10 -0500

> FWIW, it looks like not all that many arches do this; the output
> for grep -r address_hi * is pretty thin. Then, looking at
> i386/kernel/io_apic.c as an example, one can see that the 
> msi state save happens "by accident" if CONFIG_SMP is enabled;
> and so its surely broekn on uniprocesor machines.

I don't see this, in all cases write_msi_msg() will transfer
the given "*msg" to entry->msg by this assignment in
drivers/pci/msi.c:

void write_msi_msg(unsigned int irq, struct msi_msg *msg)
{
 ...
	entry->msg = *msg;
}

So as long as write_msi_msg() is invoked, it will be saved
properly.

Platforms need not do this explicitly.

^ permalink raw reply

* [BUG] powerpc does not save msi state [was Re: [PATCH 5/7] pci: Export the pci_restore_msi_state() function
From: Linas Vepstas @ 2007-10-20  0:46 UTC (permalink / raw)
  To: David Miller, linuxppc-dev; +Cc: netdev, linux-pci, mcarlson, mchan
In-Reply-To: <20071019.172706.57467960.davem@davemloft.net>

Hi,

On Fri, Oct 19, 2007 at 05:27:06PM -0700, David Miller wrote:
> From: linas@austin.ibm.com (Linas Vepstas)
> Date: Fri, 19 Oct 2007 19:04:21 -0500
> 
> > I'm working in linux-2.6.23-rc8-mm1 at the moment, and I don't see
> > that happening. viz. read_msi_msg() is not called anywhere, and I need
> > to have valid msg->address_lo and msg->address_hi and msg->data
> > in order to be able to restore.
> 
> See the pci_restore_msi_state() call done from pci_restore_state()
> in drivers/pci/pci.c, that pci_restore_msi_state() code in
> drivers/pci/msi.c very much relies upon the entry->msg values
> being uptodate and valid.
> 
> The MSI arch layer code is supposed to fill the entry->msg values in
> via arch_setup_msi_irq().  Perhaps the pseries code is forgetting to
> do that.

Yep.  Thank you for confirming the correct location for the fix.

FWIW, it looks like not all that many arches do this; the output
for grep -r address_hi * is pretty thin. Then, looking at
i386/kernel/io_apic.c as an example, one can see that the 
msi state save happens "by accident" if CONFIG_SMP is enabled;
and so its surely broekn on uniprocesor machines.

I'm cc'ing the powerpc mailing list to point this out: 
it looks like only cell/axon_msi.c and mpic_u3msi.c 
bother do do anything.  I guess that there aren't any old 
macintosh laptops that have msi on them? Because without
this, suspend and resume breaks.

Paul,
On the off chance your reading this, I'll send a pseries
patch on Monday, with luck (and some other patches too).
I'm not touching any of the other plaforms, you and benh 
would know those better.

--linas

^ permalink raw reply

* Re: [PATCH] bestcomm: Restrict disabling of bus prefetch to original mpc5200 silicon.
From: Matt Sealey @ 2007-10-19 23:58 UTC (permalink / raw)
  To: Grant Likely; +Cc: linuxppc-dev, Domen Puncer
In-Reply-To: <fa686aa40710190609jebd4e31q9240d2ff5b4a5d47@mail.gmail.com>


Grant Likely wrote:
> On 10/19/07, Domen Puncer <domen.puncer@telargo.com> wrote:
>> On 17/10/07 10:36 -0600, Grant Likely wrote:
>>> From: Grant Likely <grant.likely@secretlab.ca>
>>>
>>> Only the MPC5200 needs this bug fix.  MPC5200B is okay.
>>>
>>> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
>>> ---
>>>
>>> Sven, Domen;
>>>
>>> Can you please test this patch?
>> I found no obvious problems with it on Efika (mpc5200b)
> 
> Cool, I'll add it to my list of patches for Paulus to pull

See now that wasn't so hard was it? :D

You earned a cookie :D

-- 
Matt Sealey <matt@genesi-usa.com>
Genesi, Manager, Developer Relations

^ permalink raw reply

* RE: [PATCH v3] Device tree bindings for Xilinx devices
From: Stephen Neuendorffer @ 2007-10-19 23:42 UTC (permalink / raw)
  To: Stephen Neuendorffer, Grant Likely
  Cc: linuxppc-dev, Leonid, Wolfgang Reissnegger, Arnd Bergmann,
	microblaze-uclinux
In-Reply-To: <20071018190555.8EE7177805F@mail76-sin.bigfish.com>


Here's a full .dts generated using an updated version of
gen_mhs_devtree.py, following the proposal.
It happens to be a microblaze system, but you get the idea.

Grant: Is this pretty what you intend?

Steve

/ {
	#address-cells =3D <1>;
	#size-cells =3D <1>;
	compatible =3D "ibm,plb4";
	model =3D "system.mhs";
	Ethernet_MAC {
		compatible =3D
"xilinx,opb-ethernet-1.04.a\0xilinx,opb-ethernet";
		device_type =3D "opb_ethernet";
		interrupt-parent =3D <101>;
		interrupts =3D < 1 0 >;
		reg =3D < 40c00000 10000 >;
		xilinx,cam-exist =3D <0>;
		xilinx,dev-blk-id =3D <0>;
		xilinx,dev-mir-enable =3D <0>;
		xilinx,dma-present =3D <1>;
		xilinx,include-dev-pencoder =3D <0>;
		xilinx,ipif-rdfifo-depth =3D <4000>;
		xilinx,ipif-wrfifo-depth =3D <4000>;
		xilinx,jumbo-exist =3D <0>;
		xilinx,mac-fifo-depth =3D <10>;
		xilinx,mii-exist =3D <1>;
		xilinx,opb-clk-period-ps =3D <2710>;
		xilinx,reset-present =3D <1>;
		xilinx,rx-dre-type =3D <0>;
		xilinx,rx-include-csum =3D <0>;
		xilinx,tx-dre-type =3D <0>;
		xilinx,tx-include-csum =3D <0>;
	} ;
	IIC_EEPROM {
		compatible =3D "xilinx,opb-iic-1.02.a\0xilinx,opb-iic";
		device_type =3D "opb_iic";
		interrupt-parent =3D <101>;
		interrupts =3D < 2 0 >;
		reg =3D < 40800000 10000 >;
		xilinx,clk-freq =3D <5f5e100>;
		xilinx,iic-freq =3D <186a0>;
		xilinx,ten-bit-adr =3D <0>;
	} ;
	RS232_Uart_1 {
		compatible =3D
"xilinx,opb-uartlite-1.00.b\0xilinx,opb-uartlite";
		device_type =3D "opb_uartlite";
		interrupt-parent =3D <101>;
		interrupts =3D < 3 0 >;
		reg =3D < 40600000 10000 >;
		xilinx,baudrate =3D <2580>;
		xilinx,clk-freq =3D <5f5e100>;
		xilinx,data-bits =3D <8>;
		xilinx,odd-parity =3D <0>;
		xilinx,use-parity =3D <0>;
	} ;
	chosen {
		bootargs =3D "root=3D/dev/xsysace/disc0/part2";
		interrupt-controller =3D <101>;
		linux,platform =3D <600>;
	} ;
	cpus {
		#address-cells =3D <1>;
		#cpus =3D <1>;
		#size-cells =3D <0>;
		microblaze_0,6.00. {
			32-bit;
			clock-frequency =3D <5f5e1000>;
			d-cache-line-size =3D <10>;
			d-cache-size =3D <4000>;
			device_type =3D "cpu";
			i-cache-line-size =3D <10>;
			i-cache-size =3D <4000>;
			linux,boot-cpu;
			reg =3D <0>;
			timebase-frequency =3D <1fca055>;
			xilinx,cache-byte-size =3D <4000>;
			xilinx,dcache-baseaddr =3D <50000000>;
			xilinx,dcache-byte-size =3D <4000>;
			xilinx,dcache-highaddr =3D <5fffffff>;
			xilinx,debug-enabled =3D <1>;
			xilinx,div-zero-exception =3D <1>;
			xilinx,dopb-bus-exception =3D <1>;
			xilinx,fpu-exception =3D <1>;
			xilinx,icache-baseaddr =3D <50000000>;
			xilinx,icache-highaddr =3D <5fffffff>;
			xilinx,ill-opcode-exception =3D <1>;
			xilinx,iopb-bus-exception =3D <1>;
			xilinx,number-of-pc-brk =3D <2>;
			xilinx,pvr =3D <2>;
			xilinx,unaligned-exceptions =3D <1>;
			xilinx,use-barrel =3D <1>;
			xilinx,use-dcache =3D <1>;
			xilinx,use-div =3D <1>;
			xilinx,use-fpu =3D <1>;
			xilinx,use-icache =3D <1>;
			xilinx,use-msr-instr =3D <1>;
			xilinx,use-pcmp-instr =3D <1>;
		} ;
	} ;
	debug_module {
		compatible =3D "xilinx,opb-mdm-2.00.a\0xilinx,opb-mdm";
		device_type =3D "opb_mdm";
		reg =3D < 41400000 10000 >;
		xilinx,mb-dbg-ports =3D <1>;
		xilinx,uart-width =3D <8>;
		xilinx,use-uart =3D <1>;
	} ;
	memory@50000000 {
		device_type =3D "memory";
		edk_name =3D "DDR2_SDRAM_32Mx32";
		memreg:reg =3D < 50000000 10000000 >;
	} ;
	opb_hwicap_0 {
		compatible =3D
"xilinx,opb-hwicap-1.10.a\0xilinx,opb-hwicap";
		device_type =3D "opb_hwicap";
		reg =3D < 41300000 10000 >;
	} ;
	opb_intc_0 {
		#interrupt-cells =3D <2>;
		compatible =3D "xilinx,opb-intc-1.00.c\0xilinx,opb-intc";
		device_type =3D "opb_intc";
		interrupt-controller;
		linux,phandle =3D <101>;
		reg =3D < 41200000 10000 >;
	} ;
	opb_timer_1 {
		compatible =3D
"xilinx,opb-timer-1.00.b\0xilinx,opb-timer";
		device_type =3D "opb_timer";
		interrupt-parent =3D <101>;
		interrupts =3D < 0 0 >;
		reg =3D < 41c00000 10000 >;
		xilinx,count-width =3D <20>;
		xilinx,one-timer-only =3D <1>;
	} ;
} ;=20

^ permalink raw reply

* Re: [PATCH] powerpc: mpic: minor optimization of ipi handler
From: Olof Johansson @ 2007-10-19 23:49 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: linuxppc-dev, paulus, jgarzik
In-Reply-To: <20071019233134.GA17851@lixom.net>

Optimize MPIC IPIs, by passing in the IPI number as the argument to the
handler, since all we did was translate it back based on which mpic
the interrupt came though on (and that was always the primary mpic).


Signed-off-by: Olof Johansson <olof@lixom.net>


---

On Fri, Oct 19, 2007 at 06:31:34PM -0500, Olof Johansson wrote:
> On Sat, Oct 20, 2007 at 09:17:39AM +1000, Benjamin Herrenschmidt wrote:
> > 
> > On Fri, 2007-10-19 at 13:51 -0500, Olof Johansson wrote:
> > > Jeff Garzik pointed out that we don't actually have to lookup the mpic
> > > instance since it's passed in as the interrupt handler data for IPIs.
> > 
> > Note that's typically one of the annoying case where we use "irq"
> > for a good reasons, getting the way of Jeff attempt at removing
> > this argument.
> > 
> > I suppose a working approach would be to have 4 mpic IPI handlers...
> 
> We still need the _irq_, but we don't need to lookup the mpic based on it.
> 
> We knew the mpic pointer at irq setup time, and passed it in as the
> argument to pass to the handler. Doing a second lookup is just extra
> overhead, it should return the same controller:

Oh, I see what you mean. You didn't make it easy to parse. :)

This should actually do the work.

-Olof


diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
index e479388..a8d7c68 100644
--- a/arch/powerpc/sysdev/mpic.c
+++ b/arch/powerpc/sysdev/mpic.c
@@ -614,10 +614,9 @@ static inline void mpic_eoi(struct mpic *mpic)
 #ifdef CONFIG_SMP
 static irqreturn_t mpic_ipi_action(int irq, void *data)
 {
-	struct mpic *mpic;
+	long ipi = (long)data;
 
-	mpic = mpic_find(irq, NULL);
-	smp_message_recv(mpic_irq_to_hw(irq) - mpic->ipi_vecs[0]);
+	smp_message_recv(ipi);
 
 	return IRQ_HANDLED;
 }
@@ -1457,7 +1456,7 @@ unsigned int mpic_get_irq(void)
 void mpic_request_ipis(void)
 {
 	struct mpic *mpic = mpic_primary;
-	int i, err;
+	long i, err;
 	static char *ipi_names[] = {
 		"IPI0 (call function)",
 		"IPI1 (reschedule)",
@@ -1472,14 +1471,14 @@ void mpic_request_ipis(void)
 		unsigned int vipi = irq_create_mapping(mpic->irqhost,
 						       mpic->ipi_vecs[0] + i);
 		if (vipi == NO_IRQ) {
-			printk(KERN_ERR "Failed to map IPI %d\n", i);
+			printk(KERN_ERR "Failed to map IPI %ld\n", i);
 			break;
 		}
 		err = request_irq(vipi, mpic_ipi_action,
 				  IRQF_DISABLED|IRQF_PERCPU,
-				  ipi_names[i], mpic);
+				  ipi_names[i], (void *)i);
 		if (err) {
-			printk(KERN_ERR "Request of irq %d for IPI %d failed\n",
+			printk(KERN_ERR "Request of irq %d for IPI %ld failed\n",
 			       vipi, i);
 			break;
 		}

^ permalink raw reply related

* Re: [PATCH] [POWERPC] ucc_geth: Eliminate compile warnings
From: David Miller @ 2007-10-19 23:41 UTC (permalink / raw)
  To: Emilian.Medve; +Cc: netdev, jgarzik, linuxppc-dev
In-Reply-To: <598D5675D34BE349929AF5EDE9B03E270168520B@az33exm24.fsl.freescale.net>

From: "Medve Emilian-EMMEDVE1" <Emilian.Medve@freescale.com>
Date: Fri, 19 Oct 2007 06:39:12 -0700

> For the current situation, 32-bit QE, 32-bit PowerPC, do you find
> the patch acceptable?

No piece of code in the kernel should live in a vacuum.

In order to improve overall code quality, every piece of
driver code should avoid assuming things about pointer
sizes and things of this nature.

Then the driver can get enabled into the build on every
platform, and therefore nobody will break the build of
this driver again since it will get hit by "allmodconfig"
et al. builds even on platforms other than the one it is
meant for.

This hack fix is not acceptable, really.

^ permalink raw reply

* Re: [PATCH] powerpc: mpic: minor optimization of ipi handler
From: Olof Johansson @ 2007-10-19 23:31 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: linuxppc-dev, paulus, jgarzik
In-Reply-To: <1192835859.17235.12.camel@pasglop>

On Sat, Oct 20, 2007 at 09:17:39AM +1000, Benjamin Herrenschmidt wrote:
> 
> On Fri, 2007-10-19 at 13:51 -0500, Olof Johansson wrote:
> > Jeff Garzik pointed out that we don't actually have to lookup the mpic
> > instance since it's passed in as the interrupt handler data for IPIs.
> 
> Note that's typically one of the annoying case where we use "irq"
> for a good reasons, getting the way of Jeff attempt at removing
> this argument.
> 
> I suppose a working approach would be to have 4 mpic IPI handlers...

We still need the _irq_, but we don't need to lookup the mpic based on it.

We knew the mpic pointer at irq setup time, and passed it in as the
argument to pass to the handler. Doing a second lookup is just extra
overhead, it should return the same controller:


void mpic_request_ipis(void)
{
        struct mpic *mpic = mpic_primary;
        int i, err;
        static char *ipi_names[] = {
                "IPI0 (call function)",
                "IPI1 (reschedule)",
                "IPI2 (unused)",
                "IPI3 (debugger break)",
        };
        BUG_ON(mpic == NULL);

        printk(KERN_INFO "mpic: requesting IPIs ... \n");

        for (i = 0; i < 4; i++) {
                unsigned int vipi = irq_create_mapping(mpic->irqhost,
                                                       mpic->ipi_vecs[0] + i);
                if (vipi == NO_IRQ) {
                        printk(KERN_ERR "Failed to map IPI %d\n", i);
                        break;
                }
                err = request_irq(vipi, mpic_ipi_action,
                                  IRQF_DISABLED|IRQF_PERCPU,
                                  ipi_names[i], mpic);
                if (err) {
                        printk(KERN_ERR "Request of irq %d for IPI %d failed\n",
                               vipi, i);
                        break;
                }
        }
}


-Olof

^ permalink raw reply

* Re: [PATCH] powerpc: mpic: minor optimization of ipi handler
From: Benjamin Herrenschmidt @ 2007-10-19 23:17 UTC (permalink / raw)
  To: Olof Johansson; +Cc: linuxppc-dev, paulus, jgarzik
In-Reply-To: <20071019185110.GA11911@lixom.net>


On Fri, 2007-10-19 at 13:51 -0500, Olof Johansson wrote:
> Jeff Garzik pointed out that we don't actually have to lookup the mpic
> instance since it's passed in as the interrupt handler data for IPIs.

Note that's typically one of the annoying case where we use "irq"
for a good reasons, getting the way of Jeff attempt at removing
this argument.

I suppose a working approach would be to have 4 mpic IPI handlers...

Ben. 

> Signed-off-by: Olof Johansson <olof@lixom.net>
> 
> diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
> index e479388..6bf56f4 100644
> --- a/arch/powerpc/sysdev/mpic.c
> +++ b/arch/powerpc/sysdev/mpic.c
> @@ -612,11 +612,10 @@ static inline void mpic_eoi(struct mpic *mpic)
>  }
>  
>  #ifdef CONFIG_SMP
> -static irqreturn_t mpic_ipi_action(int irq, void *dev_id)
> +static irqreturn_t mpic_ipi_action(int irq, void *data)
>  {
> -	struct mpic *mpic;
> +	struct mpic *mpic = data;
>  
> -	mpic = mpic_find(irq, NULL);
>  	smp_message_recv(mpic_irq_to_hw(irq) - mpic->ipi_vecs[0]);
>  
>  	return IRQ_HANDLED;
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-dev

^ permalink raw reply

* Re: [PATCH 0/4] DTC: Introduce better DTS literal support
From: David Gibson @ 2007-10-19 22:57 UTC (permalink / raw)
  To: Jon Loeliger; +Cc: linuxppc-dev
In-Reply-To: <E1IivrG-00077n-O8@jdl.com>

On Fri, Oct 19, 2007 at 12:42:02PM -0500, Jon Loeliger wrote:
> Folks,
> 
> This 4 part patch series for the DTC has:
> 
>     0001-Reformat-grammar-rules-to-not-mix-language-syntax-an.patch
>     0002-Quiet-a-bogus-May-be-used-uninitialized-warning.patch
>     0003-Appease-the-printf-format-Gods-with-a-correct-typ.patch
>     0004-Begin-the-path-to-sane-literals-and-expressions.patch
> 
> The first is a pure whitespace formatting cleaning.
> The second two clean compiler warnings.
> The final one introduces a versioned DTS file with
>     support for C-like literals.

I certainly have some comments on these, but I'm busy today and won't
be able to comment in detail until Monday or so.  Please don't apply
them to mainline before then?

-- 
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

^ permalink raw reply

* [bug] block subsystem related crash on Legacy iSeries  viodasd.c
From: Will Schmidt @ 2007-10-19 21:33 UTC (permalink / raw)
  To: Jens Axboe, Stephen Rothwell; +Cc: linuxppc-dev, linux-kernel

Hi Jens, Stephen, and Everyone else.

   I am seeing this crash on a legacy iSeries box.   Bisect points at
70eb8040dc81212c884a464b75e37dca8014f3ad  (Add chained sg support to
linux/scatterlist.h).

I see there were some related troubles discussed a couple days back.
I've refreshed my tree, so believe I should have pulled in all the
changes that fixed those issues by now, so this is an additional problem
(viodasd funkyness), or I've screwed something up in my pulls, or fixes
are still pending in another tree. 

>From the register dump, looks like sg passed into memset was a -2.  

(from blk_rq_map_sg())	if (!sg)
				sg = sglist;
			else
				sg = sg_next(sg);

			memset(sg, 0, sizeof(*sg));  <--


linux-2.6.git tree at 
	commit 4fa4d23fa20de67df919030c1216295664866ad7
	Merge: a9e82d3... 4f1e5ba...
	Author: Linus Torvalds <torvalds@woody.linux-foundation.org>
	Date:   Thu Oct 18 19:31:54 2007 -0700
    Merge branch 'upstream-linus' of
master.kernel.org:/pub/scm/linux/kernel/git/jgarzik/netdev-2.6

> git log drivers/scsi/scsi_lib.c
commit a3bec5c5aea0da263111c4d8f8eabc1f8560d7bf
Author: Jens Axboe <axboe@carl.home.kernel.dk>
Date:   Wed Oct 17 19:33:05 2007 +0200

    Revert "[SCSI] Remove full sg table memset()"

> > git log block/ll_rw_blk.c
commit ba951841ceb7fa5b06ad48caa5270cc2ae17941e
Author: Jens Axboe <jens.axboe@oracle.com>
Date:   Wed Oct 17 19:34:11 2007 +0200

    [BLOCK] blk_rq_map_sg() next_sg fixup

--  The panic is:
Freeing unused kernel memory: 224k freed
Unable to handle kernel paging request for data at address 0xfffffffffffffffe
Faulting instruction address: 0xc0000000000282f0
Oops: Kernel access of bad area, sig: 11 [#1]
SMP NR_CPUS=32 iSeries
Modules linked in:
NIP: c0000000000282f0 LR: c0000000001c772c CTR: 0000000000000000
REGS: c000000002026b00 TRAP: 0300   Not tainted  (2.6.23)
MSR: 8000000000009032 <EE,ME,IR,DR>  CR: 44000022  XER: 00000008
DAR: fffffffffffffffe, DSISR: 0000000042000000
TASK = c000000002022000[1] 'swapper' THREAD: c000000002024000 CPU: 1
GPR00: 0000000000000002 c000000002026d80 c0000000005168c8 fffffffffffffffe
GPR04: 0000000000000000 000000000000001e fffffffffffffffe 0000000000000000
GPR08: 0000000000000000 0000000000000001 6db6db6db6db6db7 0000000001491000
GPR12: c00000000058d000 c000000000464f80 0000000000000000 c000000002027780
GPR16: c00000000300a0c8 0000000000000001 c0000000004d4dd0 c00000000297e868
GPR20: c000000002720000 c000000002026ec0 0000000000000001 0000000000000003
GPR24: 0000000000000000 c000000002720000 0000000000001000 0000000000000003
GPR28: fffffffffffffffe c000000002a61000 c0000000004c2510 c0000000027f64b0
NIP [c0000000000282f0] .memset+0x3c/0xfc
LR [c0000000001c772c] .blk_rq_map_sg+0x154/0x1e8
Call Trace:
[c000000002026d80] [c0000000004d4ed8] 0xc0000000004d4ed8 (unreliable)
[c000000002026e50] [c0000000002283d8] .do_viodasd_request+0xb4/0x448
[c0000000020270a0] [c0000000001c8ddc] .__generic_unplug_device+0x54/0x6c
[c000000002027120] [c0000000001ca438] .generic_unplug_device+0x30/0x78
[c0000000020271b0] [c0000000001c5888] .blk_backing_dev_unplug+0x34/0x48
[c000000002027230] [c0000000000cf75c] .block_sync_page+0x78/0x90
[c0000000020272b0] [c000000000074d50] .sync_page+0x74/0x98
[c000000002027330] [c000000000344538] .__wait_on_bit_lock+0x8c/0x110
[c0000000020273d0] [c000000000074c94] .__lock_page+0x70/0x90
[c0000000020274a0] [c0000000000758b4] .do_generic_mapping_read+0x248/0x47c
[c0000000020275a0] [c000000000077644] .generic_file_aio_read+0x144/0x1d4
[c000000002027680] [c0000000000a3ad8] .do_sync_read+0xc4/0x124
[c000000002027820] [c0000000000a4350] .vfs_read+0xd8/0x1a4
[c0000000020278c0] [c0000000000a965c] .kernel_read+0x38/0x5c
[c000000002027960] [c0000000000aad18] .do_execve+0xe8/0x208
[c000000002027a10] [c00000000000e0b4] .sys_execve+0x6c/0xf0
[c000000002027ab0] [c000000000007540] syscall_exit+0x0/0x40
--- Exception: c01 at .kernel_execve+0x8/0x14
    LR = .run_init_process+0x28/0x40
[c000000002027da0] [c0000000000b35ec] .sys_dup+0x2c/0x44 (unreliable)
[c000000002027e20] [c000000000007fb4] .init_post+0xc4/0xe8
[c000000002027ea0] [c000000000407978] .kernel_init+0x384/0x3b8
[c000000002027f90] [c000000000020000] .kernel_thread+0x4c/0x68
Instruction dump:
5084801e 7c850040 7884000e 7c001120 7c661b78 418400ac 41a2002c 7ca02850
409f000c 98860000 38c60001 409e000c <b0860000> 38c60002 409d000c 90860000
Kernel panic - not syncing: Attempted to kill init!
Rebooting in 180 seconds..                                       


Thanks,
--Will

^ permalink raw reply

* Please pull from 'for-2.6.24' branch of 4xx tree
From: Josh Boyer @ 2007-10-19 21:31 UTC (permalink / raw)
  To: paulus; +Cc: linuxppc-dev

Hi Paul,

Please pull from

 master.kernel.org:/pub/scm/linux/kernel/git/jwboyer/powerpc-4xx.git for-2.6.24

to pick up a handful of fixes for 4xx.  These are mostly to enable the
ibm_newemac driver for the various boards.  Since a few patches to the
driver are needed from Linus' tree, the branch is based off of his
latest tree as of this morning.

josh

Josh Boyer (4):
      [POWERPC] 4xx: Enable EMAC on the PPC 440GP Ebony board
      [POWERPC] 4xx: Fix timebase clock selection on Walnut
      [POWERPC] 4xx: Enable EMAC for PPC405 Walnut board
      [POWERPC] 4xx: Enable EMAC on Bamboo board

Valentine Barshak (3):
      [POWERPC] 4xx: Add RGMII support for Sequoia 440EPx
      [POWERPC] 4xx: Enable NEW EMAC support for Sequoia 440EPx.
      [POWERPC] 4xx: Split early debug output and early boot console for 44x

^ permalink raw reply

* [PATCH v3] pcmcia: Convert io_req_t to use unsigned int
From: Olof Johansson @ 2007-10-19 20:17 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Matthew Wilcox, linux-pcmcia, linux-kernel, linuxppc-dev,
	Andrew Morton, Alan Cox
In-Reply-To: <20070922091303.GA12525@lst.de>

[PCMCIA] Convert some internal-only ioaddr_t to unsigned int

Convert the io_req_t members to unsigned int, to allow use on machines
with more than 16 bits worth of IO ports (i.e. secondary busses on
ppc64, etc).

There was only a couple of places in drivers where a change was needed. I
left printk formats alone (there are lots of %04x-style formats in there),
mostly to not change the format on the platforms that only have 16-bit
io addresses, but also because the padding doesn't really add all that
much value most of the time.

I found only one sprintf of an address, and upsized the string accordingly
(I doubt anyone will have anywhere near INT_MAX as irq value, but at
least there's room for it now).

Signed-off-by: Olof Johansson <olof@lixom.net>

---

On Sat, Sep 22, 2007 at 11:13:03AM +0200, Christoph Hellwig wrote:
> On Sat, Sep 22, 2007 at 12:25:51AM -0600, Matthew Wilcox wrote:
> > > What about the formatting and field widths ?
> > > 
> > > ulong would probably be a lot saner than kio_addr_t and yet more type
> > > obfuscation.
> > 
> > I don't think anyone uses ioports > 32bit.  Certainly i386 takes an int
> > port as parameter to {in,out}[bwl] (and it really only uses 16-bits).
> > parisc uses 24 bits.  I don't know what the various ppcs do, but pci
> > bars can only be 32-bit for ioports.  So my opinion is that ioports
> > should be uint, not ulong.
> 
> The kernel seems to mostly use int, sometimes uint.  I never quite got
> why pcmcia had to have it's own strange typedef for them.

Ok, so let's switch to unsigned int. Only exception I made was to stick
to u_int in the struct itself to keep it common with the style in the
rest of it.

This also resulted in a much smaller diff, since I didn't have to change
any printk formats (see above about 0-padding).


-Olof


Index: k.org/drivers/char/pcmcia/cm4000_cs.c
===================================================================
--- k.org.orig/drivers/char/pcmcia/cm4000_cs.c
+++ k.org/drivers/char/pcmcia/cm4000_cs.c
@@ -308,7 +308,7 @@ static unsigned int calc_baudv(unsigned 
 	return (wcrcf / wbrcf);
 }
 
-static unsigned short io_read_num_rec_bytes(ioaddr_t iobase, unsigned short *s)
+static unsigned short io_read_num_rec_bytes(unsigned int iobase, unsigned short *s)
 {
 	unsigned short tmp;
 
@@ -426,7 +426,7 @@ static struct card_fixup card_fixups[] =
 static void set_cardparameter(struct cm4000_dev *dev)
 {
 	int i;
-	ioaddr_t iobase = dev->p_dev->io.BasePort1;
+	unsigned int iobase = dev->p_dev->io.BasePort1;
 	u_int8_t stopbits = 0x02; /* ISO default */
 
 	DEBUGP(3, dev, "-> set_cardparameter\n");
@@ -459,7 +459,7 @@ static int set_protocol(struct cm4000_de
 	unsigned short num_bytes_read;
 	unsigned char pts_reply[4];
 	ssize_t rc;
-	ioaddr_t iobase = dev->p_dev->io.BasePort1;
+	unsigned int iobase = dev->p_dev->io.BasePort1;
 
 	rc = 0;
 
@@ -610,7 +610,7 @@ exit_setprotocol:
 	return rc;
 }
 
-static int io_detect_cm4000(ioaddr_t iobase, struct cm4000_dev *dev)
+static int io_detect_cm4000(unsigned int iobase, struct cm4000_dev *dev)
 {
 
 	/* note: statemachine is assumed to be reset */
@@ -671,7 +671,7 @@ static void terminate_monitor(struct cm4
 static void monitor_card(unsigned long p)
 {
 	struct cm4000_dev *dev = (struct cm4000_dev *) p;
-	ioaddr_t iobase = dev->p_dev->io.BasePort1;
+	unsigned int iobase = dev->p_dev->io.BasePort1;
 	unsigned short s;
 	struct ptsreq ptsreq;
 	int i, atrc;
@@ -933,7 +933,7 @@ static ssize_t cmm_read(struct file *fil
 			loff_t *ppos)
 {
 	struct cm4000_dev *dev = filp->private_data;
-	ioaddr_t iobase = dev->p_dev->io.BasePort1;
+	unsigned int iobase = dev->p_dev->io.BasePort1;
 	ssize_t rc;
 	int i, j, k;
 
@@ -1054,7 +1054,7 @@ static ssize_t cmm_write(struct file *fi
 			 size_t count, loff_t *ppos)
 {
 	struct cm4000_dev *dev = (struct cm4000_dev *) filp->private_data;
-	ioaddr_t iobase = dev->p_dev->io.BasePort1;
+	unsigned int iobase = dev->p_dev->io.BasePort1;
 	unsigned short s;
 	unsigned char tmp;
 	unsigned char infolen;
@@ -1408,7 +1408,7 @@ static int cmm_ioctl(struct inode *inode
 		     unsigned long arg)
 {
 	struct cm4000_dev *dev = filp->private_data;
-	ioaddr_t iobase = dev->p_dev->io.BasePort1;
+	unsigned int iobase = dev->p_dev->io.BasePort1;
 	struct pcmcia_device *link;
 	int size;
 	int rc;
Index: k.org/drivers/pcmcia/pcmcia_resource.c
===================================================================
--- k.org.orig/drivers/pcmcia/pcmcia_resource.c
+++ k.org/drivers/pcmcia/pcmcia_resource.c
@@ -65,23 +65,23 @@ extern int ds_pc_debug;
  * Special stuff for managing IO windows, because they are scarce
  */
 
-static int alloc_io_space(struct pcmcia_socket *s, u_int attr, ioaddr_t *base,
-			  ioaddr_t num, u_int lines)
+static int alloc_io_space(struct pcmcia_socket *s, u_int attr,
+			  unsigned int *base, unsigned int num, u_int lines)
 {
 	int i;
-	kio_addr_t try, align;
+	unsigned int try, align;
 
 	align = (*base) ? (lines ? 1<<lines : 0) : 1;
 	if (align && (align < num)) {
 		if (*base) {
-			ds_dbg(s, 0, "odd IO request: num %#x align %#lx\n",
+			ds_dbg(s, 0, "odd IO request: num %#x align %#x\n",
 			       num, align);
 			align = 0;
 		} else
 			while (align && (align < num)) align <<= 1;
 	}
 	if (*base & ~(align-1)) {
-		ds_dbg(s, 0, "odd IO request: base %#x align %#lx\n",
+		ds_dbg(s, 0, "odd IO request: base %#x align %#x\n",
 		       *base, align);
 		align = 0;
 	}
@@ -132,8 +132,8 @@ static int alloc_io_space(struct pcmcia_
 } /* alloc_io_space */
 
 
-static void release_io_space(struct pcmcia_socket *s, ioaddr_t base,
-			     ioaddr_t num)
+static void release_io_space(struct pcmcia_socket *s, unsigned int base,
+			     unsigned int num)
 {
 	int i;
 
Index: k.org/include/pcmcia/cs.h
===================================================================
--- k.org.orig/include/pcmcia/cs.h
+++ k.org/include/pcmcia/cs.h
@@ -147,11 +147,11 @@ typedef struct config_req_t {
 
 /* For RequestIO and ReleaseIO */
 typedef struct io_req_t {
-    ioaddr_t	BasePort1;
-    ioaddr_t	NumPorts1;
+    u_int	BasePort1;
+    u_int	NumPorts1;
     u_int	Attributes1;
-    ioaddr_t	BasePort2;
-    ioaddr_t	NumPorts2;
+    u_int	BasePort2;
+    u_int	NumPorts2;
     u_int	Attributes2;
     u_int	IOAddrLines;
 } io_req_t;
Index: k.org/drivers/scsi/pcmcia/fdomain_stub.c
===================================================================
--- k.org.orig/drivers/scsi/pcmcia/fdomain_stub.c
+++ k.org/drivers/scsi/pcmcia/fdomain_stub.c
@@ -130,7 +130,7 @@ static int fdomain_config(struct pcmcia_
     cisparse_t parse;
     int i, last_ret, last_fn;
     u_char tuple_data[64];
-    char str[16];
+    char str[22];
     struct Scsi_Host *host;
 
     DEBUG(0, "fdomain_config(0x%p)\n", link);

^ permalink raw reply

* Re: FDT bindings for I2C devices
From: Guennadi Liakhovetski @ 2007-10-19 19:56 UTC (permalink / raw)
  To: Grant Likely; +Cc: linuxppc-dev, linuxppc-embedded
In-Reply-To: <fa686aa40710190738q1211a266lced10ac8767e5071@mail.gmail.com>

(it was suggested to deprecate -embedded in favour of -dev, so, added to 
cc:)

On Fri, 19 Oct 2007, Grant Likely wrote:

> On 10/19/07, Wolfgang Grandegger <wg@grandegger.com> wrote:
> > Hello,
> >
> > is it forseen to define and configure devices like RTC, temperature
> > sensors or EEPROM on the I2C bus with the Flat Device Tree? If yes, how
> > would the DTS entries look like?
> 
> booting-without-of.txt has some information about describing the controller.
> 
> Scott Wood made an attempt at defining a device binding for I2C
> devices, but it has not been merged into booting-without-of.txt yet.
> I've copied what he wrote below.  I would add to his definition the
> following:
> - If compatible is missing, driver should *not* fall back to the device name.
> - 'compatible' list should include the exact device in the form "<mfg>,<part>"

There are also already working examples in powerpc: look at 
arch/powerpc/sysdev/fsl_soc.c at the i2c_devices[] array and how it is 
used below. There are also some .dts examples upstream already, e.g., 
arch/powerpc/boot/dts/kuroboxH[GD].dts. There also have been more patches 
recently to add further devices to the table and further .dts entries. 
Notice however, it would be good to move the generic code out of 
fsl_soc.c, as there seems to be increasing interest in describing i2c 
buses in .dts.

Thanks
Guennadi
---
Guennadi Liakhovetski

^ permalink raw reply

* Re: embedded a default dtb in the kernel (was merge dtc)
From: Grant Likely @ 2007-10-19 19:09 UTC (permalink / raw)
  To: Leisner, Martin; +Cc: linuxppc-dev
In-Reply-To: <556445368AFA1C438794ABDA8901891C075945FD@USA0300MS03.na.xerox.net>

On 10/19/07, Leisner, Martin <Martin.Leisner@xerox.com> wrote:
> Is there a way to embed a default dtb into the kernel?
> When I build a kernel, I want to embed a dtb into it --
> so I don't have to deal with the headaches of finding the
> right file to match the right board (its always easier to
> deal with 1 file than 2).
>
> If there is, it makes sense to put dtc into the tree.
> If there's not, there should be a way to embed dtb's; and put
> dtc and dts's into the tree.
> If there can't be (I haven't examined this but relaying my
> experiences), then it should be in a separate repository
> (but the DTS and DTC should be in one place).
> It was a little difficult to cobble together a working
> system the first time.
>
> Also, mkimage SHOULD definitely go in the tree.  Its necessary
> to build, hence should be in the tree...

Why?  mkimage is u-boot specific, and hence is maintained by u-boot.
If you're not using u-boot, then you don't need mkimage.  What is
wrong with it being a prereq like all the other tools we use?  If
you're doing embedded development, you're installing non-distribution
cross toolchain anyway.

dtc and mkimage are embedded development tools.  They belong with the
embedded development toolchain.  mkimage is already part of ELDK.

Cheers,
g.

-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
grant.likely@secretlab.ca
(403) 399-0195

^ permalink raw reply

* Re: [PATCH] ppc44x: support for 256K PAGE_SIZE
From: Wolfgang Denk @ 2007-10-19 19:04 UTC (permalink / raw)
  To: Josh Boyer; +Cc: linuxppc-dev
In-Reply-To: <20071019113634.397c63f7@weaponx.rchland.ibm.com>

Dear Josh,

in message <20071019113634.397c63f7@weaponx.rchland.ibm.com> you wrote:
>
> >  The following patch adds support for 256KB PAGE_SIZE on ppc44x-based boards. 
> > The applications to be run on the kernel with 256KB PAGE_SIZE have to be 
> > built using the modified version of binutils, where the MAXPAGESIZE 
> > definition is set to 0x40000 (as opposite to standard 0x10000).
...
> 
> BTW, what tree did you base this on?  I don't seem to have the
> PPC_PAGE_* options in my tree.

If you like to see the patches in context, you can find this stuff in
the linux-2.6-denx repository at denx.de

The 256K page size stuff is based on and requires as prerequisite the
"ppc: Add support for bigger page sizes than 4KB on PPC44x" posted
here on April 25, see
http://patchwork.ozlabs.org/linuxppc/patch?q=Add%20support%20for%20bigger%20page%20sizes&id=10646

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd@denx.de
Q: Why do PCs have a reset button on the front?
A: Because they are expected to run Microsoft operating systems.

^ permalink raw reply

* [PATCH] powerpc: mpic: minor optimization of ipi handler
From: Olof Johansson @ 2007-10-19 18:51 UTC (permalink / raw)
  To: paulus; +Cc: linuxppc-dev, jgarzik

Jeff Garzik pointed out that we don't actually have to lookup the mpic
instance since it's passed in as the interrupt handler data for IPIs.


Signed-off-by: Olof Johansson <olof@lixom.net>

diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
index e479388..6bf56f4 100644
--- a/arch/powerpc/sysdev/mpic.c
+++ b/arch/powerpc/sysdev/mpic.c
@@ -612,11 +612,10 @@ static inline void mpic_eoi(struct mpic *mpic)
 }
 
 #ifdef CONFIG_SMP
-static irqreturn_t mpic_ipi_action(int irq, void *dev_id)
+static irqreturn_t mpic_ipi_action(int irq, void *data)
 {
-	struct mpic *mpic;
+	struct mpic *mpic = data;
 
-	mpic = mpic_find(irq, NULL);
 	smp_message_recv(mpic_irq_to_hw(irq) - mpic->ipi_vecs[0]);
 
 	return IRQ_HANDLED;

^ permalink raw reply related

* Re: Merge dtc
From: Sam Ravnborg @ 2007-10-19 18:42 UTC (permalink / raw)
  To: Milton Miller, ppcdev, Paul Mackerras
In-Reply-To: <20071019071033.GB27017@localhost.localdomain>

Hi David.

> > Give me a day or two then I shall give it a try and see what I can
> > do about it.  I will use the previsous posted URL as basis if you do
> > not tell me otherwise.
> 
> Thank you.  The previous URL should be fine, I've made no changes
> since then.

I decided to go for a kbuild specific version integrated
in boot/Makefile.
This is much more readable because this syntax is explicit.
We do not favour 3 levels of variabls to avoid rewriting the same
filename two times.
I have tested the change only with a O=.. crosscompile build.

I have tested the patch with and without DTC_GENPARSER=1.
It does not rebuild if not needed and is OK with -j10 builds.

Please consider this version in favour of your old version.

Take this as review feedback.

You can add:
Reviewed-by: Sam Ravnborg <sam@ravnborg.org> [kbuild integration only]

Thanks,
	Sam

 arch/powerpc/boot/Makefile |   40 ++++++++++++++++++++++++++++++++++++++--
 1 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index 18e3271..064dc07 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -108,17 +108,53 @@ $(patsubst %.S,%.o, $(filter %.S, $(src-boot))): %.o: %.S FORCE
 $(obj)/wrapper.a: $(obj-wlib) FORCE
 	$(call if_changed,bootar)
 
-hostprogs-y	:= addnote addRamDisk hack-coff mktree
+hostprogs-y	:= addnote addRamDisk hack-coff mktree dtc
 
 targets		+= $(patsubst $(obj)/%,%,$(obj-boot) wrapper.a)
 extra-y		:= $(obj)/wrapper.a $(obj-plat) $(obj)/empty.o \
 		   $(obj)/zImage.lds $(obj)/zImage.coff.lds $(obj)/zImage.ps3.lds
 
 wrapper		:=$(srctree)/$(src)/wrapper
-wrapperbits	:= $(extra-y) $(addprefix $(obj)/,addnote hack-coff mktree) \
+wrapperbits	:= $(extra-y) $(addprefix $(obj)/,addnote hack-coff mktree dtc) \
 			$(wrapper) FORCE
 
 #############
+# Bits for building dtc
+# DTC_GENPARSER	:= 1	# Uncomment to rebuild flex/bison output
+
+dtc-objs := dtc.o flattree.o fstree.o data.o livetree.o treesource.o srcpos.o
+dtc-objs += dtc-lexer.lex.o dtc-parser.tab.o
+dtc-objs := $(addprefix dtc-src/, $(dtc-objs))
+
+# prerequisites on generated files needs to be explicit
+$(obj)/dtc-src/dtc-parser.tab.o: $(obj)/dtc-src/dtc-parser.tab.c $(obj)/dtc-src/dtc-parser.tab.h
+$(obj)/dtc-src/dtc-lexer.lex.o:  $(obj)/dtc-src/dtc-lexer.lex.c
+$(obj)/dtc-src/data.o:           $(obj)/dtc-src/dtc-parser.tab.h
+
+HOSTCFLAGS += -I$(src)/dtc-src/
+
+targets += dtc-src/dtc-parser.tab.c
+targets += dtc-src/dtc-lexer.lex.c
+
+ifdef DTC_GENPARSER
+BISON = bison
+FLEX = flex
+
+quiet_cmd_bison = BISON   $@
+      cmd_bison = $(BISON) -o$@ -d $<; cp $@ $@_shipped
+quiet_cmd_flex = FLEX    $@
+      cmd_flex = $(FLEX) -o$@ $<; cp $@ $@_shipped
+
+$(obj)/dtc-src/dtc-parser.tab.c: $(src)/dtc-src/dtc-parser.y FORCE
+	$(call if_changed,bison)
+
+$(obj)/dtc-src/dtc-parser.tab.h: $(obj)/dtc-src/dtc-parser.tab.c
+
+$(obj)/dtc-src/dtc-lexer.lex.c: $(src)/dtc-src/dtc-lexer.l FORCE
+	$(call if_changed,flex)
+endif
+
+#############
 # Bits for building various flavours of zImage
 
 ifneq ($(CROSS32_COMPILE),)

^ permalink raw reply related

* embedded a default dtb in the kernel (was merge dtc)
From: Leisner, Martin @ 2007-10-19 18:30 UTC (permalink / raw)
  To: linuxppc-dev

Is there a way to embed a default dtb into the kernel?
When I build a kernel, I want to embed a dtb into it --
so I don't have to deal with the headaches of finding the
right file to match the right board (its always easier to
deal with 1 file than 2).

If there is, it makes sense to put dtc into the tree.
If there's not, there should be a way to embed dtb's; and put
dtc and dts's into the tree.
If there can't be (I haven't examined this but relaying my
experiences), then it should be in a separate repository
(but the DTS and DTC should be in one place).
It was a little difficult to cobble together a working=20
system the first time.

Also, mkimage SHOULD definitely go in the tree.  Its necessary
to build, hence should be in the tree...

There are cases where one kernel can support multiple boards/DTBs.
I guess boot flags can control whether to use an embedded DTB or
one passed from uboot...

marty

^ permalink raw reply

* Re: SystemACE driver problem
From: Grant Likely @ 2007-10-19 18:20 UTC (permalink / raw)
  To: aauer1; +Cc: linuxppc-embedded
In-Reply-To: <13300089.post@talk.nabble.com>

On 10/19/07, aauer1 <aauer1@gmx.at> wrote:
>
>
>
> Grant Likely-2 wrote:
> >
> > On 10/19/07, aauer1 <aauer1@gmx.at> wrote:
> >>
> >> Hello
> >>
> >> I'm trying to boot a Linux Kernel 2.6.23-rc2 from Grant Likely (thanks
> >> for
> >> the great work) on a Xilinx ML403 board. I want to use the second
> >> partition
> >> of the Compact Flash Card as root filesystem. But the boot process hangs
> >> at
> >> the initialization of the SystemACE module. A strange effect is that the
> >> DONE LED (configuration of the FPGA is done) turns off. So, this means
> >> that
> >> the FPGA loses his configuration.
> >> Has anybody recognized a similar problem with the SystemACE module??
> >>
> >> The boot log:
> >> ========
> > [snipped]
> >> [    0.268807] uartlite.0: ttyUL0 at MMIO 0x40600000 (irq = 2) is a
> >> uartlite
> >> [    0.270399] console [ttyUL0] enabled
> >> [    1.762725] RAMDISK driver initialized: 8 RAM disks of 8192K size 1024
> >> blocke
> >> [    1.852062] Registering Xilinx SystemACE driver, major=254
> >> [    1.919734] xsysace xsysace.0: ace_probe(c01638e0)
> >
> > Yes, I've seen that.  It means something went wrong with the setup and
> > caused the sysace to reload the FPGA.  Is the systemace base address
> > and bus width set correctly?
> >
> >
>
> The base address is the same as in the system.mhs file of my hardware
> design. So, I think it should be correct. The bus width is set to 16 bits
> (hardware design). So far as I can see, the sysace driver defines a 16 bit
> data bus (hard coded), too.

Hmmm; that's all very odd.  I don't know what could be causing that.

> A paper of BlueCat Linux says that there is a problem with the System ACE
> hardware module:
> "Due to a known problem of the opb_sysace IP Core programmed into the FPGA
> (incorrect operation in the interrupt mode) the SystemACE Compact Flash
> device is supported in the polling mode."
>
> Does anyone know something about the bug in the SystemACE IP core??

I don't know about the old xilinx supplied sysace driver, but the new
xsysace.c driver is robust enough to work around missed interrupts.  I
don't know of any other problems with the opb_sysace IP core.

Cheers,
g.

-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
grant.likely@secretlab.ca
(403) 399-0195

^ permalink raw reply

* Re: SystemACE driver problem
From: aauer1 @ 2007-10-19 18:13 UTC (permalink / raw)
  To: linuxppc-embedded
In-Reply-To: <fa686aa40710190704j18feabf2geb417d554ebb11c@mail.gmail.com>




Grant Likely-2 wrote:
> 
> On 10/19/07, aauer1 <aauer1@gmx.at> wrote:
>>
>> Hello
>>
>> I'm trying to boot a Linux Kernel 2.6.23-rc2 from Grant Likely (thanks
>> for
>> the great work) on a Xilinx ML403 board. I want to use the second
>> partition
>> of the Compact Flash Card as root filesystem. But the boot process hangs
>> at
>> the initialization of the SystemACE module. A strange effect is that the
>> DONE LED (configuration of the FPGA is done) turns off. So, this means
>> that
>> the FPGA loses his configuration.
>> Has anybody recognized a similar problem with the SystemACE module??
>>
>> The boot log:
>> ========
> [snipped]
>> [    0.268807] uartlite.0: ttyUL0 at MMIO 0x40600000 (irq = 2) is a
>> uartlite
>> [    0.270399] console [ttyUL0] enabled
>> [    1.762725] RAMDISK driver initialized: 8 RAM disks of 8192K size 1024
>> blocke
>> [    1.852062] Registering Xilinx SystemACE driver, major=254
>> [    1.919734] xsysace xsysace.0: ace_probe(c01638e0)
> 
> Yes, I've seen that.  It means something went wrong with the setup and
> caused the sysace to reload the FPGA.  Is the systemace base address
> and bus width set correctly?
> 
> 

The base address is the same as in the system.mhs file of my hardware
design. So, I think it should be correct. The bus width is set to 16 bits
(hardware design). So far as I can see, the sysace driver defines a 16 bit
data bus (hard coded), too. 

A paper of BlueCat Linux says that there is a problem with the System ACE
hardware module:
"Due to a known problem of the opb_sysace IP Core programmed into the FPGA
(incorrect operation in the interrupt mode) the SystemACE Compact Flash
device is supported in the polling mode."

Does anyone know something about the bug in the SystemACE IP core?? 

Thanks,
Andreas

-- 
View this message in context: http://www.nabble.com/SystemACE-driver-problem-tf4651846.html#a13300089
Sent from the linuxppc-embedded mailing list archive at Nabble.com.

^ permalink raw reply

* DTC: DTC {before,after} Comparison Script
From: Jon Loeliger @ 2007-10-19 17:49 UTC (permalink / raw)
  To: linuxppc-dev

Guys,

And just for the record, here is the QAD script that
I used to verify that all the existing DTS files in
the arch/powerpc/boot/dts directory are byte-identical
before and after my recent modifications.  Naturally,
all the DTS files are still in "legacy dts-version 0"
still.  But I don't think I broke that mode now. :-)

Feel free to productize or otherwise improve on it...

jdl

----------------------------------------------------------------

#!/usr/bin/perl

my $dtc_old = "dtc/dtc-old";
my $dtc_new = "dtc/dtc-new-debug";

my $basic_options = "-b 0 -f -I dts -O dtb";

my $linux_dts_dir = "linux-2.6/arch/powerpc/boot/dts";

# Yeah, sure, we could, like, readdir() this instead...
my @boards = (
	      "bamboo",
	      "ebony",
	      "ep88xc",
	      "holly",
	      "kilauea",
	      "kuroboxHD",
	      "kuroboxHG",
	      "lite5200",
	      "lite5200b",
	      "mpc7448hpc2",
	      "mpc8272ads",
	      "mpc8313erdb",
	      "mpc832x_mds",
	      "mpc832x_rdb",
	      "mpc8349emitx",
	      "mpc8349emitxgp",
	      "mpc834x_mds",
	      "mpc836x_mds",
	      "mpc8540ads",
	      "mpc8541cds",
	      "mpc8544ds",
	      "mpc8548cds",
	      "mpc8555cds",
	      "mpc8560ads",
	      "mpc8568mds",
	      "mpc8572ds",
	      "mpc8610_hpcd",
	      "mpc8641_hpcn",
	      "mpc866ads",	# Feh.  Bad node references...
	      "mpc885ads",
	      "pq2fads",
	      "prpmc2800",
	      "ps3",
	      "sequoia",
	      "walnut",
);

foreach my $board (@boards) {
	my $dts_file = "$linux_dts_dir/$board.dts";

	my $old_dtb_file = "/tmp/$board.dtb.old";
	my $new_dtb_file = "/tmp/$board.dtb.new";

	my $cmd_old = "$dtc_old $basic_options -o $old_dtb_file $dts_file";
	my $cmd_new = "$dtc_new $basic_options -o $new_dtb_file $dts_file";
	my $cmd_cmp = "cmp $old_dtb_file $new_dtb_file";

	print "------------------------------------------------\n";
	print "OLD: $cmd_old\n";
	unlink($old_dtb_file) if (-f $old_dtb_file);
	system("$cmd_old >& /dev/null");
	my $status = $?;
	if ($status) {
		print "    FAILED to run old DTC on $board\n";
	}

	print "NEW: $cmd_new\n";
	unlink($new_dtb_file) if (-f $new_dtb_file);
	system("$cmd_new >& /dev/null");
	$status = $?;
	if ($status) {
		print "    FAILED to run new DTC on $board\n";
	}

	if (-f $old_dtb_file && -f $new_dtb_file) {
	    print "CMP: $cmd_cmp\n";
	    system($cmd_cmp);
	    $status = $?;
	    if ($status) {
		print "    FAILED $board\n";
	    }
	} else {
	    printf "    FAILED: Missing dtb file\n";
	}
}

^ permalink raw reply

* [PATCH 4/4] DTC: Begin the path to sane literals and expressions.
From: Jon Loeliger @ 2007-10-19 17:43 UTC (permalink / raw)
  To: linuxppc-dev


Add support for the "/dts-version/ <number>;" statment.
Make legacy DTS files version 0 whether explicitly stated
or implied by a lack of /dts-version/ statement.

Begin supporting a new /dts-version/ 1 that changes the
format of the literals in a DTS source file.  In the new
format, hex constants are prefixed with 0x or 0X, and
bare numbers are decimal or octal according to standard
conventions.

Property names have been limited to start with
characters from the set [a-zA-Z,._#?].  That is, the
digits and the expression symbols have been removed.

Use of "d#', "o#", "h#" and "b#" are gone in version 1.

Several warnings are introduced for debatable constructs.

- Only /dts-version/ 0 and 1 are supported yet.

- A missing /dts-version/ statement garners a
  suggestion to add one, and defaults to verion 0.

- The /memreserve/ construct using "-" for ranges looks
  suspiciously like the subtraction of two expressions,
  so its syntax has been changed to use ".." as the range
  indicator.

Signed-off-by: Jon Loeliger <jdl@freescale.com>
---
 dtc-lexer.l  |  180 +++++++++++++++++++++++++++++++++++++++++++++------------
 dtc-parser.y |  143 +++++++++++++++++++++++++++++++---------------
 dtc.c        |   26 ++++++++
 dtc.h        |   23 ++++++--
 srcpos.h     |    1 +
 treesource.c |   24 +++++++-
 6 files changed, 303 insertions(+), 94 deletions(-)

diff --git a/dtc-lexer.l b/dtc-lexer.l
index 278a96e..a1c52c4 100644
--- a/dtc-lexer.l
+++ b/dtc-lexer.l
@@ -22,12 +22,19 @@
 
 %x INCLUDE
 %x CELLDATA
+%x CELLDATA_LEGACY
 %x BYTESTRING
+%x BYTESTRING_LEGACY
 %x MEMRESERVE
+%x MEMRESERVE_LEGACY
 
+DIGIT		[0-9]
+HEXDIGIT	[0-9a-fA-F]
+FIRSTPROPCHAR	[a-zA-Z,._#?]
 PROPCHAR	[a-zA-Z0-9,._+*#?-]
 UNITCHAR	[0-9a-f,]
 WS		[[:space:]]
+DOT		[.]
 
 REFCHAR		({PROPCHAR}|{UNITCHAR}|[/@])
 
@@ -46,11 +53,20 @@ REFCHAR		({PROPCHAR}|{UNITCHAR}|[/@])
 #endif
 
 
+unsigned int in_lexer_use_base = 16;	/* Feedback from parser.  Ugh. */
+
 
 %}
 
 %%
 
+"/dts-version/"	{
+			yylloc.filenum = srcpos_filenum;
+			yylloc.first_line = yylineno;
+			DPRINT("Keyword: /dts-version/\n");
+			return DT_DTS_VERSION;
+		}
+
 "/include/"		BEGIN(INCLUDE);
 
 <INCLUDE>\"[^"\n]*\"	{
@@ -83,24 +99,15 @@ REFCHAR		({PROPCHAR}|{UNITCHAR}|[/@])
 			yylloc.filenum = srcpos_filenum;
 			yylloc.first_line = yylineno;
 			DPRINT("Keyword: /memreserve/\n");
-			BEGIN(MEMRESERVE);
-			return DT_MEMRESERVE;
-		}
-
-<MEMRESERVE>[0-9a-fA-F]+ {
-			yylloc.filenum = srcpos_filenum;
-			yylloc.first_line = yylineno;
-			if (yyleng > 2*sizeof(yylval.addr)) {
-				fprintf(stderr, "Address value %s too large\n",
-					yytext);
+			if (dts_version == 0) {
+				BEGIN(MEMRESERVE_LEGACY);
+			} else {
+				BEGIN(MEMRESERVE);
 			}
-			yylval.addr = (u64) strtoull(yytext, NULL, 16);
-			DPRINT("Addr: %llx\n",
-			       (unsigned long long)yylval.addr);
-			return DT_ADDR;
+			return DT_MEMRESERVE;
 		}
 
-<MEMRESERVE>";"	{
+<MEMRESERVE,MEMRESERVE_LEGACY>";"	{
 			yylloc.filenum = srcpos_filenum;
 			yylloc.first_line = yylineno;
 			DPRINT("/MEMRESERVE\n");
@@ -117,7 +124,7 @@ REFCHAR		({PROPCHAR}|{UNITCHAR}|[/@])
 			return DT_LABEL;
 		}
 
-<CELLDATA>[bodh]# {
+<CELLDATA_LEGACY>[bodh]# {
 			yylloc.filenum = srcpos_filenum;
 			yylloc.first_line = yylineno;
 			if (*yytext == 'b')
@@ -132,15 +139,7 @@ REFCHAR		({PROPCHAR}|{UNITCHAR}|[/@])
 			return DT_BASE;
 		}
 
-<CELLDATA>[0-9a-fA-F]+	{
-			yylloc.filenum = srcpos_filenum;
-			yylloc.first_line = yylineno;
-			yylval.str = strdup(yytext);
-			DPRINT("Cell: '%s'\n", yylval.str);
-			return DT_CELL;
-		}
-
-<CELLDATA>">"	{
+<CELLDATA,CELLDATA_LEGACY>">"	{
 			yylloc.filenum = srcpos_filenum;
 			yylloc.first_line = yylineno;
 			DPRINT("/CELLDATA\n");
@@ -156,15 +155,7 @@ REFCHAR		({PROPCHAR}|{UNITCHAR}|[/@])
 			return DT_REF;
 		}
 
-<BYTESTRING>[0-9a-fA-F]{2} {
-			yylloc.filenum = srcpos_filenum;
-			yylloc.first_line = yylineno;
-			yylval.byte = strtol(yytext, NULL, 16);
-			DPRINT("Byte: %02x\n", (int)yylval.byte);
-			return DT_BYTE;
-		}
-
-<BYTESTRING>"]"	{
+<BYTESTRING,BYTESTRING_LEGACY>"]"	{
 			yylloc.filenum = srcpos_filenum;
 			yylloc.first_line = yylineno;
 			DPRINT("/BYTESTRING\n");
@@ -182,7 +173,63 @@ REFCHAR		({PROPCHAR}|{UNITCHAR}|[/@])
 			return yytext[0];
 		}
 
-{PROPCHAR}+	{
+
+<MEMRESERVE_LEGACY>{HEXDIGIT}+	{
+			yylloc.filenum = srcpos_filenum;
+			yylloc.first_line = yylineno;
+			DPRINT("LEGACY MEMRESERVE LITERAL bare hex: '%s'\n",
+			       yytext);
+			yylval.ire = expr_from_string(yytext, 16);
+			in_lexer_use_base = expr_default_base;
+			return DT_LITERAL;
+		}
+
+<CELLDATA_LEGACY>{HEXDIGIT}+	{
+			yylloc.filenum = srcpos_filenum;
+			yylloc.first_line = yylineno;
+			DPRINT("LEGACY CELLDATA LITERAL bare hex: '%s'\n",
+			       yytext);
+			yylval.ire = expr_from_string(yytext,
+						      in_lexer_use_base);
+			in_lexer_use_base = expr_default_base;
+			return DT_LITERAL;
+		}
+
+<BYTESTRING_LEGACY>[0-9a-fA-F]{2} {
+			yylloc.filenum = srcpos_filenum;
+			yylloc.first_line = yylineno;
+			yylval.ire = strtol(yytext, NULL, 16);
+			DPRINT("LEGACY BYTE LITERAL: %02x\n", (int)yylval.ire);
+			return DT_LITERAL;
+		}
+
+
+<CELLDATA,MEMRESERVE,BYTESTRING>{DIGIT}+	{
+			yylloc.filenum = srcpos_filenum;
+			yylloc.first_line = yylineno;
+			DPRINT("CONTEXT LITERAL bare dec: '%s'\n", yytext);
+			yylval.ire = expr_from_string(yytext, 0);
+			return DT_LITERAL;
+		}
+
+<CELLDATA,MEMRESERVE,BYTESTRING>0(x|X){HEXDIGIT}+	{
+			yylloc.filenum = srcpos_filenum;
+			yylloc.first_line = yylineno;
+			yylval.ire = expr_from_string(yytext, 0);
+			DPRINT("CONTEXT LITERAL 0x: '%llx'\n",
+			       (unsigned long long)yylval.ire);
+			return DT_LITERAL;
+		}
+
+
+<*>{DOT}{DOT}	{
+			yylloc.filenum = srcpos_filenum;
+			yylloc.first_line = yylineno;
+			DPRINT("DT_RANGE\n");
+			return DT_RANGE;
+		}
+
+{FIRSTPROPCHAR}{PROPCHAR}+	{
 			yylloc.filenum = srcpos_filenum;
 			yylloc.first_line = yylineno;
 			DPRINT("PropName: %s\n", yytext);
@@ -190,7 +237,7 @@ REFCHAR		({PROPCHAR}|{UNITCHAR}|[/@])
 			return DT_PROPNAME;
 		}
 
-{PROPCHAR}+(@{UNITCHAR}+)? {
+{FIRSTPROPCHAR}{PROPCHAR}+(@{UNITCHAR}+)? {
 			yylloc.filenum = srcpos_filenum;
 			yylloc.first_line = yylineno;
 			DPRINT("NodeName: %s\n", yytext);
@@ -198,6 +245,23 @@ REFCHAR		({PROPCHAR}|{UNITCHAR}|[/@])
 			return DT_NODENAME;
 		}
 
+{DIGIT}+	{
+			yylloc.filenum = srcpos_filenum;
+			yylloc.first_line = yylineno;
+			yylval.ire = expr_from_string(yytext, 0);
+			DPRINT("LITERAL: '%llx'\n",
+			       (unsigned long long)yylval.ire);
+			return DT_LITERAL;
+		}
+
+0(x|X){HEXDIGIT}+	{
+			yylloc.filenum = srcpos_filenum;
+			yylloc.first_line = yylineno;
+			DPRINT("LITERAL bare hex: '%s'\n", yytext);
+			yylval.ire = expr_from_string(yytext, 0);
+			return DT_LITERAL;
+		}
+
 
 <*>{WS}+	/* eat whitespace */
 
@@ -216,11 +280,19 @@ REFCHAR		({PROPCHAR}|{UNITCHAR}|[/@])
 			switch (yytext[0]) {
 				case '<':
 					DPRINT("CELLDATA\n");
-					BEGIN(CELLDATA);
+					if (dts_version == 0) {
+					    BEGIN(CELLDATA_LEGACY);
+					} else {
+					    BEGIN(CELLDATA);
+					}
 					break;
 				case '[':
 					DPRINT("BYTESTRING\n");
-					BEGIN(BYTESTRING);
+					if (dts_version == 0) {
+					    BEGIN(BYTESTRING_LEGACY);
+					} else {
+					    BEGIN(BYTESTRING);
+					}
 					break;
 				default:
 
@@ -339,3 +411,35 @@ int pop_input_file(void)
 
 	return 1;
 }
+
+/*
+ * Convert a string representation of a numeric literal
+ * in the given base into a binary representation.
+ *
+ * FIXME: should these specification errors be fatal instead?
+ */
+
+u64 expr_from_string(char *s, unsigned int base)
+{
+	u64 v;
+	char *e;
+
+	v = strtoull(s, &e, base);
+	if (*e) {
+		fprintf(stderr,
+			"Line %d: Invalid literal value '%s' : "
+			"%c is not a base %d digit; %lld assumed\n",
+			yylloc.first_line, s, *e,
+			base == 0 ? expr_default_base : base,
+			(unsigned long long) v);
+	}
+
+	if (errno == EINVAL || errno == ERANGE) {
+		fprintf(stderr,
+			"Line %d: Invalid literal value '%s'; %lld assumed\n",
+			yylloc.first_line, s, (unsigned long long) v);
+		errno = 0;
+	}
+
+	return v;
+}
diff --git a/dtc-parser.y b/dtc-parser.y
index 4698793..fd82381 100644
--- a/dtc-parser.y
+++ b/dtc-parser.y
@@ -27,6 +27,8 @@
 
 int yylex(void);
 cell_t cell_from_string(char *s, unsigned int base);
+cell_t expr_cell_value(u64 c);
+u8 expr_byte_value(u64 c);
 
 extern struct boot_info *the_boot_info;
 
@@ -35,7 +37,6 @@ extern struct boot_info *the_boot_info;
 %union {
 	cell_t cval;
 	unsigned int cbase;
-	u8 byte;
 	char *str;
 	struct data data;
 	struct property *prop;
@@ -46,25 +47,27 @@ extern struct boot_info *the_boot_info;
 	int hexlen;
 	u64 addr;
 	struct reserve_info *re;
+	u64 ire;
 }
 
+%token DT_DTS_VERSION
 %token DT_MEMRESERVE
-%token <addr> DT_ADDR
 %token <str> DT_PROPNAME
 %token <str> DT_NODENAME
 %token <cbase> DT_BASE
-%token <str> DT_CELL
-%token <byte> DT_BYTE
 %token <data> DT_STRING
 %token <str> DT_UNIT
 %token <str> DT_LABEL
 %token <str> DT_REF
+%token <ire> DT_LITERAL
+%token DT_RANGE
 
 %type <data> propdata
 %type <data> propdataprefix
 %type <re> memreserve
 %type <re> memreserves
 %type <cbase> opt_cell_base
+%type <cval> cell
 %type <data> celllist
 %type <data> bytestring
 %type <prop> propdef
@@ -76,13 +79,27 @@ extern struct boot_info *the_boot_info;
 %type <nodelist> subnodes
 %type <str> label
 %type <str> nodename
+%type <ire> expr
+%type <ire> expr_primary
 
 %%
 
 sourcefile:
-	  memreserves devicetree
+	  opt_version memreserves devicetree
 		{
-			the_boot_info = build_boot_info($1, $2);
+			the_boot_info = build_boot_info($2, $3);
+		}
+	;
+
+opt_version:
+	  /* empty */
+		{
+			yywarn("Missing /dts-version/; 0 assumed.");
+			set_dts_version(0);
+		}
+	|  DT_DTS_VERSION expr ';'
+		{
+			set_dts_version($2);
 		}
 	;
 
@@ -98,11 +115,16 @@ memreserves:
 	;
 
 memreserve:
-	  label DT_MEMRESERVE DT_ADDR DT_ADDR ';'
+	  label DT_MEMRESERVE expr expr ';'
 		{
 			$$ = build_reserve_entry($3, $4, $1);
 		}
-	| label DT_MEMRESERVE DT_ADDR '-' DT_ADDR ';'
+	| label DT_MEMRESERVE expr '-' expr ';'
+		{
+			yywarn("/memreserve/ using '-' should be converted to '..' instead.");
+			$$ = build_reserve_entry($3, $5 - $3 + 1, $1);
+		}
+	| label DT_MEMRESERVE expr DT_RANGE expr ';'
 		{
 			$$ = build_reserve_entry($3, $5 - $3 + 1, $1);
 		}
@@ -179,19 +201,10 @@ propdataprefix:
 		}
 	;
 
-opt_cell_base:
-	  /* empty */
-		{
-			$$ = 16;
-		}
-	| DT_BASE
-	;
-
 celllist:
-	  celllist opt_cell_base DT_CELL
+	  celllist cell
 		{
-			$$ = data_append_cell($1,
-					      cell_from_string($3, $2));
+			$$ = data_append_cell($1, $2);
 		}
 	| celllist DT_REF
 		{
@@ -207,8 +220,39 @@ celllist:
 		}
 	;
 
+cell:
+	  expr
+		{
+			$$ = expr_cell_value($1);
+		}
+	;
+
+expr:
+	  expr_primary
+	;
+
+expr_primary:
+	  opt_cell_base DT_LITERAL
+		{
+			$$ = $2;
+		}
+	;
+
+opt_cell_base:
+	  /* empty */
+		{
+			/* This is a lot gross, but hopefully temporary. */
+			in_lexer_use_base = 16;
+		}
+	| DT_BASE
+		{
+			/* This is a lot gross, but hopefully temporary. */
+			in_lexer_use_base = $1;
+		}
+	;
+
 bytestring:
-	  bytestring DT_BYTE
+	  bytestring expr
 		{
 			$$ = data_append_byte($1, $2);
 		}
@@ -264,7 +308,7 @@ label:
 
 %%
 
-void yyerror (char const *s)
+void yyerror(char const *s)
 {
 	const char *fname = srcpos_filename_for_num(yylloc.filenum);
 
@@ -276,32 +320,37 @@ void yyerror (char const *s)
 }
 
 
-/*
- * Convert a string representation of a numeric cell
- * in the given base into a cell.
- *
- * FIXME: should these specification errors be fatal instead?
- */
+void yywarn(char const *s, ...)
+{
+	va_list ap;
+	const char *fname;
+
+	if (quiet >= 1)
+		return;
 
-cell_t cell_from_string(char *s, unsigned int base)
+	va_start(ap, s);
+
+	fname = srcpos_filename_for_num(yylloc.filenum);
+	if (strcmp(fname, "-") == 0)
+		fname = "stdin";
+
+	fprintf(stderr, "%s:%d Warning: ", fname, yylloc.first_line);
+	vfprintf(stderr, s, ap);
+	fprintf(stderr, "\n");
+}
+
+
+cell_t expr_cell_value(u64 c)
 {
-	cell_t c;
-	char *e;
-
-	c = strtoul(s, &e, base);
-	if (*e) {
-		fprintf(stderr,
-			"Line %d: Invalid cell value '%s' : "
-			"%c is not a base %d digit; %d assumed\n",
-			yylloc.first_line, s, *e, base, c);
-	}
-
-	if (errno == EINVAL || errno == ERANGE) {
-		fprintf(stderr,
-			"Line %d: Invalid cell value '%s'; %d assumed\n",
-			yylloc.first_line, s, c);
-		errno = 0;
-	}
-
-	return c;
+	/* FIXME: Range check to fit in u32 cell_t */
+
+	return (cell_t) c;
+}
+
+
+u8 expr_byte_value(u64 c)
+{
+	/* FIXME: Range check to fit in u8 byte */
+
+	return (u8) c;
 }
diff --git a/dtc.c b/dtc.c
index 76a6dfe..6417c2d 100644
--- a/dtc.c
+++ b/dtc.c
@@ -30,6 +30,32 @@ int quiet;		/* Level of quietness */
 int reservenum;		/* Number of memory reservation slots */
 int minsize;		/* Minimum blob size */
 
+/*
+ * DTS sourcefile version.
+ */
+unsigned int dts_version = 0;
+unsigned int expr_default_base = 10;
+
+
+void set_dts_version(u64 vers)
+{
+	if (vers > 1) {
+		yywarn("Unknown version %lld; 0 assumed\n", vers);
+		dts_version = 0;
+	} else {
+		dts_version = vers;
+	}
+
+	if (dts_version == 0) {
+		expr_default_base = 16;
+		in_lexer_use_base = 16;
+	} else {
+		expr_default_base = 10;
+		in_lexer_use_base = 10;
+	}
+}
+
+
 char *join_path(char *path, char *name)
 {
 	int lenp = strlen(path);
diff --git a/dtc.h b/dtc.h
index 09dec54..900ad9f 100644
--- a/dtc.h
+++ b/dtc.h
@@ -36,7 +36,14 @@
 
 #include <fdt.h>
 
+typedef uint8_t u8;
+typedef uint16_t u16;
+typedef uint32_t u32;
+typedef uint64_t u64;
+typedef u32 cell_t;
+
 #define DEFAULT_FDT_VERSION	17
+
 /*
  * Command line options
  */
@@ -44,6 +51,13 @@ extern int quiet;		/* Level of quietness */
 extern int reservenum;		/* Number of memory reservation slots */
 extern int minsize;		/* Minimum blob size */
 
+/*
+ * DTS sourcefile version
+ */
+extern unsigned int dts_version;
+extern void set_dts_version(u64 vers);
+
+
 static inline void __attribute__((noreturn)) die(char * str, ...)
 {
 	va_list ap;
@@ -74,12 +88,6 @@ static inline void *xrealloc(void *p, size_t len)
 	return new;
 }
 
-typedef uint8_t u8;
-typedef uint16_t u16;
-typedef uint32_t u32;
-typedef uint64_t u64;
-typedef u32 cell_t;
-
 #define cpu_to_be16(x)	htons(x)
 #define be16_to_cpu(x)	ntohs(x)
 
@@ -237,5 +245,8 @@ struct boot_info *dt_from_fs(char *dirname);
 
 char *join_path(char *path, char *name);
 void fill_fullpaths(struct node *tree, char *prefix);
+u64 expr_from_string(char *s, unsigned int base);
+extern unsigned int in_lexer_use_base;
+unsigned int expr_default_base;
 
 #endif /* _DTC_H */
diff --git a/srcpos.h b/srcpos.h
index ce7ab5b..c285e47 100644
--- a/srcpos.h
+++ b/srcpos.h
@@ -63,6 +63,7 @@ typedef struct YYLTYPE {
 
 
 extern void yyerror(char const *);
+extern void yywarn(char const *, ...);
 
 extern int srcpos_filenum;
 
diff --git a/treesource.c b/treesource.c
index f62041f..653be3a 100644
--- a/treesource.c
+++ b/treesource.c
@@ -147,7 +147,11 @@ static void write_propval_cells(FILE *f, struct data val)
 
 	fprintf(f, " = <");
 	for (;;) {
-		fprintf(f, "%x", be32_to_cpu(*cp++));
+		if (dts_version == 0) {
+			fprintf(f, "%x", be32_to_cpu(*cp++));
+		} else {
+			fprintf(f, "0x%x", be32_to_cpu(*cp++));
+		}
 		if ((void *)cp >= propend)
 			break;
 		fprintf(f, " ");
@@ -162,7 +166,11 @@ static void write_propval_bytes(FILE *f, struct data val)
 
 	fprintf(f, " = [");
 	for (;;) {
-		fprintf(f, "%02hhx", *bp++);
+		if (dts_version == 0) {
+			fprintf(f, "%02hhx", *bp++);
+		} else {
+			fprintf(f, "0x%02hhx", *bp++);
+		}
 		if ((void *)bp >= propend)
 			break;
 		fprintf(f, " ");
@@ -218,12 +226,22 @@ static void write_tree_source_node(FILE *f, struct node *tree, int level)
 void dt_to_source(FILE *f, struct boot_info *bi)
 {
 	struct reserve_info *re;
+	const char *range_str;
+
+	if (dts_version == 0) {
+	    range_str = " - ";
+	} else {
+	    range_str = " .. ";
+	    fprintf(f, "/dts-version/ %d;\n\n", dts_version);
+	}
 
 	for (re = bi->reservelist; re; re = re->next) {
-		fprintf(f, "/memreserve/\t%016llx-%016llx;\n",
+		fprintf(f, "/memreserve/\t0x%016llx %s 0x%016llx;\n",
 			(unsigned long long)re->re.address,
+			range_str,
 			(unsigned long long)(re->re.address + re->re.size - 1));
 	}
+	fprintf(f, "\n");
 
 	write_tree_source_node(f, bi->dt, 0);
 }
-- 
1.5.3.1.139.g9346b

^ permalink raw reply related

* [PATCH 3/4] DTC: Appease the printf() format $Gods with a correct type.
From: Jon Loeliger @ 2007-10-19 17:43 UTC (permalink / raw)
  To: linuxppc-dev


Signed-off-by: Jon Loeliger <jdl@freescale.com>
---
 tests/get_name.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/tests/get_name.c b/tests/get_name.c
index 2481741..a76bdf8 100644
--- a/tests/get_name.c
+++ b/tests/get_name.c
@@ -55,7 +55,7 @@ void check_name(void *fdt, const char *path)
 
 	if (len != strlen(getname))
 		FAIL("fdt_get_name(%s) returned length %d instead of %d",
-		     path, len, strlen(getname));
+		     path, len, (int) strlen(getname));
 
 	/* Now check that it doesn't break if we omit len */
 	getname2 = fdt_get_name(fdt, offset, NULL);
-- 
1.5.3.1.139.g9346b

^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox