Skip to contentSkip to conversation

bootcup crash in prom tree building with specific PCI card

DISCUSSION Meelis Roos 2 participants 9 messages Jun 7, 2010 – Aug 24, 2010 SPARC + UltraSPARC (sparc/sparc64)

lore
Share & tools
lore
#0 lore raw

Hello,

After successfully testing 2.6.35-rc2-00001-g386f40c on my Ultra 10, I decided to try some FCode ROM PCI cards in this U10. Sun SYM22801 worked fine, ATTO SCSI fro APPle was found and ignored by PROM and worked in Linux, but Orange Micro Grappler 906F gave me trouble. It was detected by PROM (.properties ath the bottom of the mail) but Linux crashed early on the boot while building prom tree. The actual crash happens in prom_early_alloc and I don't understand the code well there. What debug printk-s do I need to debug this further?

PROMLIB: Sun IEEE Boot Prom 'OBP 3.31.0 2001/07/25 20:36'
PROMLIB: Root node compatible:
Linux version 2.6.35-rc1-00261-g03cd373 (mroos@u10) (gcc version 4.4.4 (Debian 4.4.4-3) ) #1 Fri Jun 4 04:44:32 EEST 2010
debug: ignoring loglevel setting.
debug: ignoring loglevel setting.
bootconsole [earlyprom0] enabled
ARCH: SUN4U
Ethernet address: 08:00:20:9e:82:fd
Kernel: Using 2 locked TLB entries for main kernel image.
Remapping the kernel... done.
spitfire_data_access_exception: SFSR[0000000000801009] SFAR[0000000e10a8e7d0], going.

              \|/ ____ \|/
              "@'/ .. \`@"
              /_| \__/ |_\
                 \__U_/

swapper(0): Dax [#1]
TSTATE: 0000000080e01604 TPC: 0000000000878328 TNPC: 0000000000878234 Y: 00000000 Not tainted
TPC: <__lmb_alloc_base+0x14c/0x164>
g0: 0000000000000000 g1: 00000000008e0c00 g2: 00000000008e0d58 g3: fffffffffffffff8
g4: 0000000000829ef0 g5: 0000000000000000 g6: 0000000000820000 g7: 0000000000000000
o0: 00000000008e0d58 o1: 00000000008e1598 o2: 0000000000000080 o3: 0000000000000000
o4: 000000001fede000 o5: 4501dc2230dcde41 sp: 0000000000822ea1 ret_pc: 2a4ee00e10a8e7c8
RPC: <0x2a4ee00e10a8e7c8>
l0: 32a4ee00e101ada5 l1: 0000000000000000 l2: 00000000f00673e8 l3: 0000000000820000
l4: 0000000000000004 l5: 0000000000000004 l6: 0000000000000000 l7: fffffffffffffff0
i0: 0000000000000050 i1: ffffffffffffffc0 i2: 0000000000000000 i3: 0000000000000000
i4: fffff8001fed6340 i5: 0000000000000000 i6: 0000000000822f51 i7: 0000000000878380
I7: <lmb_alloc_base+0xc/0x34>

Call Trace:
 [0000000000878380] lmb_alloc_base+0xc/0x34
 [000000000086c474] prom_early_alloc+0xc/0x60
 [000000000086c054] build_one_prop+0x28/0x138
 [000000000086c220] prom_create_node+0xbc/0xe8
 [000000000086c2f0] prom_build_tree+0x1c/0xac
 [000000000086c344] prom_build_tree+0x70/0xac
 [000000000086c344] prom_build_tree+0x70/0xac
 [000000000086c3d4] prom_build_devicetree+0x54/0x80
 [000000000086f7cc] paging_init+0x94c/0xd4c
 [000000000086b9fc] setup_arch+0x320/0x330
 [000000000086a544] start_kernel+0x6c/0x2ec
 [000000000071c664] tlb_fixup_done+0x80/0x9c
 [0000000000000000] (null)

Disabling lock debugging due to kernel taint
Caller[0000000000878380]: lmb_alloc_base+0xc/0x34
Caller[000000000086c474]: prom_early_alloc+0xc/0x60
Caller[000000000086c054]: build_one_prop+0x28/0x138
Caller[000000000086c220]: prom_create_node+0xbc/0xe8
Caller[000000000086c2f0]: prom_build_tree+0x1c/0xac
Caller[000000000086c344]: prom_build_tree+0x70/0xac
Caller[000000000086c344]: prom_build_tree+0x70/0xac
Caller[000000000086c3d4]: prom_build_devicetree+0x54/0x80
Caller[000000000086f7cc]: paging_init+0x94c/0xd4c
Caller[000000000086b9fc]: setup_arch+0x320/0x330
Caller[000000000086a544]: start_kernel+0x6c/0x2ec
Caller[000000000071c664]: tlb_fixup_done+0x80/0x9c
Caller[0000000000000000]: (null)
Instruction DUMP: a0043fff 9e03fff0 2efc3fc4 <c25be008> b0102000 81cfe008 01000000 106fffdb 82006010

Kernel panic - not syncing: Attempted to kill the idle task!
Call Trace:
 [000000000045676c] do_exit+0x60c/0x6a0
 [00000000004279f4] die_if_kernel+0x194/0x340
 [000000000042885c] spitfire_data_access_exception+0xbc/0xe0
 [00000000004056c4] __spitfire_data_access_exception+0x34/0x44
 [0000000000878328] __lmb_alloc_base+0x14c/0x164
 [0000000000878380] lmb_alloc_base+0xc/0x34
 [000000000086c474] prom_early_alloc+0xc/0x60
 [000000000086c054] build_one_prop+0x28/0x138
 [000000000086c220] prom_create_node+0xbc/0xe8
 [000000000086c2f0] prom_build_tree+0x1c/0xac
 [000000000086c344] prom_build_tree+0x70/0xac
 [000000000086c344] prom_build_tree+0x70/0xac
 [000000000086c3d4] prom_build_devicetree+0x54/0x80
 [000000000086f7cc] paging_init+0x94c/0xd4c
 [000000000086b9fc] setup_arch+0x320/0x330
 [000000000086a544] start_kernel+0x6c/0x2ec

Press Stop-A (L1-A) to return to the boot prom

Sun Ultra 5/10 UPA/PCI (UltraSPARC-IIi 300MHz), No Keyboard OpenBoot 3.31, 512 MB (60 ns) memory installed, Serial #10388221. Ethernet address 8:0:20:9e:82:fd, Host ID: 809e82fd.

Initializing Memory

ok cd /pci/pci
ok ls
f009908c Grappler_906F@2
f00856e8 scsi@1
ok cd Grappler_906F@2
ok .properties
assigned-addresses 82021030 00000000 00020000 00000000 00008000

                         82021014 00000000 00030000 00000000 00000100 
                         81021010 00000000 00000400 00000000 00000100 
driver,aapl,macosx,powerpc  4d 4b 58 54 4d 4f 53 58 00 00 7c bb 36 3b 7d 38 
driver,aapl,macos,powerpc  4a 6f 79 21 70 65 66 66 70 77 70 63 00 00 00 01 
power-consumption        00000000 00000000 
                         007270e0 007270e0 
                         00000000 00000000 
                         007b98a0 007b98a0 
reg                      00021000 00000000 00000000 00000000 00000000 
                         02021030 00000000 00000000 00000000 00008000 
                         02021014 00000000 00000000 00000000 00000100 
                         01021010 00000000 00000000 00000000 00000100 
model                    FAST
device_type              scsi
name                     Grappler_906F
fcode-rom-offset         00000000 
fast-back-to-back 
devsel-speed             00000001 
class-code               00010000 
interrupts               00000001 
max-latency              00000004 
More [<space>,<cr>,q,n,p,c] ?                               min-grant                00000004 
subsystem-vendor-id      000010cd 
subsystem-id             00001310 
revision-id              00000003 
device-id                00001300 
vendor-id                000010cd 

ok
ok .version
Release 3.31 Version 0 created 2001/07/25 20:36
OBP 3.31.0 2001/07/25 20:36
POST 3.1.0 2000/06/27 13:56
ok

Signature · 1 line
Meelis Roos ([email protected])
maintainer
#1 lore raw

From: Meelis Roos <[email protected]>
Date: Mon, 7 Jun 2010 17:57:50 +0300 (EEST)

Quoted 8 lines

Initializing Memory

ok cd /pci/pci
ok ls
f009908c Grappler_906F@2
f00856e8 scsi@1
ok cd Grappler_906F@2
ok .properties

What devices sit underneath "Grappler_906F@2"? Provide ".properties" output for those please.

That's what we're creating nodes for when the kernel crashes.

Frankly, I'm surprised the machine even powers on to the firmware prompt with these MAC cards in the PCI slots :-)

Thanks.

#2 lore raw
In reply to Meelis Roos
Quoted 2 lines

What devices sit underneath "Grappler_906F@2"? Provide ".properties" output for those please.

There are no devices underneath it.

Quoted 2 lines

Frankly, I'm surprised the machine even powers on to the firmware prompt with these MAC cards in the PCI slots :-)

Well, I have occasionally tried quite some of them and it has always been the same - OF sees the name but of course does not run the code, but never have I see OF crash on them.

Signature · 1 line
Meelis Roos ([email protected])
maintainer
#3 lore raw
In reply to Meelis Roos

From: Meelis Roos <[email protected]>
Date: Mon, 7 Jun 2010 17:57:50 +0300 (EEST)

Quoted 5 lines

swapper(0): Dax [#1]
TSTATE: 0000000080e01604 TPC: 0000000000878328 TNPC: 0000000000878234 Y: 00000000 Not tainted
TPC: <__lmb_alloc_base+0x14c/0x164>
g0: 0000000000000000 g1: 00000000008e0c00 g2: 00000000008e0d58 g3: fffffffffffffff8
g4: 0000000000829ef0 g5: 0000000000000000 g6: 0000000000820000 g7: 0000000000000000

Quoted 8 lines

o0: 00000000008e0d58 o1: 00000000008e1598 o2: 0000000000000080 o3: 0000000000000000
o4: 000000001fede000 o5: 4501dc2230dcde41 sp: 0000000000822ea1 ret_pc: 2a4ee00e10a8e7c8
RPC: <0x2a4ee00e10a8e7c8>
l0: 32a4ee00e101ada5 l1: 0000000000000000 l2: 00000000f00673e8 l3: 0000000000820000
l4: 0000000000000004 l5: 0000000000000004 l6: 0000000000000000 l7: fffffffffffffff0
i0: 0000000000000050 i1: ffffffffffffffc0 i2: 0000000000000000 i3: 0000000000000000
i4: fffff8001fed6340 i5: 0000000000000000 i6: 0000000000822f51 i7: 0000000000878380
I7: <lmb_alloc_base+0xc/0x34>

So, something overwrites the 'lmb' datastructures in the kernel as we pull in the device tree.

The symbol 'lmb' sits shortly after p1275buf, which is where we store arguments and return values for all prom calls.

What you could do is annotate arch/sparc/kernel/prom_common.c, function build_one_prop() with printouts of the value of lmb.memory.cnt

A good spot would be around the prom_firstprop() and prom_nextprop() invocations.

Once you see garbage values like "0x2a4ee00e10a8e7c8" in lmb.memory.cnt then you know we passed the point that corrupted memory.

I suspect there is some issue with the unusually long property names "driver,aapl,macosx,powerpc" and "driver,aapl,macos,powerpc"

I tried to find obvious problems with such things, but all the code can handle (as best as I can tell) any propery name less than 32 bytes and these are far within that range.

Let me know what the debugging shows you. Please debug against the same kernel you reproduced this with, because current kernels have renamed all of the "lmb*" routines to "memblock*" and also this whole slew or routines and datastructed have been moved out of lib/ and into mm/ which will place everything in a different spot in the kernel image, and therefore change what gets corrupted. With how things are in your particular kernel (lmb sitting right after p1275buf et al.) it'll be much easier to debug.

Thanks.

#4 lore raw
In reply to Meelis Roos
Quoted 11 lines

So, something overwrites the 'lmb' datastructures in the kernel as we pull in the device tree.

The symbol 'lmb' sits shortly after p1275buf, which is where we store arguments and return values for all prom calls.

What you could do is annotate arch/sparc/kernel/prom_common.c, function build_one_prop() with printouts of the value of lmb.memory.cnt

A good spot would be around the prom_firstprop() and prom_nextprop() invocations.

Usually (no problematic card or adaptec scsi in place of problematic card) cnt=2. With problematic card in place, cnt=3 from beginning and for a lot of prom nodes and then, yes, the corruption occurs:

build_one_prop before getproperty: cnt=3, nodeð09908c, name='driver,aapl,macosx,powerpc', valueÿfff8001fed6340, length1931 build_one_prop after getproperty: len1931, cnt2a4ee00e101ada6

Will look at it again tomorrow, enough for now.
Seems that the length on the resource itself might be the culprit?

Signature · 1 line
Meelis Roos ([email protected])
maintainer
#5 lore raw
In reply to Meelis Roos

From: Meelis Roos <[email protected]>
Date: Mon, 23 Aug 2010 13:44:07 +0300 (EEST)

Quoted 9 lines

Usually (no problematic card or adaptec scsi in place of problematic card) cnt=2. With problematic card in place, cnt=3 from beginning and for a lot of prom nodes and then, yes, the corruption occurs:

build_one_prop before getproperty: cnt=3, nodeð09908c, name='driver,aapl,macosx,powerpc', valueÿfff8001fed6340, length1931 build_one_prop after getproperty: len1931, cnt2a4ee00e101ada6

Will look at it again tomorrow, enough for now.
Seems that the length on the resource itself might be the culprit?

That enormous length is the problem, it's writing nearly 32K of garbage past the end of the PROM call buffer.

Thanks for fetching this information, I'll see if I can figure out the problem using that.

maintainer
#6 lore raw
In reply to Meelis Roos

From: Meelis Roos <[email protected]>
Date: Mon, 23 Aug 2010 13:44:07 +0300 (EEST)

Quoted 1 line

Seems that the length on the resource itself might be the culprit?

Ok, thanks for your patience on this.

Here is the fix I am testing, I will write an extensive changelog after I do some more validation on it.

The long and short of it is that we use a fixed 3K buffer for transferring things in and out of the firmware during a PROM call.

This device you have contains a propery that's 32K in size, so that fixed buffer simply won't do. :-)

The reasoning behind the fixed static buffer is historic and no longer applies.

Besides fixing this bug this change will make the kernel about 3K smaller as well.

If you could give this patch a quick test I'd appreciate it.

Thanks!

arch/sparc/include/asm/oplib_64.h +3 -24
index a5db031..3e0b2d6 100644
@@ -185,9 +185,8 @@ extern int prom_getunumber(int syndrome_code,
 			   char *buf, int buflen);
 
 /* Retain physical memory to the caller across soft resets. */
-extern unsigned long prom_retain(const char *name,
-				 unsigned long pa_low, unsigned long pa_high,
-				 long size, long align);
+extern int prom_retain(const char *name, unsigned long size,
+		       unsigned long align, unsigned long *paddr);
 
 /* Load explicit I/D TLB entries into the calling processor. */
 extern long prom_itlb_load(unsigned long index,
@@ -287,26 +286,6 @@ extern void prom_sun4v_guest_soft_state(void);
 extern int prom_ihandle2path(int handle, char *buffer, int bufsize);
 
 /* Client interface level routines. */
-extern long p1275_cmd(const char *, long, ...);
-
-#if 0
-#define P1275_SIZE(x) ((((long)((x) / 32)) << 32) | (x))
-#else
-#define P1275_SIZE(x) x
-#endif
-
-/* We support at most 16 input and 1 output argument */
-#define P1275_ARG_NUMBER		0
-#define P1275_ARG_IN_STRING		1
-#define P1275_ARG_OUT_BUF		2
-#define P1275_ARG_OUT_32B		3
-#define P1275_ARG_IN_FUNCTION		4
-#define P1275_ARG_IN_BUF		5
-#define P1275_ARG_IN_64B		6
-
-#define P1275_IN(x) ((x) & 0xf)
-#define P1275_OUT(x) (((x) << 4) & 0xf0)
-#define P1275_INOUT(i,o) (P1275_IN(i)|P1275_OUT(o))
-#define P1275_ARG(n,x) ((x) << ((n)*3 + 8))
+extern void p1275_cmd_direct(unsigned long *);
 
 #endif /* !(__SPARC64_OPLIB_H) */
arch/sparc/prom/cif.S +8 -8
index 5f27ad7..9c86b4b 100644
@@ -9,18 +9,18 @@
 #include <asm/thread_info.h>
 
 	.text
-	.globl	prom_cif_interface
-prom_cif_interface:
-	sethi	%hi(p1275buf), %o0
-	or	%o0, %lo(p1275buf), %o0
-	ldx	[%o0 + 0x010], %o1	! prom_cif_stack
-	save	%o1, -192, %sp
-	ldx	[%i0 + 0x008], %l2	! prom_cif_handler
+	.globl	prom_cif_direct
+prom_cif_direct:
+	sethi	%hi(p1275buf), %o1
+	or	%o1, %lo(p1275buf), %o1
+	ldx	[%o1 + 0x0010], %o2	! prom_cif_stack
+	save	%o2, -192, %sp
+	ldx	[%i1 + 0x0008], %l2	! prom_cif_handler
 	mov	%g4, %l0
 	mov	%g5, %l1
 	mov	%g6, %l3
 	call	%l2
-	 add	%i0, 0x018, %o0		! prom_args
+	 mov	%i0, %o0		! prom_args
 	mov	%l0, %g4
 	mov	%l1, %g5
 	mov	%l3, %g6
arch/sparc/prom/console_64.c +37 -11

70 lines not on this page · raw message

arch/sparc/prom/devops_64.c +31 -5
index 9dbd803..a017119 100644
@@ -18,16 +18,32 @@
 int
 prom_devopen(const char *dstr)
 {
-	return p1275_cmd ("open", P1275_ARG(0,P1275_ARG_IN_STRING)|
-				  P1275_INOUT(1,1),
-				  dstr);
+	unsigned long args[5];
+
+	args[0] = (unsigned long) "open";
+	args[1] = 1;
+	args[2] = 1;
+	args[3] = (unsigned long) dstr;
+	args[4] = (unsigned long) -1;
+
+	p1275_cmd_direct(args);
+
+	return (int) args[4];
 }
 
 /* Close the device described by device handle 'dhandle'. */
 int
 prom_devclose(int dhandle)
 {
-	p1275_cmd ("close", P1275_INOUT(1,0), dhandle);
+	unsigned long args[4];
+
+	args[0] = (unsigned long) "close";
+	args[1] = 1;
+	args[2] = 0;
+	args[3] = (unsigned int) dhandle;
+
+	p1275_cmd_direct(args);
+
 	return 0;
 }
 
@@ -37,5 +53,15 @@ prom_devclose(int dhandle)
 void
 prom_seek(int dhandle, unsigned int seekhi, unsigned int seeklo)
 {
-	p1275_cmd ("seek", P1275_INOUT(3,1), dhandle, seekhi, seeklo);
+	unsigned long args[7];
+
+	args[0] = (unsigned long) "seek";
+	args[1] = 3;
+	args[2] = 1;
+	args[3] = (unsigned int) dhandle;
+	args[4] = seekhi;
+	args[5] = seeklo;
+	args[6] = (unsigned long) -1;
+
+	p1275_cmd_direct(args);
 }
arch/sparc/prom/misc_64.c +220 -94

464 lines not on this page · raw message

arch/sparc/prom/p1275.c +3 -96

127 lines not on this page · raw message

arch/sparc/prom/tree_64.c +154 -56

354 lines not on this page · raw message

#7 lore raw
In reply to Meelis Roos
Quoted 1 line

Ok, thanks for your patience on this.

Thank you for the work! I have only been whining about bugs ;)

Quoted 1 line

If you could give this patch a quick test I'd appreciate it.

It just works. Tested against 2.6.36-rc2.

Signature · 1 line
Meelis Roos ([email protected])
maintainer
#8 lore raw
In reply to Meelis Roos

From: Meelis Roos <[email protected]>
Date: Tue, 24 Aug 2010 11:54:38 +0300 (EEST)

Quoted 7 lines
Quoted 1 line

Ok, thanks for your patience on this.

Thank you for the work! I have only been whining about bugs ;)

Quoted 1 line

If you could give this patch a quick test I'd appreciate it.

It just works. Tested against 2.6.36-rc2.

Thanks for testing.