27 Sep, 2011

2 commits

  • If the device pass the USB2 software LPM and the host supports hardware
    LPM, enable hardware LPM for the device to let the host decide when to
    put the link into lower power state.

    If hardware LPM is enabled for a port and driver wants to put it into
    suspend, it must first disable hardware LPM, resume the port into U0,
    and then suspend the port.

    Signed-off-by: Andiry Xu
    Signed-off-by: Sarah Sharp
    Signed-off-by: Greg Kroah-Hartman

    Andiry Xu
     
  • This commit gets BOS(Binary Device Object Store) descriptor set for Super
    Speed devices and High Speed devices which support BOS descriptor.

    BOS descriptor is used to report additional USB device-level capabilities
    that are not reported via the Device descriptor. By getting BOS descriptor
    set, driver can check device's device-level capability such as LPM
    capability.

    Signed-off-by: Andiry Xu
    Signed-off-by: Sarah Sharp
    Signed-off-by: Greg Kroah-Hartman

    Andiry Xu
     

30 Apr, 2011

1 commit


19 Mar, 2011

1 commit

  • USB defines usb_device_type pointing to usb_device_pm_ops that
    provides system-wide PM callbacks only and usb_bus_type pointing to
    usb_bus_pm_ops that provides runtime PM callbacks only. However,
    the USB runtime PM callbacks may be defined in usb_device_pm_ops
    which makes it possible to drop usb_bus_pm_ops and will allow us
    to consolidate the handling of subsystems by the PM core code.

    Signed-off-by: Rafael J. Wysocki
    Acked-by: Greg Kroah-Hartman

    Rafael J. Wysocki
     

23 Jan, 2011

1 commit


17 Nov, 2010

1 commit

  • This patch (as1428) converts USB over to the new runtime-PM core
    autosuspend framework. One slightly awkward aspect of the conversion
    is that USB devices will now have two suspend-delay attributes: the
    old power/autosuspend file and the new power/autosuspend_delay_ms
    file. One expresses the delay time in seconds and the other in
    milliseconds, but otherwise they do the same thing. The old attribute
    can be deprecated and then removed eventually.

    Signed-off-by: Alan Stern
    Signed-off-by: Greg Kroah-Hartman

    Alan Stern
     

03 Mar, 2010

2 commits

  • This patch (as1329) converts the USB stack over to the PM core's
    runtime PM framework. This involves numerous changes throughout
    usbcore, especially to hub.c and driver.c. Perhaps the most notable
    change is that CONFIG_USB_SUSPEND now depends on CONFIG_PM_RUNTIME
    instead of CONFIG_PM.

    Several fields in the usb_device and usb_interface structures are no
    longer needed. Some code which used to depend on CONFIG_USB_PM now
    depends on CONFIG_USB_SUSPEND (requiring some rearrangement of header
    files).

    The only visible change in behavior should be that following a system
    sleep (resume from RAM or resume from hibernation), autosuspended USB
    devices will be resumed just like everything else. They won't remain
    suspended. But if they aren't in use then they will naturally
    autosuspend again in a few seconds.

    Signed-off-by: Alan Stern
    Signed-off-by: Greg Kroah-Hartman

    Alan Stern
     
  • This patch (as1324) makes a small change to the code used for remote
    wakeup of root hubs. hcd_resume_work() now calls the hub driver's
    remote-wakeup routine instead of implementing its own version.

    The patch is complicated by the need to rename remote_wakeup() to
    usb_remote_wakeup(), make it non-static, and declare it in a header
    file. There's also the additional complication required to make
    everything work when CONFIG_PM isn't set; the do-nothing inline
    routine had to be moved into the header file.

    Signed-off-by: Alan Stern
    Signed-off-by: Greg Kroah-Hartman

    Alan Stern
     

12 Dec, 2009

1 commit

  • This patch (as1297) adds a "remove" attribute to each USB device's
    directory in sysfs. Writing to this attribute causes the device to be
    deconfigured (the same as writing 0 to the "bConfigurationValue"
    attribute) and then tells the hub driver to disable the device's
    upstream port. The device remains locked during these activities so
    there is no possibility of it getting reconfigured in between. The
    port will remain disabled until after the device is unplugged.

    The purpose of this is to provide a means for user programs to imitate
    the "Safely remove hardware" applet in Windows. Some devices do
    expect their ports to be disabled before they are unplugged, and they
    provide visual feedback to users indicating when they can safely be
    unplugged.

    The security implications are minimal. Writing to the "remove"
    attribute is no more dangerous than writing to the
    "bConfigurationValue" attribute.

    Signed-off-by: Alan Stern
    Cc: David Zeuthen
    Signed-off-by: Greg Kroah-Hartman

    Alan Stern
     

23 Sep, 2009

1 commit

  • This patch (as1258) implements a feature that users have been asking
    for: It gives programs the ability to "claim" a port on a hub, via a
    new usbfs ioctl. A device plugged into a "claimed" port will not be
    touched by the kernel beyond the immediate necessities of
    initialization and enumeration.

    In particular, when a device is plugged into a "claimed" port, the
    kernel will not select and install a configuration. And when a config
    is installed by usbfs or sysfs, the kernel will not probe any drivers
    for any of the interfaces. (However the kernel will fetch various
    string descriptors during enumeration. One could argue that this
    isn't really necessary, but the strings are exported in sysfs.)

    The patch does not guarantee exclusive access to these devices; it is
    still possible for more than one program to open the device file
    concurrently. Programs are responsible for coordinating access among
    themselves.

    A demonstration program showing how to use the new interface can be
    found in an attachment to

    http://marc.info/?l=linux-usb&m=124345857431452&w=2

    The patch also makes a small simplification to the hub driver,
    replacing a bunch of more-or-less useless variants of "out of memory"
    with a single message.

    Signed-off-by: Alan Stern
    Signed-off-by: Greg Kroah-Hartman

    Alan Stern
     

16 Sep, 2009

1 commit


16 Jun, 2009

2 commits


28 Jan, 2009

2 commits

  • This patch (as1198) fixes a conceptual bug: Somewhere along the line
    we managed to confuse USB class devices with USB char devices. As a
    result, the code to send a disconnect signal to userspace would not be
    built if both CONFIG_USB_DEVICE_CLASS and CONFIG_USB_DEVICEFS were
    disabled.

    The usb_fs_classdev_common_remove() routine has been renamed to
    usbdev_remove() and it is now called whenever any USB device is
    removed, not just when a class device is unregistered. The notifier
    registration and unregistration calls are no longer conditionally
    compiled. And since the common removal code will always be called as
    part of the char device interface, there's no need to call it again as
    part of the usbfs interface; thus the invocation of
    usb_fs_classdev_common_remove() has been taken out of
    usbfs_remove_device().

    Signed-off-by: Alan Stern
    Reported-by: Alon Bar-Lev
    Tested-by: Alon Bar-Lev
    Cc: stable

    Alan Stern
     
  • This patch (as1200) finishes some fixes that were left incomplete by
    an earlier patch.

    Although nobody has addressed this issue in the past, it turns out
    that we need to distinguish between two different modes of disabling
    and enabling endpoints. In one mode only the data structures in
    usbcore are affected, and in the other mode the host controller and
    device hardware states are affected as well.

    The earlier patch added an extra argument to the routines in the
    enable_endpoint pathways to reflect this difference. This patch adds
    corresponding arguments to the disable_endpoint pathways. Without
    this change, the endpoint toggle state can get out of sync between
    the host and the device. The exact mechanism depends on the details
    of the host controller (whether or not it stores its own copy of the
    toggle values).

    Signed-off-by: Alan Stern
    Reported-by: Dan Streetman
    Tested-by: Dan Streetman
    Cc: stable
    Signed-off-by: Greg Kroah-Hartman

    Alan Stern
     

08 Jan, 2009

4 commits

  • This patch (as1197) fixes an error introduced recently. Since a
    significant number of devices can't handle Set-Interface requests, we
    no longer call usb_set_interface() when a driver unbinds from an
    interface, provided the interface is already in altsetting 0. However
    the interface still does get disabled, and the call to
    usb_set_interface() was the only thing re-enabling it. Since the
    interface doesn't get re-enabled, further attempts to use it fail.

    So the patch adds a call to usb_enable_interface() when a driver
    unbinds and the interface is in altsetting 0. For this to work
    right, the interface's endpoints have to be re-enabled but their
    toggles have to be left alone. Therefore an additional argument is
    added to usb_enable_endpoint() and usb_enable_interface(), a flag
    indicating whether or not the endpoint toggles should be reset.

    This is a forward-ported version of a patch which fixes Bugzilla
    #12301.

    Signed-off-by: Alan Stern
    Reported-by: David Roka
    Reported-by: Erik Ekman
    Tested-by: Erik Ekman
    Tested-by: Alon Bar-Lev
    Signed-off-by: Greg Kroah-Hartman

    Alan Stern
     
  • This patch (as1185) makes usbcore take advantage of the bus
    notifications sent out by the driver core. Now we can create all our
    device and interface attribute files before the device or interface
    uevent is broadcast.

    A side effect is that we no longer create the endpoint "pseudo"
    devices at the same time as a device or interface is registered -- it
    seems like a bad idea to try registering an endpoint before the
    registration of its parent is complete. So the routines for creating
    and removing endpoint devices have been split out and renamed, and
    they are called explicitly when needed. A new bitflag is used for
    keeping track of whether or not the interface's endpoint devices have
    been created, since (just as with the interface attributes) they vary
    with the altsetting and hence can be changed at random times.

    Signed-off-by: Alan Stern
    Cc: Kay Sievers
    Signed-off-by: Greg Kroah-Hartman

    Alan Stern
     
  • This patch (as1177) modifies the USB core suspend and resume
    routines. The resume functions now will take a pm_message_t argument,
    so they will know what sort of resume is occurring. The new argument
    is also passed to the port suspend/resume and bus suspend/resume
    routines (although they don't use it for anything but debugging).

    In addition, special pm_message_t values are used for user-initiated,
    device-initiated (i.e., remote wakeup), and automatic suspend/resume.
    By testing these values, drivers can tell whether or not a particular
    suspend was an autosuspend. Unfortunately, they can't do the same for
    resumes -- not until the pm_message_t argument is also passed to the
    drivers' resume methods. That will require a bigger change.

    IMO, the whole Power Management framework should have been set up this
    way in the first place.

    Signed-off-by: Alan Stern
    Signed-off-by: Greg Kroah-Hartman

    Alan Stern
     
  • This patch (as1160b) adds support routines for asynchronous autosuspend
    and autoresume, with accompanying documentation updates. There
    already are several potential users of this interface, and others are
    likely to arise as autosuspend support becomes more widespread.

    Signed-off-by: Alan Stern
    Signed-off-by: Greg Kroah-Hartman

    Alan Stern
     

22 Aug, 2008

1 commit

  • This patch (as1129) adds support for the new PM callbacks to usbcore.
    The new callbacks merely invoke the same old USB power management
    routines as the old ones did.

    A minor improvement is that the callbacks are present only in the
    "USB-device" device_type structure, rather than in the bus_type
    structure. This way they will be invoked only for USB devices, not
    for USB interfaces. The core USB PM routines automatically handle
    suspending and resuming interfaces along with their devices.

    Signed-off-by: Alan Stern
    Signed-off-by: Greg Kroah-Hartman

    Alan Stern
     

22 Jul, 2008

2 commits

  • USB device files are accessible in two ways: as files in usbfs and as
    character device nodes. The two paths are supposed to behave
    identically, but they don't. When the underlying USB device is
    unplugged, disconnect signals are sent to processes with open usbfs
    files (if they requested these signals) but not to processes with open
    device node files.

    This patch (as1104) fixes the bug by moving the disconnect-signalling
    code into a common subroutine which is called from both paths.
    Putting this subroutine in devio.c removes the only out-of-file
    reference to struct dev_state, and so the structure's declaration can
    be moved from usb.h into devio.c.

    Finally, the new subroutine performs one extra action: It kills all
    the outstanding async URBs. (I'd kill the outstanding synchronous
    URBs too, if there was any way to do it.) In the past this hasn't
    mattered much, because devices were unregistered from usbfs only
    when they were disconnected. But now the unregistration can also
    occur whenever devices are unbound from the usb_generic driver. At
    any rate, killing URBs when a device is unregistered from usbfs seems
    like a good thing to do.

    Signed-off-by: Alan Stern
    Signed-off-by: Greg Kroah-Hartman

    Alan Stern
     
  • This patch (as1024) takes care of a FIXME issue: Drivers that don't
    have the necessary suspend, resume, reset_resume, pre_reset, or
    post_reset methods will be unbound and their interface reprobed when
    one of the unsupported events occurs.

    This is made slightly more difficult by the fact that bind operations
    won't work during a system sleep transition. So instead the code has
    to defer the operation until the transition ends.

    Signed-off-by: Alan Stern
    Signed-off-by: Greg Kroah-Hartman

    Alan Stern
     

15 May, 2008

1 commit

  • This patch (as1087d) fixes a long-standing problem in usbcore: Device,
    interface, and endpoint attributes aren't added until _after_ the
    creation uevent has already been broadcast.

    Unfortunately there are a few attributes which cannot be created that
    early. The "descriptors" attribute is binary and so must be created
    separately. The power-management attributes can't be created until
    the dev/power/ group exists. And the interface string can vary from
    one altsetting to another, so it has to be created dynamically.

    Signed-off-by: Alan Stern
    Cc: Kay Sievers
    Signed-off-by: Greg Kroah-Hartman

    Alan Stern
     

25 Apr, 2008

1 commit

  • power.power_state is scheduled for removal. This patch (as1053)
    removes all uses of that field from drivers/usb. Almost all of them
    were write-only, the most significant exceptions being sl811-hcd.c and
    u132-hcd.c.

    Part of this patch was written by Pavel Machek.

    Signed-off-by: Alan Stern
    Cc: David Brownell
    Acked-by: Pavel Machek
    Signed-off-by: Greg Kroah-Hartman

    Alan Stern
     

02 Feb, 2008

1 commit


13 Oct, 2007

3 commits

  • As it is global, give it a usb specific name in the global namespace.

    Cc: Inaky Perez-Gonzalez
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     
  • These USB API functions will do the full authorization/deauthorization
    to be used for a device. When authorized we effectively allow a
    configuration to be set. Reverse that when deauthorized.

    Effectively this means that we have to clean all the configuration
    descriptors on deauthorize and reload them when we authorized. We could
    do without throwing them out for wired devices, but for wireless, we can
    read them only after authenticating, and thus, when authorizing an
    authenticated device we would need to read them. So to simplify, always
    release them on deauthorize(), re-read them on authorize().

    Also fix leak reported by Ragner Magalhaes; in usb_deauthorize_device(),
    bNumConfigurations was being set to zero before the for loop, and thus
    the different raw descriptors where never being freed.

    Signed-off-by: Inaky Perez-Gonzalez
    Signed-off-by: Greg Kroah-Hartman

    Inaky Perez-Gonzalez
     
  • This patch (as944) adds an explicit "enabled" field to the
    usb_host_endpoint structure and uses it in place of the current
    mechanism. This is merely a time-space tradeoff; it makes checking
    whether URBs may be submitted to an endpoint simpler. The existing
    mechanism is efficient when converting urb->pipe to an endpoint
    pointer, but it's not so efficient when urb->ep is used instead.

    As a side effect, the procedure for enabling an endpoint is now a
    little more complicated. The ad-hoc inline code in usb.c and hub.c
    for enabling ep0 is now replaced with calls to usb_enable_endpoint,
    which is no longer static.

    Signed-off-by: Alan Stern
    Signed-off-by: Greg Kroah-Hartman

    Alan Stern
     

13 Jul, 2007

4 commits

  • This patch (as919) unifies the code paths used for normal resume and
    for reset-resume. Earlier I had failed to note a section in the USB
    spec which requires the host to resume a suspended port before
    resetting it if the attached device is enabled for remote wakeup.
    Since the port has to be resumed anyway, we might as well reuse the
    existing code.

    The main changes are:

    usb_reset_suspended_device() is eliminated.

    usb_root_hub_lost_power() is moved down next to the
    hub_reset_resume() routine, to which it is logically
    related.

    finish_port_resume() does a port reset() if the device's
    reset_resume flag is set.

    usb_port_resume() doesn't check whether the port is initially
    enabled if this is a USB-Persist sort of resume.

    Code to perform the port reset is added to the resume pathway
    for the non-CONFIG_USB_SUSPEND case.

    Signed-off-by: Alan Stern
    Signed-off-by: Greg Kroah-Hartman

    Alan Stern
     
  • This patch (as915b) combines the public routine usb_port_suspend() and
    the private routine __usb_port_suspend() into a single function.

    By removing the explicit mention of otg_port in the call to
    __usb_port_suspend(), we prevent a possible error in which the system
    tries to perform HNP on the wrong port when a non-targeted device is
    plugged into a non-OTG port.

    Signed-off-by: Alan Stern
    Signed-off-by: Greg Kroah-Hartman

    Alan Stern
     
  • This patch (as886) adds the controversial USB-persist facility,
    allowing USB devices to persist across a power loss during system
    suspend.

    The facility is controlled by a new Kconfig option (with appropriate
    warnings about the potential dangers); when the option is off the
    behavior will remain the same as it is now. But when the option is
    on, people will be able to use suspend-to-disk and keep their USB
    filesystems intact -- something particularly valuable for small
    machines where the root filesystem is on a USB device!

    Signed-off-by: Alan Stern
    Signed-off-by: Greg Kroah-Hartman

    Alan Stern
     
  • This patch (as880) strives to keep the PM core's idea of a USB
    interface's power state in synch with usbcore's own idea. In the end
    this doesn't really matter, but it's better to be consistent.

    Signed-off-by: Alan Stern
    Signed-off-by: Greg Kroah-Hartman

    Alan Stern
     

28 Apr, 2007

3 commits

  • o The "real" usb-devices export now a device node which can
    populate /dev/bus/usb.

    o The usb_device class is optional now and can be disabled in the
    kernel config. Major/minor of the "real" devices and class devices
    are the same.

    o The environment of the usb-device event contains DEVNUM and BUSNUM to
    help udev and get rid of the ugly udev rule we need for the class
    devices.

    o The usb-devices and usb-interfaces share the same bus, so I used
    the new "struct device_type" to let these devices identify
    themselves. This also removes the current logic of using a magic
    platform-pointer.
    The name of the device_type is also added to the environment
    which makes it easier to distinguish the different kinds of devices
    on the same subsystem.

    It looks like this:
    add@/devices/pci0000:00/0000:00:1d.1/usb2/2-1
    ACTION=add
    DEVPATH=/devices/pci0000:00/0000:00:1d.1/usb2/2-1
    SUBSYSTEM=usb
    SEQNUM=1533
    MAJOR=189
    MINOR=131
    DEVTYPE=usb_device
    PRODUCT=46d/c03e/2000
    TYPE=0/0/0
    BUSNUM=002
    DEVNUM=004

    This udev rule works as a replacement for usb_device class devices:
    SUBSYSTEM=="usb", ACTION=="add", ENV{DEVTYPE}=="usb_device", \
    NAME="bus/usb/$env{BUSNUM}/$env{DEVNUM}", MODE="0644"

    Updated patch, which needs the device_type patches in Greg's tree.

    I also got a bugzilla assigned for this. :)
    https://bugzilla.novell.com/show_bug.cgi?id=250659

    Signed-off-by: Kay Sievers
    Signed-off-by: Greg Kroah-Hartman

    Kay Sievers
     
  • This patch (as866) adds new entry points for external USB device
    suspend and resume requests, as opposed to internally-generated
    autosuspend or autoresume. It also changes the existing
    remote-wakeup code paths to use the new routines, since remote wakeup
    is not the same as autoresume.

    As part of the change, it turns out to be necessary to do remote
    wakeup of root hubs from a workqueue. We had been using khubd, but it
    does autoresume rather than an external resume. Using the
    ksuspend_usb_wq workqueue for this purpose seemed a logical choice.

    Signed-off-by: Alan Stern
    Signed-off-by: Greg Kroah-Hartman

    Alan Stern
     
  • This patch (as864) moves the work routine for USB autosuspend from one
    source file to another. This permits the removal of one whole global
    symbol (!) and should smooth the way for more changes in the future.

    Signed-off-by: Alan Stern
    Signed-off-by: Greg Kroah-Hartman

    Alan Stern
     

24 Feb, 2007

4 commits


02 Dec, 2006

1 commit

  • Thanks to several earlier patches, usb_autosuspend_device() and
    usb_autoresume_device() are never called with a second argument other
    than 1. This patch (as819) removes the now-redundant argument.

    It also consolidates some common code between those two routines,
    putting it into a new subroutine called usb_autopm_do_device(). And
    it includes a sizable kerneldoc update for the affected functions.

    Signed-off-by: Alan Stern
    Signed-off-by: Greg Kroah-Hartman

    Alan Stern