Lines Matching +full:set +full:- +full:of +full:- +full:ports

1 .. _usb-power-management:
7 :Date: Last-updated: February 2014
11 ---------
15 * Forms of dynamic PM
17 * Changing the default idle-delay time
21 * Other parts of the driver interface
31 -------------------------
33 Power Management (PM) is the practice of saving energy by suspending
34 parts of a computer system when they aren't being used. While a
35 component is ``suspended`` it is in a nonfunctional low-power state; it
37 ``resumed`` (returned to a functional full-power state) when the kernel
38 needs to use it. (There also are forms of PM in which components are
39 placed in a less functional but still usable state instead of being
43 When the parts being suspended include the CPU and most of the rest of
44 the system, we speak of it as a "system suspend". When a particular
67 ----------------------
74 However some devices have the capability of resuming by themselves, or
85 --------------------------
100 Forms of dynamic PM
101 -------------------
106 of time, the so-called idle-delay time.
108 Of course, nothing the kernel does on its own initiative should
116 autosuspend. In fact, at the time of this writing (Linux 2.6.23) the
118 usblp, usblcd, and usb-skeleton (which doesn't count). If a
119 non-supporting driver is bound to a device, the device won't be
134 ---------------------------------
137 subdirectory of each USB device's sysfs directory, that is, in
141 file was deprecated as of the 2.6.35 kernel and replaced by the
161 This file contains one of two words: ``on`` or ``auto``.
165 - ``on`` means that the device should be resumed and
166 autosuspend is not allowed. (Of course, system
169 - ``auto`` is the normal state in which the kernel is
180 number of milliseconds the device should remain idle
181 before the kernel will autosuspend it (the idle-delay
186 idle-delay time.
188 Writing ``-1`` to ``power/autosuspend_delay_ms`` and writing ``on`` to
189 ``power/control`` do essentially the same thing -- they both prevent the
201 Changing the default idle-delay time
202 ------------------------------------
204 The default autosuspend idle-delay time (in seconds) is controlled by
206 is loaded. For example, to set it to 5 seconds instead of 2 you would
217 process, by means of a program or script running from an initramfs
233 then each new USB device will have its autosuspend idle-delay
234 initialized to 5. (The idle-delay values for already existing devices
237 Setting the initial default idle-delay to -1 will prevent any
238 autosuspend of any USB device. This has the benefit of allowing you
243 --------
250 among printers and scanners, but plenty of other types of device have
255 than hubs. Hubs, at least, appear to be reasonably well-behaved in
259 by default for almost all USB devices. A number of people experienced
262 This means that non-hub devices won't be autosuspended unless the user
263 or a program explicitly enables it. As of this writing there aren't
268 also change the idle-delay time; 2 seconds is not the best choice for
280 a number of keyboards show that typing on a suspended keyboard, while
283 of them will issue a remote-wakeup request in response to button
293 -----------------------------------------
305 - The ``suspend`` method is called to warn the driver that the
311 - The ``resume`` method is called to tell the driver that the
315 - The ``reset_resume`` method is called to tell the driver that
318 since the device has probably lost most or all of its state
323 the ``disconnect`` method will be called instead of the ``resume`` or
327 possible to work around the hibernation-forces-disconnect problem by
331 :ref:`usb-persist`) and it can also be used under certain
345 to suspend or resume some but not all of a device's interfaces. The
350 ---------------------------------------------------
353 three of the methods listed above. In addition, a driver indicates
356 USB core whenever one of its interfaces becomes busy or idle. The
379 has returned -- say from within a work-queue routine -- provided they
395 their non-async counterparts. The big difference is that they
396 use a workqueue to do the resume or suspend part of their
414 set to ``on``, or another interface in the same device might not be
417 carry out the operation automatically when the autosuspend idle-delay
422 autosuspend, there's no idle-delay for an autoresume.
425 Other parts of the driver interface
426 -----------------------------------
432 in their :c:func:`probe` routine, if they know that the device is capable of
445 ``intf->needs_remote_wakeup`` to 1, the kernel won't autosuspend the
448 autoresume it. Normally a driver would set this flag in its ``probe``
460 busy and therefore the next autosuspend idle-delay expiration should
461 be pushed back. Many of the usb_autopm_* routines also make this call,
462 so drivers need to worry only when interrupt-driven input arrives.
470 cause autosuspends to fail with -EBUSY if the driver needs to use the
481 ----------------
483 For external events -- but not necessarily for autosuspend or
484 autoresume -- the device semaphore (udev->dev.sem) will be held when a
488 this is true of autosuspend/autoresume events as well.
492 :c:func:`usb_autopm_get_interface` (and do the reverse at the end of the
499 --------------------------------------------
502 a couple of ways.
508 the kernel's behavior in this regard has changed. As of 2.6.37 the
512 Secondly, a dynamic power-management event may occur as a system
515 For example, a suspended device may send a remote-wakeup signal while
525 ---------------------
534 ``power/`` subdirectory of each USB device's sysfs directory, that is, in
552 When a USB 3.0 lpm-capable device is plugged in to a
554 and U2 exit latencies have been set in the BOS
563 ----------------------
567 capability to disable power to ports under some conditions. Power is
568 controlled through ``Set/ClearPortFeature(PORT_POWER)`` requests to a hub.
569 In the case of a root or platform-internal hub the host controller
571 method calls to set the port power state. For more background see the
575 logically off, and may trigger the actual loss of VBUS to the port [#f3]_.
576 VBUS may be maintained in the case where a hub gangs multiple ports into
577 a shared power well causing power to remain until all ports in the gang
578 are turned off. VBUS may also be maintained by hub ports configured for
597 http://dl.dropbox.com/u/96820575/sarah-sharp-lpt-port-power-off2-mini.pdf
601 http://linuxplumbers.ubicast.tv/videos/usb-port-power-off-kerneluserspace-api/
613 -------------------------------------
616 requested by clearing the ``power/pm_qos_no_power_off`` flag of the port device
627 be careful to unbind interface drivers, not the driver of the parent usb
630 device. If a hub interface driver is unbound, control of its child ports is
631 lost and all attached child-devices will disconnect. A good rule of thumb is
636 Example of the relevant files for port power control. Note, in this example
639 prefix=/sys/devices/pci0000:00/0000:00:14.0/usb3/3-1
645 $prefix/3-1:1.0/3-1-port1/device
647 $prefix/3-1:1.0/3-1-port1/power/pm_qos_no_power_off
648 $prefix/3-1:1.0/3-1-port1/device/power/control
649 $prefix/3-1:1.0/3-1-port1/device/3-1.1:<intf0>/driver/unbind
650 $prefix/3-1:1.0/3-1-port1/device/3-1.1:<intf1>/driver/unbind
652 $prefix/3-1:1.0/3-1-port1/device/3-1.1:<intfN>/driver/unbind
654 In addition to these files some ports may have a 'peer' link to a port on
655 another hub. The expectation is that all superspeed ports have a
656 hi-speed peer::
658 $prefix/3-1:1.0/3-1-port1/peer -> ../../../../usb2/2-1/2-1:1.0/2-1-port1
659 ../../../../usb2/2-1/2-1:1.0/2-1-port1/peer -> ../../../../usb3/3-1/3-1:1.0/3-1-port1
661 Distinct from 'companion ports', or 'ehci/xhci shared switchover ports'
662 peer ports are simply the hi-speed and superspeed interface pins that
663 are combined into a single usb3 connector. Peer ports share the same
667 connection and attempt to connect to the hi-speed pins. The
670 1. Port suspend is sequenced to guarantee that hi-speed ports are powered-off
671 before their superspeed peer is permitted to power-off. The implication is
673 not cause the port to power-off until its highspeed peer has gone to its
675 if it wants to guarantee that a superspeed port will power-off.
677 2. Port resume is sequenced to force a superspeed port to power-on prior to its
684 child device can suspend (autosuspend-delay) and resume (reset-resume
689 ``<hubdev-portX>/power/pm_qos_no_power_off``:
690 This writable flag controls the state of an idle port.
694 '1' the port will remain active/powered regardless of
695 the stats of descendants. Defaults to 1.
697 ``<hubdev-portX>/power/runtime_status``:
702 ``<hubdev-portX>/connect_type``:
703 An advisory read-only flag to userspace indicating the
704 location and connection type of the port. It returns
705 one of four values 'hotplug', 'hardwired', 'not used',
706 and 'unknown'. All values, besides unknown, are set by
715 connectable. Examples are internal ports for USB
718 expected to be safe to allow these ports to suspend
727 empty internal ports, or ports that are not physically
729 powered-off at all times.
733 external hub ports which should be considered 'hotplug'
738 - since we are relying on the BIOS to get this ACPI
742 - Take care in clearing ``pm_qos_no_power_off``. Once
758 power session loss (suspend / port-power event). When
764 this time the only mechanism to clear the usb-internal
765 wakeup-capability for an interface device is to unbind
768 Summary of poweroff pre-requisite settings relative to a port device::
777 -------------------------------------
780 ports are enabled for poweroff.
782 The default configuration is that all ports start with
783 ``power/pm_qos_no_power_off`` set to ``1`` causing ports to always remain
786 Given confidence in the platform firmware's description of the ports
788 clear pm_qos_no_power_off for all 'not used' ports. The same can be
789 done for 'hardwired' ports provided poweroff is coordinated with any
793 all ports (set ``<hubdev-portX>/power/pm_qos_no_power_off`` to ``0``) when
796 ports when the screen blanks, and re-power them when the screen becomes
797 active. Smart phones and tablets may want to power off USB ports when