On Sat, Jul 09, 2011 at 07:57:19PM +0200, Claudio Jeker wrote:
> > I'll try to figure out a fix.
> 
> It could very well be that the wol ioctl is issued before the card is up.
> ifconfig is strange when flags are set while configuring address.

We must not call xl_wol_power() from xl_stop(). If we do the device
can be set into D3 sleep state at the wrong time.
It's only safe to call xl_wol_power() from xl_activate(). We already
call it for DVACT_QUIESCE, now also call it for DVACT_SUSPEND.
This fixes the '"xl0: transmission error: ff" and "xl0: command never
completed"' lockup issue (which I could reproduce).

Also, the interface needs to be running for WOL to work, so set it up
from within xl_wol() if it's not running yet. This makes a hostname.xl0
file that contains just the keyword "wol" work correctly, without the
need to "up" the interface just for WOL. Note that as written this
depends on xl_init() to reselect register window 7 before return,
which it currently does.

ok?

Index: xl.c
===================================================================
RCS file: /cvs/src/sys/dev/ic/xl.c,v
retrieving revision 1.103
diff -u -p -r1.103 xl.c
--- xl.c        8 Jul 2011 18:56:47 -0000       1.103
+++ xl.c        9 Jul 2011 23:49:00 -0000
@@ -215,6 +215,9 @@ xl_activate(struct device *self, int act
                        xl_reset(sc);
                        xl_stop(sc);
                }
+#ifndef SMALL_KERNEL
+               xl_wol_power(sc);
+#endif
                rv = config_activate_children(self, act);
                break;
        case DVACT_RESUME:
@@ -2373,10 +2376,6 @@ xl_stop(struct xl_softc *sc)
        ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
 
        xl_freetxrx(sc);
-
-#ifndef SMALL_KERNEL
-       xl_wol_power(sc);
-#endif
 }
 
 #ifndef SMALL_KERNEL
@@ -2708,6 +2707,8 @@ xl_wol(struct ifnet *ifp, int enable)
 
        XL_SEL_WIN(7);
        if (enable) {
+               if (!(ifp->if_flags & IFF_RUNNING))
+                       xl_init(sc);
                CSR_WRITE_2(sc, XL_W7_BM_PME, XL_BM_PME_MAGIC);
                sc->xl_flags |= XL_FLAG_WOL;
        } else {

Reply via email to