Subject: Suggested patch for syssrc/sys/arch/macppc/dev/if_gm.c
To: 'Tsubai Masanari' <tsubai@netbsd.org>
From: Bruce Korb <bkorb@allegronetworks.com>
List: port-macppc
Date: 04/24/2001 14:22:49
Hi Tsubai,

I confess to not understanding this change very well.
It looks like it will always clobber the state of the GMAC_OWN
bit at the end of interrupt processing.  It is not clear
to me that this is the right thing to do.

  Subject: CVS commit: syssrc
  To: None <source-changes@netbsd.org>
  From: Tsubai Masanari <tsubai@netbsd.org>
  List: source-changes
  Date: 04/24/2001 14:04:12 

  Module Name:    syssrc
  Committed By:   tsubai
  Date:           Tue Apr 24 11:04:12 UTC 2001

  Modified Files:
        syssrc/sys/arch/macppc/dev: if_gm.c

  Log Message:
  Make sure free rx buffers have GMAC_OWN set.


Also, I would like to see the resolution to the bug report
from last November go into the sources (modulo tabbing):

Index: if_gm.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/macppc/dev/if_gm.c,v
retrieving revision 1.12
diff -u -r1.12 if_gm.c
--- if_gm.c     2001/04/24 11:04:11     1.12
+++ if_gm.c     2001/04/24 21:15:42
@@ -361,6 +361,7 @@
        int i, j, len;
        u_int cmd;
 
+    again:
        for (i = sc->sc_rxlast;; i++) {
                if (i == NRXBUF)
                        i = 0;
@@ -396,19 +397,25 @@
 
 next:
                dp->cmd_hi = 0;
-               __asm __volatile ("sync");
+               __asm __volatile ("eieio");
                dp->cmd = htole32(GMAC_OWN);
        }
-       sc->sc_rxlast = i;
-
-       /* XXX Make sure free buffers have GMAC_OWN. */
-       i++;
-       for (j = 1; j < NRXBUF; j++) {
-               if (i == NRXBUF)
-                       i = 0;
-               dp = &sc->sc_rxlist[i++];
-               dp->cmd = htole32(GMAC_OWN);
-       }
+    if (sc->sc_rxlast != i) {
+        sc->sc_rxlast = i;
+        return;
+    }
+    for (;;) {
+        i = (i + 1) % NRXBUF;
+        if (sc->sc_rxlast == i)
+            break;
+        cmd = le32toh(sc->sc_rxlist[i].cmd);
+        if (cmd & GMAC_OWN)
+            continue;
+        log(LOG_ERR,"reset GMAC read hand from %d to %d for %s\n",
+            sc->sc_rxlast, i, sc->sc_dev.dv_xname);
+        sc->sc_rxlast = i;
+        goto again;
+    }
 }
 
 struct mbuf *