Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/ic Sprinkle DELAY(1)'s in several busy loops to avoi...



details:   https://anonhg.NetBSD.org/src/rev/88c095dde619
branches:  trunk
changeset: 570127:88c095dde619
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Sat Sep 25 10:47:29 2004 +0000

description:
Sprinkle DELAY(1)'s in several busy loops to avoid excessive bus access.
Inspired by OpenBSD.

diffstat:

 sys/dev/ic/mb89352.c |  20 ++++++++++++--------
 1 files changed, 12 insertions(+), 8 deletions(-)

diffs (107 lines):

diff -r 05d3e74a177e -r 88c095dde619 sys/dev/ic/mb89352.c
--- a/sys/dev/ic/mb89352.c      Sat Sep 25 10:36:15 2004 +0000
+++ b/sys/dev/ic/mb89352.c      Sat Sep 25 10:47:29 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mb89352.c,v 1.35 2004/09/25 10:36:15 tsutsui Exp $     */
+/*     $NetBSD: mb89352.c,v 1.36 2004/09/25 10:47:29 tsutsui Exp $     */
 /*     NecBSD: mb89352.c,v 1.4 1998/03/14 07:31:20 kmatsuda Exp        */
 
 /*-
@@ -70,7 +70,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mb89352.c,v 1.35 2004/09/25 10:36:15 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mb89352.c,v 1.36 2004/09/25 10:47:29 tsutsui Exp $");
 
 #ifdef DDB
 #define        integrate
@@ -1009,7 +1009,6 @@
                bus_space_write_1(iot, ioh, PCTL, PCTL_BFINT_ENAB | PH_MSGIN);
 
                while ((bus_space_read_1(iot, ioh, PSNS) & PSNS_REQ) == 0) {
-                       /* XXX needs timeout */
                        if ((bus_space_read_1(iot, ioh, PSNS) & PH_MASK)
                            != PH_MSGIN ||
                            bus_space_read_1(iot, ioh, INTS) != 0)
@@ -1019,6 +1018,7 @@
                                 * b) ran out of messages.
                                 */
                                goto out;
+                       DELAY(1);       /* XXX needs timeout */
                }
 
                msg = bus_space_read_1(iot, ioh, TEMP);
@@ -1057,7 +1057,7 @@
                /* Ack the last byte read. */
                bus_space_write_1(iot, ioh, SCMD, SCMD_SET_ACK);
                while ((bus_space_read_1(iot, ioh, PSNS) & PSNS_REQ) != 0)
-                       continue;       /* XXX needs timeout */
+                       DELAY(1);       /* XXX needs timeout */
                bus_space_write_1(iot, ioh, SCMD, SCMD_RST_ACK);
 #endif
        }
@@ -1234,7 +1234,7 @@
        /* Ack the last message byte. */
        bus_space_write_1(iot, ioh, SCMD, SCMD_SET_ACK);
        while ((bus_space_read_1(iot, ioh, PSNS) & PSNS_REQ) != 0)
-               continue;       /* XXX needs timeout */
+               DELAY(1);       /* XXX needs timeout */
        bus_space_write_1(iot, ioh, SCMD, SCMD_RST_ACK);
 #endif
 
@@ -1426,7 +1426,7 @@
 #endif
 
                while ((bus_space_read_1(iot, ioh, SSTS) & SSTS_DREG_FULL) != 0)
-                       ;
+                       DELAY(1);
                /* Send message byte. */
                bus_space_write_1(iot, ioh, DREG, *--sc->sc_omp);
                --n;
@@ -1517,6 +1517,7 @@
                        /* Break on interrupt. */
                        if (intstat != 0)
                                goto phasechange;
+                       DELAY(1);
                }
 
                xfer = min(DOUTAMOUNT, n);
@@ -1534,6 +1535,7 @@
                for (;;) {
                        if (bus_space_read_1(iot, ioh, INTS) != 0)
                                break;
+                       DELAY(1);
                }
                SPC_MISC(("extra data  "));
        } else {
@@ -1547,6 +1549,7 @@
                        /* Break on interrupt. */
                        if (intstat != 0)
                                goto phasechange;
+                       DELAY(1);
                }
        }
 
@@ -1644,6 +1647,7 @@
                                        goto phasechange;
                                intstat = bus_space_read_1(iot, ioh, INTS);
                        }
+                       DELAY(1);
                }
                SPC_MISC(("extra data  "));
        }
@@ -2032,11 +2036,11 @@
                        bus_space_write_1(iot, ioh, SCMD, SCMD_RST_ATN);
                bus_space_write_1(iot, ioh, PCTL, PCTL_BFINT_ENAB | PH_STAT);
                while ((bus_space_read_1(iot, ioh, PSNS) & PSNS_REQ) == 0)
-                       continue;       /* XXX needs timeout */
+                       DELAY(1);       /* XXX needs timeout */
                acb->target_stat = bus_space_read_1(iot, ioh, TEMP);
                bus_space_write_1(iot, ioh, SCMD, SCMD_SET_ACK);
                while ((bus_space_read_1(iot, ioh, PSNS) & PSNS_REQ) != 0)
-                       continue;       /* XXX needs timeout */
+                       DELAY(1);       /* XXX needs timeout */
                bus_space_write_1(iot, ioh, SCMD, SCMD_RST_ACK);
 
                SPC_MISC(("target_stat=0x%02x  ", acb->target_stat));



Home | Main Index | Thread Index | Old Index