nForcersHQ
 
nForcersHQForumDistributed ComputingFAQLog inRegisterSearch
 
nForcersHQ

[ACPI][Wake-on-LAN] System won't boot up after Power down
Post new topic Reply to topic    nForcersHQ.com Forum Index » nForce Linux
Login to view full posting options
Author Message
Google
AdSense

Back to top  
sphere2
nFHQ Member
nFHQ Member

Joined: 27 Nov 2003
Posts: 8

PostPosted: Thu Nov 27, 2003 2:21 pm    Post subject: [ACPI][Wake-on-LAN] System won't boot up after Power down

I've installed Debian unstable on my abit nf7-s v2.0. While I was waiting for the packages for X to trickle in, I tried to fix Wake-on-Lan. And it works... once.

If I shutdown from W2K I can ether-wake the box, but when I shutdown from Linux I cannot. I have to power on/off the box (to reset the BIOS maybe Confused) and then it will boot again after a call from ether-wake.

The kernel is a 2.4.22 one with ACPI. Does anyone have any pointers on how to get this going after a Power down. from Linux? The only strange thing I can see is that after the "Power down." message appears, two more usb******* messages flash by, but I don't have a clue what they are, it is almost impossible to see and I don't have a videocamera to tape it.
Back to top
sphere2
nFHQ Member
nFHQ Member

Joined: 27 Nov 2003
Posts: 8

PostPosted: Thu Dec 11, 2003 8:40 am    Post subject: Re: [ACPI][Wake-on-LAN] System won't boot up after Power dow

Wake-on-LAN:
NOTE: This will not work flawlessly with the nvnet driver, use forcedeth instead if you value WOL.
This works with Debian on an Abit NF7-S, but it's probably easy enough to adapt it for your setup.
http://www.scyld.com/diag/index.html
Download ftp://ftp.scyld.com/pub/diag/pci-config.c

NOTE: You have to figure out yourself what device number your nic has:
Example:
#! /bin/shsphere@barton:~/media$ lspci
[SNIP]
00:04.0 Ethernet controller: nVidia Corporation nForce2 Ethernet Controller (rev a1)
[SNIP]

sphere@barton:~/media$ ./pci-config
pci-config.c:v2.03 4/15/2002 Donald Becker (becker@scyld.com)
http://www.scyld.com/diag/index.html
[SNIP]
Device #12 at bus 0 device/function 4/0, 006610de.
[SNIP]

sphere@barton:~/media$ cat /proc/pci
PCI devices found:
[SNIP]
Bus 0, device 4, function 0:
Ethernet controller: nVidia Corporation nForce2 Ethernet Controller (rev 161).
IRQ 20.
Master Capable. No bursts. Min Gnt=1.Max Lat=20.
Non-prefetchable 32 bit memory at 0xe0087000 [0xe0087fff].
[SNIP]

sphere@barton:~/media$ ./pci-config -a -#12
pci-config.c:v2.03 4/15/2002 Donald Becker (becker@scyld.com)
http://www.scyld.com/diag/index.html
Device #12 at bus 0 device/function 4/0.
006610de 00b00007 020000a1 00000000 e0087000 0000b001 00000000 00000000
00000000 00000000 00000000 1c00147b 00000000 00000044 00000000 1401010b
1c00147b fe020001 00000100 00000004 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
Base Address 0: Memory at e0087000.
Base Address 1: I/O at 0000b000.
Address 0 memory at e0087000, decoded bits are 00000fff.
Address 1 is I/O at 0000b000, decoded bits are 00000006.
No BIOS extension (boot ROM).
Extended capabilities, first structure at offset 0x44.
Extended PCI capability type 1 at 0x44, next 0.
Power management entry ver. 2: Capabilities fe02, Ctrl 0100, Event 0000.
Power state D0.

Now that you know the device number, you can force it to power state D3 at shutdown. The forcedeth driver will complain about the transceiver. After power down you are able to wake your box up by sending it a magic packet, with ether-wake for Linux for instance.

Add script for init 0:
sphere@barton:/usr/src$ more /etc/rc0.d/S21D3NIC
echo "Putting NIC to D3 state -- FIXME!!!"
/home/sphere/media/pci-config -S -#12 | grep Power
/home/sphere/media/pci-config -a -#12 | grep Power
Back to top
l10n3l
Just got here...

Joined: 17 Aug 2007
Posts: 1

PostPosted: Fri Aug 17, 2007 11:52 am    Post subject: nforce (forcedeth) and Wake-on-LAN (WOL)

Hi,

WOL is partially broken on forcedeth, at least until the v0.56 of the driver but if you read the link below, enhancements are in progress in the forcedeth driver to fix this.

First, check the version of your forcedeth driver (you'll see the version of the driver in /var/log/messages when loading the forcedeth module).


  • For forcedeth v0.56, there is a bug in the driver that requires to send the WOL packet with a reverse MAC address, eg:
    Code:

    piano:~# ifconfig eth0
    eth0      Link encap:Ethernet  HWaddr 00:0C:76:5E:FE:3D


    The wake-up command will be
    Code:
    wol -h 192.168.254.255 3d:fe:5e:76:0c:00

    This is due to reverse byte orders of the forcedeth driver that is currently being investigated (see http://www.nvnews.net/vbulletin/showthread.php?t=70384).

  • For forcedeth version 0.49 and prior, you can try the following patch (at your own risks) (it did work for me with 0.49 within the 2.6.16 kernel):

    Note: please first try the first method above, as it may work even with a version below 0.56, and assures you that you diverge less from the standard forcedeth driver (no changes/no recompilation) which also means that you will not have to bother patching/compiling each time you install a new kernel version on your system.

    This changes in the forcedeth have been performed to reproduce what had been done manually before by Carl-Daniel Hailfinger.
    See:

    • http://www.oss.sgi.com/archives/netdev/2004-03/msg00245.html
    • http://atlas.et.tudelft.nl/verwei90/nforce2/wol.html
    • http://bugzilla.kernel.org/show_bug.cgi?id=1636

    The only advantages compared to the pci-config method described by Carl-Daniel Hailfinger is that this fix directly updates the forcedeth and thus:

    • The kernel does not complain anymore about timeouts on rx/tx when put in WOL mode... (even when this happened, it this didn't lead to a kernel crash though)
    • There is no need to tweak DEV_NEED_TIMERIRQ anymore (we actually stop interrupts processing before moving the D3 sleep mode)


    This pach worked on a debian with kernel 2.6.16 (forcedeth v0.49). It requires recompiling the module from the kernel sources (forcedeth.c)

    Using the modified forcedeth driver, I just had to add the following script at shutdown (in /etc/rc0.d/S21nforce-wol for me)
    Code:

    #!/bin/sh
    ethtool -s eth0 wol g


    This allows the forcedeth driver to be set as WOL just before shutting down the network interface

    Here is the patch for the kernel module:
    Code:

    --- drivers/net/forcedeth.c.orig   2007-08-17 10:25:00.000000000 +0200
    +++ drivers/net/forcedeth.c   2007-08-17 10:55:54.000000000 +0200
    @@ -102,8 +102,41 @@
      *   0.47: 26 Oct 2005: Add phyaddr 0 in phy scan.
      *   0.48: 24 Dec 2005: Disable TSO, bugfix for pci_map_single
      *   0.49: 10 Dec 2005: Fix tso for large buffers.
    + *         10 Aug 2007: Fix WOL support (D3 PCI power save mode)
      *
      * Known bugs:
    + * Lionel Ains (wol fix):
    + * 1) Enable wol g mode with ethtool will only work if interface is up
    + * 2) When set to wol g mode, the NIC will be brought down immediately,
    + * so this is something you want to do only at shutdown (ie: around S2
    + * in /etc/rc0.d for debian)
    + * 2) If you put your NIC in wol mode, then rmmod forcedeth, modprobe forcedeth
    + * will always fail afterwards (until next reboot). The failure actually occurs
    + * within nv_probe() which fails detecting the nforce NIC when in D3 sleep mode
    + *
    + * This changes in the forcedeth have been performed to reproduce
    + * what had been done manually before by Carl-Daniel Hailfinger
    + * See:
    + * http://www.oss.sgi.com/archives/netdev/2004-03/msg00245.html
    + * http://atlas.et.tudelft.nl/verwei90/nforce2/wol.html
    + * http://bugzilla.kernel.org/show_bug.cgi?id=1636
    + * The only advantages brought by the fact this fix directly updates the
    + * forcedeth module are that:
    + * - kernel does not complain anymore about timeouts on rx/tx when put
    + * in WOL mode... (even when this happened, it this didn't lead to a kernel
    + * crash though)
    + * - No need to tweak DEV_NEED_TIMERIRQ anymore (we actually stop interrupts
    + * processing before moving the D3 sleep mode)
    + *
    + * This worked on a debian with kernel 2.6.16 (forcedeth v0.49)
    + * Using the modified forcedeth driver, I just had to add the following
    + * script at shutdown (in /etc/rc0.d/S21nforce-wol for me)
    +
    +#!/bin/sh
    +ethtool -s eth0 wol g
    +
    + *
    + *
      * We suspect that on some hardware no TX done interrupts are generated.
      * This means recovery from netif_stop_queue only happens if the hw timer
      * interrupt fires (100 times/second, configurable with NVREG_POLL_DEFAULT)
    @@ -1014,6 +1047,34 @@
        nv_drain_rx(dev);
     }
     
    +static void nv_powersave_D0(struct net_device *dev)
    +{
    +   u8 __iomem *base = get_hwbase(dev);
    +
    +   if ((readl(base + NvRegPowerState) & NVREG_POWERSTATE_D0) == 0) {
    +      writel(NVREG_POWERSTATE_D0, base + NvRegPowerState);
    +      pci_push(base);
    +      udelay(10);
    +      printk(KERN_INFO "%s: Switching to D0 active mode\n", dev->name);
    +   }
    +   writel(readl(base + NvRegPowerState) | NVREG_POWERSTATE_VALID, base + NvRegPowerState);
    +   pci_push(base);
    +}
    +
    +static void nv_powersave_D3(struct net_device *dev)
    +{
    +   u8 __iomem *base = get_hwbase(dev);
    +
    +   if ((readl(base + NvRegPowerState) & NVREG_POWERSTATE_D3) == 0) {
    +      writel(NVREG_POWERSTATE_D3, base + NvRegPowerState);
    +      pci_push(base);
    +      udelay(10);
    +      printk(KERN_INFO "%s: Switching to D3 sleep mode (WOL)\n", dev->name);
    +   }
    +   writel(readl(base + NvRegPowerState) | NVREG_POWERSTATE_VALID, base + NvRegPowerState);
    +   pci_push(base);
    +}
    +
     /*
      * nv_start_xmit: dev->hard_start_xmit function
      * Called with dev->xmit_lock held.
    @@ -1974,11 +2035,21 @@
     
        spin_lock_irq(&np->lock);
        if (wolinfo->wolopts == 0) {
    +      /* Disabling wol */
           writel(0, base + NvRegWakeUpFlags);
    +      if ((np->wolenabled) && (!(dev->flags & IFF_UP))) {   /* wol was enabled, and interface is down, switch NIC to D0 power state right now */
    +//         printk(KERN_INFO "%s: Switching to D0 active while %s is down\n", dev->name, dev->name);
    +         nv_powersave_D0(dev);
    +      }
           np->wolenabled = 0;
        }
        if (wolinfo->wolopts & WAKE_MAGIC) {
    +      /* Enabling wol on magic */
           writel(NVREG_WAKEUPFLAGS_ENABLE, base + NvRegWakeUpFlags);
    +      if (!(np->wolenabled) && (!(dev->flags & IFF_UP))) {   /* wol was disabled, and interface is down, switch to D3 power state right now */
    +         printk(KERN_WARNING "%s: Switching to D3 sleep mode will only be effective at next up+down cycle for %s\n", dev->name, dev->name);
    +//         nv_powersave_D3(dev);   /* Not working, because if must be listening on rx/tx before being put to sleep mode */
    +      }
           np->wolenabled = 1;
        }
        spin_unlock_irq(&np->lock);
    @@ -2376,8 +2447,11 @@
        netif_stop_queue(dev);
        spin_lock_irq(&np->lock);
        nv_stop_tx(dev);
    -   nv_stop_rx(dev);
    -   nv_txrx_reset(dev);
    +   /* Lionel Ains: stop TX even if going to WOL */
    +   if (!np->wolenabled) {
    +      nv_stop_rx(dev);
    +      nv_txrx_reset(dev);
    +   }
     
        /* disable interrupts on the nic or we will lock up */
        base = get_hwbase(dev);
    @@ -2392,7 +2466,8 @@
        drain_ring(dev);
     
        if (np->wolenabled)
    -      nv_start_rx(dev);
    +//      nv_start_rx(dev); /* Not needed... we skipped nv_stop_rx() above! */
    +      nv_powersave_D3(dev);
     
        /* special op: write back the misordered MAC address - otherwise
         * the next nv_probe would see a wrong address.
    @@ -2400,7 +2475,11 @@
        writel(np->orig_mac[0], base + NvRegMacAddrA);
        writel(np->orig_mac[1], base + NvRegMacAddrB);
     
    -   /* FIXME: power down nic */
    +   /* Lionel Ains: NIC power down was done for WOL above */
    +   /* We could power down NIC (to D3 mode) while bringing down interface by
    +      uncommenting the lines below */
    +//   if (!np->wolenabled)
    +//      nv_powersave_D3(dev);
     
        return 0;
     }


    To apply this patch:
    1. Save the above patch inside a text file (let's call it /tmp/forcedeth_wol.patch

    2. Move to the Linux kernel sources directory (as root):
    Code:
    cd /usr/src/linux


    3. Then patch the forcedeth driver:
    Code:
    patch -p0 < /tmp/forcedeth_wol.patch


    4. Recompile:
    Code:
    make modules


    5. Load the new driver:
    Code:
    ifdown eth0 && rmmod forcedeth && insmod drivers/net/forcedeth.ko


    6. Activate WOL:
    Code:
    ethtool -s eth0 wol g


    7. Bring down the interface eth0 (ifdown eth0) and shutdown your machine

    8. If the wake-on-LAN works, you can use the new module (cd /usr/src/linux; make modules_install)

    9. Create the rc0.d shutdown script (the /etc/rc0.d/S21nforce-wol script I mention above) to run the ethtool -s eth0 wol g before each reboot.



Lionel Ains
Back to top
Google
AdSense
Google
Back to top  
Display posts from previous:   
Post new topic   Reply to topic    nForcersHQ.com Forum Index » nForce Linux
All times are GMT Page 1 of 1


ToS | Privacy | Forum Rules | Contact | Advertise on this site
NVIDIA, the NVIDIA logo, NVIDIA nForce and all of the NVIDIA nForce product logos are trademarks of NVIDIA Corporation
nPowered by phpBB © 2007 phpBB Group  All rights reserved © 2001-2008 Michael Day nFHQ nForcersHQ.com | Fluffy-Gear.com
nForcersHQ supporters: Impar, wardog, MiniMax, envoid, jasonh, Krips, VAIOMAN, Zetro, sensai, me&er, RElliott, ScottRempel, JHogarth, IcemanIX, Etraman, KA, Tabajara, Xiomberg, ruddywarrior, hookahmike, MMoore, RHodgson, RGilson, powerarmour, Sepal, RRavat, DigitalRuin, HammerheadTech, Bane, DHunt, Fat Jez, baikal, Jumpin' Jon, MGadzikowski, JBishop, RDeBok, JDavies, HDHyland, TMorris