All pastes #79109 Raw Edit

pcnet-recursive-xmit-20060705-1.diff

public text v1 · immutable
·published 2006-07-04 22:29 UTC
rendered paste body
Index: hw/pcnet.c
===================================================================
RCS file: /cvsroot/qemu/qemu/hw/pcnet.c,v
retrieving revision 1.1
diff -u -r1.1 pcnet.c
--- hw/pcnet.c	4 Jul 2006 11:33:00 -0000	1.1
+++ hw/pcnet.c	4 Jul 2006 22:29:16 -0000
@@ -62,6 +62,7 @@
     uint64_t timer;
     int xmit_pos, recv_pos;
     uint8_t buffer[4096];
+    int tx_busy;
 };
 
 #ifdef __GNUC__
@@ -658,6 +659,8 @@
     s->csr[114] = 0x0000;
     s->csr[122] = 0x0000;
     s->csr[124] = 0x0000;
+
+    s->tx_busy = 0;
 }
 
 static void pcnet_update_irq(PCNetState *s)
@@ -1101,7 +1104,9 @@
         s->csr[0] &= ~0x0008;
         return;
     }
-    
+
+    s->tx_busy = 1;
+
     txagain:
     if (pcnet_tdte_poll(s)) {
         struct pcnet_TMD tmd;
@@ -1164,6 +1169,8 @@
         if (count--)
           goto txagain;
     }
+
+    s->tx_busy = 0;
 }
 
 static void pcnet_poll(PCNetState *s)
@@ -1174,7 +1181,13 @@
 
     if (CSR_TDMD(s) || 
         (CSR_TXON(s) && !CSR_DPOLL(s) && pcnet_tdte_poll(s)))
+    {
+        /* prevent recursion */
+        if (s->tx_busy)
+            return;
+
         pcnet_transmit(s);
+    }
 }
 
 static void pcnet_poll_timer(void *opaque)