zigford.org

About | Links | Scripts
Sharing linux/windows scripts and tips

r8152 resume from suspend

January 19, 2021 — Jesse Harris

I recently upgraded my Precision 5510 to a Precision 5550. I was able to use btrfs send to transfer my existing Gentoo install to the new machine and used genkernel for my kernel config until I can get around to fine tuning. I have noticed an odd quirk where resuming from suspend, the ethernet port on my TB16 thunderbolt dock does not work.


Manualy I can work around this using the following commands:

    modprobe -r r8152
    modprobe r8152

But manual is tedious after a while. I want my machine to suspend and resume without issue. A google around for this issue, shows a few kernel commits which may resolve this in future and my fix might not be needed.

In the meantime, I will add a systemd hook to automatically reload the module on suspend and resume. I'm writing this blog article so that I can remember what I did.

Basically I am copying this stackoverflow article but changing the name of the module.

  1. Create r8152-refresh shell script in /lib/systemd/system-sleep/

    #!/bin/bash
    
    PROGNAME=$(basename "$0")
    state=$1
    action=$2
    
    function log {
        logger -i -t "$PROGNAME" "$*"
    }
    
    log "Running $action $state"
    
    if [[ $state == post ]]; then
        modprobe -r r8169 \
        && log "Removed r8152" \
        && modprobe -i r8152 \
        && log "Inserted r8152"
    fi
    
  2. Make it executable.

  3. There is no 3.

Checking that it works

Open the journal and follow it using journalctl -f. Suspend and resume the system.

Jan 19 12:42:46 byjp373 systemd[1]: Starting Suspend...
Jan 19 12:42:46 byjp373 r8152-refresh[1471975]: Running suspend pre
Jan 19 12:42:46 byjp373 systemd-sleep[1471971]: Suspending system...
Jan 19 12:42:46 byjp373 kernel: PM: suspend entry (s2idle)
Jan 19 12:42:59 byjp373 kernel: Filesystems sync: 0.028 seconds
Jan 19 12:42:59 byjp373 kernel: Freezing user space processes ... (elapsed 0.001 seconds) done.
Jan 19 12:42:59 byjp373 kernel: OOM killer disabled.
Jan 19 12:42:59 byjp373 kernel: Freezing remaining freezable tasks ... (elapsed 0.001 seconds) done.
Jan 19 12:42:59 byjp373 kernel: printk: Suspending console(s) (use noconsolesuspend to debug)
Jan 19 12:42:59 byjp373 kernel: PM: suspend devices took 0.250 seconds
Jan 19 12:42:59 byjp373 kernel: ACPI: EC: interrupt blocked
Jan 19 12:42:59 byjp373 kernel: ACPI: EC: interrupt unblocked
Jan 19 12:42:59 byjp373 kernel: nvme nvme0: 12/0/0 default/read/poll queues
Jan 19 12:42:59 byjp373 kernel: PM: resume devices took 0.760 seconds
Jan 19 12:42:59 byjp373 kernel: OOM killer enabled.
Jan 19 12:42:59 byjp373 gnome-shell[1453357]: libinput error: client bug: timer event3 debounce: scheduled expiry is in the past (-247ms), your system is too slow
Jan 19 12:42:59 byjp373 gnome-shell[1453357]: libinput error: client bug: timer event3 btnscroll: scheduled expiry is in the past (-72ms), your system is too slow
Jan 19 12:42:59 byjp373 kernel: Restarting tasks ... done.
Jan 19 12:42:59 byjp373 kernel: thermal thermal_zone0: failed to read out thermal zone (-61)
Jan 19 12:42:59 byjp373 systemd-sleep[1471971]: System resumed.
Jan 19 12:42:59 byjp373 kernel: PM: suspend exit
Jan 19 12:42:59 byjp373 r8152-refresh[1472079]: Running suspend post
Jan 19 12:42:59 byjp373 kernel: usbcore: deregistering interface driver r8152

Tags: gentoo, systemd, precision-5550