[macppc] empty adb bus detection

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[macppc] empty adb bus detection

Miod Vallat
A fair number of Mac Mini owners have reported that there was a long
pause during boot, while the kernel was trying to probe the non existent
adb devices.

At some point in the release cycle, a trick was found to speed up this
probe, but it turned out to cause misdetection sometimes on some
laptops, so it eventually got reverted. And thus the long delay came
back.

The following diff is another try at improving this, this time by
relying on the OpenFirmware's view of the adb bus. It works well on the
Mac Mini. But it might cause regressions on other machines again, and at
this point in the release cycle, we really can't afford this.

Could you guys with Apple hardware test the following diff, especially
on cold boots or booting off cdrom? Thanks.

Miod

PS: this diff is not yet in the snapshots.

Index: adb.c
===================================================================
RCS file: /cvs/src/sys/arch/macppc/dev/adb.c,v
retrieving revision 1.18
diff -u -p -r1.18 adb.c
--- adb.c 2006/01/18 23:21:17 1.18
+++ adb.c 2006/02/22 20:10:54
@@ -249,6 +249,7 @@ int tickle_serial = 0; /* the last pack
 int adb_cuda_serial = 0; /* the current packet */
 struct timeout adb_cuda_timeout;
 struct timeout adb_softintr_timeout;
+int adbempty = 0; /* nonzero if no adb devices */
 
 volatile u_char *Via1Base;
 
@@ -1642,8 +1643,24 @@ adbattach(struct device *parent, struct
 
  if (strcmp(ca->ca_name, "via-cuda") == 0)
  adbHardware = ADB_HW_CUDA;
- else if (strcmp(ca->ca_name, "via-pmu") == 0)
+ else if (strcmp(ca->ca_name, "via-pmu") == 0) {
  adbHardware = ADB_HW_PMU;
+
+ /*
+ * Bus reset can take a long time if no adb devices are
+ * connected, e.g. on a Mac Mini; so check for an adb
+ * child in the OF tree to speed up pm_adb_op().
+ */
+ adbempty = 1;
+ for (node = OF_child(ca->ca_node); node; node = OF_peer(node)) {
+ if (OF_getprop(node, "name", name, sizeof name) <= 0)
+ continue;
+ if (strcmp(name, "adb") == 0) {
+ adbempty = 0;
+ break;
+ }
+ }
+ }
 
  adb_polling = 1;
  adb_reinit();
Index: pm_direct.c
===================================================================
RCS file: /cvs/src/sys/arch/macppc/dev/pm_direct.c,v
retrieving revision 1.19
diff -u -p -r1.19 pm_direct.c
--- pm_direct.c 2006/02/22 07:02:23 1.19
+++ pm_direct.c 2006/02/22 20:10:54
@@ -550,6 +550,7 @@ pm_adb_op(u_char *buffer, void *compRout
 #endif
  PMData pmdata;
  struct adbCommand packet;
+ extern int adbempty;
 
  if (adbWaiting == 1)
  return 1;
@@ -582,11 +583,14 @@ pm_adb_op(u_char *buffer, void *compRout
  * - PowerMac10,1
  * causes several pmu interrupts with ifr set to PMU_INT_SNDBRT.
  * Not processing them prevents us from seeing the adb devices
- * afterwards.
+ * afterwards, so we have to expect it unless we know the adb
+ * bus is empty.
  */
- if (command == PMU_RESET_ADB)
- waitfor = PMU_INT_ADB_AUTO | PMU_INT_ADB | PMU_INT_SNDBRT;
- else
+ if (command == PMU_RESET_ADB) {
+ waitfor = PMU_INT_ADB_AUTO | PMU_INT_ADB;
+ if (adbempty == 0)
+ waitfor |= PMU_INT_SNDBRT;
+ } else
  waitfor = PMU_INT_ALL;
 
  pmdata.data[0] = (u_char)(command & 0xff);

Reply | Threaded
Open this post in threaded view
|

Re: [macppc] empty adb bus detection

Felix Kronlage-2
On Mon, Feb 27, 2006 at 10:13:43PM +0000, Miod Vallat wrote:

> Could you guys with Apple hardware test the following diff, especially
> on cold boots or booting off cdrom? Thanks.

works here (667Mhz G4-Powerbook), dmesg attached.

felix
--
Felix Kronlage                Tel:     (+49)(0)441 - 36116410
[hidden email]         Fax:     (+49)(0)441 - 36116419
http://www.bytemine.net/      PGP/GPG:             0xD9AC74D0
bytemine  -  Entwicklungsmanufaktur fuer innovative Loesungen
[ using 340440 bytes of bsd ELF symbol table ]
console out [ATY,Crown_A]console in [keyboard] ADB found
using parent ATY,CrownParent:: memaddr b8000000 size 8000000, : consaddr bc008000, : ioaddr b0020000, size 20000: memtag 8000, iotag 8000: width 1280 linebytes 5120 height 854 depth 32
Copyright (c) 1982, 1986, 1989, 1991, 1993
        The Regents of the University of California.  All rights reserved.
Copyright (c) 1995-2006 OpenBSD. All rights reserved.  http://www.OpenBSD.org

OpenBSD 3.9 (GENERIC) #1: Thu Mar  2 09:57:53 CET 2006
    [hidden email]:/usr/src/sys/arch/macppc/compile/GENERIC
real mem = 805306368 (786432K)
avail mem = 727023616 (709984K)
using 1254 buffers containing 40263680 bytes (39320K) of memory
mainbus0 (root): model PowerBook3,4
cpu0 at mainbus0: 7455 (Revision 0x201): 667 MHz: 256KB L2 cache, 1MB L3 cache
memc0 at mainbus0: uni-n
ki2c0 at memc0 offset 0xf8001000
iic0 at ki2c0
mpcpcibr0 at mainbus0 pci: uni-north, Revision 0xff
pci0 at mpcpcibr0 bus 0
pchb0 at pci0 dev 11 function 0 "Apple Uni-N2 AGP" rev 0x00
vgafb0 at pci0 dev 16 function 0 "ATI Radeon Mobility M7 LW" rev 0x00, mmio
wsdisplay0 at vgafb0 mux 1: console (std, vt100 emulation)
mpcpcibr1 at mainbus0 pci: uni-north, Revision 0x0
pci1 at mpcpcibr1 bus 0
pchb1 at pci1 dev 11 function 0 "Apple Uni-N2 Host" rev 0x00
macobio0 at pci1 dev 23 function 0 "Apple Keylargo" rev 0x03
openpic0 at macobio0 offset 0x40000: version 0x4614
macgpio0 at macobio0 offset 0x50
macgpio1 at macgpio0 offset 0x59 irq 47
"programmer-switch" at macgpio0 offset 0x61 not configured
"firewire-linkon" at macgpio0 offset 0x5f not configured
"gpio5" at macgpio0 offset 0x6f not configured
"gpio6" at macgpio0 offset 0x70 not configured
"extint-gpio4" at macgpio0 offset 0x5c not configured
"gpio11" at macgpio0 offset 0x75 not configured
"extint-gpio15" at macgpio0 offset 0x67 not configured
"escc-legacy" at macobio0 offset 0x12000 not configured
zsc0 at macobio0 offset 0x13000: irq 22,23
zstty0 at zsc0 channel 0
zstty1 at zsc0 channel 1
snapper0 at macobio0 offset 0x10000: irq 30,1,2
"timer" at macobio0 offset 0x15000 not configured
adb0 at macobio0 offset 0x16000 irq 25: via-pmu, 3 targets
akbd0 at adb0 addr 2: PowerBook G4 keyboard (Inverted T)
wskbd0 at akbd0: console keyboard, using wsdisplay0
ams0 at adb0 addr 3: EMP trackpad <tpad> 2-button, 400 dpi
wsmouse0 at ams0 mux 0
abtn0 at adb0 addr 7: brightness/volume/eject buttons
apm0 at adb0: battery flags 0x7, 94% charged
"battery" at macobio0 offset 0x0 not configured
"backlight" at macobio0 offset 0xf300 not configured
ki2c1 at macobio0 offset 0x18000
iic1 at ki2c1
wdc0 at macobio0 offset 0x1f000 irq 19: DMA
wd0 at wdc0 channel 0 drive 0: <IBM-IC25N030ATCS04-0>
wd0: 16-sector PIO, LBA, 28615MB, 58605120 sectors
wd0(wdc0:0:0): using PIO mode 4, DMA mode 2, Ultra-DMA mode 4
wdc1 at macobio0 offset 0x20000 irq 20: DMA
atapiscsi0 at wdc1 channel 0 drive 0
scsibus0 at atapiscsi0: 2 targets
cd0 at scsibus0 targ 0 lun 0: <MATSHITA, CD-RW CW-8121, AA17> SCSI0 5/cdrom removable
cd0(wdc1:0:0): using BIOS timings, DMA mode 2
wdc2 at macobio0 offset 0x21000 irq 21: DMA
wi0 at macobio0 offset 0x30000 irq 57:
wi0: Firmware 8.70 variant 1, address 00:30:65:05:81:09
audio0 at snapper0
ohci0 at pci1 dev 24 function 0 "Apple USB" rev 0x00: irq 27, version 1.0
usb0 at ohci0: USB revision 1.0
uhub0 at usb0
uhub0: Apple OHCI root hub, rev 1.00/1.00, addr 1
uhub0: 2 ports with 2 removable, self powered
ohci1 at pci1 dev 25 function 0 "Apple USB" rev 0x00: irq 28, version 1.0
usb1 at ohci1: USB revision 1.0
uhub1 at usb1
uhub1: Apple OHCI root hub, rev 1.00/1.00, addr 1
uhub1: 2 ports with 2 removable, self powered
cbb0 at pci1 dev 26 function 0 "Texas Instruments PCI1410 CardBus" rev 0x02: irq 58
cardslot0 at cbb0 slot 0 flags 0
cardbus0 at cardslot0: bus 1 device 0 cacheline 0x8, lattimer 0x20
pcmcia0 at cardslot0
mpcpcibr2 at mainbus0 pci: uni-north, Revision 0x16
pci2 at mpcpcibr2 bus 0
pchb2 at pci2 dev 11 function 0 "Apple Uni-N2 Host" rev 0x00
"AT&T/Lucent FW322 1394" rev 0x00 at pci2 dev 14 function 0 not configured
gem0 at pci2 dev 15 function 0 "Apple Uni-N GMAC" rev 0x01: irq 41, address 00:03:93:8a:bd:f8
brgphy0 at gem0 phy 0: BCM5421 10/100/1000baseT PHY, rev. 1
bootpath: '/pci@f2000000/mac-io@17/ata-4@1f000/disk@0/bsd.generic'
boot device: wd0.
root on wd0a
rootdev=0x0 rrootdev=0xb00 rawdev=0xb02