[rtems commit] PR 2011/networking GRETH: Moved print to remove potential deadlock

Joel Sherrill joel at rtems.org
Thu Feb 2 19:08:54 UTC 2012


Module:    rtems
Branch:    master
Commit:    600bd1bb59d713b7c3fcafaaf7239a2bc14d96d2
Changeset: http://git.rtems.org/rtems/commit/?id=600bd1bb59d713b7c3fcafaaf7239a2bc14d96d2

Author:    Joel Sherrill <joel.sherrill at oarcorp.com>
Date:      Thu Feb  2 13:05:24 2012 -0600

PR 2011/networking GRETH: Moved print to remove potential deadlock

Deadlock may arise when the EDCL bug link is used to tunnel
console output over Ethernet, when Ethernet is down one should
avoid using console (only during debugging of LEON targets)

Author: Marko Isomaki <marko at gaisler.com>
Signed-off-by: Daniel Hellstrom <daniel at gaisler.com>

---

 c/src/libchip/network/greth.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/c/src/libchip/network/greth.c b/c/src/libchip/network/greth.c
index e50c642..05d74c7 100644
--- a/c/src/libchip/network/greth.c
+++ b/c/src/libchip/network/greth.c
@@ -268,6 +268,7 @@ greth_initialize_hardware (struct greth_softc *sc)
     int tmp2;
     unsigned int msecs;
     struct timeval tstart, tnow;
+    int anegtout;
 
     greth_regs *regs;
 
@@ -303,6 +304,10 @@ greth_initialize_hardware (struct greth_softc *sc)
     sc->sp = 0;
     sc->auto_neg = 0;
     sc->auto_neg_time = 0;
+    /* the anegtout variable is needed because print cannot be done before mac has
+       been reconfigured due to a possible deadlock situation if rtems 
+       is run through the edcl with uart polling (-u)*/
+    anegtout = 0;
     if ((phyctrl >> 12) & 1) {
             /*wait for auto negotiation to complete*/
             msecs = 0;
@@ -329,7 +334,7 @@ greth_initialize_hardware (struct greth_softc *sc)
                     msecs = (tnow.tv_sec-tstart.tv_sec)*1000+(tnow.tv_usec-tstart.tv_usec)/1000;
                     if ( msecs > GRETH_AUTONEGO_TIMEOUT_MS ){
                             sc->auto_neg_time = msecs;
-                            printk("Auto negotiation timed out. Selecting default config\n\r");
+                            anegtout = 1
                             tmp1 = read_mii(phyaddr, 0);
                             sc->gb = ((phyctrl >> 6) & 1) && !((phyctrl >> 13) & 1);
                             sc->sp = !((phyctrl >> 6) & 1) && ((phyctrl >> 13) & 1);
@@ -477,7 +482,11 @@ auto_neg_done:
 #endif
 
     regs->ctrl |= GRETH_CTRL_RXEN | (sc->fd << 4) | GRETH_CTRL_RXIRQ | (sc->sp << 7) | (sc->gb << 8);
-
+    
+    if (anegtout) {
+            printk("Auto negotiation timed out. Selecting default config\n\r");
+    }
+    
     print_init_info(sc);
 }
 




More information about the vc mailing list