Skip to content

Instantly share code, notes, and snippets.

@ceres-c
Last active November 24, 2021 17:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ceres-c/54f6455f01e0ce23fc7a881c1fb400aa to your computer and use it in GitHub Desktop.
Save ceres-c/54f6455f01e0ce23fc7a881c1fb400aa to your computer and use it in GitHub Desktop.
A mkinitcpio hook to fix e1000e network driver issues with WoL packets on startup

The X230 I use for playing with Coreboot has a Intel Corporation 82579LM ethernet card with WoL support. Problem is, when the laptop is woken up via a WoL packet, the e1000e driver in linux is not able to bring up the network card correctly.

As highlighted on this Arch forums post, the problem can be solved resetting the PCI device before the driver is loaded. This mkinitcpio hook does exactly that if you add reset-e1000e as the first hook in your HOOKS list. Don't forget to rebuild your initrd.

#!/bin/bash
# Place this file in /etc/initcpio/install/reset-e1000e
build ()
{
add_runscript
}
help ()
{
cat<<HELPEOF
This hook reset the 82579LM Ethernet board on my Thinkpad X230 laptop on
boot to restore it to a clean state after a WoL packet woke up the PC.
HELPEOF
}
#!/usr/bin/ash
# Place this file in /etc/initcpio/hooks/reset-e1000e
run_hook ()
{
echo "Resetting PCI Ethernet card"
# Hardcoded PCI path, check the right one on your machine
echo 1 > /sys/devices/pci0000\:00/0000\:00\:19.0/reset
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment