Vampire Mice: Vampire Mice: How USB How USB Power Management Power Management Impacts You Impacts You Sarah Sharp [email protected] Jan 25, 2013
Jun 10, 2015
Vampire Mice:Vampire Mice:How USBHow USB
Power ManagementPower ManagementImpacts YouImpacts You
Sarah Sharp
Jan 25, 2013
2Software and Services Group (SSG)
System Software Division (SSD)
Mouse: flickr.com rick-in-rio
Mouse: flickr.com 27048731@N03
3Software and Services Group (SSG)
System Software Division (SSD)
Mouse: flickr.com rick-in-rio
Mouse: flickr.com 27048731@N03
4Software and Services Group (SSG)
System Software Division (SSD)
Agenda
• How USB PM works
• ...and how it doesn't work
• New USB 3.0 and 2.1 features
• New features in Intel systems
5 Software and Services Group (SSG)System Software Division (SSD)
How USBPower ManagementWorks
Lightbulb: flickr.com hozae
6Software and Services Group (SSG)
System Software Division (SSD)
USB Power Management
• Three types of PM:• USB device suspend
• USB host suspend
• Link Power Management
Light bulb: flickr.com molotalk
7Software and Services Group (SSG)
System Software Division (SSD)
USB Device Suspend
• Devices suspended when they're inactive
• Hubs suspend whenall children are suspended
• USB hosts suspend whenall ports are suspended
8Software and Services Group (SSG)
System Software Division (SSD)
USB Device Suspend
• Implications of active USB host• Active DMA transfers
• Increased C state residency
• Increased power consumption
9Software and Services Group (SSG)
System Software Division (SSD)
USB Device Suspend
• USB device suspend requirements• Device must support suspend
• Driver must support auto-suspend
• No active USB transfers
• Userspace can't poll
• Remote wakeup (optional)
10 Software and Services Group (SSG)System Software Division (SSD)
How USBPower ManagementDoesn't Work
Broken light bulb: flickr.com ginsnob
11Software and Services Group (SSG)
System Software Division (SSD)
USB Device Suspend Issues
• Missing driver auto-suspend support
• Impossible to get to idle
• Userspace polls devices
Are we there yet?
Is an SD card inserted yet?
SD card reader: flickr.com osde-info
12Software and Services Group (SSG)
System Software Division (SSD)
USB Device Suspend Issues
• Many USB devices are broken• Disconnect on resume
• Unsafe suspend behavior
• No remote wakeups
• Event loss during resume
• Firmware updates may help• Device descriptors often
unchanged
Mouse: flickr.com declanjewell
13Software and Services Group (SSG)
System Software Division (SSD)
USB Device Suspend Issues
• Different systems producedifferent behavior• Electrical issues?
• Host hardware bugs?
• Powered USB hubs?
• Device driver bugs?
dusty computer: flickr.com johnjack
14Software and Services Group (SSG)
System Software Division (SSD)
USB Device Suspend Issues
• What to do about broken devices?• Huge blacklist in kernel
• Make it userspace's problem!• USB device suspend off by default
• Userspace must turn it on
• # echo auto >/sys/bus/usb/devices/*/power/control
• Powertop can turn it on
Blame: flickr.com iandesign
15Software and Services Group (SSG)
System Software Division (SSD)
Turning on USB PM
16Software and Services Group (SSG)
System Software Division (SSD)
Turning on USB PM
• Powertop auto-suspend enabling doesn't persist across• Device unplug
• Reboot
• Solution: create a udev rule
• github.com/sarahsharp/usb-pm-tools
Boot: flickr.com jamiecat
17Software and Services Group (SSG)
System Software Division (SSD)
USB Device Suspend
Takeaway:
All your USB devicesmust be suspendedto get good platformpower management.
1. Test your devices.
2. Enable auto-suspend
18 Software and Services Group (SSG)System Software Division (SSD)
USBLink Power Management
19Software and Services Group (SSG)
System Software Division (SSD)
Challenges withUSB device suspend
• Users must turn it on
• Requires driver modification
• Timeout is course-grained
• Devices can't refuse suspend
Blame: flickr.com iandesign
20Software and Services Group (SSG)
System Software Division (SSD)
USB 3.0Link Power Management
• USB 3.0 Link PM• Link PM states: U1 and U2
• Idea:• Host & hubs track idleness
• OS sets timeout once
• No driver modification
• Devices can refuse U1/U2
U1
U1U2
21Software and Services Group (SSG)
System Software Division (SSD)
USB 3.0Link Power Management
• Some USB 3.0 devices don't do Link PM
• How to tell?
# lsusb -v -d 1d6b:0003 | grep "Port [0-9]*"
Hub Port Status:
Port 1: 0000.02a0 5Gbps power Rx.Detect
Port 2: 0000.0243 5Gbps power U2 enable connect
Port 3: 0000.02a0 5Gbps power Rx.Detect
Port 4: 0000.02a0 5Gbps power Rx.Detect
22Software and Services Group (SSG)
System Software Division (SSD)
USB 2.1 Link PM
• New 'L1' low power state
• No changes to USB 2.0 hubs
• Only for devices on roothub• Good for integrated devices
L0L0
L1L0
23 Software and Services Group (SSG)System Software Division (SSD)
New IntelUSB PM Features
24Software and Services Group (SSG)
System Software Division (SSD)
Current and FutureIntel Products
• Current gen:• CPU: Ivy Bridge
• Chipset: Panther Point
• Next gen:• CPU: Haswell
• Chipsets: Lynx Point
Panther: flickr.com tim_ellisLynx: flickr.com keithmwilliams
25Software and Services Group (SSG)
System Software Division (SSD)
Intel USB PMImprovements
• Panther Point• Finally has xHCI host controller!
• Only four ports under xHCI
• Supports USB 3.0 Link PM
• Lynx Point• All ports under xHCI
• Supports USB 3.0 andUSB 2.1 Link PM
Panther: flickr.com tim_ellisLynx: flickr.com keithmwilliams
26Software and Services Group (SSG)
System Software Division (SSD)
Intel Lynx PointUSB PM Improvements
• Motivation• Unused internal ports
• Unused internal USB devices
internal laptop: flickr novakreofinger print scanner: flickr mikedent
27Software and Services Group (SSG)
System Software Division (SSD)
Intel Lynx PointUSB PM Improvements
• Idea:• Completely power off port
• Lose USB events:• Disconnect
• Connect
• Remote wakeup events
internal laptop: flickr novakreofinger print scanner: flickr mikedent
28 Software and Services Group (SSG)System Software Division (SSD)
Summary
www.threadless.com/product/2168/USB_Port
29Software and Services Group (SSG)
System Software Division (SSD)
Summary
• USB device suspend is often broken
• Try powertop
• Check out github.com/sarahsharp/usb-pm-tools
• Link PM improvements
• New Intel USB PM features
• Thanks!