Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/ic Rearrange ex_intr() to use C_INTR_LATCH the same ...



details:   https://anonhg.NetBSD.org/src/rev/cd7784f5527a
branches:  trunk
changeset: 480696:cd7784f5527a
user:      mycroft <mycroft%NetBSD.org@localhost>
date:      Tue Jan 18 03:35:40 2000 +0000

description:
Rearrange ex_intr() to use C_INTR_LATCH the same way the ep driver does,
to prevent race conditions.

diffstat:

 sys/dev/ic/elinkxl.c |  36 +++++++++++++++++++++++-------------
 1 files changed, 23 insertions(+), 13 deletions(-)

diffs (66 lines):

diff -r 53e5335a5c09 -r cd7784f5527a sys/dev/ic/elinkxl.c
--- a/sys/dev/ic/elinkxl.c      Tue Jan 18 03:11:11 2000 +0000
+++ b/sys/dev/ic/elinkxl.c      Tue Jan 18 03:35:40 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: elinkxl.c,v 1.21 1999/12/12 03:00:47 thorpej Exp $     */
+/*     $NetBSD: elinkxl.c,v 1.22 2000/01/18 03:35:40 mycroft Exp $     */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -1100,22 +1100,33 @@
          return ret;
        }
        for (;;) {
+               bus_space_write_2(iot, ioh, ELINK_COMMAND, C_INTR_LATCH);
+
                stat = bus_space_read_2(iot, ioh, ELINK_STATUS);
-               if (!(stat & S_MASK))
-                       break;
+
+               if ((stat & S_MASK) == 0) {
+                       if ((stat & S_INTR_LATCH) == 0) {
+#if 0
+                               printf("%s: intr latch cleared\n",
+                                      sc->sc_dev.dv_xname);
+#endif
+                               break;
+                       }
+               }
+
+               ret = 1;
+
                /*
                 * Acknowledge interrupts.
                 */
                bus_space_write_2(iot, ioh, ELINK_COMMAND, ACK_INTR |
-                                     (stat & S_MASK));
+                                 (stat & S_MASK));
                if (sc->intr_ack)
-                   (*sc->intr_ack)(sc);
-               ret = 1;
+                       (*sc->intr_ack)(sc);
+
                if (stat & S_HOST_ERROR) {
                        printf("%s: adapter failure (%x)\n",
                            sc->sc_dev.dv_xname, stat);
-                       bus_space_write_2(iot, ioh, ELINK_COMMAND,
-                           C_INTR_LATCH);
                        ex_reset(sc);
                        ex_init(sc);
                        return 1;
@@ -1262,11 +1273,10 @@
                        }
                }
        }
-       if (ret) {
-               bus_space_write_2(iot, ioh, ELINK_COMMAND, C_INTR_LATCH);
-               if (ifp->if_snd.ifq_head != NULL)
-                       ex_start(ifp);
-       }
+
+       /* no more interrupts */
+       if (ret && ifp->if_snd.ifq_head)
+               ex_start(ifp);
        return ret;
 }
 



Home | Main Index | Thread Index | Old Index