This is the mail archive of the ecos-patches@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Fix potential stall with Coldfire Ethernet


Bart Veer wrote:
This is not the right fix, and the problem is nothing to do with the
toolchain.

FreeScale have redefined the nop instruction for ColdFires to act as a
barrier instruction. When the cpu executes nop it stalls the
instruction pipeline until all previous instructions have completed.
Also, if the processor has some kind of write buffer between the cache
and external memory then nop will stall until the write buffer has
been emptied. Most of the time you do not need to worry about pipeline
effects like this, but DMA engines and cache interactions nearly
always need very special care.

The operation immediately before starting the transmit is a
HAL_DCACHE_STORE(). Without the nop that macro may not have finished
executing, so the cache store is still happening at the point that the
ethernet engine fetches the buffer descriptors. Hence the ethernet
engine may see bogus buffer descriptors, and confusion results.

The correct solution is to incorporate the nop into your processor's
HAL_DCACHE_STORE() macro, thus making the macro do precisely what it
is supposed to do. That will fix any other uses of HAL_DCACHE_STORE(),
not just the ethernet driver. It also avoids adding an unnecessary nop
instruction on processors which do not need it, e.g. the mcf5272 which
does not have a data cache at all.

You are 100% correct about cache/DMA interactions. The MCF5208 Device Errdata document admits that the micro's cache implementation is buggy and each cache clear operation must be followed by NOP. Also, all cache synchronisation essentially boils down to cache clear because there are no advanced operations.


I was about to reply that we know about this and have a NOP where needed but upon looking closer it turns out HAL_DCACHE_STORE() is not implemented at all. Ahh - the pride, thrill and exitement of finding totally stupid errors that have consumed hours and days of your life.

It's not all that simple, though. Stalling occurs also when cache is disabled. I'll do some more reserarch on this issue next week.

--
Kind regards,
Tarmo Kuuse


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]