Subject: Building the kernel for a Broadcom SB1

From: Jonathan Day <[email-masked]>
Date: Wed, 21 Sep 2005 10:24:35 -0700 (PDT)

Hi,

Things've been interesting here, of late. I've got the
toolchain to compile natively 64-bit code (with
considerable effort and the instructions from Linux
From Scratch) and I have a working Linux 2.6.12-rc2
kernel with the SB1 patches from the linux-mips
mailing lists.

So far, so good. Tried compiling the 2.6.14-rc1
kernel, forward-porting all the changes that hadn't
been merged in. the kernel locks in the initial boot
sequence, after a couple of printf's.

Are there any kernel patches for the Broadcom/SiByte
processors that are specific to the 2.6.13-* or
2.6.14-*, or any options that are definitely producing
Bad Code on these kernels but not earlier?

__________________________________ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com

---

From: Andy Isaacson <[email-masked]>
Date: Thu, 22 Sep 2005 00:22:59 -0700

> sequence, after a couple of printf's.

We'd be able to help more if you simply pasted in the console output
rather than being vague.

> Bad Code on these kernels but not earlier?

I'm building and testing CVS HEAD as of Wednesday afternoon with the
attached patch and .config.

-andy

Cleaning up state...
Transferring control to the kernel.
Kernel entry point is at 0x803e1000
Broadcom SiByte BCM1250 B2 @ 600 MHz (SB1 rev 2)
Board type: SiByte BCM91250A (SWARM)
@@@@ This is a BCM1250 B1/B2, but the kernel is conservatively configured for an 'A' stepping. @@@@
Linux version 2.6.14-rc1 (adi@bobble) (gcc version 3.4.1 broadcom_2004e_341 (SpecifixInc)) #1 SMP Wed Sep 21 23:59:40 PDT 2005
CPU revision is: 01040102
FPU revision is: 000f0102
swarm setup: M41T81 RTC detected.
This kernel optimized for board runs with CFE
Determined physical RAM map:
 memory: 000000000fe9be00 @ 0000000000000000 (usable)
 memory: 000000001ffffe00 @ 0000000080000000 (usable)
 memory: 000000000ffffe00 @ 00000000c0000000 (usable)
 memory: 000000001ffffe00 @ 0000000100000000 (usable)
Built 1 zonelists
Kernel command line: root=/dev/nfs ip=any nfsroot=XXX
Primary instruction cache 32kB, 4-way, linesize 32 bytes.
Primary data cache 32kB, 4-way, linesize 32 bytes.
Synthesized TLB refill handler (40 instructions).
Synthesized TLB load handler fastpath (54 instructions).
Synthesized TLB store handler fastpath (49 instructions).
Synthesized TLB modify handler fastpath (48 instructions).
PID hash table entries: 4096 (order: 12, 131072 bytes)
Dentry cache hash table entries: 1048576 (order: 11, 8388608 bytes)
Inode-cache hash table entries: 524288 (order: 10, 4194304 bytes)
Memory: 1489260k/1571424k available (2360k kernel code, 81480k reserved, 585k data, 204k init, 0k highmem)
Mount-cache hash table entries: 256
Checking for 'wait' instruction...  unavailable.
Checking for the multiply/shift bug... no.
Checking for the daddi bug... no.
Checking for the daddiu bug... no.
Detected 1 available secondary CPU(s)
CPU revision is: 03040102
FPU revision is: 000f0102
Primary instruction cache 32kB, 4-way, linesize 32 bytes.
Primary data cache 32kB, 4-way, linesize 32 bytes.
Synthesized TLB refill handler (40 instructions).
Brought up 2 CPUs
NET: Registered protocol family 16
Initializing Cryptographic API
io scheduler noop registered
io scheduler anticipatory registered
io scheduler deadline registered
io scheduler cfq registered
RAMDISK driver initialized: 16 RAM disks of 9220K size 1024 blocksize
eth0: enabling TCP rcv checksum
eth0: enabling TCP rcv checksum
eth0: SiByte Ethernet at 0x10064000, address: 00:02:4C:FE:0A:96
eth1: enabling TCP rcv checksum
eth1: enabling TCP rcv checksum
eth1: SiByte Ethernet at 0x10065000, address: 00:02:4C:FE:0A:97
Uniform Multi-Platform E-IDE driver Revision: 7.00alpha2
ide: Assuming 33MHz system bus speed for PIO modes; override with idebus=xx
ide-floppy driver 0.99.newide
NET: Registered protocol family 2
IP route cache hash table entries: 262144 (order: 9, 2097152 bytes)
TCP established hash table entries: 262144 (order: 10, 4194304 bytes)
TCP bind hash table entries: 65536 (order: 8, 1048576 bytes)
TCP: Hash tables configured (established 262144 bind 65536)
TCP reno registered
TCP bic registered
NET: Registered protocol family 1
NET: Registered protocol family 17
NET: Registered protocol family 15
eth0: Link speed: 100BaseT FDX
eth1: Link speed: 1000BaseT FDX
Sending DHCP requests ., OK

Fix problems for SiByte chips:
 - CONFIG_64BIT build fixes
 - remove MIPS_CPU_4KTLB from ->options because sb1 has its own TLB routines

 arch/mips/kernel/cpu-probe.c           |    2 ++
 arch/mips/mm/c-sb1.c                   |    4 ++++
 include/asm-mips/addrspace.h           |    1 +
 include/asm-mips/mach-generic/spaces.h |    7 ++++---
 4 files changed, 11 insertions(+), 3 deletions(-)

Index: lmo-1480/include/asm-mips/addrspace.h
===================================================================
--- lmo-1480.orig/include/asm-mips/addrspace.h	2005-09-15 14:20:58.000000000 -0700
+++ lmo-1480/include/asm-mips/addrspace.h	2005-09-15 14:21:06.000000000 -0700
@@ -131,6 +131,7 @@
     || defined (CONFIG_CPU_R5000)					\
     || defined (CONFIG_CPU_NEVADA)					\
     || defined (CONFIG_CPU_TX49XX)					\
+    || defined (CONFIG_CPU_SB1)						\
     || defined (CONFIG_CPU_MIPS64_R1)
 #define KUSIZE		_LLCONST_(0x0000010000000000)	/* 2^^40 */
 #define KUSIZE_64	_LLCONST_(0x0000010000000000)	/* 2^^40 */
Index: lmo-1480/include/asm-mips/mach-generic/spaces.h
===================================================================
--- lmo-1480.orig/include/asm-mips/mach-generic/spaces.h	2005-09-15 14:20:58.000000000 -0700
+++ lmo-1480/include/asm-mips/mach-generic/spaces.h	2005-09-15 14:21:06.000000000 -0700
@@ -11,6 +11,7 @@
 #define _ASM_MACH_GENERIC_SPACES_H
 
 #include <linux/config.h>
+#include <asm/addrspace.h>
 
 #ifdef CONFIG_32BIT
 
@@ -63,9 +64,9 @@
 #define UNCAC_BASE		0x9000000000000000
 #define MAP_BASE		0xc000000000000000
 
-#define TO_PHYS(x)		(             ((x) & TO_PHYS_MASK))
-#define TO_CAC(x)		(CAC_BASE   | ((x) & TO_PHYS_MASK))
-#define TO_UNCAC(x)		(UNCAC_BASE | ((x) & TO_PHYS_MASK))
+#define TO_PHYS(x)		(             ((unsigned long)(x) & TO_PHYS_MASK))
+#define TO_CAC(x)		(CAC_BASE   | ((unsigned long)(x) & TO_PHYS_MASK))
+#define TO_UNCAC(x)		(UNCAC_BASE | ((unsigned long)(x) & TO_PHYS_MASK))
 
 #endif /* CONFIG_64BIT */
 
Index: lmo-1480/arch/mips/mm/c-sb1.c
===================================================================
--- lmo-1480.orig/arch/mips/mm/c-sb1.c	2005-09-15 14:20:58.000000000 -0700
+++ lmo-1480/arch/mips/mm/c-sb1.c	2005-09-15 14:21:06.000000000 -0700
@@ -503,7 +503,11 @@
 
 	/* Special cache error handler for SB1 */
 	set_uncached_handler (0x100, &except_vec2_sb1, 0x80);
+#ifdef CONFIG_32BIT
 	memcpy((void *)KSEG1ADDR(&handle_vec2_sb1), &handle_vec2_sb1, 0x80);
+#elif defined(CONFIG_64BIT)
+	memcpy((void *)TO_UNCAC(&handle_vec2_sb1), &handle_vec2_sb1, 0x80);
+#endif
 
 	probe_cache_sizes();
 
Index: lmo-1480/arch/mips/kernel/cpu-probe.c
===================================================================
--- lmo-1480.orig/arch/mips/kernel/cpu-probe.c	2005-09-15 14:20:58.000000000 -0700
+++ lmo-1480/arch/mips/kernel/cpu-probe.c	2005-09-15 14:21:06.000000000 -0700
@@ -612,6 +612,8 @@
 	switch (c->processor_id & 0xff00) {
 	case PRID_IMP_SB1:
 		c->cputype = CPU_SB1;
+		/* SB1 uses custom TLB code */
+		c->options &= ~MIPS_CPU_4KTLB;
 #ifdef CONFIG_SB1_PASS_1_WORKAROUNDS
 		/* FPU in pass1 is known to have issues. */
 		c->options &= ~(MIPS_CPU_FPU | MIPS_CPU_32FPR);

---

From: Jonathan Day <[email-masked]>
Date: Thu, 22 Sep 2005 10:22:50 -0700 (PDT)

Oops, my bad! Ok, well here is the entire log for the
boot sequence, including non-kernel stuff. I've also
attached the kernel configuration I'm using.

Incidently, I'm now not so sure it's a bug in the
kernel that's the factor - I've done some experiments
and discovered that there may be a bug in the ZBus.
Code that runs quickly will hard-crash the processor,
but adding anything that just inserts wait states or
otherwise slows down activity will cause the code to
run just fine.

To see if this could be related to the kernel issues,
I recompiled kernel sources I -know- absolutely works
with the board. Where it had debugging code enabled
for the Infiniband and a few other places, for the
working build, I disabled the debugs. everything else
was kept exactly the same. The whole system locked
absolutely solid.

I'll try the suggested patches & config - with and
without the debugs enabled - to see what happens. I'm
also going to scour around for diagnostic tools to see
if I can get a clearer picture of what is happening
and why.

Jonathan

Initializing Arena.
Initializing PCI. [normal]
PCI bus 0 slot 1/0: Warning: SipReady already set
PCI bus 0 slot 1/0: HT init: InitDone not set
PCI bus 0 slot 1/0:   Link Cmd = 0x20010008, Link Ctrl
= 0x00000000
Initializing Devices.
SENTOSA board revision 2
Config switch: 2
CPU: BCM1250 rev 0x11
L2 Cache Status: Wafer ID:   0x92CEE019  [Lot 9395,
Wafer 23]
Manuf Test: Bin A [2CPU_FI_FD_F2 (OK)]
SysCfg: 0000000024C20800 [PLL_DIV: 16, IOB0_DIV:
CPUCLK/4, IOB1_DIV:
CPUCLK/3]
CPU type 0x1040102: 800MHz
Total memory: 0x10000000 bytes (256MB)

Total memory used by CFE:  0x8FE99CE0 - 0x90000000
(1467168)
Initialized Data:          0x8FE99CE0 - 0x8FEA3B60
(40576)
BSS Area:                  0x8FEA3B60 - 0x8FEA41A0
(1600)
Local Heap:                0x8FEA41A0 - 0x8FFA41A0
(1048576)
Stack Area:                0x8FFA41A0 - 0x8FFA61A0
(8192)
Text (code) segment:       0x8FFA61A0 - 0x8FFFFFBC
(368156)
Boot area (physical):      0x0FE58000 - 0x0FE98000
Relocation Factor:         I:F03A61A0 - D:0FE98CE0

eth0: Link speed: 100BaseT FDX
Device eth0:  hwaddr 00-02-4C-FD-0D-3C, ipaddr
10.1.1.53, mask
255.255.0.0
        gateway 10.1.1.1, nameserver 10.1.1.3, domain
xyronsemi.com
Loader:elf Filesys:tftp Dev:eth0
File:10.1.1.52:vmlinux.32
Options:(null)
Loading: 0xffffffff80100000/2903912
0xffffffff803c4f68/305896 Entry at
0xffffffff80396000
Closing network.
Starting program at 0xffffffff80396000
Broadcom SiByte BCM1250 B2 @ 800 MHz (SB1 rev 2)
Board type: SiByte BCM91250E (Sentosa)

---

From: Daniel Jacobowitz <[email-masked]>
Date: Thu, 22 Sep 2005 17:32:09 -0400

> Board type: SiByte BCM91250E (Sentosa)

[*hang* here]

Andy's patches should fix this; I grabbed them from Thiemo's
experimental Debian packages a couple of days ago and they brought my
Sentosa up again.

-- 
Daniel Jacobowitz
CodeSourcery, LLC

---

From: Jonathan Day <[email-masked]>
Date: Thu, 22 Sep 2005 17:19:49 -0700 (PDT)

I'm trying the patches with various configurations.
Every kernel I've tried building with both the
kobjects and debug info enabled in the kernel hacking
menu will work fine. Any kernel with either (or both)
disabled will lock up on boot.

At this time, I have no clear idea as to why the
debugs are making such a big difference. Particularly
if other people aren't experiencing exactly the same
problem. Any thoughts would be welcome.