OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
[macppc] empty adb bus detection

From: Miod Vallat (miodonline.fr)
Date: Mon Feb 27 2006 - 16:13:43 CST


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);