public inbox for ecos-patches@sourceware.org
 help / color / mirror / Atom feed
From: Bart Veer <bartv@ecoscentric.com>
To: Tarmo Kuuse <tarmo.kuuse@mail.ee>
Cc: ecos-patches@sources.redhat.com
Subject: Re: Fix potential stall with Coldfire Ethernet
Date: Wed, 04 Mar 2009 11:10:00 -0000	[thread overview]
Message-ID: <pn4oy9k0hn.fsf@delenn.bartv.net> (raw)
In-Reply-To: <goj05c$vm5$1@ger.gmane.org> (message from Tarmo Kuuse on Tue, 03 	Mar 2009 12:18:20 +0200)

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2502 bytes --]

>>>>> "Tarmo" == Tarmo Kuuse <tarmo.kuuse@mail.ee> writes:

    Tarmo> While struggling with eCos on Coldfire 5208 I stumbled on a
    Tarmo> nasty bug. The fast ethernet controller often stalls if
    Tarmo> transmission is flagged immediately after copying data to
    Tarmo> buffer.

    Tarmo> I have no idea why this happens. Maybe my compiler (from
    Tarmo> CodeSourcery, not eCos) does something to confuse the FEC.
    Tarmo> Maybe the 5208 hardware is buggy.

    Tarmo> Hopefully the currently supported devices (5282 and 532x)
    Tarmo> are safe when built with eCos toolchain (I cannot test it).
    Tarmo> The patch could save a few neurons for someone.

    Tarmo> Patch adds a NOP between filling the buffer and flagging
    Tarmo> the transmitter.

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.

Bart

-- 
Bart Veer                                   eCos Configuration Architect
eCosCentric Limited    The eCos experts      http://www.ecoscentric.com/
Barnwell House, Barnwell Drive, Cambridge, UK.      Tel: +44 1223 245571
Registered in England and Wales: Reg No 4422071.
Besuchen Sie uns vom 3.-5.03.09 auf der Embedded World 2009, Stand 11-300
Visit us at Embedded World 2009, Nürnberg, Germany, 3-5 Mar, Stand 11-300

  reply	other threads:[~2009-03-04 11:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-03 11:45 Tarmo Kuuse
2009-03-04 11:10 ` Bart Veer [this message]
2009-03-05 10:29   ` Tarmo Kuuse

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=pn4oy9k0hn.fsf@delenn.bartv.net \
    --to=bartv@ecoscentric.com \
    --cc=ecos-patches@sources.redhat.com \
    --cc=tarmo.kuuse@mail.ee \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).