Surface Pro 1796 Wifi not resuming after suspend

[suchus@PSYCHO ~]$ inxi -Fxzc0
System:    Host: PSYCHO Kernel: 4.17.0-1-MANJARO x86_64 bits: 64 compiler: gcc v: 8.1.0 Desktop: i3 4.15.0.1 
           Distro: Manjaro Linux 17.1.10 Hakoila 
Machine:   Type: Laptop System: Microsoft product: Surface Pro v: D:0B:09F:5C:09P:38S:01E:0 serial: N/A 
           Mobo: Microsoft model: Surface Pro serial: N/A UEFI: Microsoft v: 233.2110.770 date: 01/30/2018 
CPU:       Topology: Dual Core model: Intel Core i5-7300U bits: 64 type: MT MCP arch: Kaby Lake rev: 9 
           L2 cache: 3072 KiB 
           flags: lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx bogomips: 21704 
           Speed: 2257 MHz min/max: 400/3500 MHz Core speeds (MHz): 1: 1600 2: 1520 3: 1182 4: 1399 
Graphics:  Card-1: Intel HD Graphics 620 driver: i915 v: kernel bus ID: 00:02.0 
           Display: x11 server: X.Org 1.19.6 driver: intel unloaded: fbdev,modesetting,vesa 
           resolution: 2736x1824~60Hz 
           OpenGL: renderer: Mesa DRI Intel HD Graphics 620 (Kaby Lake GT2) v: 4.5 Mesa 18.0.3 
           direct render: Yes 
Audio:     Card-1: Intel Sunrise Point-LP HD Audio driver: snd_hda_intel v: kernel bus ID: 00:1f.3 
           Sound Server: ALSA v: k4.17.0-1-MANJARO 
Network:   Card-1: Marvell 88W8897 [AVASTAR] 802.11ac Wireless driver: mwifiex_pcie v: 1.0 bus ID: 01:00.0 
           IF: wlp1s0 state: up mac: <filter> 
Drives:    HDD Total Size: 297.95 GiB used: 6.68 GiB (2.2%) 
           ID-1: /dev/nvme0n1 vendor: Intel model: SSDPEBKF256G7 size: 238.47 GiB 
           ID-2: /dev/sda type: USB vendor: Generic model: SD MMC size: 59.48 GiB 
Partition: ID-1: / size: 47.00 GiB used: 6.66 GiB (14.2%) fs: ext4 dev: /dev/nvme0n1p5 
Sensors:   System Temperatures: cpu: 33.0 C mobo: N/A 
           Fan Speeds (RPM): N/A 
Info:      Processes: 151 Uptime: 6m Memory: 7.72 GiB used: 1.04 GiB (13.5%) Init: systemd Compilers: 
           gcc: 8.1.0 Shell: bash v: 4.4.19 inxi: 3.0.08 

when it suspends the first time (either closing lid or just leaving it alone) everythings resumes fine:

[suchus@PSYCHO ~]$ dmesg | tail -20
[  776.608048] [drm] Reducing the compressed framebuffer size. This may lead to less power savings than a non-reduced-size. Try to increase stolen memory size if available in BIOS.
[  776.625134] OOM killer enabled.
[  776.625135] Restarting tasks ... done.
[  776.636921] PM: suspend exit
[  776.643976] IPv6: ADDRCONF(NETDEV_UP): wlp1s0: link is not ready
[  776.644043] IPv6: ADDRCONF(NETDEV_UP): wlp1s0: link is not ready
[  776.727575] IPv6: ADDRCONF(NETDEV_UP): wlp1s0: link is not ready
[  776.895995] usb 1-7: new full-speed USB device number 4 using xhci_hcd
[  777.037414] usb 1-7: New USB device found, idVendor=045e, idProduct=09c0, bcdDevice= 0.07
[  777.037420] usb 1-7: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[  777.037424] usb 1-7: Product: Surface Type Cover
[  777.037427] usb 1-7: Manufacturer: Microsoft
[  777.044347] input: Microsoft Surface Type Cover Keyboard as /devices/pci0000:00/0000:00:14.0/usb1/1-7/1-7:1.0/0003:045E:09C0.0004/input/input32
[  777.100119] input: Microsoft Surface Type Cover Consumer Control as /devices/pci0000:00/0000:00:14.0/usb1/1-7/1-7:1.0/0003:045E:09C0.0004/input/input34
[  777.100469] input: Microsoft Surface Type Cover Touchpad as /devices/pci0000:00/0000:00:14.0/usb1/1-7/1-7:1.0/0003:045E:09C0.0004/input/input36
[  777.101132] hid-multitouch 0003:045E:09C0.0004: input,hiddev0,hidraw0: USB HID v1.11 Keyboard [Microsoft Surface Type Cover] on usb-0000:00:14.0-7/input0
[  777.609760]  sda: sda1
[  780.220230] mwifiex_pcie 0000:01:00.0: info: trying to associate to 'NACHTKAPP' bssid f8:35:dd:35:db:57
[  780.243103] mwifiex_pcie 0000:01:00.0: info: associated to bssid f8:35:dd:35:db:57 successfully
[  780.299959] IPv6: ADDRCONF(NETDEV_CHANGE): wlp1s0: link becomes ready

Sometimes it works a second or even a third time suspending/resuming. Most of the time (after the first resume) wifi is not coming back up. Only a reboot fixes this.

[suchus@PSYCHO ~]$ dmesg | tail -20
[ 1167.288631] input: Microsoft Surface Type Cover Keyboard as /devices/pci0000:00/0000:00:14.0/usb1/1-7/1-7:1.0/0003:045E:09C0.0005/input/input51
[ 1167.344147] input: Microsoft Surface Type Cover Consumer Control as /devices/pci0000:00/0000:00:14.0/usb1/1-7/1-7:1.0/0003:045E:09C0.0005/input/input53
[ 1167.344419] input: Microsoft Surface Type Cover Touchpad as /devices/pci0000:00/0000:00:14.0/usb1/1-7/1-7:1.0/0003:045E:09C0.0005/input/input55
[ 1167.344835] hid-multitouch 0003:045E:09C0.0005: input,hiddev0,hidraw0: USB HID v1.11 Keyboard [Microsoft Surface Type Cover] on usb-0000:00:14.0-7/input0
[ 1167.864193]  sda: sda1
[ 1168.267117] mwifiex_pcie 0000:01:00.0: Firmware wakeup failed
[ 1168.267693] mwifiex_pcie 0000:01:00.0: PREP_CMD: FW in reset state
[ 1168.275623] mwifiex_pcie 0000:01:00.0: PREP_CMD: FW in reset state
[ 1168.275690] mwifiex_pcie 0000:01:00.0: PREP_CMD: FW in reset state
[ 1168.275788] mwifiex_pcie 0000:01:00.0: PREP_CMD: FW in reset state
[ 1168.276120] mwifiex_pcie 0000:01:00.0: PREP_CMD: FW in reset state
[ 1168.276162] mwifiex_pcie 0000:01:00.0: PREP_CMD: FW in reset state
[ 1168.276270] mwifiex_pcie 0000:01:00.0: PREP_CMD: FW in reset state
[ 1168.277131] mwifiex_pcie 0000:01:00.0: PREP_CMD: FW in reset state
[ 1168.277954] mwifiex_pcie 0000:01:00.0: PREP_CMD: FW in reset state
[ 1168.308293] IPv6: ADDRCONF(NETDEV_UP): wlp1s0: link is not ready
[ 1168.309294] mwifiex_pcie 0000:01:00.0: PREP_CMD: FW in reset state
[ 1168.309298] mwifiex_pcie 0000:01:00.0: scan failed: -1
[ 1171.989912] mwifiex_pcie 0000:01:00.0: PREP_CMD: FW in reset state
[ 1171.989919] mwifiex_pcie 0000:01:00.0: scan failed: -1

Any suggestions? Maybe there is a new marvel driver available for Manjaro. I tried Kernel 4.14, 4.16, and am now running 4.17 out of the repos.

I added this (file was empty) but it does not help:

[suchus@PSYCHO ~]$ cat /etc/NetworkManager/NetworkManager.conf
# Configuration file for NetworkManager.
# See "man 5 NetworkManager.conf" for details.
[device-mac-randomization]
wifi.scan-rand-mac-address=no

[connection-mac-randomization]
ethernet.cloned-mac-address=permanent
wifi.cloned-mac-address=permanent

[connection]
wifi.powersave=2

Thanks ahead

Edit: I just saw that the driver is changing MAC-Addees all the time. I cannot use that and thought this would be fixed by adding the lines to NetworkManager.conf. This is a really crappy default because the Hotspot in my truck only allows certain MACs. I wonder if this causes my resume problem.

Yes, that is very possible.

Just a general suggestion that doesn't matter what hardware is involved. Try turning your WiFi off via the toggle key or switch before you suspend your laptop. See if that makes any difference.

Also try a manual systemd suspend via the terminal.

sudo systemctl suspend

I'll try these options now. But that can only be a workaround (if it works at all)

Yes, but it narrows down the issues involved, so it would be good to know.

Also try a lower version kernel such as the LTS 4.9. Sometimes newer is not necessarily better.

IPV6 may also be causing problems you might want to consider disabling it on both your laptop and router to see if it makes a difference.

Ok, I can do a 'systemctl suspend' once and wifi will reconnect after wakup. when I do it the second time it will be stuck in reset mode. I also tried 'systemctl stop/start NetworkManager' which mostly succeeds. But sometimes it needs a second start command in order to come back up. Looks like suspending wifi and simply shutting it down are two different things. Preventing wifi to suspend would (maybe) do it. I have already uninstalled tlp but that did not change anything. I have pretty much reached the end of my knowledge. Especially because I know almost nothing about systemd. Any help is much appreciated.

Before suspending, you could try:

modprobe -r mwifiex_pcie

After coming out of suspend:

modprobe mwifiex_pcie

i did not mention it but i already did that. wifi will not come back. Maybe we have a problem with the socket here, that becomes somehow corrupted. Just installed 4.9. Let me check this out for a moment.
thank u so much for ur hints

Nothing changes with 4.9 kernel. We need to find a way to prevent suspend for wifi. The funny thing is, ArchMouse works much better with Linux than it does with Win10. Going back to that crap is not an option because it represents me with BSODs all the time after 1803.

Does your laptop have an SSD. If it's a spinner hibernate is an option that may work till a fix is made.

It has an SSD
Surface Pro 1796
It is actually a Tablet. I bought it because of the 3:2 screen which nobody else offers.

How long have you had Manjaro installed. Was suspend ever working correctly before.

Not sure, a couple of weeks now. I tried almost all Distris but did not like them. The last was Fedora 28. I was looking for something "schlank" and was really surprised when Manjaro i3 booted on this hardware. Manjaro will be my choice.

Perhaps turn your wifi off via toggle.

sudo systemctl stop NetworkManager

sudo systemctl suspend

Then after resume, wait at least 30 seconds:

sudo systemctl start NetworkManager

I think this would be a very long shot but try this:

sudo systemctl enable NetworkManager-wait-online.service	
sudo systemctl start NetworkManager-wait-online.service

Restart, and test suspend again.

Nope. No matter what I did it keeps on hanging in the reset state after the second suspend. I think this is pointing to a driver problem. The only way out of it is a reboot.
Maybe there is a way to reset the device w/o reboot.

I am booting Win10 now and check out what happenst with suspend. This way I can make sure the device is not malfunctioning.

device works alright. Nothing like this happens with Win10.

Did you try the last couple of options I posted. If not give them a try.

Yes, I did. The result after the second suspend is always

[ 1168.267693] mwifiex_pcie 0000:01:00.0: PREP_CMD: FW in reset state

Did you do this again, before and after the second suspend attempt. Obviosly you are not going to do this every time, but if you find a combination that works it can be automated.

Yes, i did all of this multiple times and with muliple reboots. I think some bytes get stuck in the hardware and need to be flushed after suspend. Kinda resetting the device w/o reboot. I have no idea how.

Forum kindly sponsored by