Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
USB ports and webcam don't work after suspend-resume.
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
sakshams
n00b
n00b


Joined: 09 Dec 2015
Posts: 2
Location: India

PostPosted: Tue Dec 15, 2015 5:22 pm    Post subject: USB ports and webcam don't work after suspend-resume. Reply with quote

Hello everyone :) I'm new to this forum, having been helpless regarding an issue since really long.
I've been using Gentoo since 3 months, having made the move from Arch which I had used for about 6 months+.
I love tweaking my Linux to the very limit, which is why I went with using a custom kernel. This issue is the last one sticking up since then, and it sure is an extremely annoying one. (of note, it didn't happen on my 4.2.3 generic kernel on Arch).

I'm on 4.2.3 vanilla sources. It so happens that everything works properly after a fresh boot. Webcam, USB devices etc.
Weirdly enough, No USB device works after a resume. No USB mouse, hard disk etc etc. Also, no webcam is detected after a resume too.


Here's a sample lsusb output
Code:

Bus 002 Device 003: ID 046d:c535 Logitech, Inc.
Bus 002 Device 002: ID 8087:8000 Intel Corp.
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 004: ID 0bda:b728 Realtek Semiconductor Corp.
Bus 001 Device 003: ID 174f:14b8 Syntek
Bus 001 Device 002: ID 8087:8008 Intel Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub


Here's the same one after a suspend-resume:
Code:

Bus 002 Device 002: ID 8087:8000 Intel Corp.
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 8087:8008 Intel Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub


Here's the lsmod output before suspend:
Code:

Module                  Size  Used by
bbswitch                4832  0
uvcvideo               74426  0
videobuf2_vmalloc       4838  1 uvcvideo
videobuf2_memops        1959  1 videobuf2_vmalloc
videobuf2_core         33499  1 uvcvideo
rtl8723be             119303  0
btcoexist             170253  1 rtl8723be
rtl_pci                28420  1 rtl8723be
rtlwifi                75624  3 btcoexist,rtl_pci,rtl8723be
x86_pkg_temp_thermal     4791  0
kvm_intel             147142  0
kvm                   414225  1 kvm_intel
vboxnetadp             17798  0
vboxnetflt             16370  0
vboxdrv               326290  2 vboxnetadp,vboxnetflt
efivarfs                5563  1


It's the same after suspend.

Here's what I've tried so far:

1. Try to make usbcore modular in my kernel config. Interestingly, even though Gentoo Wiki shows it to be compiled as 'M', I cannot change it to 'M' in make menuconfig. Also, I asked another experienced gentoo user who has it compiled in-kernel, and doesn't experience this issue.

2. Check for udev rules. So I don't have any custom kernel rules even remotely related. I did see this weird thing though. This file in /lib/udev/rules.d: This file named 42-usb-hid-pm.rules which didn't exist in my Arch installation, nor in that user's gentoo. Equery tells me it was installed by systemd. I deleted this file, that didn't help too. Here are some of the interesting contents of that file:
Code:

ACTION=="add", SUBSYSTEM=="usb", SUBSYSTEMS=="usb", ATTRS{removable}=="removable", GOTO="usb_hid_pm_end"
ACTION=="add", SUBSYSTEM=="usb", SUBSYSTEMS=="usb", ATTRS{removable}=="unknown", GOTO="usb_hid_pm_end"
ACTION=="add", SUBSYSTEM=="usb", ATTR{bInterfaceClass}=="03", ATTRS{removable}=="fixed", TEST=="../power/control", ATTR{../power/control}="auto"


3. Disabled USB autosuspend from powertop. Again, didn't help. I don't know of any other way to do that.

4. Bugging other experienced kernel hackers about this. This always worked. Turns out, its my first post here because nothing has worked till now.

This issue has been really crippling for me, as I'm in the habit of suspending my laptop often. Any help would be greatly appreciated :)
_________________
Hack on.
Back to top
View user's profile Send private message
arom
n00b
n00b


Joined: 27 Aug 2011
Posts: 9
Location: Italy

PostPosted: Thu Dec 17, 2015 10:50 pm    Post subject: Reply with quote

Hi sakshams,
today i was experiencing the exact same problem you described, and i think i've managed to find a solution. I'm running kernel 3.16.5-gentoo, on an Acer Veriton M2632G.

Messing around with sysfs, i've discovered a write-only file called "remove" under each of the EHCI controller devices. Basically, by writing a non-zero value to this file, you just remove the device from the pci bus:

https://www.kernel.org/doc/Documentation/filesystems/sysfs-pci.txt

So, my solution is to remove the EHCI controllers, and then perform a PCI bus rescan to re-add them.
First of all, i've identified the USB controller device ids on the machine:

Code:
# lspci | grep -i usb

00:14.0 USB controller: Intel Corporation 8 Series/C220 Series Chipset Family USB xHCI (rev 05)
00:1a.0 USB controller: Intel Corporation 8 Series/C220 Series Chipset Family USB EHCI #2 (rev 05)
00:1d.0 USB controller: Intel Corporation 8 Series/C220 Series Chipset Family USB EHCI #1 (rev 05)


Then, to remove the devices, i echoed a "1" into the remove file under each device path (in this case 00:14.0, 00:1a.0 and 00:1d.0) :

Code:
echo 1 > /sys/devices/pci0000\:00/0000\:00\:14.0/remove
echo 1 > /sys/devices/pci0000\:00/0000\:00\:1a.0/remove
echo 1 > /sys/devices/pci0000\:00/0000\:00\:1d.0/remove


Finally, to perform the PCI rescan:

Code:
echo 1 > /sys/bus/pci/rescan


Right after the rescan, dmesg shows that the controllers are re-initialized. After that, my usb drives are detected again.

As a final touch, i've automated the above steps in my hibernate script; i simply remove the devices before going to sleep, and then i do the rescan on resume. This is done by adding the following lines in /etc/hibernate/common.conf :

Code:
OnSuspend 00 echo 1 > /sys/devices/pci0000\:00/0000\:00\:14.0/remove
OnSuspend 00 echo 1 > /sys/devices/pci0000\:00/0000\:00\:1a.0/remove
OnSuspend 00 echo 1 > /sys/devices/pci0000\:00/0000\:00\:1d.0/remove
OnResume 00 echo 1 > /sys/bus/pci/rescan


For now it seems to work...

Hope this helps!

Bye :)
_________________
arom
Back to top
View user's profile Send private message
sakshams
n00b
n00b


Joined: 09 Dec 2015
Posts: 2
Location: India

PostPosted: Fri Dec 18, 2015 7:00 am    Post subject: Reply with quote

Hi arom.
Thanks for the reply. Yes this does seem to work for now. Infact, I could even get it to work by removing the devices and rescanning, both of them AFTER waking up. So I just needed to run a script everytime I wake from suspend.

Anyhow, this topic is still not closed I guess. There should be a proper fix. I don't even see the Runtime PM management option in my kernel config to try tweaking it.
_________________
Hack on.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum