1. 04 2月, 2011 1 次提交
  2. 15 1月, 2011 1 次提交
    • S
      usb: Realloc xHCI structures after a hub is verified. · 653a39d1
      Sarah Sharp 提交于
      When there's an xHCI host power loss after a suspend from memory, the USB
      core attempts to reset and verify the USB devices that are attached to the
      system.  The xHCI driver has to reallocate those devices, since the
      hardware lost all knowledge of them during the power loss.
      
      When a hub is plugged in, and the host loses power, the xHCI hardware
      structures are not updated to say the device is a hub.  This is usually
      done in hub_configure() when the USB hub is detected.  That function is
      skipped during a reset and verify by the USB core, since the core restores
      the old configuration and alternate settings, and the hub driver has no
      idea this happened.  This bug makes the xHCI host controller reject the
      enumeration of low speed devices under the resumed hub.
      
      Therefore, make the USB core re-setup the internal xHCI hub device
      information by calling update_hub_device() when hub_activate() is called
      for a hub reset resume.  After a host power loss, all devices under the
      roothub get a reset-resume or a disconnect.
      
      This patch should be queued for the 2.6.37 stable tree.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Cc: stable@kernel.org
      653a39d1
  3. 17 11月, 2010 3 次提交
    • A
      USB: improve uses of usb_mark_last_busy · c08512c7
      Alan Stern 提交于
      This patch (as1434) cleans up the uses of usb_mark_last_busy() in
      usbcore.  The function will be called when a device is resumed and
      whenever a usage count is decremented.  A call that was missing from
      the hub driver is added: A hub is used whenever one of its ports gets
      suspended (this prevents hubs from suspending immediately after their
      last child).
      
      In addition, the call to disable autosuspend support for new devices
      by default is moved from usb_detect_quirks() (where it doesn't really
      belong) into usb_new_device() along with all the other runtime-PM
      initializations.  Finally, an extra pm_runtime_get_noresume() is added
      to prevent new devices from autosuspending while they are being
      registered.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      c08512c7
    • A
      USB: use the runtime-PM autosuspend implementation · fcc4a01e
      Alan Stern 提交于
      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: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      fcc4a01e
    • M
      USB: make usb_mark_last_busy use pm_runtime_mark_last_busy · 6ddf27cd
      Ming Lei 提交于
      Since the runtime-PM core already defines a .last_busy field in
      device.power, this patch uses it to replace the .last_busy field
      defined in usb_device and uses pm_runtime_mark_last_busy to implement
      usb_mark_last_busy.
      Signed-off-by: NMing Lei <tom.leiming@gmail.com>
      Reviewed-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      6ddf27cd
  4. 23 10月, 2010 4 次提交
    • A
      USB: accept some invalid ep0-maxpacket values · 56626a72
      Alan Stern 提交于
      A few devices (such as the RCA VR5220 voice recorder) are so
      non-compliant with the USB spec that they have invalid maxpacket sizes
      for endpoint 0.  Nevertheless, as long as we can safely use them, we
      may as well do so.
      
      This patch (as1432) softens our acceptance criterion by allowing
      high-speed devices to have ep0-maxpacket sizes other than 64.  A
      warning is printed in the system log when this happens, and the
      existing error message is clarified.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Reported-by: NJames <bjlockie@lockie.ca>
      Cc: stable <stable@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      56626a72
    • S
      usb: Fix issue with USB 3.0 devices after system resume · 85f0ff46
      Sarah Sharp 提交于
      When the system suspends and a host controller's power is lost, the USB
      core attempts to revive any USB devices that had the persist_enabled flag
      set.  For non-SuperSpeed devices, it will disable the port, and then set
      the udev->reset_resume flag.  This will cause the USB core to reset the
      device, verify the device descriptors to make sure it's the same device,
      and re-install any non-default configurations or alternate interface
      settings.
      
      However, we can't disable SuperSpeed root hub ports because that turns off
      SuperSpeed terminations, which will inhibit any devices connecting at USB
      3.0 speeds.  (Plus external hubs don't allow SuperSpeed ports to be
      disabled.)
      
      Because of this logic in hub_activate():
                      /* We can forget about a "removed" device when there's a
                       * physical disconnect or the connect status changes.
                       */
                      if (!(portstatus & USB_PORT_STAT_CONNECTION) ||
                                      (portchange & USB_PORT_STAT_C_CONNECTION))
                              clear_bit(port1, hub->removed_bits);
      
                      if (!udev || udev->state == USB_STATE_NOTATTACHED) {
                              /* Tell khubd to disconnect the device or
                               * check for a new connection
                               */
                              if (udev || (portstatus & USB_PORT_STAT_CONNECTION))
                                      set_bit(port1, hub->change_bits);
      
                      } else if (portstatus & USB_PORT_STAT_ENABLE) {
                              /* The power session apparently survived the resume.
                               * If there was an overcurrent or suspend change
                               * (i.e., remote wakeup request), have khubd
                               * take care of it.
                               */
                              if (portchange)
                                      set_bit(port1, hub->change_bits);
      
                      } else if (udev->persist_enabled) {
                              udev->reset_resume = 1;
                              set_bit(port1, hub->change_bits);
      
                      } else {
                              /* The power session is gone; tell khubd */
                              usb_set_device_state(udev, USB_STATE_NOTATTACHED);
                              set_bit(port1, hub->change_bits);
                      }
      
      a SuperSpeed device after a resume with a loss of power will never get the
      reset_resume flag set.  Instead the core will assume the power session
      survived and that the device still has the same address, configuration,
      and alternate interface settings.  The xHCI host controller will have no
      knowledge of the device (since all xhci_virt_devices were destroyed when
      power loss was discovered, and xhci_discover_or_reset_device() has not
      been called), and all URBs to the device will fail.
      
      If the device driver responds by resetting the device, everything will
      continue smoothly.  However, if lsusb is used before the device driver
      resets the device (or there is no driver), then all lsusb descriptor
      fetches will fail.
      
      The quick fix is to pretend the port is disabled in hub_activate(), by
      clearing the local variable.  But I'm not sure what other parts of the hub
      driver need to be changed because they have assumptions about when ports
      will be disabled.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: NAndiry Xu <andiry.xu@amd.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      85f0ff46
    • A
      USB: core: use kernel assigned address for devices under xHCI · c8d4af8e
      Andiry Xu 提交于
      xHCI driver uses hardware assigned device address. This may cause device
      address conflict in certain cases.
      
      Use kernel assigned address for devices under xHCI. Store the xHC assigned
      address locally in xHCI driver.
      Signed-off-by: NAndiry Xu <andiry.xu@amd.com>
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      c8d4af8e
    • W
      USB: core: update comment to match current function name · 4bec9917
      Wolfram Sang 提交于
      Found while debugging a USB problem and trying to find the mentioned function.
      Signed-off-by: NWolfram Sang <w.sang@pengutronix.de>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      4bec9917
  5. 11 8月, 2010 3 次提交
  6. 27 7月, 2010 1 次提交
    • S
      USB: Fix USB3.0 Port Speed Downgrade after port reset · 809cd1cb
      Sarah Sharp 提交于
      Without this fix, a USB 3.0 port is downgraded to full speed after a port
      reset of a configured device.  The USB 3.0 terminations will be disabled
      permanently, and USB 3.0 devices will always enumerate as full speed
      devices, until the host controller is unplugged (if it is an ExpressCard)
      or the computer is rebooted.
      
      Fajun Chen traced this traced the speed downgrade issue to the port reset
      and the interpretation of port status in USB hub driver code.  The hub
      code was not testing for the port being a SuperSpeed port, and it fell
      through to the else case of Full Speed.
      
      The following patch adds SuperSpeed mapping from the port status, and
      fixes the speed downgrade issue.
      Reported-by: NFajun Chen <fajun.chen@seagate.com>
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Cc: stable <stable@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      809cd1cb
  7. 21 5月, 2010 5 次提交
    • A
      USB: usbcore: Do not disable USB3 protocol ports in hub_activate() · 9f0a6cd3
      Andiry Xu 提交于
      When USB3 protocol port detects an USB3.0 device attach, the port will
      automatically transition to the Enabled state upon the completion
      of successful link training.
      
      Do not disable USB3 protocol ports in hub_activate(), or USB3.0 device
      will fail to be recognized if xHCI bus power management is implemented.
      Signed-off-by: NAndiry Xu <andiry.xu@amd.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      9f0a6cd3
    • A
      USB: don't enable remote wakeup by default · 7aba8d01
      Alan Stern 提交于
      This patch (as1364) avoids enabling remote wakeup by default on all
      non-root-hub USB devices.  Individual drivers or userspace will have
      to enable it wherever it is needed, such as for keyboards or network
      interfaces.  Note: This affects only system sleep, not autosuspend.
      
      External hubs will continue to relay wakeup requests received from
      downstream through their upstream port, even when remote wakeup is not
      enabled for the hub itself.  Disabling remote wakeup on a hub merely
      prevents it from generating wakeup requests in response to connect,
      disconnect, and overcurrent events.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      7aba8d01
    • A
      USB: straighten out port feature vs. port status usage · 749da5f8
      Alan Stern 提交于
      This patch (as1349b) clears up the confusion in many USB host
      controller drivers between port features and port statuses.  In mosty
      cases it's true that the status bit is in the position given by the
      corresponding feature value, but that's not always true and it's not
      guaranteed in the USB spec.
      
      There's no functional change, just replacing expressions of the form
      (1 << USB_PORT_FEAT_x) with USB_PORT_STAT_x, which has the same value.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      749da5f8
    • A
      USB: remove bogus USB_PORT_FEAT_*_SPEED symbols · 288ead45
      Alan Stern 提交于
      This patch (as1348) removes the bogus
      USB_PORT_FEAT_{HIGHSPEED,SUPERSPEED} symbols from ch11.h.  No such
      features are defined by the USB spec.  (There is a PORT_LOWSPEED
      feature, but the spec doesn't mention it except to say that host
      software should never use it.)  The speed indicators are port
      statuses, not port features.
      
      As a temporary workaround for the xhci-hcd driver, a fictional
      USB_PORT_STAT_SUPER_SPEED symbol is added.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      CC: Sarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      288ead45
    • E
      USB: make hcd.h public (drivers dependency) · 27729aad
      Eric Lescouet 提交于
      The usbcore headers: hcd.h and hub.h are shared between usbcore,
      HCDs and a couple of other drivers (e.g. USBIP modules).
      So, it makes sense to move them into a more public location and
      to cleanup dependency of those modules on kernel internal headers.
      This patch moves hcd.h from drivers/usb/core into include/linux/usb/
      Signed-of-by: NEric Lescouet <eric@lescouet.org>
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      27729aad
  8. 03 3月, 2010 8 次提交
    • N
      USB hub: make USB device id constant · 1e927d96
      Németh Márton 提交于
      The id_table field of the struct usb_device_id is constant in <linux/usb.h>
      so it is worth to make the initialization data also constant.
      
      The semantic match that finds this kind of pattern is as follows:
      (http://coccinelle.lip6.fr/)
      
      // <smpl>
      @r@
      disable decl_init,const_decl_init;
      identifier I1, I2, x;
      @@
      	struct I1 {
      	  ...
      	  const struct I2 *x;
      	  ...
      	};
      @s@
      identifier r.I1, y;
      identifier r.x, E;
      @@
      	struct I1 y = {
      	  .x = E,
      	};
      @c@
      identifier r.I2;
      identifier s.E;
      @@
      	const struct I2 E[] = ... ;
      @depends on !c@
      identifier r.I2;
      identifier s.E;
      @@
      +	const
      	struct I2 E[] = ...;
      // </smpl>
      Signed-off-by: NNémeth Márton <nm127@freemail.hu>
      Cc: Julia Lawall <julia@diku.dk>
      Cc: cocci@diku.dk
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      1e927d96
    • H
      USB: Move hcd free_dev call into usb_disconnect to fix oops · f7410ced
      Herbert Xu 提交于
      USB: Move hcd free_dev call into usb_disconnect
      
      I found a way to oops the kernel:
      
      1. Open a USB device through devio.
      2. Remove the hcd module in the host kernel.
      3. Close the devio file descriptor.
      
      The problem is that closing the file descriptor does usb_release_dev
      as it is the last reference.  usb_release_dev then tries to invoke
      the hcd free_dev function (or rather dereferencing the hcd driver
      struct).  This causes an oops as the hcd driver has already been
      unloaded so the struct is gone.
      
      This patch tries to fix this by bringing the free_dev call earlier
      and into usb_disconnect.  I have verified that repeating the
      above steps no longer crashes with this patch applied.
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      Cc: stable <stable@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      f7410ced
    • A
      USB: convert to the runtime PM framework · 9bbdf1e0
      Alan Stern 提交于
      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: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      9bbdf1e0
    • A
      USB: implement usb_enable_autosuspend · 088f7fec
      Alan Stern 提交于
      This patch (as1326) adds usb_enable_autosuspend() and
      usb_disable_autosuspend() routines for use by drivers.  If a driver
      knows that its device can handle suspends and resumes correctly, it
      can enable autosuspend all by itself.  This is equivalent to the user
      writing "auto" to the device's power/level attribute.
      
      The implementation differs slightly from what it used to be.  Now
      autosuspend is disabled simply by doing usb_autoresume_device() (to
      increment the usage counter) and enabled by doing
      usb_autosuspend_device() (to decrement the usage counter).
      
      The set_level() attribute method is updated to use the new routines,
      and the USB Power-Management documentation is updated.
      
      The patch adds a usb_enable_autosuspend() call to the hub driver's
      probe routine, allowing the special-case code for hubs in quirks.c to
      be removed.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      088f7fec
    • A
      USB: consolidate remote wakeup routines · 0534d468
      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: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      0534d468
    • G
      USB: rename USB_SPEED_VARIABLE to USB_SPEED_WIRELESS · 551cdbbe
      Greg Kroah-Hartman 提交于
      It's really the wireless speed, so rename the thing to make
      more sense.  Based on a recommendation from David Vrabel
      
      Cc: David Vrabel <david.vrabel@csr.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      551cdbbe
    • D
      USB: retain USB device power/wakeup setting across reconfiguration · 16985408
      Dan Streetman 提交于
      Currently a non-root-hub USB device's wakeup settings are initialized when the
      device is set to a configured state using device_init_wakeup(), but this is not
      correct as wakeup is split into "capable" (can_wakeup) and "enabled"
      (should_wakeup).  The settings should be initialized instead in the device
      initialization (usb_new_device) with the "capable" setting disabled and the
      "enabled" setting enabled.  The "capable" setting should be set based on the
      device being configured or unconfigured, and "enabled" setting set based on
      the sysfs power/wakeup control.
      
      This patch retains the sysfs power/wakeup setting of a non-root-hub USB device
      over a USB device re-configuration, which can happen (for example) after a
      suspend/resume cycle.
      Signed-off-by: NDan Streetman <ddstreet@ieee.org>
      Cc: David Brownell <dbrownell@users.sourceforge.net>
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      
      16985408
    • S
      USB: Add call to notify xHC of a device reset. · a5f0efab
      Sarah Sharp 提交于
      Add a new host controller driver method, reset_device(), that the USB core
      will use to notify the host of a successful device reset.  The call may
      fail due to out-of-memory errors; attempt the port reset sequence again if
      that happens.  Update hub_port_init() to allow resetting a configured
      device.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      a5f0efab
  9. 27 2月, 2010 1 次提交
    • R
      PM: Allow USB devices to suspend/resume asynchronously · 927bc916
      Rafael J. Wysocki 提交于
      Set power.async_suspend for USB devices, endpoints and interfaces,
      allowing them to be suspended and resumed asynchronously during
      system sleep transitions.
      
      The power.async_suspend flag is also set for devices that don't have
      suspend or resume callbacks, because otherwise they would make the
      main suspend/resume thread wait for their "asynchronous" children
      (during suspend) or parents (during resume), effectively negating the
      possible gains from executing these devices' suspend and resume
      callbacks asynchronously.
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      927bc916
  10. 21 1月, 2010 2 次提交
    • S
      USB: Fix duplicate sysfs problem after device reset. · 04a723ea
      Sarah Sharp 提交于
      Borislav Petkov reports issues with duplicate sysfs endpoint files after a
      resume from a hibernate.  It turns out that the code to support alternate
      settings under xHCI has issues when a device with a non-default alternate
      setting is reset during the hibernate:
      
      [  427.681810] Restarting tasks ...
      [  427.681995] hub 1-0:1.0: state 7 ports 6 chg 0004 evt 0000
      [  427.682019] usb usb3: usb resume
      [  427.682030] ohci_hcd 0000:00:12.0: wakeup root hub
      [  427.682191] hub 1-0:1.0: port 2, status 0501, change 0000, 480 Mb/s
      [  427.682205] usb 1-2: usb wakeup-resume
      [  427.682226] usb 1-2: finish reset-resume
      [  427.682886] done.
      [  427.734658] ehci_hcd 0000:00:12.2: port 2 high speed
      [  427.734663] ehci_hcd 0000:00:12.2: GetStatus port 2 status 001005 POWER sig=se0 PE CONNECT
      [  427.746682] hub 3-0:1.0: hub_reset_resume
      [  427.746693] hub 3-0:1.0: trying to enable port power on non-switchable hub
      [  427.786715] usb 1-2: reset high speed USB device using ehci_hcd and address 2
      [  427.839653] ehci_hcd 0000:00:12.2: port 2 high speed
      [  427.839666] ehci_hcd 0000:00:12.2: GetStatus port 2 status 001005 POWER sig=se0 PE CONNECT
      [  427.847717] ohci_hcd 0000:00:12.0: GetStatus roothub.portstatus [1] = 0x00010100 CSC PPS
      [  427.915497] hub 1-2:1.0: remove_intf_ep_devs: if: ffff88022f9e8800 ->ep_devs_created: 1
      [  427.915774] hub 1-2:1.0: remove_intf_ep_devs: bNumEndpoints: 1
      [  427.915934] hub 1-2:1.0: if: ffff88022f9e8800: endpoint devs removed.
      [  427.916158] hub 1-2:1.0: create_intf_ep_devs: if: ffff88022f9e8800 ->ep_devs_created: 0, ->unregistering: 0
      [  427.916434] hub 1-2:1.0: create_intf_ep_devs: bNumEndpoints: 1
      [  427.916609]  ep_81: create, parent hub
      [  427.916632] ------------[ cut here ]------------
      [  427.916644] WARNING: at fs/sysfs/dir.c:477 sysfs_add_one+0x82/0x96()
      [  427.916649] Hardware name: System Product Name
      [  427.916653] sysfs: cannot create duplicate filename '/devices/pci0000:00/0000:00:12.2/usb1/1-2/1-2:1.0/ep_81'
      [  427.916658] Modules linked in: binfmt_misc kvm_amd kvm powernow_k8 cpufreq_ondemand cpufreq_powersave cpufreq_userspace freq_table cpufreq_conservative ipv6 vfat fat
      +8250_pnp 8250 pcspkr ohci_hcd serial_core k10temp edac_core
      [  427.916694] Pid: 278, comm: khubd Not tainted 2.6.33-rc2-00187-g08d869aa-dirty #13
      [  427.916699] Call Trace:
      
      The problem is caused by a mismatch between the USB core's view of the
      device state and the USB device and xHCI host's view of the device state.
      
      After the device reset and re-configuration, the device and the xHCI host
      think they are using alternate setting 0 of all interfaces.  However, the
      USB core keeps track of the old state, which may include non-zero
      alternate settings.  It uses intf->cur_altsetting to keep the endpoint
      sysfs files for the old state across the reset.
      
      The bandwidth allocation functions need to know what the xHCI host thinks
      the current alternate settings are, so original patch set
      intf->cur_altsetting to the alternate setting 0.  This caused duplicate
      endpoint files to be created.
      
      The solution is to not set intf->cur_altsetting before calling
      usb_set_interface() in usb_reset_and_verify_device().  Instead, we add a
      new flag to struct usb_interface to tell usb_hcd_alloc_bandwidth() to use
      alternate setting 0 as the currently installed alternate setting.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Tested-by: NBorislav Petkov <petkovbb@googlemail.com>
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      04a723ea
    • A
      USB: add missing delay during remote wakeup · 49d0f078
      Alan Stern 提交于
      This patch (as1330) fixes a bug in khbud's handling of remote
      wakeups.  When a device sends a remote-wakeup request, the parent hub
      (or the host controller driver, for directly attached devices) begins
      the resume sequence and notifies khubd when the sequence finishes.  At
      this point the port's SUSPEND feature is automatically turned off.
      
      However the device needs an additional 10-ms resume-recovery time
      (TRSMRCY in the USB spec).  Khubd does not wait for this delay if the
      SUSPEND feature is off, and as a result some devices fail to behave
      properly following a remote wakeup.  This patch adds the missing
      delay to the remote-wakeup path.
      
      It also extends the resume-signalling delay used by ehci-hcd and
      uhci-hcd from 20 ms (the value in the spec) to 25 ms (the value we use
      for non-remote-wakeup resumes).  The extra time appears to help some
      devices.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Cc: stable <stable@kernel.org>
      Cc: Rickard Bellini <rickard.bellini@ericsson.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      
      49d0f078
  11. 24 12月, 2009 2 次提交
    • A
      USB: fix bugs in usb_(de)authorize_device · da307123
      Alan Stern 提交于
      This patch (as1315) fixes some bugs in the USB core authorization
      code:
      
      	usb_deauthorize_device() should deallocate the device strings
      	instead of leaking them, and it should invoke
      	usb_destroy_configuration() (which does proper reference
      	counting) instead of freeing the config information directly.
      
      	usb_authorize_device() shouldn't change the device strings
      	until it knows that the authorization will succeed, and it should
      	autosuspend the device at the end (having autoresumed the
      	device at the start).
      
      	Because the device strings can be changed, the sysfs routines
      	to display the strings must protect the string pointers by
      	locking the device.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      CC: Inaky Perez-Gonzalez <inaky@linux.intel.com>
      Acked-by: NDavid Vrabel <david.vrabel@csr.com>
      Cc: stable <stable@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      
      da307123
    • A
      USB: rename usb_configure_device · 8d8558d1
      Alan Stern 提交于
      This patch (as1314) renames usb_configure_device() and
      usb_configure_device_otg() in the hub driver.  Neither name is
      appropriate because these routines enumerate devices, they don't
      configure them.  That's handled by usb_choose_configuration() and
      usb_set_configuration().
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Cc: stable <stable@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      8d8558d1
  12. 12 12月, 2009 6 次提交
    • F
      USB: core: hub: fix sparse warning · 2eb5052e
      Felipe Balbi 提交于
      Fix the following sparse warning:
      
      drivers/usb/core/hub.c:1664:37: warning: Using plain integer as NULL pointer
      Signed-off-by: NFelipe Balbi <felipe.balbi@nokia.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      2eb5052e
    • S
      USB: Check bandwidth when switching alt settings. · 3f0479e0
      Sarah Sharp 提交于
      Make the USB core check the bandwidth when switching from one
      interface alternate setting to another.  Also check the bandwidth
      when resetting a configuration (so that alt setting 0 is used).  If
      this check fails, the device's state is unchanged.  If the device
      refuses the new alt setting, re-instate the old alt setting in the
      host controller hardware.
      
      If a USB device doesn't have an alternate interface setting 0, install
      the first alt setting in its descriptors when a new configuration is
      requested, or the device is reset.
      
      Add a mutex per root hub to protect bandwidth operations:
      adding/reseting/changing configurations, and changing alternate interface
      settings.  We want to ensure that the xHCI host controller and the USB
      device are set up for the same configurations and alternate settings.
      There are two (possibly three) steps to do this:
      
       1. The host controller needs to check that bandwidth is available for a
          different setting, by issuing and waiting for a configure endpoint
          command.
       2. Once that returns successfully, a control message is sent to the
          device.
       3. If that fails, the host controller must be notified through another
          configure endpoint command.
      
      The mutex is used to make these three operations seem atomic, to prevent
      another driver from using more bandwidth for a different device while
      we're in the middle of these operations.
      
      While we're touching the bandwidth code, rename usb_hcd_check_bandwidth()
      to usb_hcd_alloc_bandwidth().  This function does more than just check
      that the bandwidth change won't exceed the bus bandwidth; it actually
      changes the bandwidth configuration in the xHCI host controller.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      3f0479e0
    • A
      USB: prepare for changover to Runtime PM framework · 8e4ceb38
      Alan Stern 提交于
      This patch (as1303) revises the USB Power Management infrastructure to
      make it compatible with the new driver-model Runtime PM framework:
      
      	Drivers are no longer allowed to access intf->pm_usage_cnt
      	directly; the PM framework manages its own usage counters.
      
      	usb_autopm_set_interface() is eliminated, because it directly
      	sets intf->pm_usage_cnt.
      
      	usb_autopm_enable() and usb_autopm_disable() are eliminated,
      	because they call usb_autopm_set_interface().
      
      	usb_autopm_get_interface_no_resume() and
      	usb_autopm_put_interface_no_suspend() are added.  They
      	correspond to pm_runtime_get_noresume() and
      	pm_runtime_put_noidle() in the PM framework.
      
      	The power/level attribute no longer accepts "suspend", only
      	"on" and "auto".  The PM framework doesn't allow devices to be
      	forced into a suspended mode.
      
      The hub driver contains the only code that violates the new
      guidelines.  It is updated to use the new interface routines instead.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      8e4ceb38
    • A
      USB: add a "remove hardware" sysfs attribute · 253e0572
      Alan Stern 提交于
      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: NAlan Stern <stern@rowland.harvard.edu>
      Cc: David Zeuthen <davidz@redhat.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      253e0572
    • A
      USB: don't use a fixed DMA mapping for hub status URBs · d697cdda
      Alan Stern 提交于
      This patch (as1296) gets rid of the fixed DMA-buffer mapping used by
      the hub driver for its status URB.  This URB doesn't get used much --
      mainly when a device is plugged in or unplugged -- so the dynamic
      mapping overhead is minimal.  And most systems have many fewer
      external hubs than root hubs, which don't need a mapped buffer anyway.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      d697cdda
    • O
      USB: improved error handling in usb_port_suspend() · 0c487206
      Oliver Neukum 提交于
      usb: better error handling in usb_port_suspend
      
      - disable remote wakeup only if it was enabled
      - refuse to autosuspend if remote wakeup fails to be enabled
      Signed-off-by: NOliver Neukum <oliver@neukum.org>
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      0c487206
  13. 01 12月, 2009 1 次提交
    • A
      USB: EHCI: don't send Clear-TT-Buffer following a STALL · c2f6595f
      Alan Stern 提交于
      This patch (as1304) fixes a regression in ehci-hcd.  Evidently some
      hubs don't handle Clear-TT-Buffer requests correctly, so we should
      avoid sending them when they don't appear to be absolutely necessary.
      The reported symptom is that output on a downstream audio device cuts
      out because the hub stops relaying isochronous packets.
      
      The patch prevents Clear-TT-Buffer requests from being sent following
      a STALL handshake.  In theory a STALL indicates either that the
      downstream device sent a STALL or that no matching TT buffer could be
      found.  In either case, the transfer is completed and the TT buffer
      does not remain busy, so it doesn't need to be cleared.
      
      Also, the patch fixes a minor flaw in the code that actually sends the
      Clear-TT-Buffer requests.  Although the pipe direction isn't really
      used for control transfers, it should be a Send rather than a Receive.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Reported-by: NJavier Kohen <jkohen@users.sourceforge.net>
      CC: David Brownell <david-b@pacbell.net>
      Cc: stable <stable@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      c2f6595f
  14. 23 9月, 2009 2 次提交
    • S
      USB: Add hub descriptor update hook for xHCI · b356b7c7
      Sarah Sharp 提交于
      Add a hook for updating xHCI internal structures after khubd fetches the
      hub descriptor and sets up the hub's TT information.  The xHCI driver must
      update the internal structures before devices under the hub can be
      enumerated.
      Signed-off-by: NSarah Sharp <sarah.a.sharp@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      b356b7c7
    • A
      USB: don't lose mode switch events on suspended devices · 527101ce
      Alan Stern 提交于
      This patch (as1268) changes the way usbcore handles child devices that
      undergo a disconnection and reconnection while the parent hub is
      suspended.  Currently, if the child isn't enabled for remote wakeup we
      leave it alone, figuring that it will go through a reset-resume when
      somebody tries to use it.
      
      However this isn't a good approach if the reason for the disconnection
      is that the child decided to switch modes or in some other way alter
      its descriptors.  In that case we want to re-enumerate it as soon as
      possible, not wait until somebody forces a reset-resume.
      
      To resolve the issue, this patch treats reconnected suspended child
      devices as though they had requested a remote wakeup, even if they
      weren't enabled for it.  The mode switch or descriptor change will be
      detected during the reset part of the reset-resume, and the device
      will be re-enumerated immediately.
      
      The disadvantage of this change is that it will cause autosuspended
      devices to be resumed when the computer wakes up from a system sleep
      during which the root hub was reset or lost power.  This shouldn't
      matter much; some people would even argue that autosuspended devices
      should _always_ be resumed when the system wakes up!
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Tested-by: N"Yang Fei-AFY095" <fei.yang@motorola.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      527101ce