Tuesday, June 21, 2011

Power Management and USB keyboards

I discovered recently Power Management is a complex interaction between hardware and software, and there's a very common setup in which this interaction fails. The problem centers around the sleep state, sometimes called standby (because Microsoft incorrectly used this term in place of "sleep"), or technically speaking S3. When I upgraded my home computer from Win2000 to WinXP I noticed a difference in the sleep state. The monitor would still go black and the computer would appear to be asleep, but the fans on the power supply were still running. This was an annoyance but it literally would be years before I discovered what is going on here.

If you have a USB keyboard which is configured to wake the machine from sleep then the USB bus must be powered. Makes sense, the keyboard cannot wake the machine if there's no power to the keyboard. Here's where the hardware/software interaction comes into play. The hardware (motherboard and power supply) must be able to trickle power to the USB bus. Windows checks if the hardware supports this and if so the machine enters full sleep (S3), if not the machine enters a slightly reduced power state (S1).

That's how it's supposed to work, but it doesn't always happen that way. Windows XP and 2003 ignore what the hardware claims to support and always assumes the hardware does not support S3. This means by default XP and 2003 with a USB keyboard will never enter a sleep state. How much wasted power are we talking about? Using a Kill-A-Watt I tested my home system (Core 2 Quad). Windows sitting idle the machine uses 86 watts of power. In sleep (S3) the machine uses 6 watts. And in S1 the machine still uses 86 watts. A lot of people like to leave there machines on 24/7. Let's say the machine is in use 8 hours a day, which means for 16 hours the machine should be sleep but instead it's using 80 watts extra. This equals 467 kWhr per machine per year, or $51 per machine per year (assuming 11 cents per kWhr).

There are several solutions to this problem.

1) You can disable the keyboard wake capability. In Device Manager (run devmgmt.msc) find your keyboard. Right-click and select properties, then select the Power Management tab. Uncheck “Allow this device to bring the computer out of standby.” Now your computer should go completely into standby mode, but you will have to use the power button on the computer to wake it back up.



2) You can set the USBBIOSx registry key detailed in KB841858. This key forces XP and 2003 to always assume your hardware supports trickle power for USB. This will allow your computer to enter full sleep and still use the keyboard to wake the machine.

Windows XP is still the most common OS, and USB keyboards are very common - so we're talking about a lot of machines in this world that are wasting a ton of electricity. Is your machine one of them?

No comments:

Post a Comment