You are not logged in.

#1 2017-12-31 19:22:45

mcdorfenberger
Member
Registered: 2017-12-07
Posts: 3

USB SD Card device not found after suspend

After waking from suspend, the SD Card in my SD slot is no longer found, even if I remove and plug it back in.

Macbook Air Mid-2015.  Nearly all hardware working fine.
A few revisions ago, it began to wake immediately after sleep.  Switching to linux-macbook kernel has fixed this.

I've got a JetDrive 256G fast SD Card in the slot, which runs on the USB bus.

Prior to suspend:

lsusb:

Bus 002 Device 002: ID 05ac:8406 Apple, Inc. 
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 05ac:0291 Apple, Inc. 
Bus 001 Device 006: ID 05ac:828f Apple, Inc. 
Bus 001 Device 002: ID 0a5c:4500 Broadcom Corp. BCM2046B1 USB 2.0 Hub (part of BCM2046 Bluetooth)
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

lsblk:

tyler@amitabha:~$ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0   113G  0 disk 
├─sda1   8:1    0   512M  0 part 
├─sda2   8:2    0    35G  0 part /
├─sda3   8:3    0     4G  0 part [SWAP]
└─sda4   8:4    0  73.5G  0 part /home
sdb      8:16   1 241.9G  0 disk 
└─sdb1   8:17   1 241.9G  0 part /run/media/tyler/Kalacakra

After wake from suspend, Bus 002 Device 002 is missing from lsusb:

tyler@amitabha:~$ lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 05ac:0291 Apple, Inc. 
Bus 001 Device 006: ID 05ac:828f Apple, Inc. 
Bus 001 Device 002: ID 0a5c:4500 Broadcom Corp. BCM2046B1 USB 2.0 Hub (part of BCM2046 Bluetooth)
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

and lsblk will show:

NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0  113G  0 disk 
├─sda1   8:1    0  512M  0 part 
├─sda2   8:2    0   35G  0 part /
├─sda3   8:3    0    4G  0 part [SWAP]
└─sda4   8:4    0 73.5G  0 part /home

dmesg excerpt:

[ 3286.413304] ACPI: EC: event unblocked
[ 3286.413511] usb usb1: root hub lost power or was reset
[ 3286.413515] usb usb2: root hub lost power or was reset
[ 3286.413730] Found FaceTime HD camera with device id: 1570
[ 3286.435009] sd 0:0:0:0: [sda] Starting disk
[ 3286.518886] pciehp 0000:06:00.0:pcie204: Device 0000:07:00.0 already exists at 0000:07:00, cannot hot-add
[ 3286.518888] pciehp 0000:06:00.0:pcie204: Cannot add device at 0000:07:00
[ 3286.625573] usb 2-3: Disable of device-initiated U1 failed.
[ 3286.625604] usb 2-3: Disable of device-initiated U2 failed.
[ 3286.625607] usb 2-3: usb_reset_and_verify_device Failed to disable LTM
               .
[ 3286.625623] xhci_hcd 0000:00:14.0: Cannot set link state.
[ 3286.625630] usb usb2-port3: cannot disable (err = -32)
[ 3286.625645] xhci_hcd 0000:00:14.0: Cannot set link state.
[ 3286.625649] usb usb2-port3: cannot disable (err = -32)
[ 3286.748661] ata1: SATA link up 6.0 Gbps (SStatus 133 SControl 300)
[ 3286.748920] ata1.00: unexpected _GTF length (8)
[ 3286.749262] ata1.00: unexpected _GTF length (8)
[ 3286.749354] ata1.00: configured for UDMA/133
[ 3286.765615] usb 1-3: reset full-speed USB device number 2 using xhci_hcd
[ 3287.028924] usb 1-5: reset full-speed USB device number 3 using xhci_hcd
[ 3287.242230] usb 1-3.3: reset full-speed USB device number 6 using xhci_hcd
[ 3289.495451] Loaded firmware, size: 1392kb
[ 3289.744797] facetimehd 0000:02:00.0: Direct firmware load for facetimehd/1871_01XX.dat failed with error -2
[ 3289.745051] usb 1-3.3:1.0: rebind failed: -517
[ 3289.745078] usb 1-5:1.2: rebind failed: -517
[ 3289.745368] OOM killer enabled.
[ 3289.745369] Restarting tasks ... done.
[ 3289.809588] video LNXVIDEO:00: Restoring backlight state
[ 3289.809725] PM: suspend exit
[ 3289.816486] IPv6: ADDRCONF(NETDEV_UP): wlp3s0: link is not ready
[ 3289.866018] Bluetooth: hci0: BCM: chip id 73 build 1071
[ 3289.867006] Bluetooth: hci0: BCM: product 05ac:828f
[ 3289.868007] Bluetooth: hci0: BCM: features 0x07
[ 3289.884041] Bluetooth: hci0: BCM20702B0 Generic USB Class 1 @ 20 MHz
[ 3289.888498] IPv6: ADDRCONF(NETDEV_UP): wlp3s0: link is not ready
[ 3289.915877] input: bcm5974 as /devices/pci0000:00/0000:00:14.0/usb1/1-5/1-5:1.2/input/input17
[ 3292.155663] xhci_hcd 0000:00:14.0: Cannot set link state.
[ 3292.155674] usb usb2-port3: cannot disable (err = -32)
[ 3292.155684] usb 2-3: USB disconnect, device number 2
[ 3292.995606] xhci_hcd 0000:00:14.0: Cannot set link state.
[ 3292.995614] usb usb2-port3: cannot disable (err = -32)
[ 3292.995637] xhci_hcd 0000:00:14.0: Cannot set link state.
[ 3292.995644] usb usb2-port3: cannot disable (err = -32)
[ 3293.028961] blk_partition_remap: fail for partition 1
[ 3293.028965] Buffer I/O error on dev sdb1, logical block 31490048, lost sync page write
[ 3293.028970] JBD2: Error -5 detected when updating journal superblock for sdb1-8.
[ 3293.028971] Aborting journal on device sdb1-8.
[ 3293.028973] blk_partition_remap: fail for partition 1
[ 3293.028975] Buffer I/O error on dev sdb1, logical block 31490048, lost sync page write
[ 3293.028976] JBD2: Error -5 detected when updating journal superblock for sdb1-8.
[ 3294.476691] IPv6: ADDRCONF(NETDEV_CHANGE): wlp3s0: link becomes ready

Most noteworthy are the errors at the very end related to dev sdb1.  Yet when I run fsck against that partition, I see no errors.

thanks for your help!

Offline

#2 2017-12-31 21:50:29

seth
Member
Registered: 2012-09-03
Posts: 50,009

Re: USB SD Card device not found after suspend

https://zedt.eu/tech/linux/restarting-u … em-centos/

echo "0000:00:14.0" | sudo tee /sys/bus/pci/drivers/xhci_hcd/unbind; sleep 5; echo "0000:00:14.0" | sudo tee /sys/bus/pci/drivers/xhci_hcd/bind

Though this is what fails on resume. If it's not a timing thing (your HW isn't ready for the reset) you could also try to re-load the "xhci-hcd" module.
Be careful, you could loose your input (and require a reboot) so don't keep an unsave thesis draft open while trying this ;-)

Offline

#3 2018-01-01 13:59:07

mcdorfenberger
Member
Registered: 2017-12-07
Posts: 3

Re: USB SD Card device not found after suspend

Hey -- thanks for getting me started.  By using that string of commands I was able to revive the SD Card.

*edit*:  It worked a few times, but now I am getting various issues such as segmentation fault which left, as you suggested, the system totally useless outside of the power button.

I'm still puzzled as to why this is happening.  The article you refer to describes cheaper hardware just disappearing.  But in my case, it consistently works when I freshly start my system, stays available and working fine until I suspend, and then doesn't return until I reboot.

If there's some way to allow some extra time for the driver to wake up after suspend, or any further diagnosis, I would prefer to do that then to append this command to the end of the waking process.  I was thinking about adding root-suspend and root-resume targets which would unbind and then bind the driver before and after sleep/wake... but now I'm concerned that I don't know exactly how to troubleshoot what is really going on here.

Any pointers?

thanks again

Last edited by mcdorfenberger (2018-01-01 14:40:03)

Offline

#4 2018-01-01 14:35:06

seth
Member
Registered: 2012-09-03
Posts: 50,009

Re: USB SD Card device not found after suspend

Add sth. like /usr/lib/systemd/system-sleep/sdbuttkick.sh

#!/bin/sh
case $1/$2 in
	pre/*)
	;;
	post/*)
	sleep 5; echo "0000:00:14.0" > /sys/bus/pci/drivers/xhci_hcd/unbind
        sleep 5; echo "0000:00:14.0" > /sys/bus/pci/drivers/xhci_hcd/bind
	;;
esac

Ensure to make the script executable!

This will wait 5 seconds after a wakeup and start a rebind (with another 5 seconds delay between un- and binding.
You can play with the timings, the BUS ID is hardcoded, but I understand this is an internal reader, so it should not change anyway.

The theory for the cause is that the device isn't fully initialized when resuming from S3 and doesn't properly respond when probed.
This isn't a problem when booting because there is this rather long delay after the power supply and the actual beginning of even the HW probing (UEFI, bootloader, kernel unpacking)

Offline

#5 2018-01-01 15:05:05

mcdorfenberger
Member
Registered: 2017-12-07
Posts: 3

Re: USB SD Card device not found after suspend

oh thanks for that last explanation.  I might just roll back about exactly two months to vanilla linux kernel and see if I get that functionality back, because this still isn't doing it.

What works is running the script after reboot but before suspend.  The SD card disappears for five seconds.  After suspend, I get nothing, and the following results from dmesg:

[  116.589114] ACPI: Low-level resume complete
[  116.589214] PM: Restoring platform NVS memory
[  116.841489] thunderbolt 0000:07:00.0: resume finished
[  118.022877] xhci_hcd 0000:00:14.0: Cannot set link state.
[  118.022900] xhci_hcd 0000:00:14.0: Cannot set link state.
[  121.251991] input: bcm5974 as /devices/pci0000:00/0000:00:14.0/usb1/1-5/1-5:1.2/input/input21
[  125.292839] xhci_hcd 0000:00:14.0: Cannot set link state.
[  127.049479] xhci_hcd 0000:00:14.0: Cannot set link state.
[  127.082885] Buffer I/O error on dev sdb1, logical block 31490048, lost sync page write
[  127.082898] Buffer I/O error on dev sdb1, logical block 31490048, lost sync page write
[  136.320416] xhci_hcd 0000:00:14.0: remove, state 4
[  136.321082] xhci_hcd 0000:00:14.0: USB bus 2 deregistered
[  136.336429] xhci_hcd 0000:00:14.0: xHCI host controller not responding, assume dead
[  136.336446] xhci_hcd 0000:00:14.0: remove, state 1
[  136.483685] xhci_hcd 0000:00:14.0: Host halt failed, -19
[  136.483692] xhci_hcd 0000:00:14.0: Host not accessible, reset failed.
[  136.483849] xhci_hcd 0000:00:14.0: USB bus 1 deregistered
[  141.487401] xhci_hcd 0000:00:14.0: xHCI Host Controller
[  141.487416] xhci_hcd 0000:00:14.0: new USB bus registered, assigned bus number 1
[  141.488613] xhci_hcd 0000:00:14.0: hcc params 0x200077c1 hci version 0x100 quirks 0x0004b890
[  141.488634] xhci_hcd 0000:00:14.0: cache line size of 256 is not supported
[  141.491121] hub 1-0:1.0: USB hub found
[  141.491617] hub 1-0:1.0: 11 ports detected
[  141.493471] xhci_hcd 0000:00:14.0: xHCI Host Controller
[  141.493494] xhci_hcd 0000:00:14.0: new USB bus registered, assigned bus number 2
[  141.494075] hub 2-0:1.0: USB hub found
[  141.494102] hub 2-0:1.0: 4 ports detected

Offline

#6 2018-01-01 15:28:58

seth
Member
Registered: 2012-09-03
Posts: 50,009

Re: USB SD Card device not found after suspend

Tried

sudo modprobe -r xhci-hcd; sleep 1; sudo modprobe xhci-hcd

Same risk of loosing input.

Offline

Board footer

Powered by FluxBB