2009-10-11 STR9105その5
稀にメモリがぶっ壊れるのはどうもドライバのバグとかではなくて、そもそもTWR-350自体が不安定っぽい。 というのは、evbarm/gemini/gemini_machdep.c がやっているように、pmap_map_chunk(〜, VM_PROT_READ|VM_PROT_EXECUTE, 〜) で kernel text 領域を read only にしたのだが、それでもたまに化けることがあるのだ。write protect が機能しているのは確認済み。 DMA のせいかと思っていろいろ試してみたが、DMAを全く使っていない状態でもメモリが壊れることがあったので、やはりDMAでもないだろう。 と言っても最初から入っているLinuxはバカスカ落ちる訳でもなく安定して動いているので、やっぱりNetBSDが何かおかしいんだろうなぁ。 STR8100/9100はパワーマネージメントレジスタで各種クロックやレギュレータの電圧までソフトでコントロールできるので、そのへんの設定が足りないのではなかろうか。 とりあえずいろいろいじって今はそこそこ安定してるので後回し。
というわけで、いろいろ手間取っているがPCIを動かすのである。とりあえず pci config が読めるまで動いた。まだ mapping とか書いてないので pci device の attach が失敗してるけど。
とりあえず dmesg。あいかわらず PCI Vendor ID がふざけた値。
NetBSD/evbarm STR8100/9100 Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc. All rights reserved. Copyright (c) 1982, 1986, 1989, 1991, 1993 The Regents of the University of California. All rights reserved. NetBSD 5.99.20 (STR91xx) #469: Sun Oct 11 04:25:29 JST 2009 ryo@falsie:/src/cvs/NetBSD/sys/arch/evbarm/compile/STR91xx total memory = 32768 KB avail memory = 27588 KB mainbus0 (root) cpu0 at mainbus0: FA526 rev 1 (ARMv4 core) cpu0: DC enabled IC enabled WB enabled LABT cpu0: 16KB/16B 2-way Instruction cache cpu0: 16KB/16B 2-way write-back-locking-B Data cache star0 at mainbus0: Star Orion Family SoC: STR9100, 200MHz starclk0 at star0 addr 0x79000000-0x79000047 irq 0: Programmable Timer com0 at star0 addr 0x78000000-0x7800001f irq 10: ns16550a, working fifo com0: console ohci0 at star0 addr 0xc4000000-0xc400005b irq 23: USB1.1 Host Controller ohci0: OHCI version 1.0, legacy support usb0 at ohci0: USB revision 1.0 ehci0 at star0 addr 0xcc000000-0xcc00006b irq 24: USB2.0 Host Controller ehci0: ohci or uhci probably not configured usb1 at ehci0: USB revision 2.0 starrtc0 at star0 addr 0x7b000000-0x7b000037 irq 14: Real-time Clock starwdog0 at star0 addr 0x7a000000-0x7a00001b irq 3: Watch Dog Timer stargpio0 at star0 addr 0x7c000000-0x7c000047 irq 4: GPIO gpio0 at stargpio0: 32 pins gsec0 at star0 addr 0x70000000-0x7000029b irq 18: Gigabit Switch Engine gse0 at gsec0 port0 gse0: Ethernet address 00:08:a1:c0:45:7e ukphy0 at gse0 phy 0: OUI 0x0009c3, model 0x0005, rev. 4 ukphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto gse1 at gsec0 port1 gse1: Ethernet address 00:08:a1:c0:45:7f ukphy1 at gse1 phy 1: OUI 0x0009c3, model 0x0005, rev. 4 ukphy1: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto starpci0 at star0 addr 0xa0000000-0xa0000003 irq 8: PCI Host Bridge pci0 at starpci0 unknown vendor 0xeeee product 0x0000 (miscellaneous prehistoric) at pci0 dev 0 function 0: PCI configuration registers: Common header: 0x00: 0x0000eeee 0xf0000000 0x00000000 0x00000000 Vendor ID: 0xeeee Device ID: 0x0000 Command register: 0x0000 I/O space accesses: off Memory space accesses: off Bus mastering: off Special cycles: off MWI transactions: off Palette snooping: off Parity error checking: off Address/data stepping: off System error (SERR): off Fast back-to-back transactions: off Interrupt disable: off Status register: 0xf000 Capability List support: off 66 MHz capable: off User Definable Features (UDF) support: off Fast back-to-back capable: off Data parity error detected: off DEVSEL timing: fast (0x0) Slave signaled Target Abort: off Master received Target Abort: on Master received Master Abort: on Asserted System Error (SERR): on Parity error detected: on Class Name: prehistoric (0x00) Subclass Name: miscellaneous (0x00) Interface: 0x00 Revision ID: 0x00 BIST: 0x00 Header Type: 0x00 (0x00) Latency Timer: 0x00 Cache Line Size: 0x00 Type 0 ("normal" device) header: 0x10: 0x00000000 0x00000000 0x00000000 0x00000000 0x20: 0x00000000 0x00000000 0x00000000 0x00000000 0x30: 0x00000000 0x00000000 0x00000000 0x00000000 Base address register at 0x10 not implemented(?) Base address register at 0x14 not implemented(?) Base address register at 0x18 not implemented(?) Base address register at 0x1c not implemented(?) Base address register at 0x20 not implemented(?) Base address register at 0x24 not implemented(?) Cardbus CIS Pointer: 0x00000000 Subsystem vendor ID: 0x0000 Subsystem ID: 0x0000 Expansion ROM Base Address: 0x00000000 Reserved @ 0x34: 0x00000000 Reserved @ 0x38: 0x00000000 Maximum Latency: 0x00 Minimum Grant: 0x00 Interrupt pin: 0x00 (none) Interrupt line: 0x00 Device-dependent header: 0x40: 0x0000eeee 0xf0000000 0x00000000 0x00000000 0x50: 0x00000000 0x00000000 0x00000000 0x00000000 0x60: 0x00000000 0x00000000 0x00000000 0x00000000 0x70: 0x00000000 0x00000000 0x00000000 0x00000000 0x80: 0x0000eeee 0xf0000000 0x00000000 0x00000000 0x90: 0x00000000 0x00000000 0x00000000 0x00000000 0xa0: 0x00000000 0x00000000 0x00000000 0x00000000 0xb0: 0x00000000 0x00000000 0x00000000 0x00000000 0xc0: 0x0000eeee 0xf0000000 0x00000000 0x00000000 0xd0: 0x00000000 0x00000000 0x00000000 0x00000000 0xe0: 0x00000000 0x00000000 0x00000000 0x00000000 0xf0: 0x00000000 0x00000000 0x00000000 0x00000000 Don't know how to pretty-print device-dependent header. unknown vendor 0xeeee product 0x0000 (miscellaneous prehistoric) at pci0 dev 0 function 0 (intrswiz 0, intrpin 0, i/o off, mem off, no quirks) not configured ral0 at pci0 dev 2 function 0: PCI configuration registers: Common header: 0x00: 0x03021814 0xffff8000 0x00000000 0x00000000 Vendor Name: Ralink Technologies (0x1814) Device Name: RT2561 802.11b/g (0x0302) Command register: 0x8000 I/O space accesses: off Memory space accesses: off Bus mastering: off Special cycles: off MWI transactions: off Palette snooping: off Parity error checking: off Address/data stepping: off System error (SERR): off Fast back-to-back transactions: off Interrupt disable: off Status register: 0xffff Capability List support: on 66 MHz capable: on User Definable Features (UDF) support: on Fast back-to-back capable: on Data parity error detected: on DEVSEL timing: unknown/reserved (0x3) Slave signaled Target Abort: on Master received Target Abort: on Master received Master Abort: on Asserted System Error (SERR): on Parity error detected: on Class Name: prehistoric (0x00) Subclass Name: miscellaneous (0x00) Interface: 0x00 Revision ID: 0x00 BIST: 0x00 Header Type: 0x00 (0x00) Latency Timer: 0x00 Cache Line Size: 0x00 Type 0 ("normal" device) header: 0x10: 0x00020001 0x00000000 0x00000000 0x00000000 0x20: 0x00000000 0x00000000 0x00000000 0x00000000 0x30: 0x00000000 0x00000000 0x00000000 0x00000000 Base address register at 0x10 type: 32-bit i/o base: 0x00020000, size: 0x00020000 Base address register at 0x14 not implemented(?) Base address register at 0x18 not implemented(?) Base address register at 0x1c not implemented(?) Base address register at 0x20 not implemented(?) Base address register at 0x24 not implemented(?) Cardbus CIS Pointer: 0x00000000 Subsystem vendor ID: 0x0000 Subsystem ID: 0x0000 Expansion ROM Base Address: 0x00000000 Capability list pointer: 0x00 Reserved @ 0x38: 0x00000000 Maximum Latency: 0x00 Minimum Grant: 0x00 Interrupt pin: 0x00 (none) Interrupt line: 0x00 Device-dependent header: 0x40: 0x03021814 0xffff8000 0x00000000 0x00000000 0x50: 0x00020001 0x00000000 0x00000000 0x00000000 0x60: 0x00000000 0x00000000 0x00000000 0x00000000 0x70: 0x00000000 0x00000000 0x00000000 0x00000000 0x80: 0x03021814 0xffff8000 0x00000000 0x00000000 0x90: 0x00020001 0x00000000 0x00000000 0x00000000 0xa0: 0x00000000 0x00000000 0x00000000 0x00000000 0xb0: 0x00000000 0x00000000 0x00000000 0x00000000 0xc0: 0x03021814 0xffff8000 0x00000000 0x00000000 0xd0: 0x00020001 0x00000000 0x00000000 0x00000000 0xe0: 0x00000000 0x00000000 0x00000000 0x00000000 0xf0: 0x00000000 0x00000000 0x00000000 0x00000000 Don't know how to pretty-print device-dependent header. Ralink Technologies RT2561 802.11b/g (miscellaneous prehistoric) at ? dev 2 function 0 (intrswiz 0, intrpin 0, i/o off, mem off, no quirks): Ralink Technologies RT2561 802.11b/g (rev. 0x00) pci_mem_find: expected type mem, found i/o : could not map memory space uhub0 at usb0: Star OHCI root hub, class 9/0, rev 1.00/1.00, addr 1 uhub1 at usb1: Star EHCI root hub, class 9/0, rev 2.00/1.00, addr 1 umass0 at uhub1 port 2 configuration 1 interface 0 umass0: BUFFALO USB Flash Disk, rev 2.00/1.10, addr 2 scsibus0 at umass0: 2 targets, 1 lun per target sd0 at scsibus0 target 0 lun 0: <BUFFALO, USB Flash Disk, 3.10> disk removable sd0: 7648 MB, 15296 cyl, 32 head, 32 sec, 512 bytes/sect x 15663104 sectors boot device: <unknown>
どうでもいいが STR8100/9100 のデバイスの I/O アドレスへのマッピングは大名チックで、
A0000000 | PCI Config Data Reg |
A4000000 | PCI Config Address Reg |
みたいなメモリマップなのである。PCI Config Data Reg も PCI Config Address Reg も 4byte の I/O レジスタが1つあるだけだ。
これをそれぞれ仮想アドレスにmappingするので、TLBのエントリが無駄になってしょうがない。どうしてくれよう。
しかも I/O アドレスが離れているので kernel config に書く時も不便で、現状は
# On-chip PCI Interface starpci0 at star? addr1 0xa0000000 irq 8 pci0 at starpci0
として starpci_attach で address + 0x04000000 を PCI config address と見倣しているのだが、気分的には
# On-chip PCI Interface starpci0 at star? addr1 0xa0000000 addr2 0xa4000000 irq 8 pci0 at starpci0
こう書きたい所だ。しかしこれはこれでどうもなぁ。
つーか SoC なデバイスを kernel config file にずらずらとアドレスやIRQを書くのが間違ってる。 SoC なんだから CPU 側で持ってるデバイスを config_found() すべきだ。 そもそも evbarm/*/*_machdep.c の initarm() で pmap_devmap_register() する時に、全デバイスの I/O アドレスを知ってるんだから。
…と思うんだけど、他のarchはそうしてないんだよね。チキンだから周りに習ってしまいました。
やっぱりそのうち SoC のバスを attach する時に各デバイスを config_found() するように書き換えよう…
EOF