This is the mail archive of the
ecos-patches@sources.redhat.com
mailing list for the eCos project.
Laki USB patch
- From: Andrew Lunn <andrew dot lunn at ascom dot ch>
- To: eCos Patches <ecos-patches at sources dot redhat dot com>
- Date: Thu, 5 Dec 2002 17:17:19 +0100
- Subject: Laki USB patch
Hi Bart
I found another bug in the LAKI USB driver. When setting up for a
recieve on end point 4, it invalidates the buffer which is in cached
memory. It does this to be sure that when it copies the data out of
the buffer some time later, it gets the new contents from the DRAM and
not the old data in the cache.
Unfortunatly, the invalidate works on cache lines and so invalidates
more than just the buffer. I found it was also invalidating parts of
usbs_eth0. The critical value which was causing my problem is the
rx_buffer_full member. usbs_ethdrv_recv() is used to move a just
received packet into an mbuf. Once its made the copy it sets
rx_buffer_full to false and then starts a new receive. This calls
ep4_start_rx, which is doing the cache invalidate. After the
invalidate, the rx_buffer_full flag goes back to its old, true, value,
so causing the upper layer to do the receive again, and again.....
I changed the invalidate to a flush. This will ensure the contents of
the cache line are written to DRAM, so rx_buffer_full remains valid
and that the buffer is made invalid in cache.
What im not so sure about is interrupts. What happens if there is an
interrupt during the flush?
Andrew
Index: ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/devs/usb/nec_upd985xx/current/ChangeLog,v
retrieving revision 1.4
diff -u -r1.4 ChangeLog
--- ChangeLog 2 Dec 2002 20:48:15 -0000 1.4
+++ ChangeLog 5 Dec 2002 16:03:05 -0000
@@ -1,3 +1,8 @@
+2002-12-05 Andrew Lunn <andrew.lunn@ascom.ch>
+
+ * src/usbs_upd985xx.c (ep4_start_rx): flush rather and invalidate
+ the buffer, because other variables are also in the cache line.
+
2002-12-01 Bart Veer <bartv@ecoscentric.com>
* src/usbs_upd985xx.c, cdl/usbs_upd985xx.cdl:
Index: src/usbs_upd985xx.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/devs/usb/nec_upd985xx/current/src/usbs_upd985xx.c,v
retrieving revision 1.4
diff -u -r1.4 usbs_upd985xx.c
--- src/usbs_upd985xx.c 2 Dec 2002 20:48:45 -0000 1.4
+++ src/usbs_upd985xx.c 5 Dec 2002 16:03:06 -0000
@@ -2143,7 +2143,7 @@
uncached->ep4_rx_bufdescs[current_bufdesc].buffer = MIPS_TO_UNCACHED(ep4.common.buffer + ep4.head_size);
uncached->ep4_rx_bufdescs[current_bufdesc].control = RXBUFDESC_CTRL_BUFDESC_BUFDESC | ep4.direct_size;
current_bufdesc++;
- HAL_DCACHE_INVALIDATE(ep4.common.buffer + ep4.head_size, ep4.direct_size);
+ HAL_DCACHE_FLUSH(ep4.common.buffer + ep4.head_size, ep4.direct_size);
}
// And the size of the tail. This is the transfer size minus what we have accumulated so far.