LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH 7/8] pseries: phyp dump: Unregister and print dump areas.
From: Stephen Rothwell @ 2008-01-08  4:25 UTC (permalink / raw)
  To: Manish Ahuja; +Cc: mahuja, linuxppc-dev, linasvepstas, lkessler, strosake
In-Reply-To: <4782C5CB.4080802@austin.ibm.com>

[-- Attachment #1: Type: text/plain, Size: 2078 bytes --]

Hi Manish,

Just more trivial stuff.

On Mon, 07 Jan 2008 18:37:31 -0600 Manish Ahuja <ahuja@austin.ibm.com> wrote:
>
>  static void register_dump_area(struct phyp_dump_header *ph, unsigned long addr)
>  {
>  	int rc;
> -	ph->cpu_data.destination_address += addr;
> -	ph->hpte_data.destination_address += addr;
> -	ph->kernel_data.destination_address += addr;
>  
> +	/* Add addr value if not initialized before */
> +	if (ph->cpu_data.destination_address == 0) {
> +		ph->cpu_data.destination_address += addr;

Could be just '=' like further down, right?

> +static void invalidate_last_dump(struct phyp_dump_header *ph, unsigned long addr)
> +{

> +	if (rc)
> +	{

We prefer
	if (rc) {

> +static void unregister_dump_area(struct phyp_dump_header *ph)
> +{

> +	if (rc)
> +	{

And again.

>  static ssize_t
>  show_release_region(struct kset * kset, char *buf)

We normally put the function name on the same line as the type.

>  {
> -	return sprintf(buf, "ola\n");
> +	u64 second_addr_range;
> +
> +	/* total reserved size - start of scratch area */
> +	second_addr_range = phdr.cpu_data.destination_address -
> +				phyp_dump_info->init_reserve_size;
> +	return sprintf(buf, "CPU:0x%lx-0x%lx: HPTE:0x%lx-0x%lx:"
> +			    " DUMP:0x%lx-0x%lx, 0x%lx-0x%lx:\n",
> +	  phdr.cpu_data.destination_address, phdr.cpu_data.length_copied,
> +	  phdr.hpte_data.destination_address, phdr.hpte_data.length_copied,
> +	  phdr.kernel_data.destination_address, phdr.kernel_data.length_copied,
> +	  phyp_dump_info->init_reserve_start, second_addr_range);

This indentation should be (probably) two tabs.

> +	/* re-register the dump area, if old dump was invalid */
> +	if ((dump_header) && (dump_header->status & DUMP_ERROR_FLAG)) {
            ^           ^
Extra parentheses.

> +		invalidate_last_dump (&phdr, dump_area_start);
> +		register_dump_area (&phdr, dump_area_start);

No spaces after function names.

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply

* Re: [PATCH 6/8] pseries: phyp dump: debugging print routines.
From: Stephen Rothwell @ 2008-01-08  4:03 UTC (permalink / raw)
  To: Manish Ahuja; +Cc: mahuja, linuxppc-dev, linasvepstas, lkessler, strosake
In-Reply-To: <4782C53D.4060506@austin.ibm.com>

[-- Attachment #1: Type: text/plain, Size: 359 bytes --]

Hi Manish,

Just a trivial comment.

On Mon, 07 Jan 2008 18:35:09 -0600 Manish Ahuja <ahuja@austin.ibm.com> wrote:
>
> +	printk(KERN_INFO "dump disk section = %d\n",ph->dump_disk_section);

Please put a space after the ','.  Here and later.

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply

* Re: [PATCH][POWERPC] Workaround for iommu page alignment (#2)
From: Benjamin Herrenschmidt @ 2008-01-08  4:02 UTC (permalink / raw)
  To: Olof Johansson; +Cc: linuxppc-dev list, Paul Mackerras, Linux Kernel list
In-Reply-To: <20080108034824.GA7983@lixom.net>

> And sloppy of me to not catch it. Anyway:
> 
> Acked-by: Olof Johansson <olof@lixom.net>
> 
> I wonder how long until there's a device that has some other < PAGE_SIZE
> alignment bug^Wrequirement that we'll need to meet too. :(

Yeah, it's a worry...

Ben.

^ permalink raw reply

* Re: [PATCH 5/8] pseries: phyp dump: register dump area.
From: Stephen Rothwell @ 2008-01-08  3:59 UTC (permalink / raw)
  To: Manish Ahuja; +Cc: mahuja, linuxppc-dev, linasvepstas, lkessler, strosake
In-Reply-To: <4782C3AE.8060202@austin.ibm.com>

[-- Attachment #1: Type: text/plain, Size: 1569 bytes --]

Hi Manish,

On Mon, 07 Jan 2008 18:28:30 -0600 Manish Ahuja <ahuja@austin.ibm.com> wrote:
>
> +++ linux-2.6.24-rc3-git1/arch/powerpc/platforms/pseries/phyp_dump.c	2007-11-21 16:06:52.000000000 -0600
> +static unsigned long init_dump_header(struct phyp_dump_header *ph)
> +{

> +	/* Get the required dump region sizes */
> +	rtas = of_find_node_by_path("/rtas");

You need to of_node_put(rtas) somewhere.

> +	if (sizes[0] == 1)
> +		cpu_state_size = *((unsigned long *) &sizes[1]);

We normally don't put spaces after casts.

> +	ph->first_offset_section =
> +		(u32) &(((struct phyp_dump_header *) 0)->cpu_data);

		(u32)offsetof(struct phyp_dump_header, cpu_data);

> +static void register_dump_area(struct phyp_dump_header *ph, unsigned long addr)
> +{

> +	if (rc)
> +	{
> +		printk (KERN_ERR "phyp-dump: unexpected error (%d) on register\n", rc);
> +	}

The braces are not needed.

> +
> +	dump_area_length = init_dump_header (&phdr);

We don't put spaces after function names.

> +	free_area_length = phyp_dump_info->init_reserve_size - dump_area_length;
> +	dump_area_start = phyp_dump_info->init_reserve_start + free_area_length;
> +	dump_area_start = dump_area_start & PAGE_MASK; /* align down */
> +	free_area_length = dump_area_start - phyp_dump_info->init_reserve_start;
> +
>  	if (dump_header == NULL) {
> -		release_all();
> -		return 0;
> +		register_dump_area (&phdr, dump_area_start);

Ditto.

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply

* Re: [PATCH 4/8] pseries: phyp dump: use sysfs to release reserved mem
From: Stephen Rothwell @ 2008-01-08  3:45 UTC (permalink / raw)
  To: Manish Ahuja; +Cc: mahuja, linuxppc-dev, linasvepstas, lkessler, strosake
In-Reply-To: <4782C225.3060305@austin.ibm.com>

[-- Attachment #1: Type: text/plain, Size: 697 bytes --]

On Mon, 07 Jan 2008 18:21:57 -0600 Manish Ahuja <ahuja@austin.ibm.com> wrote:
>
> +static int __init phyp_dump_setup(void)
> +{
>
> +	/* Is there dump data waiting for us? */
> +	rtas = of_find_node_by_path("/rtas");
> +	dump_header = of_get_property(rtas, "ibm,kernel-dump", &header_len);
                                                               ^^^^^^^^^^^
You could pass NULL here as header_len appears to be unused. Also you
need "of_node_put(rtas)" somewhere (probably just here would do).

> +	if (dump_header == NULL) {
> +		release_all();
> +		return 0;
> +	}
-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply

* Re: [PATCH][POWERPC] Workaround for iommu page alignment (#2)
From: Olof Johansson @ 2008-01-08  3:48 UTC (permalink / raw)
  To: Benjamin Herrenschmidt
  Cc: linuxppc-dev list, Paul Mackerras, Linux Kernel list
In-Reply-To: <1199748862.6734.20.camel@pasglop>

On Tue, Jan 08, 2008 at 10:34:22AM +1100, Benjamin Herrenschmidt wrote:
> powerpc: Workaround for iommu page alignment
> 
> Our iommu page size is currently always 4K. That means with our current
> code, drivers may do a dma_map_sg() of a 64K page and obtain a dma_addr_t
> that is only 4K aligned.
> 
> This works fine in most cases except some infiniband HW it seems, where
> they tell the HW about the page size and it ignores the low bits of the
> DMA address.
> 
> This works around it by making our IOMMU code enforce a PAGE_SIZE alignment
> for mappings of objects that are page aligned in the first place and whose
> size is larger or equal to a page.
> 
> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> ---
> 
> And this version actually does what the comment says (I had forgotten
> to quilt ref... a common mistake).

And sloppy of me to not catch it. Anyway:

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

I wonder how long until there's a device that has some other < PAGE_SIZE
alignment bug^Wrequirement that we'll need to meet too. :(


-Olof

^ permalink raw reply

* RE: [PATCH 3/3] USB device tree cleanups
From: Li Yang @ 2008-01-08  3:32 UTC (permalink / raw)
  To: Stephen Rothwell; +Cc: linuxppc-dev
In-Reply-To: <20080108101028.db21d18a.sfr@canb.auug.org.au>

> -----Original Message-----
> From: linuxppc-dev-bounces+leoli=3Dfreescale.com@ozlabs.org=20
> [mailto:linuxppc-dev-bounces+leoli=3Dfreescale.com@ozlabs.org]=20
> On Behalf Of Stephen Rothwell
> Sent: Tuesday, January 08, 2008 7:10 AM
> To: Li Yang
> Cc: linuxppc-dev@ozlabs.org; paulus@samba.org
> Subject: Re: [PATCH 3/3] USB device tree cleanups
>=20
> On Mon,  7 Jan 2008 20:03:20 +0800 Li Yang=20
> <leoli@freescale.com> wrote:
> >
> > +++ b/arch/powerpc/sysdev/fsl_soc.c
> > @@ -533,9 +533,7 @@ static int __init fsl_usb_of_init(void)
> >  		*usb_dev_dr_client =3D NULL;
> >  	int ret;
> > =20
> > -	for (np =3D NULL, i =3D 0;
> > -	     (np =3D of_find_compatible_node(np, "usb",=20
> "fsl-usb2-mph")) !=3D NULL;
> > -	     i++) {
> > +	for_each_compatible_node(np, NULL, "fsl-usb2-mph") {
>=20
> 'i' is no longer being updated (or indeed set to anything)=20
> but is still used in the loop - at least in Paulus' current tree).

Good catch. My careless mistake.  Thanks.

- Leo

^ permalink raw reply

* Re: [PATCH 2/8] pseries: phyp dump: config file
From: Stephen Rothwell @ 2008-01-08  3:18 UTC (permalink / raw)
  To: Manish Ahuja; +Cc: mahuja, linuxppc-dev, linasvepstas, lkessler, strosake
In-Reply-To: <4782C0C8.2050702@austin.ibm.com>

[-- Attachment #1: Type: text/plain, Size: 445 bytes --]

On Mon, 07 Jan 2008 18:16:08 -0600 Manish Ahuja <ahuja@austin.ibm.com> wrote:
>
> 
> Add hypervisor-assisted dump to kernel config
> 
> Signed-off-by: Linas Vepstas <linas@austin.ibm.com>

This patch should probably come last in the series so that all the code
is there before some bisecting autobuilder tries to configure it.

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply

* Re: [PATCH 3/8] pseries: phyp dump: reserve-release proof-of-concept
From: Stephen Rothwell @ 2008-01-08  3:16 UTC (permalink / raw)
  To: Manish Ahuja; +Cc: mahuja, linuxppc-dev, linasvepstas, lkessler, strosake
In-Reply-To: <4782C2FB.7020105@austin.ibm.com>

[-- Attachment #1: Type: text/plain, Size: 1771 bytes --]

Hi Manish,

Just some trivial things ...

On Mon, 07 Jan 2008 18:25:31 -0600 Manish Ahuja <ahuja@austin.ibm.com> wrote:
>
> 
> +++ linux-2.6.24-rc2-git4/include/asm-powerpc/phyp_dump.h	2007-11-19 17:44:21.000000000 -0600
> +#ifndef _PPC64_PHYP_DUMP_H

We more usually use _ASM_POWERPC_PHYP_DUMP_H

> +#define _PPC64_PHYP_DUMP_H
> +
> +#ifdef CONFIG_PHYP_DUMP

Do these things really need protecting by this CONFIG variable? i.e. does
anything change depending on the visibility of these various symbols?

> +++ linux-2.6.24-rc2-git4/arch/powerpc/platforms/pseries/phyp_dump.c	2007-11-19 19:07:49.000000000 -0600
> @@ -0,0 +1,71 @@
> +/*
> + * Hypervisor-assisted dump
> + *
> + * Linas Vepstas, Manish Ahuja 2007
> + * Copyrhgit (c) 2007 IBM Corp.
      ^^^^^^^^^
typo.  and you should really be using '©' in new copyright notices (or
nothing).

> +/**
> + * release_memory_range -- release memory previously lmb_reserved
> + * @start_pfn: starting physical frame number
> + * @nr_pages: number of pages to free.
> + *
> + * This routine will release memory that had been previously
> + * lmb_reserved in early boot. The released memory becomes
> + * available for genreal use.
                    ^^^^^^^
typo.

> +release_memory_range(unsigned long start_pfn, unsigned long nr_pages)
> +{
> +	struct page *rpage;
> +	unsigned long end_pfn;
> +	long i;
> +
> +	end_pfn = start_pfn + nr_pages;
> +
> +	for (i=start_pfn; i <= end_pfn; i++) {

spaces around '='

> +static int __init phyp_dump_setup(void)
> +{

> +}
> +
> +subsys_initcall(phyp_dump_setup);

Normally we don't leave a blank line here.

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply

* Re: [PATCH v6] qe: add ability to upload QE firmware
From: Stephen Rothwell @ 2008-01-08  2:37 UTC (permalink / raw)
  To: Timur Tabi; +Cc: linuxppc-dev
In-Reply-To: <11997441442105-git-send-email-timur@freescale.com>

[-- Attachment #1: Type: text/plain, Size: 1249 bytes --]

On Mon,  7 Jan 2008 16:15:44 -0600 Timur Tabi <timur@freescale.com> wrote:
>
> +struct qe_firmware_info *qe_get_firmware_info(void)
> +{

> +	/* Find the 'firmware' child node */
> +	while ((fw = of_get_next_child(qe, fw)))

If you use:
	for_each_child_of_node(qe, fw)
You don't need to initialise 'fw' in its declararion.

> +	/* Did we find the 'firmware' node? */
> +	if (!fw) {
> +		of_node_put(fw);

This of_node_put is not necessary (as fw is NULL);

> +	prop = of_find_property(fw, "extended-modes", NULL);
> +	if (prop && (prop->length == sizeof(u64))) {
> +		const u64 *iprop = prop->value;
> +
> +		qe_firmware_info.extended_modes = *iprop;
> +	}

Why not:
	const u64 *iprop;
	int len;

	iprop = of_get_property(fs, "extended-modes", &len);
	if (iprop && (len == sizeof(u64))
		qe_firmware_info.extended_modes = *iprop;

> +	prop = of_find_property(fw, "virtual-traps", NULL);
> +	if (prop && (prop->length == 32)) {
> +		const u32 *iprop = prop->value;
> +
> +		for (i = 0; i < ARRAY_SIZE(qe_firmware_info.vtraps); i++)
> +			qe_firmware_info.vtraps[i] = iprop[i];
> +	}

And similarly?

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply

* How complete should the DTS be?
From: Sean MacLennan @ 2008-01-08  2:07 UTC (permalink / raw)
  To: linuxppc-dev

Just a general question about DTS "completeness". Like all 440EP 
processors, the taco has two i2c buses. However, only one bus has 
anything connected to it.

Should I show both bus entries in the DTS, or only the one that is used? 
I have generally only been showing the devices that are present. i.e. 
Only one emac, only one serial port.

Is there a convention for this?

Cheers,
   Sean

^ permalink raw reply

* [PATCH] i2c-ibm_iic driver - new patch
From: Sean MacLennan @ 2008-01-08  2:03 UTC (permalink / raw)
  To: Arnd Bergmann, linuxppc-dev, Stefan Roese
In-Reply-To: <20080106001238.GI4326@localhost.localdomain>

[-- Attachment #1: Type: text/plain, Size: 1125 bytes --]

Second attempt. I think I have covered all the comments. It now should 
work with both ppc and powerpc architectures.

You can now specify fast-mode in the .dts file.

You can now specify an index for each entry.  If you don't I try to 
chose reasonable defaults. i.e. I keep a static int that is incremented. 
If you mix index entries with non-index entries, you are on your own.

Below is the example for the taco, I have shown fast-mode set in IIC1 as 
an example:

            IIC0: i2c@ef600700 {
                device_type = "i2c";
                compatible = "ibm,iic-440ep", "ibm,iic-440gp", "ibm,iic";
                reg = <ef600700 14>;
                interrupt-parent = <&UIC0>;
                interrupts = <2 4>;
                index = <0>;
            };

            IIC1: i2c@ef600800 {
                device_type = "i2c";
                compatible = "ibm,iic-440ep", "ibm,iic-440gp", "ibm,iic";
                reg = <ef600800 14>;
                interrupt-parent = <&UIC0>;
                interrupts = <7 4>;
                index = <1>;
                fast-mode;
            };

Cheers,
   Sean


[-- Attachment #2: i2c-patch --]
[-- Type: text/plain, Size: 6512 bytes --]

diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index c466c6c..e9e1493 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -241,7 +241,6 @@ config I2C_PIIX4
 
 config I2C_IBM_IIC
 	tristate "IBM PPC 4xx on-chip I2C interface"
-	depends on IBM_OCP
 	help
 	  Say Y here if you want to use IIC peripheral found on 
 	  embedded IBM PPC 4xx based systems. 
diff --git a/drivers/i2c/busses/i2c-ibm_iic.c b/drivers/i2c/busses/i2c-ibm_iic.c
index 9b43ff7..0b10bb1 100644
--- a/drivers/i2c/busses/i2c-ibm_iic.c
+++ b/drivers/i2c/busses/i2c-ibm_iic.c
@@ -6,7 +6,10 @@
  * Copyright (c) 2003, 2004 Zultys Technologies.
  * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net>
  *
- * Based on original work by 
+ * Copyright (c) 2008 PIKA Technologies
+ * Sean MacLennan <smaclennan@pikatech.com>
+ *
+ * Based on original work by
  * 	Ian DaSilva  <idasilva@mvista.com>
  *      Armin Kuster <akuster@mvista.com>
  * 	Matt Porter  <mporter@mvista.com>
@@ -39,12 +42,17 @@
 #include <asm/io.h>
 #include <linux/i2c.h>
 #include <linux/i2c-id.h>
+
+#ifdef CONFIG_IBM_OCP
 #include <asm/ocp.h>
 #include <asm/ibm4xx.h>
+#else
+#include <linux/of_platform.h>
+#endif
 
 #include "i2c-ibm_iic.h"
 
-#define DRIVER_VERSION "2.1"
+#define DRIVER_VERSION "2.2"
 
 MODULE_DESCRIPTION("IBM IIC driver v" DRIVER_VERSION);
 MODULE_LICENSE("GPL");
@@ -657,6 +665,7 @@ static inline u8 iic_clckdiv(unsigned int opb)
 	return (u8)((opb + 9) / 10 - 1);
 }
 
+#ifdef CONFIG_IBM_OCP
 /*
  * Register single IIC interface
  */
@@ -831,3 +840,192 @@ static void __exit iic_exit(void)
 
 module_init(iic_init);
 module_exit(iic_exit);
+#else
+/*
+ * Register single IIC interface
+ */
+static int __devinit iic_probe(struct of_device *ofdev,
+							   const struct of_device_id *match)
+{
+	static int index = 0;
+	struct device_node *np = ofdev->node;
+	struct ibm_iic_private* dev;
+	struct i2c_adapter* adap;
+	const u32 *addrp, *freq;
+	u64 addr;
+	int ret;
+
+	if (!(dev = kzalloc(sizeof(*dev), GFP_KERNEL))) {
+		printk(KERN_CRIT "ibm-iic: failed to allocate device data\n");
+		return -ENOMEM;
+	}
+
+	/* This assumes we don't mix index and non-index entries. */
+	if((addrp = of_get_property(np, "index", NULL)))
+		dev->idx = *addrp;
+	else
+		dev->idx = index++;
+
+	dev_set_drvdata(&ofdev->dev, dev);
+
+	if((addrp = of_get_address(np, 0, NULL, NULL)) == NULL ||
+	   (addr = of_translate_address(np, addrp)) == OF_BAD_ADDR) {
+		printk(KERN_CRIT "ibm-iic%d: Unable to get iic address\n",
+			   dev->idx);
+		ret = -EBUSY;
+		goto fail1;
+	}
+
+	if (!(dev->vaddr = ioremap(addr, sizeof(struct iic_regs)))){
+		printk(KERN_CRIT "ibm-iic%d: failed to ioremap device registers\n",
+			dev->idx);
+		ret = -ENXIO;
+		goto fail1;
+	}
+
+	init_waitqueue_head(&dev->wq);
+
+	if(iic_force_poll)
+		dev->irq = NO_IRQ;
+	else if((dev->irq = irq_of_parse_and_map(np, 0)) == NO_IRQ)
+		printk(KERN_ERR __FILE__ ": irq_of_parse_and_map failed\n");
+
+	if (dev->irq != NO_IRQ) {
+		/* Disable interrupts until we finish initialization,
+		   assumes level-sensitive IRQ setup...
+		 */
+		iic_interrupt_mode(dev, 0);
+		if(request_irq(dev->irq, iic_handler, 0, "IBM IIC", dev)){
+			printk(KERN_ERR "ibm-iic%d: request_irq %d failed\n",
+				   dev->idx, dev->irq);
+			/* Fallback to the polling mode */
+			dev->irq = NO_IRQ;
+		}
+	}
+
+	if (dev->irq == NO_IRQ)
+		printk(KERN_WARNING "ibm-iic%d: using polling mode\n",
+			   dev->idx);
+
+	/* Board specific settings */
+	if(iic_force_fast || of_get_property(np, "fast-mode", NULL))
+		dev->fast_mode = 1;
+	else
+		dev->fast_mode = 0;
+
+	/* clckdiv is the same for *all* IIC interfaces, but I'd rather
+	 * make a copy than introduce another global. --ebs
+	 */
+	if((freq = of_get_property(np, "clock-frequency", NULL)) == NULL &&
+	   (freq = of_get_property(np->parent, "clock-frequency", NULL)) == NULL) {
+		printk(KERN_CRIT "ibm-iic%d: Unable to get bus frequency\n", dev->idx);
+		ret = -EBUSY;
+		goto fail;
+	}
+
+	dev->clckdiv = iic_clckdiv(*freq);
+	DBG("%d: clckdiv = %d\n", dev->idx, dev->clckdiv);
+
+	/* Initialize IIC interface */
+	iic_dev_init(dev);
+
+	/* Register it with i2c layer */
+	adap = &dev->adap;
+	adap->dev.parent = &ofdev->dev;
+	strcpy(adap->name, "IBM IIC");
+	i2c_set_adapdata(adap, dev);
+	adap->id = I2C_HW_OCP;
+	adap->class = I2C_CLASS_HWMON;
+	adap->algo = &iic_algo;
+	adap->client_register = NULL;
+	adap->client_unregister = NULL;
+	adap->timeout = 1;
+	adap->retries = 1;
+	adap->nr = dev->idx;
+
+	if ((ret = i2c_add_numbered_adapter(adap)) < 0) {
+		printk(KERN_CRIT "ibm-iic%d: failed to register i2c adapter\n",
+			dev->idx);
+		goto fail;
+	}
+
+	printk(KERN_INFO "ibm-iic%d: using %s mode\n", dev->idx,
+		dev->fast_mode ? "fast (400 kHz)" : "standard (100 kHz)");
+
+	return 0;
+
+fail:
+	if (dev->irq != NO_IRQ){
+		iic_interrupt_mode(dev, 0);
+		free_irq(dev->irq, dev);
+	}
+
+	iounmap(dev->vaddr);
+fail1:
+	dev_set_drvdata(&ofdev->dev, NULL);
+	kfree(dev);
+	return ret;
+}
+
+/*
+ * Cleanup initialized IIC interface
+ */
+static int __devexit iic_remove(struct of_device *ofdev)
+{
+	struct ibm_iic_private* dev = (struct ibm_iic_private*)dev_get_drvdata(&ofdev->dev);
+
+	BUG_ON(dev == NULL);
+	if (i2c_del_adapter(&dev->adap)){
+		printk(KERN_CRIT "ibm-iic%d: failed to delete i2c adapter :(\n",
+			dev->idx);
+		/* That's *very* bad, just shutdown IRQ ... */
+		if (dev->irq >= 0){
+		    iic_interrupt_mode(dev, 0);
+		    free_irq(dev->irq, dev);
+		    dev->irq = -1;
+		}
+	} else {
+		if (dev->irq != NO_IRQ){
+		    iic_interrupt_mode(dev, 0);
+		    free_irq(dev->irq, dev);
+		}
+		iounmap(dev->vaddr);
+		kfree(dev);
+	}
+
+	return 0;
+}
+
+
+static struct of_device_id ibm_iic_match[] =
+{
+	{ .type = "i2c", .compatible = "ibm,iic-405ex", },
+	{ .type = "i2c", .compatible = "ibm,iic-405gp", },
+	{ .type = "i2c", .compatible = "ibm,iic-440gp", },
+	{ .type = "i2c", .compatible = "ibm,iic-440gpx", },
+	{ .type = "i2c", .compatible = "ibm,iic-440grx", },
+	{}
+};
+
+static struct of_platform_driver ibm_iic_driver =
+{
+	.name   = "ibm-iic",
+	.match_table = ibm_iic_match,
+	.probe  = iic_probe,
+	.remove = iic_remove,
+};
+
+static int __init ibm_iic_init(void)
+{
+	printk(KERN_INFO "IBM IIC driver v" DRIVER_VERSION "\n");
+	return of_register_platform_driver(&ibm_iic_driver);
+}
+module_init(ibm_iic_init);
+
+static void __exit ibm_iic_exit(void)
+{
+	of_unregister_platform_driver(&ibm_iic_driver);
+}
+module_exit(ibm_iic_exit);
+#endif
+

^ permalink raw reply related

* Re: How to config linux kernel(ARCH=powerpc)?
From: Josh Boyer @ 2008-01-08  1:55 UTC (permalink / raw)
  To: tony, jie han; +Cc: linuxppc-embedded
In-Reply-To: <200801080918222817608@163.com>

On Tue, 8 Jan 2008 09:18:23 +0800
"tony" <hangtoo@163.com> wrote:

> hi Jie
> maybe you should try it like this:
> linux-2.6-denx->make ARCH=ppc CROSS_COMPILE=ppc_4xx- pasemi_defconfig
> make sure you have installed the ppc_4xx- tools.

Um.. no.  pasemi is a 64bit CPU.  Get the powerpc tree from kernel.org,
make sure you have a PowerPC 64bit toolchain, and try with make
ARCH=powerpc

josh

^ permalink raw reply

* Re:How to config linux kernel(ARCH=powerpc)?
From: tony @ 2008-01-08  1:18 UTC (permalink / raw)
  To: linuxppc-embedded

[-- Attachment #1: Type: text/plain, Size: 194 bytes --]

hi Jie
maybe you should try it like this:
linux-2.6-denx->make ARCH=ppc CROSS_COMPILE=ppc_4xx- pasemi_defconfig
make sure you have installed the ppc_4xx- tools.
good luck

tony

               

[-- Attachment #2: Type: text/html, Size: 945 bytes --]

^ permalink raw reply

* Re: [PATCH] i2c-ibm_iic driver
From: Sean MacLennan @ 2008-01-08  1:16 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: linuxppc-dev
In-Reply-To: <200801051224.52693.arnd@arndb.de>

Arnd Bergmann wrote:
> If there is a good reason to specify fast or slow mode per board, you may want
> to make that a property in the device node.
>   
I tried to add fast_mode to the .dts file and failed.

            IIC1: i2c@ef600800 {
                device_type = "i2c";
                compatible = "ibm,iic-440ep", "ibm,iic-440gp", "ibm,iic";
                reg = <ef600800 14>;
                interrupt-parent = <&UIC0>;
                interrupts = <7 4>;
                fast-mode = <0>;
            };

As soon as a I add the fast-mode line I get the following error on boot:

fdt_wrapper_setprop():105  FDT_ERR_NOSPACE

Remove the line and I boot. Any ideas?

Cheers,
   Sean

^ permalink raw reply

* Re: [PATCH 3/8] pseries: phyp dump: reserve-release proof-of-concept
From: Michael Ellerman @ 2008-01-08  1:13 UTC (permalink / raw)
  To: linasvepstas; +Cc: mahuja, linuxppc-dev, lkessler, strosake, Arnd Bergmann
In-Reply-To: <3ae3aa420801071649w6a8d3939y176dc389d68f4870@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1945 bytes --]

On Mon, 2008-01-07 at 18:49 -0600, Linas Vepstas wrote:
> On 07/01/2008, Arnd Bergmann <arnd@arndb.de> wrote:
> > On Tuesday 08 January 2008, Manish Ahuja wrote:
> >
> > > Initial patch for reserving memory in early boot, and freeing it later.
> > > If the previous boot had ended with a crash, the reserved memory would contain
> > > a copy of the crashed kernel data.
> > >
> > > Signed-off-by: Manish Ahuja <mahuja@us.ibm.com>
> > > Signed-off-by: Linas Vepstas <linas@austin.ibm.com>
> >
> > I think the signed-off-by chain needs to be modified. The way it appears,
> > you handled the patch first, then sent it to Linas, who forwarded it
> > to whoever will take the patches from the list.

> > This obviously isn't true, since you are actually the one who is sending
> > out the patches. Moreover, I believe that the linas@austin.ibm.com
> > address is now dead, and shouldn't be used for this any more.
> 
> Hmm. I wanted to indicate that the work was done while I was at IBM;
> clearly, no one is going through git and changing old, expired email
> addrs, and so submission based on the old addr seemed appropriate.
> 
> I'm taking the Signed-off-by line as a quasi-legal thing: a fancy ID string,
> identifying the author(s),  rather than a new way to manage email
> address books.

No one's changing the git history (you can't), but it seems silly to
submit a patch with an address that is already dead. There is a general
expectation that if/when someone finds a bug in the code they can email
the signed-off-by addresses and get a real person.

As far as indicating it was written at IBM, that should be covered by
the copyright notices.

cheers

-- 
Michael Ellerman
OzLabs, IBM Australia Development Lab

wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)

We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply

* Re: [RFC 1/2] mpc5200: Add common clock setting routine mpc52xx_set_psc_clkdiv()
From: Stephen Rothwell @ 2008-01-08  1:04 UTC (permalink / raw)
  To: Grant Likely; +Cc: linuxppc-dev, dragos.carp
In-Reply-To: <20080107190335.13535.29837.stgit@trillian.secretlab.ca>

[-- Attachment #1: Type: text/plain, Size: 1247 bytes --]

On Mon, 07 Jan 2008 12:03:59 -0700 Grant Likely <grant.likely@secretlab.ca> wrote:
>
> +++ b/arch/powerpc/platforms/52xx/mpc52xx_common.c
>  
> -static struct of_device_id __init mpc52xx_ids[] = {

Why not just leave this here and mark in __initdata?

> +/**
> + * mpc52xx_declare_of_platform_devices: register internal devices and children
> + *					of the localplus bus to the of_platform
> + *					bus.
> + */
>  void __init
>  mpc52xx_declare_of_platform_devices(void)
>  {
> +	const static struct of_device_id mpc52xx_bus_ids[] = {

Or just mark it __initdata instead of const?

> +		{ .compatible = "fsl,mpc5200-immr", },
> +		{ .compatible = "fsl,lpb", },
> +		{ .type = "builtin", .compatible = "mpc5200", }, /* efika */
> +		{ .type = "soc", .compatible = "mpc5200", }, /* old */

And you lost the comment about the last two being deprecated mates.

> +mpc52xx_map_common_devices(void)
>  {
>  	struct device_node *np;
> -	struct of_device_id gpt_ids[] = {
> +	const static struct of_device_id gpt_ids[] = {

Again __initdata?

> +	const static struct of_device_id cdm_ids[] = {

And again?

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply

* Re: [PATCH v2] [POWERPC] Update MPC8610 HPCD to support audio drivers
From: Stephen Rothwell @ 2008-01-08  0:56 UTC (permalink / raw)
  To: Timur Tabi; +Cc: liam.girdwood, alsa-devel, linuxppc-dev
In-Reply-To: <1199732204578-git-send-email-timur@freescale.com>

[-- Attachment #1: Type: text/plain, Size: 922 bytes --]

Hi Timur,

On Mon,  7 Jan 2008 12:56:43 -0600 Timur Tabi <timur@freescale.com> wrote:
>
> +++ b/arch/powerpc/platforms/86xx/mpc8610_hpcd.c
> @@ -34,9 +34,27 @@
>  
>  #include <asm/mpic.h>
>  
> +#include <linux/of_platform.h>
>  #include <sysdev/fsl_pci.h>
>  #include <sysdev/fsl_soc.h>
>  
> +static struct of_device_id mpc8610_ids[] = {

__initdata

> +	{ .compatible = "fsl,mpc8610", },
> +	{}
> +};
> +
> +static int __init mpc8610_declare_of_platform_devices(void)
> +{
> +	if (!machine_is(mpc86xx_hpcd))
> +		return 0;
> +
> +	/* Without this call, the SSI device driver won't get probed. */
> +	of_platform_bus_probe(NULL, mpc8610_ids, NULL);
> +
> +	return 0;
> +}
> +device_initcall(mpc8610_declare_of_platform_devices);

We have machine_device_initcall for this now.

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply

* Re: [PATCH 6/8] pseries: phyp dump: debugging print routines.
From: Arnd Bergmann @ 2008-01-08  0:49 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: mahuja, lkessler, linasvepstas, strosake
In-Reply-To: <4782C53D.4060506@austin.ibm.com>

On Tuesday 08 January 2008, Manish Ahuja wrote:
> +#ifdef DEBUG
> +static void print_dump_header(const struct phyp_dump_header *ph)
> +{
> +=A0=A0=A0=A0=A0=A0=A0printk(KERN_INFO "dump header:\n");
> ...
> +=A0=A0=A0=A0=A0=A0=A0printk(KERN_INFO "SRSD length_copied =3D%lx\n",ph->=
kernel_data.length_copied);
> +}
> +#endif
> +

If you move the #if to inside of the function,

> =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0printk (KERN_ERR "phyp-du=
mp: unexpected error (%d) on register\n", rc);
> +#ifdef DEBUG
> +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0print_dump_header (ph);
> +#endif
> =A0=A0=A0=A0=A0=A0=A0=A0}

> =A0=A0=A0=A0=A0=A0=A0=A0}
> +#ifdef DEBUG
> +=A0=A0=A0=A0=A0=A0=A0print_dump_header (dump_header);
> +#endif


you don't need the #ifdefs here.

	Arnd <><

^ permalink raw reply

* Re: [PATCH 3/8] pseries: phyp dump: reserve-release proof-of-concept
From: Manish Ahuja @ 2008-01-08  0:50 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: mahuja, linuxppc-dev, linasvepstas, lkessler, strosake
In-Reply-To: <200801080126.51897.arnd@arndb.de>

Arnd,

Sorry this patch ended up out of sequence. I reposted it properly again in the other thread.

We did talk about using gmail address, but Linas was more comfortable using this as this is
where he was, when we did this. Hence the use of Austin address with gmail being on the cc list.

I am sure he will chime in with more details about it when he gets the opportunity.

Thanks,
Manish



Arnd Bergmann wrote:
> On Tuesday 08 January 2008, Manish Ahuja wrote:
> 
>> Initial patch for reserving memory in early boot, and freeing it later.
>> If the previous boot had ended with a crash, the reserved memory would contain
>> a copy of the crashed kernel data.
>>
>> Signed-off-by: Manish Ahuja <mahuja@us.ibm.com>
>> Signed-off-by: Linas Vepstas <linas@austin.ibm.com>
> 
> I think the signed-off-by chain needs to be modified. The way it appears,
> you handled the patch first, then sent it to Linas, who forwarded it
> to whoever will take the patches from the list.
> 
> This obviously isn't true, since you are actually the one who is sending
> out the patches. Moreover, I believe that the linas@austin.ibm.com
> address is now dead, and shouldn't be used for this any more.
> 
> So, depending on which of you two wrote the majority of a patch, I think
> it should be either
> 
> | Signed-off-by: Manish Ahuja <mahuja@us.ibm.com>
> | Acked-by: Linas Vepstas <linasvepstas@gmail.com>
> 
> or 
> 
> | From: Linas Vepstas <linasvepstas@gmail.com>
> | Signed-off-by: Manish Ahuja <mahuja@us.ibm.com>
> 
> 	Arnd <><

^ permalink raw reply

* Re: [PATCH 3/8] pseries: phyp dump: reserve-release proof-of-concept
From: Linas Vepstas @ 2008-01-08  0:49 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: mahuja, linuxppc-dev, lkessler, strosake
In-Reply-To: <200801080126.51897.arnd@arndb.de>

On 07/01/2008, Arnd Bergmann <arnd@arndb.de> wrote:
> On Tuesday 08 January 2008, Manish Ahuja wrote:
>
> > Initial patch for reserving memory in early boot, and freeing it later.
> > If the previous boot had ended with a crash, the reserved memory would contain
> > a copy of the crashed kernel data.
> >
> > Signed-off-by: Manish Ahuja <mahuja@us.ibm.com>
> > Signed-off-by: Linas Vepstas <linas@austin.ibm.com>
>
> I think the signed-off-by chain needs to be modified. The way it appears,
> you handled the patch first, then sent it to Linas, who forwarded it
> to whoever will take the patches from the list.

Well,
-- there was dual authorship. I remangled the patches while Manish wrote
code & tested. And I'd mailed them out the first time around, so you could
say I forwarded after heavy editing.


> This obviously isn't true, since you are actually the one who is sending
> out the patches. Moreover, I believe that the linas@austin.ibm.com
> address is now dead, and shouldn't be used for this any more.

Hmm. I wanted to indicate that the work was done while I was at IBM;
clearly, no one is going through git and changing old, expired email
addrs, and so submission based on the old addr seemed appropriate.

I'm taking the Signed-off-by line as a quasi-legal thing: a fancy ID string,
identifying the author(s),  rather than a new way to manage email
address books.

> So, depending on which of you two wrote the majority of a patch, I think
> it should be either

I'm not sure there was a clear majority. I think Manish did more work
in general, but we hacked this together side by side. I got him to create
working tested code; I busted it up into individual, clean, documented,
mailing-list ready chunks.

--linas

^ permalink raw reply

* Re: [RFC] Add of_find_matching_node() helper function
From: Stephen Rothwell @ 2008-01-08  0:48 UTC (permalink / raw)
  To: Grant Likely; +Cc: linuxppc-dev, paulus
In-Reply-To: <20080107181418.11906.13427.stgit@trillian.secretlab.ca>

[-- Attachment #1: Type: text/plain, Size: 1227 bytes --]

Hi Grant,

On Mon, 07 Jan 2008 11:15:56 -0700 Grant Likely <grant.likely@secretlab.ca> wrote:
>
> +++ b/include/linux/of.h
> @@ -60,5 +66,7 @@ extern const void *of_get_property(const struct device_node *node,
>  				int *lenp);
>  extern int of_n_addr_cells(struct device_node *np);
>  extern int of_n_size_cells(struct device_node *np);
> +extern const struct of_device_id *of_match_node(
> +	const struct of_device_id *matches, const struct device_node *node);
>  
>  #endif /* _LINUX_OF_H */
> diff --git a/include/linux/of_device.h b/include/linux/of_device.h
> index 212bffb..6dc1195 100644
> --- a/include/linux/of_device.h
> +++ b/include/linux/of_device.h
> @@ -10,8 +10,6 @@
>  
>  #define	to_of_device(d) container_of(d, struct of_device, dev)
>  
> -extern const struct of_device_id *of_match_node(
> -	const struct of_device_id *matches, const struct device_node *node);
>  extern const struct of_device_id *of_match_device(
>  	const struct of_device_id *matches, const struct of_device *dev);

So you should really change all the callers of of_match_node to include linux/of.h.
-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply

* [PATCH 8/8] pseries: phyp dump: Tracking memory range freed.
From: Manish Ahuja @ 2008-01-08  0:39 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: mahuja, linasvepstas, lkessler, strosake
In-Reply-To: <4782B985.2090508@austin.ibm.com>



This patch tracks the size freed. For now it does a simple
rudimentary calculation of the ranges freed. The idea is
to keep it simple at the external shell script level and 
send in large chunks for now.

Signed-off-by: Manish Ahuja <mahuja@us.ibm.com>
-----

---
 arch/powerpc/platforms/pseries/phyp_dump.c |   36 +++++++++++++++++++++++++++++
 include/asm-powerpc/phyp_dump.h            |    3 ++
 2 files changed, 39 insertions(+)

Index: 2.6.24-rc5/include/asm-powerpc/phyp_dump.h
===================================================================
--- 2.6.24-rc5.orig/include/asm-powerpc/phyp_dump.h	2008-01-07 22:55:28.000000000 -0600
+++ 2.6.24-rc5/include/asm-powerpc/phyp_dump.h	2008-01-07 22:58:02.000000000 -0600
@@ -24,6 +24,9 @@ struct phyp_dump {
 	/* Memory that is reserved during very early boot. */
 	unsigned long init_reserve_start;
 	unsigned long init_reserve_size;
+	/* Scratch area memory details */
+	unsigned long scratch_reserve_start;
+	unsigned long scratch_reserve_size;
 };
 
 extern struct phyp_dump *phyp_dump_info;
Index: 2.6.24-rc5/arch/powerpc/platforms/pseries/phyp_dump.c
===================================================================
--- 2.6.24-rc5.orig/arch/powerpc/platforms/pseries/phyp_dump.c	2008-01-07 22:57:27.000000000 -0600
+++ 2.6.24-rc5/arch/powerpc/platforms/pseries/phyp_dump.c	2008-01-07 22:58:02.000000000 -0600
@@ -287,6 +287,39 @@ release_memory_range(unsigned long start
 	}
 }
 
+/**
+ * track_freed_range -- Counts the range being freed.
+ * Once the counter goes to zero, it re-registers dump for
+ * future use.
+ */
+static void
+track_freed_range(unsigned long addr, unsigned long length)
+{
+	static unsigned long scratch_area_size, reserved_area_size;
+
+	if (addr < phyp_dump_info->init_reserve_start)
+		return;
+
+	if ((addr >= phyp_dump_info->init_reserve_start) &&
+	    (addr <= phyp_dump_info->init_reserve_start +
+	     phyp_dump_info->init_reserve_size))
+		reserved_area_size += length;
+
+	if ((addr >= phyp_dump_info->scratch_reserve_start) &&
+	    (addr <= phyp_dump_info->scratch_reserve_start +
+	     phyp_dump_info->scratch_reserve_size))
+		scratch_area_size += length;
+
+	if ((reserved_area_size == phyp_dump_info->init_reserve_start) &&
+	    (scratch_area_size == phyp_dump_info->scratch_reserve_size)) {
+
+		invalidate_last_dump(&phdr,
+				phyp_dump_info->scratch_reserve_start);
+		register_dump_area (&phdr,
+				phyp_dump_info->scratch_reserve_start);
+	}
+}
+
 /* ------------------------------------------------- */
 /**
  * sysfs_release_region -- sysfs interface to release memory range.
@@ -310,6 +343,8 @@ store_release_region(struct kset *kset, 
 	if (ret != 2)
 		return -EINVAL;
 
+	track_freed_range(start_addr, length);
+
 	/* Range-check - don't free any reserved memory that
 	 * wasn't reserved for phyp-dump */
 	if (start_addr < phyp_dump_info->init_reserve_start)
@@ -414,6 +449,7 @@ static int __init phyp_dump_setup(void)
 	}
 
 	/* Don't allow user to release the 256MB scratch area */
+	/* this might be wrong */
 	phyp_dump_info->init_reserve_size = free_area_length;
 
 	/* Should we create a dump_subsys, analogous to s390/ipl.c ? */

^ permalink raw reply

* How to config linux kernel(ARCH=powerpc)?
From: jie han @ 2008-01-08  0:32 UTC (permalink / raw)
  To: linuxppc-embedded

[-- Attachment #1: Type: text/plain, Size: 808 bytes --]

Hi everyone:

I downloaded linux kernel 2.6 from www.denx.de and unzip the kernel source code.My operation is make mrproper at first and  then make pasemi_defconfig,it didn't work,the show message as follow:

linux-2.6-denx->make mrproper

linux-2.6-denx->make pasemi_defconfig
kernel/power/Kconfig:68:warning: 'select' used by config symbol 'PM_SLEEP_SMP' refers to undefined symbol 'HOTPLUG_CPU'
***
*** Can't find default configuration "arch/ppc/configs/pasemi_defconfig"!
***
make[1]: *** [pasemi_defconfig] Error 1
make: *** [pasemi_defconfig] Error 2

 I make the other default config file under arch/powperpc/configs directory,it show the same wrong message.How can I do fix it ?Thanks ahead,

Sincerely,

Jie


       
---------------------------------
Never miss a thing.   Make Yahoo your homepage.

[-- Attachment #2: Type: text/html, Size: 939 bytes --]

^ permalink raw reply

* [PATCH 7/8] pseries: phyp dump: Unregister and print dump areas.
From: Manish Ahuja @ 2008-01-08  0:37 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: mahuja, linasvepstas, lkessler, strosake
In-Reply-To: <4782B985.2090508@austin.ibm.com>


Routines to invalidate and unregister dump routines. 
Unregister has not been used yet, I will release another
patch for that at a later stage with the kdump integration patches.

There is also a routine which calculates the regions to be
freed and exports that through sysfs.

Signed-off-by: Manish Ahuja <mahuja@us.ibm.com>

---
 arch/powerpc/platforms/pseries/phyp_dump.c |   79 ++++++++++++++++++++++++++---
 1 file changed, 73 insertions(+), 6 deletions(-)

Index: 2.6.24-rc5/arch/powerpc/platforms/pseries/phyp_dump.c
===================================================================
--- 2.6.24-rc5.orig/arch/powerpc/platforms/pseries/phyp_dump.c	2008-01-07 18:06:11.000000000 -0600
+++ 2.6.24-rc5/arch/powerpc/platforms/pseries/phyp_dump.c	2008-01-07 22:57:27.000000000 -0600
@@ -69,6 +69,10 @@ static struct phyp_dump_header phdr;
 #define DUMP_SOURCE_CPU 0x0001
 #define DUMP_SOURCE_HPTE 0x0002
 #define DUMP_SOURCE_RMO  0x0011
+#define DUMP_ERROR_FLAG 0x2000
+#define DUMP_TRIGGERED 0x4000
+#define DUMP_PERFORMED 0x8000
+
 
 /**
  * init_dump_header() - initialize the header declaring a dump
@@ -187,10 +191,15 @@ static void print_dump_header(const stru
 static void register_dump_area(struct phyp_dump_header *ph, unsigned long addr)
 {
 	int rc;
-	ph->cpu_data.destination_address += addr;
-	ph->hpte_data.destination_address += addr;
-	ph->kernel_data.destination_address += addr;
 
+	/* Add addr value if not initialized before */
+	if (ph->cpu_data.destination_address == 0) {
+		ph->cpu_data.destination_address += addr;
+		ph->hpte_data.destination_address += addr;
+		ph->kernel_data.destination_address += addr;
+	}
+
+	/* ToDo Invalidate kdump and free memory range. */
 	do {
 		rc = rtas_call(ibm_configure_kernel_dump, 3, 1, NULL,
 		               1, ph, sizeof(struct phyp_dump_header));
@@ -205,6 +214,49 @@ static void register_dump_area(struct ph
 	}
 }
 
+static void invalidate_last_dump(struct phyp_dump_header *ph, unsigned long addr)
+{
+	int rc;
+
+	/* Add addr value if not initialized before */
+	if (ph->cpu_data.destination_address == 0) {
+		ph->cpu_data.destination_address = addr;
+		ph->hpte_data.destination_address += addr;
+		ph->kernel_data.destination_address += addr;
+	}
+
+	do {
+		rc = rtas_call(ibm_configure_kernel_dump, 3, 1, NULL,
+		               2, ph, sizeof(struct phyp_dump_header));
+	} while (rtas_busy_delay(rc));
+
+	if (rc)
+	{
+		printk (KERN_ERR "phyp-dump: unexpected error (%d) on invalidate\n", rc);
+#ifdef DEBUG
+		print_dump_header (ph);
+#endif
+	}
+}
+
+static void unregister_dump_area(struct phyp_dump_header *ph)
+{
+	int rc;
+
+	do {
+		rc = rtas_call(ibm_configure_kernel_dump, 3, 1, NULL,
+		               3, ph, sizeof(struct phyp_dump_header));
+	} while (rtas_busy_delay(rc));
+
+	if (rc)
+	{
+		printk (KERN_ERR "phyp-dump: unexpected error (%d) on unregister\n", rc);
+#ifdef DEBUG
+		print_dump_header (ph);
+#endif
+	}
+}
+
 /* ------------------------------------------------- */
 /**
  * release_memory_range -- release memory previously lmb_reserved
@@ -279,7 +331,17 @@ store_release_region(struct kset *kset, 
 static ssize_t
 show_release_region(struct kset * kset, char *buf)
 {
-	return sprintf(buf, "ola\n");
+	u64 second_addr_range;
+
+	/* total reserved size - start of scratch area */
+	second_addr_range = phdr.cpu_data.destination_address -
+				phyp_dump_info->init_reserve_size;
+	return sprintf(buf, "CPU:0x%lx-0x%lx: HPTE:0x%lx-0x%lx:"
+			    " DUMP:0x%lx-0x%lx, 0x%lx-0x%lx:\n",
+	  phdr.cpu_data.destination_address, phdr.cpu_data.length_copied,
+	  phdr.hpte_data.destination_address, phdr.hpte_data.length_copied,
+	  phdr.kernel_data.destination_address, phdr.kernel_data.length_copied,
+	  phyp_dump_info->init_reserve_start, second_addr_range);
 }
 
 static struct subsys_attribute rr = __ATTR(release_region, 0600,
@@ -344,6 +406,13 @@ static int __init phyp_dump_setup(void)
 		goto release_mem;
 	}
 
+	/* re-register the dump area, if old dump was invalid */
+	if ((dump_header) && (dump_header->status & DUMP_ERROR_FLAG)) {
+		invalidate_last_dump (&phdr, dump_area_start);
+		register_dump_area (&phdr, dump_area_start);
+		goto release_mem;
+	}
+
 	/* Don't allow user to release the 256MB scratch area */
 	phyp_dump_info->init_reserve_size = free_area_length;
 
@@ -354,8 +423,6 @@ static int __init phyp_dump_setup(void)
 		goto release_mem;
 	}
 
-	/* ToDo: re-register the dump area, for next time. */
-
 	return 0;
 
 release_mem:

^ permalink raw reply


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