LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] powerpc/405: Fix missing #{address,size}-cells in i2c node
From: Grant Likely @ 2011-01-03 22:06 UTC (permalink / raw)
  To: linuxppc-dev, jwboyer, solomon

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---

I'm putting this patch into my next-devicetree branch.

g.

 arch/powerpc/boot/dts/hotfoot.dts |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/boot/dts/hotfoot.dts b/arch/powerpc/boot/dts/hotfoot.dts
index cad9c38..71d3bb4 100644
--- a/arch/powerpc/boot/dts/hotfoot.dts
+++ b/arch/powerpc/boot/dts/hotfoot.dts
@@ -117,6 +117,8 @@
 			};
 
 			IIC: i2c@ef600500 {
+				#address-cells = <1>;
+				#size-cells = <0>;
 				compatible = "ibm,iic-405ep", "ibm,iic";
 				reg = <0xef600500 0x00000011>;
 				interrupt-parent = <&UIC0>;

^ permalink raw reply related

* [PATCH] powerpc/dts: fix syntax bugs in bluestone.dts
From: Grant Likely @ 2011-01-03 21:07 UTC (permalink / raw)
  To: tmarri, jwboyer, linuxppc-dev

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---

I'm picking this one up immediately into my next-devicetree branch

g.

 arch/powerpc/boot/dts/bluestone.dts |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/boot/dts/bluestone.dts b/arch/powerpc/boot/dts/bluestone.dts
index 9bb3d72..2a56a0d 100644
--- a/arch/powerpc/boot/dts/bluestone.dts
+++ b/arch/powerpc/boot/dts/bluestone.dts
@@ -33,7 +33,7 @@
 	aliases {
 		ethernet0 = &EMAC0;
 		serial0 = &UART0;
-		serial1 = &UART1;
+		//serial1 = &UART1; --gcl missing UART1 label
 	};
 
 	cpus {
@@ -52,7 +52,7 @@
 			d-cache-size = <32768>;
 			dcr-controller;
 			dcr-access-method = "native";
-			next-level-cache = <&L2C0>;
+			//next-level-cache = <&L2C0>; --gcl missing L2C0 label
 		};
 	};
 
@@ -142,7 +142,7 @@
 					/*RXEOB*/ 0x7 0x4
 					/*SERR*/  0x3 0x4
 					/*TXDE*/  0x4 0x4
-					/*RXDE*/  0x5 0x4
+					/*RXDE*/  0x5 0x4>;
 		};
 
 		POB0: opb {
@@ -182,7 +182,7 @@
 						reg = <0x001a0000 0x00060000>;
 					};
 				};
-			}
+			};
 
 			UART0: serial@ef600300 {
 				device_type = "serial";

^ permalink raw reply related

* Re: [RFC] MPIC Bindings and Bindings for AMP Systems
From: Scott Wood @ 2011-01-03 20:22 UTC (permalink / raw)
  To: Meador Inge; +Cc: linuxppc-dev, devicetree-discuss, Blanchard, Hollis
In-Reply-To: <4D12E4F1.2030004@mentor.com>

On Wed, 22 Dec 2010 23:58:09 -0600
Meador Inge <meador_inge@mentor.com> wrote:

> NOTE: The 'interrupt-parent' is implicit since message register nodes
>         are always children of interrupt controller nodes.
> 
> ** Example:
> 
> 	mpic: pic@40000 {
> 		interrupt-controller;
> 		#address-cells = <0>;
> 		#interrupt-cells = <2>;
> 		reg = <0x40000 0x40000>;
> 		compatible = "chrp,open-pic";
> 		device_type = "open-pic";
> 		protected-sources = <0xb1>;
> 
> 		msgr@1400 {
> 			compatible = "fsl,p2020-msgr", "fsl,mpic-msgr";
> 			reg = <0x1400 0x200>;
> 			cell-index = <0>;
> 			interrupts = <0xb0 0x2 0xb1 0x2
>                                        0xb2 0x2 0xb3 0x2>;
> 		};
> 
> 		msgr@2400 {
> 			compatible = "fsl,p2020-msgr", "fsl,mpic-msgr";
> 			reg = <0x2400 0x200>;
> 			cell-index = <1>;
> 			interrupts = <0xb4 0x2 0xb5 0x2
>                                        0xb6 0x2 0xb7 0x2>;
> 	         };	
> 	};

These nodes cannot go under the mpic node, because interrupt
controllers need #address-cells = <0>.

It would be nice if the binding provided some way of partitioning
up individual message interrupts within a block.

Interrupt generation could be exported as a "service", similar to
(inbound) interrupts and gpios.

Perhaps a something like this, with "doorbell" being a new standard
hw-independent service with its own binding:

msg1: mpic-msg@1400 {
	compatible = "fsl,mpic-v3.0-msg";
	reg = <0x1400 0x200>;
	interrupts <176 2 178 2>;

	// We have message registers 0 and 2 for sending,
	// and 1 and 3 for receiving.
	// If absent, we own all message registers in this block.
	fsl,mpic-msg-send-mask = <0x5>;
	fsl,mpic-msg-receive-mask = <0xa>;

	doorbell-controller;

	// split into #doorbell-send-cells and #doorbell-receive-cells?
	#doorbell-cells = <1>;
};

some-amp-protocol-thingy {
	send-doorbells = <&msg1 0>; // generate messages on MSGR0
	receive-doorbells = <&msg1 0>; // receive messages on MSGR1
};

some-other-amp-protocol-thingy {
	send-doorbells = <&msg1 1>; // generate messages on MSGR2
	receive-doorbells = <&msg1 1>; // receive messages on MSGR3
};

Doorbell capabilities such as passing a 32-bit message can be negotiated
between the drivers for the doorbell controller and the doorbell client.

-Scott

^ permalink raw reply

* Re: [RFC] MPIC Bindings and Bindings for AMP Systems
From: Scott Wood @ 2011-01-03 19:51 UTC (permalink / raw)
  To: Grant Likely
  Cc: Meador Inge, Blanchard, Hollis, devicetree-discuss, linuxppc-dev
In-Reply-To: <20101223223325.GK20384@angua.secretlab.ca>

On Thu, 23 Dec 2010 15:33:25 -0700
Grant Likely <grant.likely@secretlab.ca> wrote:

> On Thu, Dec 23, 2010 at 03:49:54PM -0600, Meador Inge wrote:
> > How do you
> > see this working in terms of processing the data?  It seems like we
> > are going to have to be aware of N values instead of 1, which seems
> > worse.
> 
> This argument has been rehashed many times, but it basically comes
> down to compatible values should ideally be anchored to a real
> implemented device, not to a family of devices, or to an unversioned
> specification.

Freescale MPICs do have version numbers (version registers, even).  We
should put that version (possibly along with a compatible version) in
the compatible, though, for blocks such as this which don't include the
main MPIC registers and thus the version registers.

> In practise, the implementation doesn't actually look any different
> except that the 'reference' version specifies a specific
> implementation instead of a generic name.  To use a concrete example,
> if there are two parts using this MPIC, like the freescale p2040 and
> p4080, and say for argument that the p2040 was implemented first, then
> the compatible values would look like:
> 
> for the p2040:   compatible = "fsl,p2040-msgr";
> for the p4080:   compatible = "fsl,p4080-msgr", "fsl,p2040-msgr";

While I don't think it affected the message unit, p4080 rev 1 has a
different version of the MPIC from p4080 rev 2 (4.0 versus 4.1, IIRC).

I don't think "mpic-" should be dropped, whether a specific chip is
added or not.  "msgr" just seems too generic, and "mpic-" tells the
reader where in the chip manual they can find information about it.

> > >?  This needs some more explanation.  cell-index often gets abused as
> > >a way to enumerate devices.  Typically, the address of the device
> > >itself is sufficient to identify the device.
> > 
> > The message registers typically come in blocks of four memory mapped
> > registers and may not be in contiguous memory (example [3]).  The
> > intent of 'cell-index' is to put an ordering on the blocks (so, yes,
> > enumeration).  We could order them by address as well I suppose.
> > One less property to worry about :)

But why do we care about ordering them?  What's important is just that
you use the same one on both the sending partition and the receiving
partition.

-Scott

^ permalink raw reply

* Re: PowerPC MPC5200B ATA MWDMA regression
From: Sergei Shtylyov @ 2011-01-03 16:33 UTC (permalink / raw)
  To: Tejun Heo, Roman Fietze; +Cc: linux-ide, linuxppc-dev
In-Reply-To: <4D21EAF1.2010504@ru.mvista.com>

Hello.

On 03-01-2011 18:27, Sergei Shtylyov wrote:

>>>> The commit you bisected to contains all those conversions too. Take a
>>>> look at a similar driver and look at how it has been converted
>>>> recently. Even better, just send the driver upstream. :-)

>>> It's already there...

>> Ouch, did I forget to convert

> It probably wasn't obvious as this driver had lived in non-BMDMA section of
> Kconfig before the recent patch:

> http://marc.info/?l=linux-ide&m=129303304605907

>> it or was it a merge timing problem?
>> Anyways, sorry about that. Please go ahead and fix it. :-)

    Looks like the commit that added DMA support should be thanked for the 
mischief:

http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=6b61e69e7bc1cfe80ab54c6321f19061f9487ed3

WBR, Sergei

^ permalink raw reply

* [PATCH] Make auto-loading of therm_pm72 possible
From: Marc Zyngier @ 2011-01-03 15:57 UTC (permalink / raw)
  To: Linux PPC Development

The therm_pm72 driver, used on the PowerMac G5 range, cannot be
auto-loaded, since the driver itself creates both the device node
and the driver instance.

Moving the device node creation to the platform setup code and
adding the necessary MODULE_DEVICE_TABLE() information allows the
driver to be automatically loaded by udev on any semi-modern
distribution.

It "fixes" a major source of problem on G5 machines where the
driver wasn't explicitely loaded by default, and the system
would automatically shutdown under load.

Tested on an Xserve G5.

Signed-off-by: Marc Zyngier <maz@misterjones.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
 arch/powerpc/platforms/powermac/setup.c |    9 +++++++++
 drivers/macintosh/therm_pm72.c          |   30 +++++-------------------------
 2 files changed, 14 insertions(+), 25 deletions(-)

diff --git a/arch/powerpc/platforms/powermac/setup.c b/arch/powerpc/platforms/powermac/setup.c
index 9deb274..d5aceb7 100644
--- a/arch/powerpc/platforms/powermac/setup.c
+++ b/arch/powerpc/platforms/powermac/setup.c
@@ -506,6 +506,15 @@ static int __init pmac_declare_of_platform_devices(void)
 		of_platform_device_create(np, "smu", NULL);
 		of_node_put(np);
 	}
+	np = of_find_node_by_type(NULL, "fcu");
+	if (np == NULL) {
+		/* Some machines have strangely broken device-tree */
+		np = of_find_node_by_path("/u3@0,f8000000/i2c@f8001000/fan@15e");
+	}
+	if (np) {
+		of_platform_device_create(np, "temperature", NULL);
+		of_node_put(np);
+	}
 
 	return 0;
 }
diff --git a/drivers/macintosh/therm_pm72.c b/drivers/macintosh/therm_pm72.c
index 4454927..2e041fd 100644
--- a/drivers/macintosh/therm_pm72.c
+++ b/drivers/macintosh/therm_pm72.c
@@ -2213,6 +2213,9 @@ static void fcu_lookup_fans(struct device_node *fcu_node)
 static int fcu_of_probe(struct platform_device* dev, const struct of_device_id *match)
 {
 	state = state_detached;
+	of_dev = dev;
+
+	dev_info(&dev->dev, "PowerMac G5 Thermal control driver %s\n", VERSION);
 
 	/* Lookup the fans in the device tree */
 	fcu_lookup_fans(dev->dev.of_node);
@@ -2235,6 +2238,7 @@ static const struct of_device_id fcu_match[] =
 	},
 	{},
 };
+MODULE_DEVICE_TABLE(of, fcu_match);
 
 static struct of_platform_driver fcu_of_platform_driver = 
 {
@@ -2252,8 +2256,6 @@ static struct of_platform_driver fcu_of_platform_driver =
  */
 static int __init therm_pm72_init(void)
 {
-	struct device_node *np;
-
 	rackmac = of_machine_is_compatible("RackMac3,1");
 
 	if (!of_machine_is_compatible("PowerMac7,2") &&
@@ -2261,34 +2263,12 @@ static int __init therm_pm72_init(void)
 	    !rackmac)
 	    	return -ENODEV;
 
-	printk(KERN_INFO "PowerMac G5 Thermal control driver %s\n", VERSION);
-
-	np = of_find_node_by_type(NULL, "fcu");
-	if (np == NULL) {
-		/* Some machines have strangely broken device-tree */
-		np = of_find_node_by_path("/u3@0,f8000000/i2c@f8001000/fan@15e");
-		if (np == NULL) {
-			    printk(KERN_ERR "Can't find FCU in device-tree !\n");
-			    return -ENODEV;
-		}
-	}
-	of_dev = of_platform_device_create(np, "temperature", NULL);
-	if (of_dev == NULL) {
-		printk(KERN_ERR "Can't register FCU platform device !\n");
-		return -ENODEV;
-	}
-
-	of_register_platform_driver(&fcu_of_platform_driver);
-	
-	return 0;
+	return of_register_platform_driver(&fcu_of_platform_driver);
 }
 
 static void __exit therm_pm72_exit(void)
 {
 	of_unregister_platform_driver(&fcu_of_platform_driver);
-
-	if (of_dev)
-		of_device_unregister(of_dev);
 }
 
 module_init(therm_pm72_init);
-- 
1.7.2.3

^ permalink raw reply related

* Re: PowerPC MPC5200B ATA MWDMA regression
From: Sergei Shtylyov @ 2011-01-03 15:27 UTC (permalink / raw)
  To: Tejun Heo; +Cc: linux-ide, linuxppc-dev, Sergei Shtylyov, Roman Fietze
In-Reply-To: <AANLkTi=5TrmxeWppabYaFUr-AhLwWcn4b_EQgLSJT44T@mail.gmail.com>

Hello.

On 03-01-2011 17:33, Tejun Heo wrote:

>>> The commit you bisected to contains all those conversions too.  Take a
>>> look at a similar driver and look at how it has been converted
>>> recently.  Even better, just send the driver upstream.  :-)

>>    It's already there...

> Ouch, did I forget to convert

    It probably wasn't obvious as this driver had lived in non-BMDMA section 
of Kconfig before the recent patch:

http://marc.info/?l=linux-ide&m=129303304605907

> it or was it a merge timing problem?
> Anyways, sorry about that.  Please go ahead and fix it. :-)

WBR, Sergei

^ permalink raw reply

* Re: [PATCH 1/5]arch:powerpc:platforms:85xx:mpc85xx_mds.c Typo change singal to signal
From: Jiri Kosina @ 2011-01-03 15:10 UTC (permalink / raw)
  To: Justin P. Mattock; +Cc: gregkh, linuxppc-dev, linux-kernel
In-Reply-To: <1293754184-1928-1-git-send-email-justinmattock@gmail.com>

On Thu, 30 Dec 2010, Justin P. Mattock wrote:

> The patches below fixes a typo "singal" to "signal". Please let me 
> know if anything needs to be changed.
> 
> Signed-off-by: Justin P. Mattock <justinmattock@gmail.com>
> 
> ---
>  arch/powerpc/platforms/85xx/mpc85xx_mds.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/arch/powerpc/platforms/85xx/mpc85xx_mds.c b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
> index aa34cac..747d1ee 100644
> --- a/arch/powerpc/platforms/85xx/mpc85xx_mds.c
> +++ b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
> @@ -309,7 +309,7 @@ static void __init mpc85xx_mds_qe_init(void)
>  			/* P1021 has pins muxed for QE and other functions. To
>  			 * enable QE UEC mode, we need to set bit QE0 for UCC1
>  			 * in Eth mode, QE0 and QE3 for UCC5 in Eth mode, QE9
> -			 * and QE12 for QE MII management singals in PMUXCR
> +			 * and QE12 for QE MII management signals in PMUXCR
>  			 * register.
>  			 */

Applied.

-- 
Jiri Kosina
SUSE Labs, Novell Inc.

^ permalink raw reply

* Re: PowerPC MPC5200B ATA MWDMA regression
From: Roman Fietze @ 2011-01-03 14:34 UTC (permalink / raw)
  To: Tejun Heo; +Cc: linux-ide, linuxppc-dev
In-Reply-To: <20110103135929.GO18831@htj.dyndns.org>

Hallo Tejun,

On Monday, 03.January.2011 14:59:29 Tejun Heo wrote:

> Which driver is it?

drivers/ata/pata_mpc52xx.c from the standard tree, 100% unchanged. As
I said, for the bisect I was using the original, unchanged
torvalds/master tree from git.kernel.org.

> You probably now want to use ata_bmdma_qc_issue() ...

I'm sorry, but if I would know about the details, and would know more
about ATA I would have tried to patch pata_mpc52xx.c by myself.

>  Even better, just send the driver upstream.

It has been there for a long while. You even patched it last summer.


Roman

-- 
Roman Fietze              Telemotive AG Buero Muehlhausen
Breitwiesen                             73347 Muehlhausen
Tel.: +49(0)7335/18493-45        http://www.telemotive.de

^ permalink raw reply

* Re: PowerPC MPC5200B ATA MWDMA regression
From: Tejun Heo @ 2011-01-03 14:33 UTC (permalink / raw)
  To: Sergei Shtylyov; +Cc: linux-ide, linuxppc-dev, Roman Fietze
In-Reply-To: <4D21DD55.2000000@ru.mvista.com>

On Mon, Jan 3, 2011 at 3:29 PM, Sergei Shtylyov <sshtylyov@mvista.com> wrot=
e:
>> The commit you bisected to contains all those conversions too. =A0Take a
>> look at a similar driver and look at how it has been converted
>> recently. =A0Even better, just send the driver upstream. =A0:-)
>
> =A0 It's already there...

Ouch, did I forget to convert it or was it a merge timing problem?
Anyways, sorry about that.  Please go ahead and fix it. :-)

--=20
tejun

^ permalink raw reply

* Re: PowerPC MPC5200B ATA MWDMA regression
From: Sergei Shtylyov @ 2011-01-03 14:29 UTC (permalink / raw)
  To: Tejun Heo; +Cc: linux-ide, linuxppc-dev, Roman Fietze
In-Reply-To: <20110103135929.GO18831@htj.dyndns.org>

Hello.

On 03-01-2011 16:59, Tejun Heo wrote:

>> When merging more recent kernel versions, tried that using v2.6.35 and
>> v2.6.36, into our tree (branched at v2.6.34), I detected, that MWDMA2
>> on the HW listed in the subject does no longer work.

>> So I bisected that using the original, standard kernel tree using a
>> minimum config using

>>     git bisect start v2.6.35 v2.6.34

>> The final result is:

>> 360ff7833098e944e5003618b03894251e937802 is the first bad commit
>> commit 360ff7833098e944e5003618b03894251e937802
>> Author: Tejun Heo<tj@kernel.org>
>> Date:   Mon May 10 21:41:42 2010 +0200

>>      libata-sff: separate out BMDMA qc_issue

>> ...


>> I double checked the failure with the latest torvalds/master as well
>> (b518a64983cbf2ff31), still the same issue.

>> The HW is an own board very close to the original Freescale
>> Lite5200/Lite5200B. The relevant part of the device tree source file
>> contains "mwdma-mode =<2>;" inside the ata section.

>> In the bad case the log always shows (the exact drive or drive type
>> doesn't matter, double checked):

>> [    1.553501] ata1.00: ATA-5: HEJ423020F9AT00, 00MJA0A0, max UDMA/100
>> [    1.560003] ata1.00: 39070080 sectors, multi 0: LBA
>> [    1.581418] ata1.00: configured for MWDMA2
>> [    1.586644] scsi 0:0:0:0: Direct-Access     ATA      HEJ423020F9AT00  00MJ PQ: 0 ANSI: 5
>> [    1.597831] sd 0:0:0:0: [sda] 39070080 512-byte logical blocks: (20.0 GB/18.6 GiB)
>> [    1.606876] sd 0:0:0:0: [sda] Write Protect is off
>> [    1.611907] sd 0:0:0:0: [sda] Mode Sense: 00 3a 00 00
>> [    1.617627] sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
>> [    1.629423]  sda:
>> [    1.631702] ------------[ cut here ]------------
>> [    1.636613] Badness at /home/fietze/src/linux-2.6-telemotive/drivers/ata/libata-sff.c:1466
>> [    1.645047] NIP: c01ae650 LR: c01ae624 CTR: c01accbc
>> [    1.650115] REGS: c7955b30 TRAP: 0700   Not tainted  (2.6.34-rc7-obelix)
>> [    1.656948] MSR: 00021032<ME,CE,IR,DR>   CR: 24008084  XER: 00000000
>> [    1.663452] TASK = c78f2490[784] 'async/0' THREAD: c7954000
>> [    1.668957] GPR00: 00000001 c7955be0 c78f2490 00000050 c904aa78 00000001 00000000 00000000
>> [    1.677497] GPR08: 00000000 c034ee50 00000000 00000000 44008082 1001a7f0 c7955f68 07fb2938
>> [    1.686037] GPR16: c78a8000 07fb2914 07f3f64c c0340000 c031ed00 c78a8000 00000000 c0010adc
>> [    1.694577] GPR24: c7842820 00000002 c7949428 c7948000 00000003 00000000 c7948000 c794809c
>> [    1.703321] NIP [c01ae650] ata_sff_qc_issue+0x74/0x248
>> [    1.708564] LR [c01ae624] ata_sff_qc_issue+0x48/0x248
>> [    1.713712] Call Trace:
>> [    1.716211] [c7955be0] [c01ae624] ata_sff_qc_issue+0x48/0x248 (unreliable)

> Which driver is it?

    It's 'pata_mpc52xx' I think.

> You probably now want to use ata_bmdma_qc_issue()
> instead of ata_sff_qc_issue() (or inherit from ata_bmdma_port_ops
> instead of ata_sff_port_ops) as sff doesn't deal with BMDMA anymore.

    Indeed, the driver inherits from 'ata_sff_port_ops'...

> The commit you bisected to contains all those conversions too.  Take a
> look at a similar driver and look at how it has been converted
> recently.  Even better, just send the driver upstream.  :-)

    It's already there...

> Good luck.

WBR, Sergei

^ permalink raw reply

* Re: PowerPC MPC5200B ATA MWDMA regression
From: acrux @ 2011-01-03 14:27 UTC (permalink / raw)
  To: linuxppc-dev
In-Reply-To: <201101031445.47922.roman.fietze@telemotive.de>

hi,

my MPC5200B (Genesi EFIKA PowerPC) works fine with linux-2.6.36.2 and these two patches:
http://lists.ozlabs.org/pipermail/linuxppc-dev/2010-December/087632.html
http://lists.ozlabs.org/pipermail/linuxppc-dev/2010-December/087633.html


i hope this helps,
cheers
--acrux

-- 
GNU/Linux on Power Architecture
CRUX PPC - http://cruxppc.org/

^ permalink raw reply

* Re: PowerPC MPC5200B ATA MWDMA regression
From: Tejun Heo @ 2011-01-03 13:59 UTC (permalink / raw)
  To: Roman Fietze; +Cc: linux-ide, linuxppc-dev
In-Reply-To: <201101031445.47922.roman.fietze@telemotive.de>

On Mon, Jan 03, 2011 at 02:45:47PM +0100, Roman Fietze wrote:
> Hello,
> 
> When merging more recent kernel versions, tried that using v2.6.35 and
> v2.6.36, into our tree (branched at v2.6.34), I detected, that MWDMA2
> on the HW listed in the subject does no longer work.
> 
> So I bisected that using the original, standard kernel tree using a
> minimum config using
> 
>    git bisect start v2.6.35 v2.6.34
> 
> The final result is:
> 
> 360ff7833098e944e5003618b03894251e937802 is the first bad commit
> commit 360ff7833098e944e5003618b03894251e937802
> Author: Tejun Heo <tj@kernel.org>
> Date:   Mon May 10 21:41:42 2010 +0200
> 
>     libata-sff: separate out BMDMA qc_issue
> 
> ...
> 
> 
> I double checked the failure with the latest torvalds/master as well
> (b518a64983cbf2ff31), still the same issue.
> 
> The HW is an own board very close to the original Freescale
> Lite5200/Lite5200B. The relevant part of the device tree source file
> contains "mwdma-mode = <2>;" inside the ata section.
> 
> In the bad case the log always shows (the exact drive or drive type
> doesn't matter, double checked):
> 
> [    1.553501] ata1.00: ATA-5: HEJ423020F9AT00, 00MJA0A0, max UDMA/100
> [    1.560003] ata1.00: 39070080 sectors, multi 0: LBA 
> [    1.581418] ata1.00: configured for MWDMA2
> [    1.586644] scsi 0:0:0:0: Direct-Access     ATA      HEJ423020F9AT00  00MJ PQ: 0 ANSI: 5
> [    1.597831] sd 0:0:0:0: [sda] 39070080 512-byte logical blocks: (20.0 GB/18.6 GiB)
> [    1.606876] sd 0:0:0:0: [sda] Write Protect is off
> [    1.611907] sd 0:0:0:0: [sda] Mode Sense: 00 3a 00 00
> [    1.617627] sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
> [    1.629423]  sda:
> [    1.631702] ------------[ cut here ]------------
> [    1.636613] Badness at /home/fietze/src/linux-2.6-telemotive/drivers/ata/libata-sff.c:1466
> [    1.645047] NIP: c01ae650 LR: c01ae624 CTR: c01accbc
> [    1.650115] REGS: c7955b30 TRAP: 0700   Not tainted  (2.6.34-rc7-obelix)
> [    1.656948] MSR: 00021032 <ME,CE,IR,DR>  CR: 24008084  XER: 00000000
> [    1.663452] TASK = c78f2490[784] 'async/0' THREAD: c7954000
> [    1.668957] GPR00: 00000001 c7955be0 c78f2490 00000050 c904aa78 00000001 00000000 00000000 
> [    1.677497] GPR08: 00000000 c034ee50 00000000 00000000 44008082 1001a7f0 c7955f68 07fb2938 
> [    1.686037] GPR16: c78a8000 07fb2914 07f3f64c c0340000 c031ed00 c78a8000 00000000 c0010adc 
> [    1.694577] GPR24: c7842820 00000002 c7949428 c7948000 00000003 00000000 c7948000 c794809c 
> [    1.703321] NIP [c01ae650] ata_sff_qc_issue+0x74/0x248
> [    1.708564] LR [c01ae624] ata_sff_qc_issue+0x48/0x248
> [    1.713712] Call Trace:
> [    1.716211] [c7955be0] [c01ae624] ata_sff_qc_issue+0x48/0x248 (unreliable)

Which driver is it?  You probably now want to use ata_bmdma_qc_issue()
instead of ata_sff_qc_issue() (or inherit from ata_bmdma_port_ops
instead of ata_sff_port_ops) as sff doesn't deal with BMDMA anymore.
The commit you bisected to contains all those conversions too.  Take a
look at a similar driver and look at how it has been converted
recently.  Even better, just send the driver upstream.  :-)

Good luck.

-- 
tejun

^ permalink raw reply

* PowerPC MPC5200B ATA MWDMA regression
From: Roman Fietze @ 2011-01-03 13:45 UTC (permalink / raw)
  To: Tejun Heo; +Cc: linux-ide, linuxppc-dev

Hello,

When merging more recent kernel versions, tried that using v2.6.35 and
v2.6.36, into our tree (branched at v2.6.34), I detected, that MWDMA2
on the HW listed in the subject does no longer work.

So I bisected that using the original, standard kernel tree using a
minimum config using

   git bisect start v2.6.35 v2.6.34

The final result is:

360ff7833098e944e5003618b03894251e937802 is the first bad commit
commit 360ff7833098e944e5003618b03894251e937802
Author: Tejun Heo <tj@kernel.org>
Date:   Mon May 10 21:41:42 2010 +0200

    libata-sff: separate out BMDMA qc_issue

...


I double checked the failure with the latest torvalds/master as well
(b518a64983cbf2ff31), still the same issue.

The HW is an own board very close to the original Freescale
Lite5200/Lite5200B. The relevant part of the device tree source file
contains "mwdma-mode = <2>;" inside the ata section.

In the bad case the log always shows (the exact drive or drive type
doesn't matter, double checked):

[    1.553501] ata1.00: ATA-5: HEJ423020F9AT00, 00MJA0A0, max UDMA/100
[    1.560003] ata1.00: 39070080 sectors, multi 0: LBA 
[    1.581418] ata1.00: configured for MWDMA2
[    1.586644] scsi 0:0:0:0: Direct-Access     ATA      HEJ423020F9AT00  00MJ PQ: 0 ANSI: 5
[    1.597831] sd 0:0:0:0: [sda] 39070080 512-byte logical blocks: (20.0 GB/18.6 GiB)
[    1.606876] sd 0:0:0:0: [sda] Write Protect is off
[    1.611907] sd 0:0:0:0: [sda] Mode Sense: 00 3a 00 00
[    1.617627] sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[    1.629423]  sda:
[    1.631702] ------------[ cut here ]------------
[    1.636613] Badness at /home/fietze/src/linux-2.6-telemotive/drivers/ata/libata-sff.c:1466
[    1.645047] NIP: c01ae650 LR: c01ae624 CTR: c01accbc
[    1.650115] REGS: c7955b30 TRAP: 0700   Not tainted  (2.6.34-rc7-obelix)
[    1.656948] MSR: 00021032 <ME,CE,IR,DR>  CR: 24008084  XER: 00000000
[    1.663452] TASK = c78f2490[784] 'async/0' THREAD: c7954000
[    1.668957] GPR00: 00000001 c7955be0 c78f2490 00000050 c904aa78 00000001 00000000 00000000 
[    1.677497] GPR08: 00000000 c034ee50 00000000 00000000 44008082 1001a7f0 c7955f68 07fb2938 
[    1.686037] GPR16: c78a8000 07fb2914 07f3f64c c0340000 c031ed00 c78a8000 00000000 c0010adc 
[    1.694577] GPR24: c7842820 00000002 c7949428 c7948000 00000003 00000000 c7948000 c794809c 
[    1.703321] NIP [c01ae650] ata_sff_qc_issue+0x74/0x248
[    1.708564] LR [c01ae624] ata_sff_qc_issue+0x48/0x248
[    1.713712] Call Trace:
[    1.716211] [c7955be0] [c01ae624] ata_sff_qc_issue+0x48/0x248 (unreliable)
[    1.723243] [c7955c00] [c019dd10] ata_qc_issue+0x1ac/0x31c
[    1.728850] [c7955c30] [c01a3540] ata_scsi_translate+0x104/0x1b0
[    1.734987] [c7955c50] [c018a8e0] scsi_dispatch_cmd+0xf4/0x208
[    1.740952] [c7955c70] [c01912bc] scsi_request_fn+0x268/0x404
[    1.746827] [c7955ca0] [c013bc84] __generic_unplug_device+0x48/0x5c
[    1.753227] [c7955cb0] [c013c518] generic_unplug_device+0x28/0x44
[    1.759449] [c7955cc0] [c0139c08] blk_unplug+0x20/0x30
[    1.764697] [c7955cd0] [c00ad148] block_sync_page+0x50/0x6c
[    1.770403] [c7955ce0] [c005a6b8] sync_page+0x4c/0x70
[    1.775577] [c7955cf0] [c0252f24] __wait_on_bit_lock+0x94/0x124
[    1.781623] [c7955d10] [c005a638] __lock_page+0x50/0x60
[    1.786961] [c7955d40] [c005addc] do_read_cache_page+0x18c/0x190
[    1.793093] [c7955d70] [c005ae38] read_cache_page+0x14/0x28
[    1.798793] [c7955d80] [c00d2a44] read_dev_sector+0x40/0xb0
[    1.804488] [c7955da0] [c00d36fc] msdos_partition+0x58/0x888
[    1.810270] [c7955e20] [c00d33e8] rescan_partitions+0x18c/0x430
[    1.816326] [c7955e80] [c00b51d8] __blkdev_get+0x1a0/0x368
[    1.821929] [c7955ec0] [c00d31ec] register_disk+0x140/0x158
[    1.827620] [c7955ef0] [c0143024] add_disk+0xe4/0x144
[    1.832784] [c7955f20] [c0198aa8] sd_probe_async+0xd4/0x1d8
[    1.838478] [c7955f40] [c00429f4] async_thread+0x120/0x2a8
[    1.844079] [c7955fc0] [c003af90] kthread+0x78/0x7c
[    1.849076] [c7955ff0] [c0010fd4] kernel_thread+0x4c/0x68
[    1.854581] Instruction dump:
[    1.857606] 4bffe96d 8b9f0014 2f9c0002 419e00e8 2b9c0002 419d0040 2f9c0001 419e0158 
[    1.865525] 3d20c035 3929ee50 89690006 69600001 <0f000000> 2f8b0000 38600040 419e01bc 
[    1.873859] ata1.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x0
[    1.880541] ata1.00: failed command: READ DMA
[    1.885101] ata1.00: cmd c8/00:08:00:00:00/00:00:00:00:00/e0 tag 0 dma 4096 in
[    1.885116]          res 50/00:00:7f:29:54/00:00:00:00:00/a0 Emask 0x40 (internal error)
[    1.900812] ata1.00: status: { DRDY }
[    1.921430] ata1.00: configured for MWDMA2
[    1.925775] ata1: EH complete
[    1.929052] ata1.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x0
[    1.935739] ata1.00: failed command: READ DMA
[    1.940301] ata1.00: cmd c8/00:08:00:00:00/00:00:00:00:00/e0 tag 0 dma 4096 in
[    1.940316]          res 50/00:00:7f:29:54/00:00:00:00:00/a0 Emask 0x40 (internal error)
[    1.956013] ata1.00: status: { DRDY }
[    1.981416] ata1.00: configured for MWDMA2
[    1.985755] ata1: EH complete
[    1.989027] ata1.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x0
[    1.995707] ata1.00: failed command: READ DMA
[    2.000262] ata1.00: cmd c8/00:08:00:00:00/00:00:00:00:00/e0 tag 0 dma 4096 in
[    2.000275]          res 50/00:00:7f:29:54/00:00:00:00:00/a0 Emask 0x40 (internal error)
[    2.015971] ata1.00: status: { DRDY }
[    2.041420] ata1.00: configured for MWDMA2
[    2.045767] ata1: EH complete
[    2.049044] ata1.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x0
[    2.055730] ata1.00: failed command: READ DMA
[    2.060287] ata1.00: cmd c8/00:08:00:00:00/00:00:00:00:00/e0 tag 0 dma 4096 in
[    2.060301]          res 50/00:00:7f:29:54/00:00:00:00:00/a0 Emask 0x40 (internal error)
[    2.075997] ata1.00: status: { DRDY }
...

and then while operating the drive e.g. using dd if=/dev/sda ...:

[   81.936231] ata1.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x0
[   81.942966] ata1.00: failed command: READ DMA
[   81.947534] ata1.00: cmd c8/00:00:00:00:00/00:00:00:00:00/e0 tag 0 dma 131072 in
[   81.947550]          res 50/00:00:7f:29:54/00:00:00:00:00/a0 Emask 0x40 (internal error)
[   81.963422] ata1.00: status: { DRDY }
[   81.983316] ata1.00: configured for MWDMA2
[   81.987690] ata1: EH complete
[   81.990974] ata1.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x0
[   81.997661] ata1.00: failed command: READ DMA
[   82.002219] ata1.00: cmd c8/00:00:00:00:00/00:00:00:00:00/e0 tag 0 dma 131072 in
[   82.002234]          res 50/00:00:7f:29:54/00:00:00:00:00/a0 Emask 0x40 (internal error)
[   82.018186] ata1.00: status: { DRDY }
[   82.047323] ata1.00: configured for MWDMA2
[   82.051695] ata1: EH complete
...

and so on.

If I would understand more of IDE/ATA/libata I would have tried own
fixes, so I'm sorry to bother you with test results instead of
patches.


Roman

-- 
Roman Fietze              Telemotive AG Buero Muehlhausen
Breitwiesen                             73347 Muehlhausen
Tel.: +49(0)7335/18493-45        http://www.telemotive.de

^ permalink raw reply

* [PATCH 02/32] powerpc/cell: use system_wq in cpufreq_spudemand
From: Tejun Heo @ 2011-01-03 13:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: Tejun Heo, Dave Jones, linuxppc-dev, cpufreq, Arnd Bergmann
In-Reply-To: <1294062595-30097-1-git-send-email-tj@kernel.org>

With cmwq, there's no reason to use a separate workqueue in
cpufreq_spudemand.  Use system_wq instead.  The work items are already
sync canceled on stop, so it's already guaranteed that no work is
running when spu_gov_exit() is entered.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: linuxppc-dev@lists.ozlabs.org
Cc: Dave Jones <davej@redhat.com>
Cc: cpufreq@vger.kernel.org
---
Only compile tested.  Please feel free to take it into the subsystem
tree or simply ack - I'll route it through the wq tree.

Thanks.

 arch/powerpc/platforms/cell/cpufreq_spudemand.c |   20 +++-----------------
 1 files changed, 3 insertions(+), 17 deletions(-)

diff --git a/arch/powerpc/platforms/cell/cpufreq_spudemand.c b/arch/powerpc/platforms/cell/cpufreq_spudemand.c
index 968c1c0..d809836 100644
--- a/arch/powerpc/platforms/cell/cpufreq_spudemand.c
+++ b/arch/powerpc/platforms/cell/cpufreq_spudemand.c
@@ -39,8 +39,6 @@ struct spu_gov_info_struct {
 };
 static DEFINE_PER_CPU(struct spu_gov_info_struct, spu_gov_info);
 
-static struct workqueue_struct *kspugov_wq;
-
 static int calc_freq(struct spu_gov_info_struct *info)
 {
 	int cpu;
@@ -71,14 +69,14 @@ static void spu_gov_work(struct work_struct *work)
 	__cpufreq_driver_target(info->policy, target_freq, CPUFREQ_RELATION_H);
 
 	delay = usecs_to_jiffies(info->poll_int);
-	queue_delayed_work_on(info->policy->cpu, kspugov_wq, &info->work, delay);
+	schedule_delayed_work_on(info->policy->cpu, &info->work, delay);
 }
 
 static void spu_gov_init_work(struct spu_gov_info_struct *info)
 {
 	int delay = usecs_to_jiffies(info->poll_int);
 	INIT_DELAYED_WORK_DEFERRABLE(&info->work, spu_gov_work);
-	queue_delayed_work_on(info->policy->cpu, kspugov_wq, &info->work, delay);
+	schedule_delayed_work_on(info->policy->cpu, &info->work, delay);
 }
 
 static void spu_gov_cancel_work(struct spu_gov_info_struct *info)
@@ -152,27 +150,15 @@ static int __init spu_gov_init(void)
 {
 	int ret;
 
-	kspugov_wq = create_workqueue("kspugov");
-	if (!kspugov_wq) {
-		printk(KERN_ERR "creation of kspugov failed\n");
-		ret = -EFAULT;
-		goto out;
-	}
-
 	ret = cpufreq_register_governor(&spu_governor);
-	if (ret) {
+	if (ret)
 		printk(KERN_ERR "registration of governor failed\n");
-		destroy_workqueue(kspugov_wq);
-		goto out;
-	}
-out:
 	return ret;
 }
 
 static void __exit spu_gov_exit(void)
 {
 	cpufreq_unregister_governor(&spu_governor);
-	destroy_workqueue(kspugov_wq);
 }
 
 
-- 
1.7.1

^ permalink raw reply related

* PATA_WINBOND  lost interrupt - linux-2.6.36.2 - ppc64
From: acrux @ 2011-01-03 12:08 UTC (permalink / raw)
  To: linuxppc-dev

hi,
there is a problem using new pata drivers with an old IBM Intellistation POWER 275  (9114-275 pSeries POWER4+).
These boxes are equipped with an IDE dvd-rom drive (PATA_WINBOND driver). 
0000:00:03.1 IDE interface: Symphony Labs SL82c105 (rev 05)

I can report, instead, that the old ide-cd driver BLK_DEV_SL82C105 (i tested the same scenario but with linux-2.6.32.7) works fine. Obviously it happens only when boot or try to read from the dvdrom drive.

[...]
ata1: lost interrupt (Status 0x50)
ata1.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x6 frozen
sr 1:0:0:0: CDB: Xdread, Read track info: 52 01 00 00 00 01 00 00 20 00
ata1.00: cmd a0/01:00:00:20:00/00:00:00:00:00/a0 tag 0 dma 16416 in
         res 40/00:02:00:08:00/00:00:00:00:00/a0 Emask 0x4 (timeout)
ata1.00: status: { DRDY }
ata1: soft resetting link
ata1.00: configured for MWDMA2
ata1: EH complete
sr0: CDROM (ioctl) error, command: Xdread, Read track info 52 01 00 00 00 01 00 00 20 00
sr: Sense Key : Aborted Command [current] [descriptor]
sr: Add. Sense: No additional sense information
ata1: lost interrupt (Status 0x50)
ata1.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x6 frozen
sr 1:0:0:0: [sr0] CDB: Xpwrite, Read disk info: 51 00 00 00 00 00 00 00 20 00
ata1.00: cmd a0/01:00:00:20:00/00:00:00:00:00/a0 tag 0 dma 16416 in
         res 40/00:02:00:0c:00/00:00:00:00:00/a0 Emask 0x4 (timeout)
ata1.00: status: { DRDY }
ata1: soft resetting link
ata1.00: configured for MWDMA2
ata1: EH complete
ata1: lost interrupt (Status 0x50)
ata1.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x6 frozen
sr 1:0:0:0: CDB: Get configuration: 46 00 00 00 00 00 00 00 20 00
ata1.00: cmd a0/01:00:00:20:00/00:00:00:00:00/a0 tag 0 dma 16416 in
         res 40/00:02:00:0c:00/00:00:00:00:00/a0 Emask 0x4 (timeout)
ata1.00: status: { DRDY }
ata1: soft resetting link
ata1.00: configured for MWDMA2
sr0: CDROM (ioctl) error, command: 
ata1: EH complete
Get configuration 46 00 00 00 00 00 00 00 20 00
sr: Sense Key : Aborted Command [current] [descriptor]
sr: Add. Sense: No additional sense information
ata1: lost interrupt (Status 0x50)
ata1.00: limiting speed to MWDMA1:PIO4
ata1.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x6 frozen
sr 1:0:0:0: [sr0] CDB: Xpwrite, Read disk info: 51 00 00 00 00 00 00 00 20 00
ata1.00: cmd a0/01:00:00:20:00/00:00:00:00:00/a0 tag 0 dma 16416 in
         res 40/00:02:00:0c:00/00:00:00:00:00/a0 Emask 0x4 (timeout)
ata1.00: status: { DRDY }
ata1: soft resetting link
ata1.00: configured for MWDMA1
ata1: EH complete
ata1: lost interrupt (Status 0x50)
ata1.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x6 frozen
sr 1:0:0:0: CDB: Get configuration: 46 00 00 00 00 00 00 00 20 00
ata1.00: cmd a0/01:00:00:20:00/00:00:00:00:00/a0 tag 0 dma 16416 in
         res 40/00:02:00:0c:00/00:00:00:00:00/a0 Emask 0x4 (timeout)
ata1.00: status: { DRDY }
ata1: soft resetting link
ata1.00: configured for MWDMA1
ata1: EH complete
sr0: CDROM (ioctl) error, command: Get configuration 46 00 00 00 00 00 00 00 20 00
sr: Sense Key : Aborted Command [current] [descriptor]
sr: Add. Sense: No additional sense information
[...]

Here the full dmesg and kernel config:
http://cruxppc.org/~acrux/linux-2.6.36.2-IntellistationPOWER275.dmesg
http://cruxppc.org/~acrux/linux-2.6.36.2-IntellistationPOWER275.config



thanks,
--acrux
-- 
GNU/Linux on Power Architecture
CRUX PPC - http://cruxppc.org/

^ permalink raw reply

* Re: ppc_set_hwdebug vs ptrace_set_debugreg
From: Andreas Schwab @ 2011-01-02 14:58 UTC (permalink / raw)
  To: prasad; +Cc: linuxppc-dev, Dave Kleikamp, Srikar Dronamraju, Paul Mackerras
In-Reply-To: <20110102125401.GA2390@in.ibm.com>

"K.Prasad" <prasad@linux.vnet.ibm.com> writes:

> The watch-vfork test actually fails on my system (4 unexpected failures)

It should pass all four tests.  If gdb cannot even set a watchpoint it
cannot trigger the crash, of course.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply

* Re: ppc_set_hwdebug vs ptrace_set_debugreg
From: K.Prasad @ 2011-01-02 12:54 UTC (permalink / raw)
  To: Andreas Schwab
  Cc: linuxppc-dev, Dave Kleikamp, Srikar Dronamraju, Paul Mackerras
In-Reply-To: <m2oc8lhcik.fsf@igel.home>

On Thu, Dec 16, 2010 at 06:07:47PM +0100, Andreas Schwab wrote:
> "K.Prasad" <prasad@linux.vnet.ibm.com> writes:
> 
> > How about the revised patch below? It is only compile-tested; have you
> > got a quick test case that I can run?
> 
> It crashes the kernel when running the watch-vfork test.
> 
> Andreas.
>

Hi Andreas,
	I tried running it multiple times but saw no crash (or error
messages in dmesg). Can you send me the crash logs? What's the behaviour
when the testcase is run on an unpatched kernel?

The watch-vfork test actually fails on my system (4 unexpected failures)
irrespective of the kernel containing the patch or not.

Thanks,
K.Prasad
P.S.: I'd been on vacation and couldn't look at this issue during then.

^ permalink raw reply

* So long and thanks for all the fish.
From: Sean MacLennan @ 2011-01-01 22:06 UTC (permalink / raw)
  To: linuxppc-dev

Happy New Year!

I didn't survive the latest round of layoffs at Pika. So in two weeks
the smaclennan@pikatech.com email will be dead. I also will no longer
have access to a Warp.

I would like to thank all the people on this list that helped me with
with the PPC. Everybody gave freely of their time and experience. I
really appreciate all the help, it made working on the Warp very
enjoyable.

If you need to contact me for whatever reason, just use the reply
address on this email (seanm@seanm.ca). Who knows, maybe I will get
another job working with the PPC and we shall meet again!

Cheers,
   Sean

^ permalink raw reply

* Re: [PATCH] of/flattree: Add of_flat_dt_match() helper function
From: Grant Likely @ 2011-01-01  0:54 UTC (permalink / raw)
  To: Stephen Neuendorffer; +Cc: devicetree-discuss, linuxppc-dev
In-Reply-To: <AANLkTikG+F+LbbHKfHKzcMKZjxxj=GzhjdeHZ6Jo10mq@mail.gmail.com>

On Fri, Dec 31, 2010 at 07:59:02AM -0800, Stephen Neuendorffer wrote:
> On Fri, Dec 31, 2010 at 1:15 AM, Grant Likely <grant.likely@secretlab.ca>wrote:
> 
> > This patch adds of_flat_dt_match() which tests a node for
> > compatibility with a list of values and converts the relevant powerpc
> > platform code to use it.  This approach simplifies the board support
> > code a bit.
> >
> > Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
> >
> 
> reviewed-by: Stephen Neuendorffer <stephen.neuendorffer@xilinx.com>
> 
> minor nits below.

Fixed, thanks.

g.

> 
> 
> > ---
> >  arch/powerpc/platforms/40x/ppc40x_simple.c    |   13 +++-------
> >  arch/powerpc/platforms/512x/mpc5121_generic.c |   13 +---------
> >  arch/powerpc/platforms/52xx/lite5200.c        |   16 +++++-------
> >  arch/powerpc/platforms/52xx/media5200.c       |   13 +---------
> >  arch/powerpc/platforms/52xx/mpc5200_simple.c  |   13 +---------
> >  arch/powerpc/platforms/83xx/mpc830x_rdb.c     |   13 ++++++----
> >  arch/powerpc/platforms/83xx/mpc831x_rdb.c     |   11 +++++---
> >  arch/powerpc/platforms/83xx/mpc837x_rdb.c     |   15 +++++++----
> >  arch/powerpc/platforms/85xx/tqm85xx.c         |   20 +++++++--------
> >  drivers/of/fdt.c                              |   34
> > ++++++++++++++++++++++++-
> >  include/linux/of_fdt.h                        |    1 +
> >  11 files changed, 84 insertions(+), 78 deletions(-)
> >
> > diff --git a/arch/powerpc/platforms/40x/ppc40x_simple.c
> > b/arch/powerpc/platforms/40x/ppc40x_simple.c
> > index 546bbc2..2521d93 100644
> > --- a/arch/powerpc/platforms/40x/ppc40x_simple.c
> > +++ b/arch/powerpc/platforms/40x/ppc40x_simple.c
> > @@ -50,7 +50,7 @@ machine_device_initcall(ppc40x_simple,
> > ppc40x_device_probe);
> >  * Again, if your board needs to do things differently then create a
> >  * board.c file for it rather than adding it to this list.
> >  */
> > -static char *board[] __initdata = {
> > +static const char *board[] __initdata = {
> >        "amcc,acadia",
> >        "amcc,haleakala",
> >        "amcc,kilauea",
> > @@ -60,14 +60,9 @@ static char *board[] __initdata = {
> >
> >  static int __init ppc40x_probe(void)
> >  {
> > -       unsigned long root = of_get_flat_dt_root();
> > -       int i = 0;
> > -
> > -       for (i = 0; i < ARRAY_SIZE(board); i++) {
> > -               if (of_flat_dt_is_compatible(root, board[i])) {
> > -                       ppc_pci_set_flags(PPC_PCI_REASSIGN_ALL_RSRC);
> > -                       return 1;
> > -               }
> > +       if (of_flat_dt_match(of_get_flat_dt_root(), board)) {
> > +               ppc_pci_set_flags(PPC_PCI_REASSIGN_ALL_RSRC);
> > +               return 1;
> >        }
> >
> >        return 0;
> > diff --git a/arch/powerpc/platforms/512x/mpc5121_generic.c
> > b/arch/powerpc/platforms/512x/mpc5121_generic.c
> > index e487eb0..926731f 100644
> > --- a/arch/powerpc/platforms/512x/mpc5121_generic.c
> > +++ b/arch/powerpc/platforms/512x/mpc5121_generic.c
> > @@ -26,7 +26,7 @@
> >  /*
> >  * list of supported boards
> >  */
> > -static char *board[] __initdata = {
> > +static const char *board[] __initdata = {
> >        "prt,prtlvt",
> >        NULL
> >  };
> > @@ -36,16 +36,7 @@ static char *board[] __initdata = {
> >  */
> >  static int __init mpc5121_generic_probe(void)
> >  {
> > -       unsigned long node = of_get_flat_dt_root();
> > -       int i = 0;
> > -
> > -       while (board[i]) {
> > -               if (of_flat_dt_is_compatible(node, board[i]))
> > -                       break;
> > -               i++;
> > -       }
> > -
> > -       return board[i] != NULL;
> > +       return of_flat_dt_match(of_get_flat_dt_root(), board);
> >  }
> >
> >  define_machine(mpc5121_generic) {
> > diff --git a/arch/powerpc/platforms/52xx/lite5200.c
> > b/arch/powerpc/platforms/52xx/lite5200.c
> > index de55bc0..01ffa64 100644
> > --- a/arch/powerpc/platforms/52xx/lite5200.c
> > +++ b/arch/powerpc/platforms/52xx/lite5200.c
> > @@ -172,20 +172,18 @@ static void __init lite5200_setup_arch(void)
> >        mpc52xx_setup_pci();
> >  }
> >
> > +static const char *board[] __initdata = {
> > +       "fsl,lite5200",
> > +       "fsl,lite5200b",
> > +       NULL,
> > +};
> > +
> >  /*
> >  * Called very early, MMU is off, device-tree isn't unflattened
> >  */
> >  static int __init lite5200_probe(void)
> >  {
> > -       unsigned long node = of_get_flat_dt_root();
> > -       const char *model = of_get_flat_dt_prop(node, "model", NULL);
> > -
> > -       if (!of_flat_dt_is_compatible(node, "fsl,lite5200") &&
> > -           !of_flat_dt_is_compatible(node, "fsl,lite5200b"))
> > -               return 0;
> > -       pr_debug("%s board found\n", model ? model : "unknown");
> > -
> > -       return 1;
> > +       return of_flat_dt_match(of_get_flat_dt_root(), board);
> >  }
> >
> >  define_machine(lite5200) {
> > diff --git a/arch/powerpc/platforms/52xx/media5200.c
> > b/arch/powerpc/platforms/52xx/media5200.c
> > index 0bac3a3..2c7780c 100644
> > --- a/arch/powerpc/platforms/52xx/media5200.c
> > +++ b/arch/powerpc/platforms/52xx/media5200.c
> > @@ -239,7 +239,7 @@ static void __init media5200_setup_arch(void)
> >  }
> >
> >  /* list of the supported boards */
> > -static char *board[] __initdata = {
> > +static const char *board[] __initdata = {
> >        "fsl,media5200",
> >        NULL
> >  };
> > @@ -249,16 +249,7 @@ static char *board[] __initdata = {
> >  */
> >  static int __init media5200_probe(void)
> >  {
> > -       unsigned long node = of_get_flat_dt_root();
> > -       int i = 0;
> > -
> > -       while (board[i]) {
> > -               if (of_flat_dt_is_compatible(node, board[i]))
> > -                       break;
> > -               i++;
> > -       }
> > -
> > -       return (board[i] != NULL);
> > +       return of_flat_dt_match(of_get_flat_dt_root(), board);
> >  }
> >
> >  define_machine(media5200_platform) {
> > diff --git a/arch/powerpc/platforms/52xx/mpc5200_simple.c
> > b/arch/powerpc/platforms/52xx/mpc5200_simple.c
> > index d45be5b..e36d6e2 100644
> > --- a/arch/powerpc/platforms/52xx/mpc5200_simple.c
> > +++ b/arch/powerpc/platforms/52xx/mpc5200_simple.c
> > @@ -49,7 +49,7 @@ static void __init mpc5200_simple_setup_arch(void)
> >  }
> >
> >  /* list of the supported boards */
> > -static char *board[] __initdata = {
> > +static const char *board[] __initdata = {
> >        "intercontrol,digsy-mtc",
> >        "manroland,mucmc52",
> >        "manroland,uc101",
> > @@ -66,16 +66,7 @@ static char *board[] __initdata = {
> >  */
> >  static int __init mpc5200_simple_probe(void)
> >  {
> > -       unsigned long node = of_get_flat_dt_root();
> > -       int i = 0;
> > -
> > -       while (board[i]) {
> > -               if (of_flat_dt_is_compatible(node, board[i]))
> > -                       break;
> > -               i++;
> > -       }
> > -
> > -       return (board[i] != NULL);
> > +       return of_flat_dt_match(of_get_flat_dt_root(), board);
> >  }
> >
> >  define_machine(mpc5200_simple_platform) {
> > diff --git a/arch/powerpc/platforms/83xx/mpc830x_rdb.c
> > b/arch/powerpc/platforms/83xx/mpc830x_rdb.c
> > index 846831d..661d354 100644
> > --- a/arch/powerpc/platforms/83xx/mpc830x_rdb.c
> > +++ b/arch/powerpc/platforms/83xx/mpc830x_rdb.c
> > @@ -57,16 +57,19 @@ static void __init mpc830x_rdb_init_IRQ(void)
> >        ipic_set_default_priority();
> >  }
> >
> > +struct const char *board[] __initdata = {
> > +       "MPC8308RDB",
> > +       "fsl,mpc8308rdb",
> > +       "denx,mpc8308_p1m",
> > +       NULL
> > +}
> > +
> >  /*
> >  * Called very early, MMU is off, device-tree isn't unflattened
> >  */
> >  static int __init mpc830x_rdb_probe(void)
> >  {
> > -       unsigned long root = of_get_flat_dt_root();
> > -
> > -       return of_flat_dt_is_compatible(root, "MPC8308RDB") ||
> > -              of_flat_dt_is_compatible(root, "fsl,mpc8308rdb") ||
> > -              of_flat_dt_is_compatible(root, "denx,mpc8308_p1m");
> > +       return of_flat_dt_match(of_get_flat_dt_root(), board);
> >  }
> >
> >  static struct of_device_id __initdata of_bus_ids[] = {
> > diff --git a/arch/powerpc/platforms/83xx/mpc831x_rdb.c
> > b/arch/powerpc/platforms/83xx/mpc831x_rdb.c
> > index ae525e4..b54cd73 100644
> > --- a/arch/powerpc/platforms/83xx/mpc831x_rdb.c
> > +++ b/arch/powerpc/platforms/83xx/mpc831x_rdb.c
> > @@ -60,15 +60,18 @@ static void __init mpc831x_rdb_init_IRQ(void)
> >        ipic_set_default_priority();
> >  }
> >
> > +struct const char *board[] __initdata = {
> > +       "MPC8313ERDB",
> > +       "fsl,mpc8315erdb",
> > +       NULL
> > +}
> > +
> >  /*
> >  * Called very early, MMU is off, device-tree isn't unflattened
> >  */
> >  static int __init mpc831x_rdb_probe(void)
> >  {
> > -       unsigned long root = of_get_flat_dt_root();
> > -
> > -       return of_flat_dt_is_compatible(root, "MPC8313ERDB") ||
> > -              of_flat_dt_is_compatible(root, "fsl,mpc8315erdb");
> > +       return of_flat_dt_match(of_get_flat_dt_root(), board);
> >  }
> >
> >  static struct of_device_id __initdata of_bus_ids[] = {
> > diff --git a/arch/powerpc/platforms/83xx/mpc837x_rdb.c
> > b/arch/powerpc/platforms/83xx/mpc837x_rdb.c
> > index 910caa6..7bafbf2 100644
> > --- a/arch/powerpc/platforms/83xx/mpc837x_rdb.c
> > +++ b/arch/powerpc/platforms/83xx/mpc837x_rdb.c
> > @@ -101,17 +101,20 @@ static void __init mpc837x_rdb_init_IRQ(void)
> >        ipic_set_default_priority();
> >  }
> >
> > +static const char *board[] __initdata = {
> > +       "fsl,mpc8377rdb",
> > +       "fsl,mpc8378rdb",
> > +       "fsl,mpc8379rdb",
> > +       "fsl,mpc8377wlan",
> > +       NULL
> > +};
> > +
> >  /*
> >  * Called very early, MMU is off, device-tree isn't unflattened
> >  */
> >  static int __init mpc837x_rdb_probe(void)
> >  {
> > -       unsigned long root = of_get_flat_dt_root();
> > -
> > -       return of_flat_dt_is_compatible(root, "fsl,mpc8377rdb") ||
> > -              of_flat_dt_is_compatible(root, "fsl,mpc8378rdb") ||
> > -              of_flat_dt_is_compatible(root, "fsl,mpc8379rdb") ||
> > -              of_flat_dt_is_compatible(root, "fsl,mpc8377wlan");
> > +       return of_flat_dt_match(of_get_flat_dt_root(), board);
> >  }
> >
> >  define_machine(mpc837x_rdb) {
> > diff --git a/arch/powerpc/platforms/85xx/tqm85xx.c
> > b/arch/powerpc/platforms/85xx/tqm85xx.c
> > index 8f29bbc..5e847d0 100644
> > --- a/arch/powerpc/platforms/85xx/tqm85xx.c
> > +++ b/arch/powerpc/platforms/85xx/tqm85xx.c
> > @@ -186,21 +186,21 @@ static int __init declare_of_platform_devices(void)
> >  }
> >  machine_device_initcall(tqm85xx, declare_of_platform_devices);
> >
> > +static const char *board[] __initdata = {
> > +       "tqc,tqm8540",
> > +       "tqc,tqm8541",
> > +       "tqc,tqm8548",
> > +       "tqc,tqm8555",
> > +       "tqc,tqm8560",
> > +       NULL
> > +};
> > +
> >  /*
> >  * Called very early, device-tree isn't unflattened
> >  */
> >  static int __init tqm85xx_probe(void)
> >  {
> > -       unsigned long root = of_get_flat_dt_root();
> > -
> > -       if ((of_flat_dt_is_compatible(root, "tqc,tqm8540")) ||
> > -           (of_flat_dt_is_compatible(root, "tqc,tqm8541")) ||
> > -           (of_flat_dt_is_compatible(root, "tqc,tqm8548")) ||
> > -           (of_flat_dt_is_compatible(root, "tqc,tqm8555")) ||
> > -           (of_flat_dt_is_compatible(root, "tqc,tqm8560")))
> > -               return 1;
> > -
> > -       return 0;
> > +       return of_flat_dt_match(of_get_flat_dt_root(), board);
> >  }
> >
> >  define_machine(tqm85xx) {
> > diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
> > index 8a90ee4..5a3db04 100644
> > --- a/drivers/of/fdt.c
> > +++ b/drivers/of/fdt.c
> > @@ -78,19 +78,23 @@ void *of_fdt_get_property(struct boot_param_header
> > *blob,
> >  * @blob: A device tree blob
> >  * @node: node to test
> >  * @compat: compatible string to compare with compatible list.
> > + *
> > + * On match, returns a non-zero value with smaller values returned for
> > more
> > + * specific compatible values.
> >  */
> >  int of_fdt_is_compatible(struct boot_param_header *blob,
> >                      unsigned long node, const char *compat)
> >  {
> >        const char *cp;
> > -       unsigned long cplen, l;
> > +       unsigned long cplen, l, score = 0;
> >
> >        cp = of_fdt_get_property(blob, node, "compatible", &cplen);
> >        if (cp == NULL)
> >                return 0;
> >        while (cplen > 0) {
> > +               score++;
> >                if (of_compat_cmp(cp, compat, strlen(compat)) == 0)
> > -                       return 1;
> > +                       return score;
> >                l = strlen(cp) + 1;
> >                cp += l;
> >                cplen -= l;
> > @@ -99,6 +103,24 @@ int of_fdt_is_compatible(struct boot_param_header
> > *blob,
> >        return 0;
> >  }
> >
> > +/**
> > + * of_flat_dt_match - Return true if node matches a list of compatible
> > values
> >
> 
> copy-paste error.
> 
> 
> > + */
> > +int of_fdt_match(struct boot_param_header *blob, unsigned long node,
> > +                 const char **compat)
> > +{
> > +       unsigned int tmp, score = 0;
> > +
> > +       while (*compat) {
> > +               tmp = of_fdt_is_compatible(blob, node, *compat);
> > +               if (tmp && (score == 0 || (tmp < score)))
> > +                       score = tmp;
> > +               compat++;
> > +       }
> > +
> > +       return score;
> > +}
> > +
> >  static void *unflatten_dt_alloc(unsigned long *mem, unsigned long size,
> >                                       unsigned long align)
> >  {
> > @@ -511,6 +533,14 @@ int __init of_flat_dt_is_compatible(unsigned long
> > node, const char *compat)
> >        return of_fdt_is_compatible(initial_boot_params, node, compat);
> >  }
> >
> > +/**
> > + * of_flat_dt_match - Return true if node matches a list of compatible
> > values
> > + */
> > +int __init of_flat_dt_match(unsigned long node, const char **compat)
> > +{
> > +       return of_fdt_match(initial_boot_params, node, compat);
> > +}
> > +
> >  #ifdef CONFIG_BLK_DEV_INITRD
> >  /**
> >  * early_init_dt_check_for_initrd - Decode initrd location from flat tree
> > diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h
> > index 9ce5dfd..fb327f3 100644
> > --- a/include/linux/of_fdt.h
> > +++ b/include/linux/of_fdt.h
> > @@ -84,6 +84,7 @@ extern int of_scan_flat_dt(int (*it)(unsigned long node,
> > const char *uname,
> >  extern void *of_get_flat_dt_prop(unsigned long node, const char *name,
> >                                 unsigned long *size);
> >  extern int of_flat_dt_is_compatible(unsigned long node, const char *name);
> > +extern int of_flat_dt_match(unsigned long node, const char **matches);
> >
> 
> Maybe export of_fdt_match, too?
> 
> 
> >  extern unsigned long of_get_flat_dt_root(void);
> >
> >  extern int early_init_dt_scan_chosen(unsigned long node, const char
> > *uname,
> >
> > _______________________________________________
> > Linuxppc-dev mailing list
> > Linuxppc-dev@lists.ozlabs.org
> > https://lists.ozlabs.org/listinfo/linuxppc-dev
> >

^ permalink raw reply

* Re: PMU_IOC_SLEEP failed
From: Benjamin Herrenschmidt @ 2010-12-31 23:30 UTC (permalink / raw)
  To: jjDaNiMoTh; +Cc: linuxppc-dev
In-Reply-To: <AANLkTim=HWGMWtXxQF3RzuVMHuG+RJNkzEMU=RnY2nuf@mail.gmail.com>

On Wed, 2010-12-29 at 00:35 +0100, jjDaNiMoTh wrote:
> >> (dmesg..)
> >> [...]
> >> radeonfb_pci_register BEGIN
> >> radeonfb 0000:00:10.0: BAR 0: can't reserve [mem
> 0xb8000000-0xbfffffff pref]
> >> radeonfb (0000:00:10.0): cannot request region 0.
> >> radeonfb: probe of 0000:00:10.0 failed with error -16
> >
> > That looks bad indeed. Send me the complete dmesg, a snapshot of the
> > device-tree (tar -c /proc/device-tree >foo.tar) and the output
> > of /proc/iomem please.
> 
> [1] http://nat.vacau.com/linux/iomem.txt.gz
> [2] http://nat.vacau.com/linux/dmesg_37-rc.txt.gz
> [3] http://nat.vacau.com/linux/device_tree.tar 

Are you trying to use radeonfb as a module ? The dmesg seems to indicate
that you have offb taking control of the framebuffer, preventing
radeonfb from loading.

There's no offb->radeonfb handover (the handover mechanism is new and
only used by KMS for now). On those machines, radeonfb should be
built-in.

Cheers,
Ben.

^ permalink raw reply

* Re: [PATCH] of/flattree: Add of_flat_dt_match() helper function
From: Stephen Neuendorffer @ 2010-12-31 15:59 UTC (permalink / raw)
  To: Grant Likely; +Cc: devicetree-discuss, linuxppc-dev
In-Reply-To: <20101231091500.7355.2314.stgit@localhost6.localdomain6>

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

On Fri, Dec 31, 2010 at 1:15 AM, Grant Likely <grant.likely@secretlab.ca>wrote:

> This patch adds of_flat_dt_match() which tests a node for
> compatibility with a list of values and converts the relevant powerpc
> platform code to use it.  This approach simplifies the board support
> code a bit.
>
> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
>

reviewed-by: Stephen Neuendorffer <stephen.neuendorffer@xilinx.com>

minor nits below.


> ---
>  arch/powerpc/platforms/40x/ppc40x_simple.c    |   13 +++-------
>  arch/powerpc/platforms/512x/mpc5121_generic.c |   13 +---------
>  arch/powerpc/platforms/52xx/lite5200.c        |   16 +++++-------
>  arch/powerpc/platforms/52xx/media5200.c       |   13 +---------
>  arch/powerpc/platforms/52xx/mpc5200_simple.c  |   13 +---------
>  arch/powerpc/platforms/83xx/mpc830x_rdb.c     |   13 ++++++----
>  arch/powerpc/platforms/83xx/mpc831x_rdb.c     |   11 +++++---
>  arch/powerpc/platforms/83xx/mpc837x_rdb.c     |   15 +++++++----
>  arch/powerpc/platforms/85xx/tqm85xx.c         |   20 +++++++--------
>  drivers/of/fdt.c                              |   34
> ++++++++++++++++++++++++-
>  include/linux/of_fdt.h                        |    1 +
>  11 files changed, 84 insertions(+), 78 deletions(-)
>
> diff --git a/arch/powerpc/platforms/40x/ppc40x_simple.c
> b/arch/powerpc/platforms/40x/ppc40x_simple.c
> index 546bbc2..2521d93 100644
> --- a/arch/powerpc/platforms/40x/ppc40x_simple.c
> +++ b/arch/powerpc/platforms/40x/ppc40x_simple.c
> @@ -50,7 +50,7 @@ machine_device_initcall(ppc40x_simple,
> ppc40x_device_probe);
>  * Again, if your board needs to do things differently then create a
>  * board.c file for it rather than adding it to this list.
>  */
> -static char *board[] __initdata = {
> +static const char *board[] __initdata = {
>        "amcc,acadia",
>        "amcc,haleakala",
>        "amcc,kilauea",
> @@ -60,14 +60,9 @@ static char *board[] __initdata = {
>
>  static int __init ppc40x_probe(void)
>  {
> -       unsigned long root = of_get_flat_dt_root();
> -       int i = 0;
> -
> -       for (i = 0; i < ARRAY_SIZE(board); i++) {
> -               if (of_flat_dt_is_compatible(root, board[i])) {
> -                       ppc_pci_set_flags(PPC_PCI_REASSIGN_ALL_RSRC);
> -                       return 1;
> -               }
> +       if (of_flat_dt_match(of_get_flat_dt_root(), board)) {
> +               ppc_pci_set_flags(PPC_PCI_REASSIGN_ALL_RSRC);
> +               return 1;
>        }
>
>        return 0;
> diff --git a/arch/powerpc/platforms/512x/mpc5121_generic.c
> b/arch/powerpc/platforms/512x/mpc5121_generic.c
> index e487eb0..926731f 100644
> --- a/arch/powerpc/platforms/512x/mpc5121_generic.c
> +++ b/arch/powerpc/platforms/512x/mpc5121_generic.c
> @@ -26,7 +26,7 @@
>  /*
>  * list of supported boards
>  */
> -static char *board[] __initdata = {
> +static const char *board[] __initdata = {
>        "prt,prtlvt",
>        NULL
>  };
> @@ -36,16 +36,7 @@ static char *board[] __initdata = {
>  */
>  static int __init mpc5121_generic_probe(void)
>  {
> -       unsigned long node = of_get_flat_dt_root();
> -       int i = 0;
> -
> -       while (board[i]) {
> -               if (of_flat_dt_is_compatible(node, board[i]))
> -                       break;
> -               i++;
> -       }
> -
> -       return board[i] != NULL;
> +       return of_flat_dt_match(of_get_flat_dt_root(), board);
>  }
>
>  define_machine(mpc5121_generic) {
> diff --git a/arch/powerpc/platforms/52xx/lite5200.c
> b/arch/powerpc/platforms/52xx/lite5200.c
> index de55bc0..01ffa64 100644
> --- a/arch/powerpc/platforms/52xx/lite5200.c
> +++ b/arch/powerpc/platforms/52xx/lite5200.c
> @@ -172,20 +172,18 @@ static void __init lite5200_setup_arch(void)
>        mpc52xx_setup_pci();
>  }
>
> +static const char *board[] __initdata = {
> +       "fsl,lite5200",
> +       "fsl,lite5200b",
> +       NULL,
> +};
> +
>  /*
>  * Called very early, MMU is off, device-tree isn't unflattened
>  */
>  static int __init lite5200_probe(void)
>  {
> -       unsigned long node = of_get_flat_dt_root();
> -       const char *model = of_get_flat_dt_prop(node, "model", NULL);
> -
> -       if (!of_flat_dt_is_compatible(node, "fsl,lite5200") &&
> -           !of_flat_dt_is_compatible(node, "fsl,lite5200b"))
> -               return 0;
> -       pr_debug("%s board found\n", model ? model : "unknown");
> -
> -       return 1;
> +       return of_flat_dt_match(of_get_flat_dt_root(), board);
>  }
>
>  define_machine(lite5200) {
> diff --git a/arch/powerpc/platforms/52xx/media5200.c
> b/arch/powerpc/platforms/52xx/media5200.c
> index 0bac3a3..2c7780c 100644
> --- a/arch/powerpc/platforms/52xx/media5200.c
> +++ b/arch/powerpc/platforms/52xx/media5200.c
> @@ -239,7 +239,7 @@ static void __init media5200_setup_arch(void)
>  }
>
>  /* list of the supported boards */
> -static char *board[] __initdata = {
> +static const char *board[] __initdata = {
>        "fsl,media5200",
>        NULL
>  };
> @@ -249,16 +249,7 @@ static char *board[] __initdata = {
>  */
>  static int __init media5200_probe(void)
>  {
> -       unsigned long node = of_get_flat_dt_root();
> -       int i = 0;
> -
> -       while (board[i]) {
> -               if (of_flat_dt_is_compatible(node, board[i]))
> -                       break;
> -               i++;
> -       }
> -
> -       return (board[i] != NULL);
> +       return of_flat_dt_match(of_get_flat_dt_root(), board);
>  }
>
>  define_machine(media5200_platform) {
> diff --git a/arch/powerpc/platforms/52xx/mpc5200_simple.c
> b/arch/powerpc/platforms/52xx/mpc5200_simple.c
> index d45be5b..e36d6e2 100644
> --- a/arch/powerpc/platforms/52xx/mpc5200_simple.c
> +++ b/arch/powerpc/platforms/52xx/mpc5200_simple.c
> @@ -49,7 +49,7 @@ static void __init mpc5200_simple_setup_arch(void)
>  }
>
>  /* list of the supported boards */
> -static char *board[] __initdata = {
> +static const char *board[] __initdata = {
>        "intercontrol,digsy-mtc",
>        "manroland,mucmc52",
>        "manroland,uc101",
> @@ -66,16 +66,7 @@ static char *board[] __initdata = {
>  */
>  static int __init mpc5200_simple_probe(void)
>  {
> -       unsigned long node = of_get_flat_dt_root();
> -       int i = 0;
> -
> -       while (board[i]) {
> -               if (of_flat_dt_is_compatible(node, board[i]))
> -                       break;
> -               i++;
> -       }
> -
> -       return (board[i] != NULL);
> +       return of_flat_dt_match(of_get_flat_dt_root(), board);
>  }
>
>  define_machine(mpc5200_simple_platform) {
> diff --git a/arch/powerpc/platforms/83xx/mpc830x_rdb.c
> b/arch/powerpc/platforms/83xx/mpc830x_rdb.c
> index 846831d..661d354 100644
> --- a/arch/powerpc/platforms/83xx/mpc830x_rdb.c
> +++ b/arch/powerpc/platforms/83xx/mpc830x_rdb.c
> @@ -57,16 +57,19 @@ static void __init mpc830x_rdb_init_IRQ(void)
>        ipic_set_default_priority();
>  }
>
> +struct const char *board[] __initdata = {
> +       "MPC8308RDB",
> +       "fsl,mpc8308rdb",
> +       "denx,mpc8308_p1m",
> +       NULL
> +}
> +
>  /*
>  * Called very early, MMU is off, device-tree isn't unflattened
>  */
>  static int __init mpc830x_rdb_probe(void)
>  {
> -       unsigned long root = of_get_flat_dt_root();
> -
> -       return of_flat_dt_is_compatible(root, "MPC8308RDB") ||
> -              of_flat_dt_is_compatible(root, "fsl,mpc8308rdb") ||
> -              of_flat_dt_is_compatible(root, "denx,mpc8308_p1m");
> +       return of_flat_dt_match(of_get_flat_dt_root(), board);
>  }
>
>  static struct of_device_id __initdata of_bus_ids[] = {
> diff --git a/arch/powerpc/platforms/83xx/mpc831x_rdb.c
> b/arch/powerpc/platforms/83xx/mpc831x_rdb.c
> index ae525e4..b54cd73 100644
> --- a/arch/powerpc/platforms/83xx/mpc831x_rdb.c
> +++ b/arch/powerpc/platforms/83xx/mpc831x_rdb.c
> @@ -60,15 +60,18 @@ static void __init mpc831x_rdb_init_IRQ(void)
>        ipic_set_default_priority();
>  }
>
> +struct const char *board[] __initdata = {
> +       "MPC8313ERDB",
> +       "fsl,mpc8315erdb",
> +       NULL
> +}
> +
>  /*
>  * Called very early, MMU is off, device-tree isn't unflattened
>  */
>  static int __init mpc831x_rdb_probe(void)
>  {
> -       unsigned long root = of_get_flat_dt_root();
> -
> -       return of_flat_dt_is_compatible(root, "MPC8313ERDB") ||
> -              of_flat_dt_is_compatible(root, "fsl,mpc8315erdb");
> +       return of_flat_dt_match(of_get_flat_dt_root(), board);
>  }
>
>  static struct of_device_id __initdata of_bus_ids[] = {
> diff --git a/arch/powerpc/platforms/83xx/mpc837x_rdb.c
> b/arch/powerpc/platforms/83xx/mpc837x_rdb.c
> index 910caa6..7bafbf2 100644
> --- a/arch/powerpc/platforms/83xx/mpc837x_rdb.c
> +++ b/arch/powerpc/platforms/83xx/mpc837x_rdb.c
> @@ -101,17 +101,20 @@ static void __init mpc837x_rdb_init_IRQ(void)
>        ipic_set_default_priority();
>  }
>
> +static const char *board[] __initdata = {
> +       "fsl,mpc8377rdb",
> +       "fsl,mpc8378rdb",
> +       "fsl,mpc8379rdb",
> +       "fsl,mpc8377wlan",
> +       NULL
> +};
> +
>  /*
>  * Called very early, MMU is off, device-tree isn't unflattened
>  */
>  static int __init mpc837x_rdb_probe(void)
>  {
> -       unsigned long root = of_get_flat_dt_root();
> -
> -       return of_flat_dt_is_compatible(root, "fsl,mpc8377rdb") ||
> -              of_flat_dt_is_compatible(root, "fsl,mpc8378rdb") ||
> -              of_flat_dt_is_compatible(root, "fsl,mpc8379rdb") ||
> -              of_flat_dt_is_compatible(root, "fsl,mpc8377wlan");
> +       return of_flat_dt_match(of_get_flat_dt_root(), board);
>  }
>
>  define_machine(mpc837x_rdb) {
> diff --git a/arch/powerpc/platforms/85xx/tqm85xx.c
> b/arch/powerpc/platforms/85xx/tqm85xx.c
> index 8f29bbc..5e847d0 100644
> --- a/arch/powerpc/platforms/85xx/tqm85xx.c
> +++ b/arch/powerpc/platforms/85xx/tqm85xx.c
> @@ -186,21 +186,21 @@ static int __init declare_of_platform_devices(void)
>  }
>  machine_device_initcall(tqm85xx, declare_of_platform_devices);
>
> +static const char *board[] __initdata = {
> +       "tqc,tqm8540",
> +       "tqc,tqm8541",
> +       "tqc,tqm8548",
> +       "tqc,tqm8555",
> +       "tqc,tqm8560",
> +       NULL
> +};
> +
>  /*
>  * Called very early, device-tree isn't unflattened
>  */
>  static int __init tqm85xx_probe(void)
>  {
> -       unsigned long root = of_get_flat_dt_root();
> -
> -       if ((of_flat_dt_is_compatible(root, "tqc,tqm8540")) ||
> -           (of_flat_dt_is_compatible(root, "tqc,tqm8541")) ||
> -           (of_flat_dt_is_compatible(root, "tqc,tqm8548")) ||
> -           (of_flat_dt_is_compatible(root, "tqc,tqm8555")) ||
> -           (of_flat_dt_is_compatible(root, "tqc,tqm8560")))
> -               return 1;
> -
> -       return 0;
> +       return of_flat_dt_match(of_get_flat_dt_root(), board);
>  }
>
>  define_machine(tqm85xx) {
> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
> index 8a90ee4..5a3db04 100644
> --- a/drivers/of/fdt.c
> +++ b/drivers/of/fdt.c
> @@ -78,19 +78,23 @@ void *of_fdt_get_property(struct boot_param_header
> *blob,
>  * @blob: A device tree blob
>  * @node: node to test
>  * @compat: compatible string to compare with compatible list.
> + *
> + * On match, returns a non-zero value with smaller values returned for
> more
> + * specific compatible values.
>  */
>  int of_fdt_is_compatible(struct boot_param_header *blob,
>                      unsigned long node, const char *compat)
>  {
>        const char *cp;
> -       unsigned long cplen, l;
> +       unsigned long cplen, l, score = 0;
>
>        cp = of_fdt_get_property(blob, node, "compatible", &cplen);
>        if (cp == NULL)
>                return 0;
>        while (cplen > 0) {
> +               score++;
>                if (of_compat_cmp(cp, compat, strlen(compat)) == 0)
> -                       return 1;
> +                       return score;
>                l = strlen(cp) + 1;
>                cp += l;
>                cplen -= l;
> @@ -99,6 +103,24 @@ int of_fdt_is_compatible(struct boot_param_header
> *blob,
>        return 0;
>  }
>
> +/**
> + * of_flat_dt_match - Return true if node matches a list of compatible
> values
>

copy-paste error.


> + */
> +int of_fdt_match(struct boot_param_header *blob, unsigned long node,
> +                 const char **compat)
> +{
> +       unsigned int tmp, score = 0;
> +
> +       while (*compat) {
> +               tmp = of_fdt_is_compatible(blob, node, *compat);
> +               if (tmp && (score == 0 || (tmp < score)))
> +                       score = tmp;
> +               compat++;
> +       }
> +
> +       return score;
> +}
> +
>  static void *unflatten_dt_alloc(unsigned long *mem, unsigned long size,
>                                       unsigned long align)
>  {
> @@ -511,6 +533,14 @@ int __init of_flat_dt_is_compatible(unsigned long
> node, const char *compat)
>        return of_fdt_is_compatible(initial_boot_params, node, compat);
>  }
>
> +/**
> + * of_flat_dt_match - Return true if node matches a list of compatible
> values
> + */
> +int __init of_flat_dt_match(unsigned long node, const char **compat)
> +{
> +       return of_fdt_match(initial_boot_params, node, compat);
> +}
> +
>  #ifdef CONFIG_BLK_DEV_INITRD
>  /**
>  * early_init_dt_check_for_initrd - Decode initrd location from flat tree
> diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h
> index 9ce5dfd..fb327f3 100644
> --- a/include/linux/of_fdt.h
> +++ b/include/linux/of_fdt.h
> @@ -84,6 +84,7 @@ extern int of_scan_flat_dt(int (*it)(unsigned long node,
> const char *uname,
>  extern void *of_get_flat_dt_prop(unsigned long node, const char *name,
>                                 unsigned long *size);
>  extern int of_flat_dt_is_compatible(unsigned long node, const char *name);
> +extern int of_flat_dt_match(unsigned long node, const char **matches);
>

Maybe export of_fdt_match, too?


>  extern unsigned long of_get_flat_dt_root(void);
>
>  extern int early_init_dt_scan_chosen(unsigned long node, const char
> *uname,
>
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev
>

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

^ permalink raw reply

* [PATCH] macintosh: wrong test in fan_{read,write}_reg()
From: roel kluin @ 2010-12-31 14:57 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, linuxppc-dev, Andrew Morton, LKML

Fix error test in fan_{read,write}_reg()

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
 drivers/macintosh/therm_pm72.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

ENODEV and EIO are positive (22 and 8), so the tests did not work.

diff --git a/drivers/macintosh/therm_pm72.c b/drivers/macintosh/therm_pm72.c
index 4454927..6256a08 100644
--- a/drivers/macintosh/therm_pm72.c
+++ b/drivers/macintosh/therm_pm72.c
@@ -443,7 +443,7 @@ static int fan_read_reg(int reg, unsigned char *buf, int nb)
 	tries = 0;
 	for (;;) {
 		nr = i2c_master_recv(fcu, buf, nb);
-		if (nr > 0 || (nr < 0 && nr != ENODEV) || tries >= 100)
+		if (nr > 0 || (nr < 0 && nr != -ENODEV) || tries >= 100)
 			break;
 		msleep(10);
 		++tries;
@@ -464,7 +464,7 @@ static int fan_write_reg(int reg, const unsigned char *ptr, int nb)
 	tries = 0;
 	for (;;) {
 		nw = i2c_master_send(fcu, buf, nb);
-		if (nw > 0 || (nw < 0 && nw != EIO) || tries >= 100)
+		if (nw > 0 || (nw < 0 && nw != -EIO) || tries >= 100)
 			break;
 		msleep(10);
 		++tries;

^ permalink raw reply related

* [PATCH] of/flattree: Add of_flat_dt_match() helper function
From: Grant Likely @ 2010-12-31  9:15 UTC (permalink / raw)
  To: devicetree-discuss, linuxppc-dev

This patch adds of_flat_dt_match() which tests a node for
compatibility with a list of values and converts the relevant powerpc
platform code to use it.  This approach simplifies the board support
code a bit.

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
 arch/powerpc/platforms/40x/ppc40x_simple.c    |   13 +++-------
 arch/powerpc/platforms/512x/mpc5121_generic.c |   13 +---------
 arch/powerpc/platforms/52xx/lite5200.c        |   16 +++++-------
 arch/powerpc/platforms/52xx/media5200.c       |   13 +---------
 arch/powerpc/platforms/52xx/mpc5200_simple.c  |   13 +---------
 arch/powerpc/platforms/83xx/mpc830x_rdb.c     |   13 ++++++----
 arch/powerpc/platforms/83xx/mpc831x_rdb.c     |   11 +++++---
 arch/powerpc/platforms/83xx/mpc837x_rdb.c     |   15 +++++++----
 arch/powerpc/platforms/85xx/tqm85xx.c         |   20 +++++++--------
 drivers/of/fdt.c                              |   34 ++++++++++++++++++++++++-
 include/linux/of_fdt.h                        |    1 +
 11 files changed, 84 insertions(+), 78 deletions(-)

diff --git a/arch/powerpc/platforms/40x/ppc40x_simple.c b/arch/powerpc/platforms/40x/ppc40x_simple.c
index 546bbc2..2521d93 100644
--- a/arch/powerpc/platforms/40x/ppc40x_simple.c
+++ b/arch/powerpc/platforms/40x/ppc40x_simple.c
@@ -50,7 +50,7 @@ machine_device_initcall(ppc40x_simple, ppc40x_device_probe);
  * Again, if your board needs to do things differently then create a
  * board.c file for it rather than adding it to this list.
  */
-static char *board[] __initdata = {
+static const char *board[] __initdata = {
 	"amcc,acadia",
 	"amcc,haleakala",
 	"amcc,kilauea",
@@ -60,14 +60,9 @@ static char *board[] __initdata = {
 
 static int __init ppc40x_probe(void)
 {
-	unsigned long root = of_get_flat_dt_root();
-	int i = 0;
-
-	for (i = 0; i < ARRAY_SIZE(board); i++) {
-		if (of_flat_dt_is_compatible(root, board[i])) {
-			ppc_pci_set_flags(PPC_PCI_REASSIGN_ALL_RSRC);
-			return 1;
-		}
+	if (of_flat_dt_match(of_get_flat_dt_root(), board)) {
+		ppc_pci_set_flags(PPC_PCI_REASSIGN_ALL_RSRC);
+		return 1;
 	}
 
 	return 0;
diff --git a/arch/powerpc/platforms/512x/mpc5121_generic.c b/arch/powerpc/platforms/512x/mpc5121_generic.c
index e487eb0..926731f 100644
--- a/arch/powerpc/platforms/512x/mpc5121_generic.c
+++ b/arch/powerpc/platforms/512x/mpc5121_generic.c
@@ -26,7 +26,7 @@
 /*
  * list of supported boards
  */
-static char *board[] __initdata = {
+static const char *board[] __initdata = {
 	"prt,prtlvt",
 	NULL
 };
@@ -36,16 +36,7 @@ static char *board[] __initdata = {
  */
 static int __init mpc5121_generic_probe(void)
 {
-	unsigned long node = of_get_flat_dt_root();
-	int i = 0;
-
-	while (board[i]) {
-		if (of_flat_dt_is_compatible(node, board[i]))
-			break;
-		i++;
-	}
-
-	return board[i] != NULL;
+	return of_flat_dt_match(of_get_flat_dt_root(), board);
 }
 
 define_machine(mpc5121_generic) {
diff --git a/arch/powerpc/platforms/52xx/lite5200.c b/arch/powerpc/platforms/52xx/lite5200.c
index de55bc0..01ffa64 100644
--- a/arch/powerpc/platforms/52xx/lite5200.c
+++ b/arch/powerpc/platforms/52xx/lite5200.c
@@ -172,20 +172,18 @@ static void __init lite5200_setup_arch(void)
 	mpc52xx_setup_pci();
 }
 
+static const char *board[] __initdata = {
+	"fsl,lite5200",
+	"fsl,lite5200b",
+	NULL,
+};
+
 /*
  * Called very early, MMU is off, device-tree isn't unflattened
  */
 static int __init lite5200_probe(void)
 {
-	unsigned long node = of_get_flat_dt_root();
-	const char *model = of_get_flat_dt_prop(node, "model", NULL);
-
-	if (!of_flat_dt_is_compatible(node, "fsl,lite5200") &&
-	    !of_flat_dt_is_compatible(node, "fsl,lite5200b"))
-		return 0;
-	pr_debug("%s board found\n", model ? model : "unknown");
-
-	return 1;
+	return of_flat_dt_match(of_get_flat_dt_root(), board);
 }
 
 define_machine(lite5200) {
diff --git a/arch/powerpc/platforms/52xx/media5200.c b/arch/powerpc/platforms/52xx/media5200.c
index 0bac3a3..2c7780c 100644
--- a/arch/powerpc/platforms/52xx/media5200.c
+++ b/arch/powerpc/platforms/52xx/media5200.c
@@ -239,7 +239,7 @@ static void __init media5200_setup_arch(void)
 }
 
 /* list of the supported boards */
-static char *board[] __initdata = {
+static const char *board[] __initdata = {
 	"fsl,media5200",
 	NULL
 };
@@ -249,16 +249,7 @@ static char *board[] __initdata = {
  */
 static int __init media5200_probe(void)
 {
-	unsigned long node = of_get_flat_dt_root();
-	int i = 0;
-
-	while (board[i]) {
-		if (of_flat_dt_is_compatible(node, board[i]))
-			break;
-		i++;
-	}
-
-	return (board[i] != NULL);
+	return of_flat_dt_match(of_get_flat_dt_root(), board);
 }
 
 define_machine(media5200_platform) {
diff --git a/arch/powerpc/platforms/52xx/mpc5200_simple.c b/arch/powerpc/platforms/52xx/mpc5200_simple.c
index d45be5b..e36d6e2 100644
--- a/arch/powerpc/platforms/52xx/mpc5200_simple.c
+++ b/arch/powerpc/platforms/52xx/mpc5200_simple.c
@@ -49,7 +49,7 @@ static void __init mpc5200_simple_setup_arch(void)
 }
 
 /* list of the supported boards */
-static char *board[] __initdata = {
+static const char *board[] __initdata = {
 	"intercontrol,digsy-mtc",
 	"manroland,mucmc52",
 	"manroland,uc101",
@@ -66,16 +66,7 @@ static char *board[] __initdata = {
  */
 static int __init mpc5200_simple_probe(void)
 {
-	unsigned long node = of_get_flat_dt_root();
-	int i = 0;
-
-	while (board[i]) {
-		if (of_flat_dt_is_compatible(node, board[i]))
-			break;
-		i++;
-	}
-	
-	return (board[i] != NULL);
+	return of_flat_dt_match(of_get_flat_dt_root(), board);
 }
 
 define_machine(mpc5200_simple_platform) {
diff --git a/arch/powerpc/platforms/83xx/mpc830x_rdb.c b/arch/powerpc/platforms/83xx/mpc830x_rdb.c
index 846831d..661d354 100644
--- a/arch/powerpc/platforms/83xx/mpc830x_rdb.c
+++ b/arch/powerpc/platforms/83xx/mpc830x_rdb.c
@@ -57,16 +57,19 @@ static void __init mpc830x_rdb_init_IRQ(void)
 	ipic_set_default_priority();
 }
 
+struct const char *board[] __initdata = {
+	"MPC8308RDB",
+	"fsl,mpc8308rdb",
+	"denx,mpc8308_p1m",
+	NULL
+}
+
 /*
  * Called very early, MMU is off, device-tree isn't unflattened
  */
 static int __init mpc830x_rdb_probe(void)
 {
-	unsigned long root = of_get_flat_dt_root();
-
-	return of_flat_dt_is_compatible(root, "MPC8308RDB") ||
-	       of_flat_dt_is_compatible(root, "fsl,mpc8308rdb") ||
-	       of_flat_dt_is_compatible(root, "denx,mpc8308_p1m");
+	return of_flat_dt_match(of_get_flat_dt_root(), board);
 }
 
 static struct of_device_id __initdata of_bus_ids[] = {
diff --git a/arch/powerpc/platforms/83xx/mpc831x_rdb.c b/arch/powerpc/platforms/83xx/mpc831x_rdb.c
index ae525e4..b54cd73 100644
--- a/arch/powerpc/platforms/83xx/mpc831x_rdb.c
+++ b/arch/powerpc/platforms/83xx/mpc831x_rdb.c
@@ -60,15 +60,18 @@ static void __init mpc831x_rdb_init_IRQ(void)
 	ipic_set_default_priority();
 }
 
+struct const char *board[] __initdata = {
+	"MPC8313ERDB",
+	"fsl,mpc8315erdb",
+	NULL
+}
+
 /*
  * Called very early, MMU is off, device-tree isn't unflattened
  */
 static int __init mpc831x_rdb_probe(void)
 {
-	unsigned long root = of_get_flat_dt_root();
-
-	return of_flat_dt_is_compatible(root, "MPC8313ERDB") ||
-	       of_flat_dt_is_compatible(root, "fsl,mpc8315erdb");
+	return of_flat_dt_match(of_get_flat_dt_root(), board);
 }
 
 static struct of_device_id __initdata of_bus_ids[] = {
diff --git a/arch/powerpc/platforms/83xx/mpc837x_rdb.c b/arch/powerpc/platforms/83xx/mpc837x_rdb.c
index 910caa6..7bafbf2 100644
--- a/arch/powerpc/platforms/83xx/mpc837x_rdb.c
+++ b/arch/powerpc/platforms/83xx/mpc837x_rdb.c
@@ -101,17 +101,20 @@ static void __init mpc837x_rdb_init_IRQ(void)
 	ipic_set_default_priority();
 }
 
+static const char *board[] __initdata = {
+	"fsl,mpc8377rdb",
+	"fsl,mpc8378rdb",
+	"fsl,mpc8379rdb",
+	"fsl,mpc8377wlan",
+	NULL
+};
+
 /*
  * Called very early, MMU is off, device-tree isn't unflattened
  */
 static int __init mpc837x_rdb_probe(void)
 {
-	unsigned long root = of_get_flat_dt_root();
-
-	return of_flat_dt_is_compatible(root, "fsl,mpc8377rdb") ||
-	       of_flat_dt_is_compatible(root, "fsl,mpc8378rdb") ||
-	       of_flat_dt_is_compatible(root, "fsl,mpc8379rdb") ||
-	       of_flat_dt_is_compatible(root, "fsl,mpc8377wlan");
+	return of_flat_dt_match(of_get_flat_dt_root(), board);
 }
 
 define_machine(mpc837x_rdb) {
diff --git a/arch/powerpc/platforms/85xx/tqm85xx.c b/arch/powerpc/platforms/85xx/tqm85xx.c
index 8f29bbc..5e847d0 100644
--- a/arch/powerpc/platforms/85xx/tqm85xx.c
+++ b/arch/powerpc/platforms/85xx/tqm85xx.c
@@ -186,21 +186,21 @@ static int __init declare_of_platform_devices(void)
 }
 machine_device_initcall(tqm85xx, declare_of_platform_devices);
 
+static const char *board[] __initdata = {
+	"tqc,tqm8540",
+	"tqc,tqm8541",
+	"tqc,tqm8548",
+	"tqc,tqm8555",
+	"tqc,tqm8560",
+	NULL
+};
+
 /*
  * Called very early, device-tree isn't unflattened
  */
 static int __init tqm85xx_probe(void)
 {
-	unsigned long root = of_get_flat_dt_root();
-
-	if ((of_flat_dt_is_compatible(root, "tqc,tqm8540")) ||
-	    (of_flat_dt_is_compatible(root, "tqc,tqm8541")) ||
-	    (of_flat_dt_is_compatible(root, "tqc,tqm8548")) ||
-	    (of_flat_dt_is_compatible(root, "tqc,tqm8555")) ||
-	    (of_flat_dt_is_compatible(root, "tqc,tqm8560")))
-		return 1;
-
-	return 0;
+	return of_flat_dt_match(of_get_flat_dt_root(), board);
 }
 
 define_machine(tqm85xx) {
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 8a90ee4..5a3db04 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -78,19 +78,23 @@ void *of_fdt_get_property(struct boot_param_header *blob,
  * @blob: A device tree blob
  * @node: node to test
  * @compat: compatible string to compare with compatible list.
+ *
+ * On match, returns a non-zero value with smaller values returned for more
+ * specific compatible values.
  */
 int of_fdt_is_compatible(struct boot_param_header *blob,
 		      unsigned long node, const char *compat)
 {
 	const char *cp;
-	unsigned long cplen, l;
+	unsigned long cplen, l, score = 0;
 
 	cp = of_fdt_get_property(blob, node, "compatible", &cplen);
 	if (cp == NULL)
 		return 0;
 	while (cplen > 0) {
+		score++;
 		if (of_compat_cmp(cp, compat, strlen(compat)) == 0)
-			return 1;
+			return score;
 		l = strlen(cp) + 1;
 		cp += l;
 		cplen -= l;
@@ -99,6 +103,24 @@ int of_fdt_is_compatible(struct boot_param_header *blob,
 	return 0;
 }
 
+/**
+ * of_flat_dt_match - Return true if node matches a list of compatible values
+ */
+int of_fdt_match(struct boot_param_header *blob, unsigned long node,
+                 const char **compat)
+{
+	unsigned int tmp, score = 0;
+
+	while (*compat) {
+		tmp = of_fdt_is_compatible(blob, node, *compat);
+		if (tmp && (score == 0 || (tmp < score)))
+			score = tmp;
+		compat++;
+	}
+
+	return score;
+}
+
 static void *unflatten_dt_alloc(unsigned long *mem, unsigned long size,
 				       unsigned long align)
 {
@@ -511,6 +533,14 @@ int __init of_flat_dt_is_compatible(unsigned long node, const char *compat)
 	return of_fdt_is_compatible(initial_boot_params, node, compat);
 }
 
+/**
+ * of_flat_dt_match - Return true if node matches a list of compatible values
+ */
+int __init of_flat_dt_match(unsigned long node, const char **compat)
+{
+	return of_fdt_match(initial_boot_params, node, compat);
+}
+
 #ifdef CONFIG_BLK_DEV_INITRD
 /**
  * early_init_dt_check_for_initrd - Decode initrd location from flat tree
diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h
index 9ce5dfd..fb327f3 100644
--- a/include/linux/of_fdt.h
+++ b/include/linux/of_fdt.h
@@ -84,6 +84,7 @@ extern int of_scan_flat_dt(int (*it)(unsigned long node, const char *uname,
 extern void *of_get_flat_dt_prop(unsigned long node, const char *name,
 				 unsigned long *size);
 extern int of_flat_dt_is_compatible(unsigned long node, const char *name);
+extern int of_flat_dt_match(unsigned long node, const char **matches);
 extern unsigned long of_get_flat_dt_root(void);
 
 extern int early_init_dt_scan_chosen(unsigned long node, const char *uname,

^ permalink raw reply related

* Re: [PATCH 2/5] of/device: make for_each_node* check status properties
From: Grant Likely @ 2010-12-31  7:46 UTC (permalink / raw)
  To: Deepak Saxena; +Cc: devicetree-discuss, linuxppc-dev
In-Reply-To: <20101208192957.GF32473@mentor.com>

On Wed, Dec 08, 2010 at 11:29:57AM -0800, Deepak Saxena wrote:
> Some early device drivers don't actually implement a struct of_platform_driver,
> and instead use the for_each_node* iterators to search for matching device
> nodes. Disabled device nodes will no longer be returned by these iterators.
> 
> Signed-off-by: Hollis Blanchard <hollis_blanchard@mentor.com>
> Signed-off-by: Deepak Saxena <deepak_saxena@mentor.com>

As already discussed, the generic device tree iterator and search
functions should not be filtering the results as done here.

g.

> ---
>  arch/powerpc/kernel/pci_of_scan.c         |    2 --
>  arch/powerpc/platforms/83xx/usb.c         |    2 +-
>  arch/powerpc/platforms/85xx/mpc85xx_mds.c |   13 ++-----------
>  arch/powerpc/sysdev/fsl_pci.c             |    5 -----
>  arch/powerpc/sysdev/ppc4xx_pci.c          |   15 ---------------
>  drivers/of/base.c                         |   25 +++++++++++++++++++++++--
>  6 files changed, 26 insertions(+), 36 deletions(-)
> 
> diff --git a/arch/powerpc/kernel/pci_of_scan.c b/arch/powerpc/kernel/pci_of_scan.c
> index e751506..fa4f719 100644
> --- a/arch/powerpc/kernel/pci_of_scan.c
> +++ b/arch/powerpc/kernel/pci_of_scan.c
> @@ -310,8 +310,6 @@ static void __devinit __of_scan_bus(struct device_node *node,
>  	/* Scan direct children */
>  	for_each_child_of_node(node, child) {
>  		pr_debug("  * %s\n", child->full_name);
> -		if (!of_device_is_available(child))
> -			continue;
>  		reg = of_get_property(child, "reg", &reglen);
>  		if (reg == NULL || reglen < 20)
>  			continue;
> diff --git a/arch/powerpc/platforms/83xx/usb.c b/arch/powerpc/platforms/83xx/usb.c
> index 3ba4bb7..749c70b 100644
> --- a/arch/powerpc/platforms/83xx/usb.c
> +++ b/arch/powerpc/platforms/83xx/usb.c
> @@ -211,7 +211,7 @@ int mpc837x_usb_cfg(void)
>  	int ret = 0;
>  
>  	np = of_find_compatible_node(NULL, NULL, "fsl-usb2-dr");
> -	if (!np || !of_device_is_available(np))
> +	if (!np)
>  		return -ENODEV;
>  	prop = of_get_property(np, "phy_type", NULL);
>  
> diff --git a/arch/powerpc/platforms/85xx/mpc85xx_mds.c b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
> index aa34cac..5d1a33f 100644
> --- a/arch/powerpc/platforms/85xx/mpc85xx_mds.c
> +++ b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
> @@ -170,10 +170,8 @@ static void __init mpc85xx_publish_qe_devices(void)
>  	struct device_node *np;
>  
>  	np = of_find_compatible_node(NULL, NULL, "fsl,qe");
> -	if (!of_device_is_available(np)) {
> -		of_node_put(np);
> +	if (!np)
>  		return;
> -	}
>  
>  	of_platform_bus_probe(NULL, mpc85xx_qe_ids, NULL);
>  }
> @@ -267,11 +265,6 @@ static void __init mpc85xx_mds_qe_init(void)
>  			return;
>  	}
>  
> -	if (!of_device_is_available(np)) {
> -		of_node_put(np);
> -		return;
> -	}
> -
>  	qe_reset();
>  	of_node_put(np);
>  
> @@ -328,10 +321,8 @@ static void __init mpc85xx_mds_qeic_init(void)
>  	struct device_node *np;
>  
>  	np = of_find_compatible_node(NULL, NULL, "fsl,qe");
> -	if (!of_device_is_available(np)) {
> -		of_node_put(np);
> +	if (!np)
>  		return;
> -	}
>  
>  	np = of_find_compatible_node(NULL, NULL, "fsl,qe-ic");
>  	if (!np) {
> diff --git a/arch/powerpc/sysdev/fsl_pci.c b/arch/powerpc/sysdev/fsl_pci.c
> index 818f7c6..fba4ec7 100644
> --- a/arch/powerpc/sysdev/fsl_pci.c
> +++ b/arch/powerpc/sysdev/fsl_pci.c
> @@ -623,11 +623,6 @@ int __init mpc83xx_add_bridge(struct device_node *dev)
>  
>  	is_mpc83xx_pci = 1;
>  
> -	if (!of_device_is_available(dev)) {
> -		pr_warning("%s: disabled by the firmware.\n",
> -			   dev->full_name);
> -		return -ENODEV;
> -	}
>  	pr_debug("Adding PCI host bridge %s\n", dev->full_name);
>  
>  	/* Fetch host bridge registers address */
> diff --git a/arch/powerpc/sysdev/ppc4xx_pci.c b/arch/powerpc/sysdev/ppc4xx_pci.c
> index 156aa7d..cf2adec 100644
> --- a/arch/powerpc/sysdev/ppc4xx_pci.c
> +++ b/arch/powerpc/sysdev/ppc4xx_pci.c
> @@ -321,13 +321,6 @@ static void __init ppc4xx_probe_pci_bridge(struct device_node *np)
>  	const int *bus_range;
>  	int primary = 0;
>  
> -	/* Check if device is enabled */
> -	if (!of_device_is_available(np)) {
> -		printk(KERN_INFO "%s: Port disabled via device-tree\n",
> -		       np->full_name);
> -		return;
> -	}
> -
>  	/* Fetch config space registers address */
>  	if (of_address_to_resource(np, 0, &rsrc_cfg)) {
>  		printk(KERN_ERR "%s: Can't get PCI config register base !",
> @@ -1890,14 +1883,6 @@ static void __init ppc4xx_probe_pciex_bridge(struct device_node *np)
>  	port = &ppc4xx_pciex_ports[portno];
>  	port->index = portno;
>  
> -	/*
> -	 * Check if device is enabled
> -	 */
> -	if (!of_device_is_available(np)) {
> -		printk(KERN_INFO "PCIE%d: Port disabled via device-tree\n", port->index);
> -		return;
> -	}
> -
>  	port->node = of_node_get(np);
>  	pval = of_get_property(np, "sdr-base", NULL);
>  	if (pval == NULL) {
> diff --git a/drivers/of/base.c b/drivers/of/base.c
> index 710b53b..5d269a4 100644
> --- a/drivers/of/base.c
> +++ b/drivers/of/base.c
> @@ -344,6 +344,8 @@ EXPORT_SYMBOL(of_get_next_child);
>   *
>   *	Returns a node pointer with refcount incremented, use
>   *	of_node_put() on it when done.
> + *
> + *	Does not return nodes marked unavailable by a status property.
>   */
>  struct device_node *of_find_node_by_path(const char *path)
>  {
> @@ -352,6 +354,7 @@ struct device_node *of_find_node_by_path(const char *path)
>  	read_lock(&devtree_lock);
>  	for (; np; np = np->allnext) {
>  		if (np->full_name && (of_node_cmp(np->full_name, path) == 0)
> +			&& of_device_is_available(np)
>  		    && of_node_get(np))
>  			break;
>  	}
> @@ -370,6 +373,8 @@ EXPORT_SYMBOL(of_find_node_by_path);
>   *
>   *	Returns a node pointer with refcount incremented, use
>   *	of_node_put() on it when done.
> + *
> + *	Does not return nodes marked unavailable by a status property.
>   */
>  struct device_node *of_find_node_by_name(struct device_node *from,
>  	const char *name)
> @@ -380,6 +385,7 @@ struct device_node *of_find_node_by_name(struct device_node *from,
>  	np = from ? from->allnext : allnodes;
>  	for (; np; np = np->allnext)
>  		if (np->name && (of_node_cmp(np->name, name) == 0)
> +			&& of_device_is_available(np)
>  		    && of_node_get(np))
>  			break;
>  	of_node_put(from);
> @@ -399,6 +405,8 @@ EXPORT_SYMBOL(of_find_node_by_name);
>   *
>   *	Returns a node pointer with refcount incremented, use
>   *	of_node_put() on it when done.
> + *
> + *	Does not return nodes marked unavailable by a status property.
>   */
>  struct device_node *of_find_node_by_type(struct device_node *from,
>  	const char *type)
> @@ -409,6 +417,7 @@ struct device_node *of_find_node_by_type(struct device_node *from,
>  	np = from ? from->allnext : allnodes;
>  	for (; np; np = np->allnext)
>  		if (np->type && (of_node_cmp(np->type, type) == 0)
> +			&& of_device_is_available(np)
>  		    && of_node_get(np))
>  			break;
>  	of_node_put(from);
> @@ -430,6 +439,8 @@ EXPORT_SYMBOL(of_find_node_by_type);
>   *
>   *	Returns a node pointer with refcount incremented, use
>   *	of_node_put() on it when done.
> + *
> + *	Does not return nodes marked unavailable by a status property.
>   */
>  struct device_node *of_find_compatible_node(struct device_node *from,
>  	const char *type, const char *compatible)
> @@ -442,7 +453,9 @@ struct device_node *of_find_compatible_node(struct device_node *from,
>  		if (type
>  		    && !(np->type && (of_node_cmp(np->type, type) == 0)))
>  			continue;
> -		if (of_device_is_compatible(np, compatible) && of_node_get(np))
> +		if (of_device_is_compatible(np, compatible)
> +			&& of_device_is_available(np)
> +			&& of_node_get(np))
>  			break;
>  	}
>  	of_node_put(from);
> @@ -462,6 +475,8 @@ EXPORT_SYMBOL(of_find_compatible_node);
>   *
>   *	Returns a node pointer with refcount incremented, use
>   *	of_node_put() on it when done.
> + *
> + *	Does not return nodes marked unavailable by a status property.
>   */
>  struct device_node *of_find_node_with_property(struct device_node *from,
>  	const char *prop_name)
> @@ -472,6 +487,8 @@ struct device_node *of_find_node_with_property(struct device_node *from,
>  	read_lock(&devtree_lock);
>  	np = from ? from->allnext : allnodes;
>  	for (; np; np = np->allnext) {
> +		if (!of_device_is_available(np))
> +			continue;
>  		for (pp = np->properties; pp != 0; pp = pp->next) {
>  			if (of_prop_cmp(pp->name, prop_name) == 0) {
>  				of_node_get(np);
> @@ -526,6 +543,8 @@ EXPORT_SYMBOL(of_match_node);
>   *
>   *	Returns a node pointer with refcount incremented, use
>   *	of_node_put() on it when done.
> + *
> + *	Does not return nodes marked unavailable by a status property.
>   */
>  struct device_node *of_find_matching_node(struct device_node *from,
>  					  const struct of_device_id *matches)
> @@ -535,7 +554,9 @@ struct device_node *of_find_matching_node(struct device_node *from,
>  	read_lock(&devtree_lock);
>  	np = from ? from->allnext : allnodes;
>  	for (; np; np = np->allnext) {
> -		if (of_match_node(matches, np) && of_node_get(np))
> +		if (of_match_node(matches, np)
> +			&& of_device_is_available(np)
> +			&& of_node_get(np))
>  			break;
>  	}
>  	of_node_put(from);
> -- 
> 1.6.3.3
> 
> _______________________________________________
> devicetree-discuss mailing list
> devicetree-discuss@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/devicetree-discuss

^ 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