1. 12 Jul, 2007 7 commits
    • Alan Stern's avatar
      USB: Make device reset stop retrying after disconnect · dd4dd19e
      Alan Stern authored
      This patch (as898) changes the port reset code in the hub driver.  If
      a connect change occurs, it is reported the same way as a disconnect
      (which of course is what it really is).
      It also changes usb_reset_device(), to prevent the routine from futilely
      retrying the reset after a disconnect has occurred.
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
    • Alan Stern's avatar
      USB: add RESET_RESUME device quirk · 6bc6cff5
      Alan Stern authored
      This patch (as888) adds a new USB device quirk for devices which are
      unable to resume correctly.  By using the new code added for the
      USB-persist facility, it is a simple matter to reset these devices
      instead of resuming them.  To get things kicked off, a quirk entry is
      added for the Philips PSC805.
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
    • Alan Stern's avatar
      USB: add USB-Persist facility · 0458d5b4
      Alan Stern authored
      This patch (as886) adds the controversial USB-persist facility,
      allowing USB devices to persist across a power loss during system
      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: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
    • Alan Stern's avatar
      USB: make hub driver's release more robust · e8054854
      Alan Stern authored
      This revised patch (as893c) improves the method used by the hub driver
      to release its private data structure.  The current code is non-robust,
      relying on a memory region not getting reused by another driver after
      it has been freed.  The patch adds a reference count to the structure,
      resolving the question of when to release it.
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
    • Alan Stern's avatar
      USB: remove "locktree" routine from the hub driver · 06b84e8a
      Alan Stern authored
      This patch (as892) removes the "locktree" routine from the hub driver.
      It currently is used in only one place, by a single kernel thread;
      hence it isn't doing any good.
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
    • Alan Stern's avatar
      USB: don't unsuspend for a new connection · 8adb4786
      Alan Stern authored
      This patch (as889) prevents the hub driver from trying to resume a
      port when there is a new connection.  For one thing, the resume is not
      needed -- the upcoming port reset will clear the suspend feature
      automatically.  For another, on some systems the resume fails and
      causes problems.
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
    • Alan Stern's avatar
      USB: move bus_suspend and bus_resume method calls · b6f6436d
      Alan Stern authored
      This patch (as885) moves the root-hub bus_suspend() and bus_resume()
      method calls from the hub driver's suspend and resume methods into the
      usb_generic driver methods, where they make just as much sense.
      Their old locations were not fully correct.  For example, in a kernel
      compiled without CONFIG_USB_SUSPEND, if one were to do:
      	echo -n 1-0:1.0 >/sys/bus/usb/drivers/hub/unbind
      to unbind the hub driver from a root hub, there would then be no way
      to suspend that root hub.  Attempts to put the system to sleep would
      fail; the USB controller driver would refuse to suspend because the
      root hub was still active.
      The patch also makes a very slight change in the way devices with no
      driver are handled during suspend.  Rather than doing a standard USB
      port-suspend directly, now the suspend routine in usb_generic is
      called.  In practice this should never affect anyone.
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
  2. 11 Jul, 2007 1 commit
    • Rafael J. Wysocki's avatar
      PM: Remove prev_state from struct dev_pm_info · 515c5357
      Rafael J. Wysocki authored
      The prev_state member of struct dev_pm_info (defined in include/linux/pm.h) is
      only used during a resume to check if the device's state before the suspend was
      'off', in which case the device is not resumed.  However, in such cases the
      decision whether or not to resume the device should be made on the driver level
      and the resume callbacks from the device's bus and class should be executed
      anyway (the may be needed for some things other than just powering on the
      Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
  3. 29 May, 2007 1 commit
    • Alan Stern's avatar
      USB: replace flush_workqueue with cancel_sync_work · d5d4db70
      Alan Stern authored
      This patch (as912) replaces a couple of calls to flush_workqueue()
      with cancel_sync_work() and cancel_rearming_delayed_work().  Using a
      more directed approach allows us to avoid some nasty deadlocks.  The
      prime example occurs when a first-level device (the parent is a root
      hub) is removed while at the same time the root hub gets a remote
      wakeup request.  khubd would try to flush the autosuspend workqueue
      while holding the root-hub's lock, and the remote-wakeup workqueue
      routine would be waiting to lock the root hub.
      The patch also reorganizes the power management portion of
      usb_disconnect(), separating it out into its own routine.  The
      autosuspend workqueue entry is cancelled immediately instead of
      waiting for the device's release routine.  In addition,
      synchronization with the autosuspend thread is carried out even for
      root hubs (an oversight in the original code).
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Greg KH <gregkh@suse.de>
      Cc: Mark Lord <lkml@rtr.ca>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
  4. 23 May, 2007 2 commits
  5. 08 May, 2007 1 commit
  6. 27 Apr, 2007 4 commits
    • Alan Stern's avatar
      USB: add "last_busy" field for use in autosuspend · 1941044a
      Alan Stern authored
      This patch (as877) adds a "last_busy" field to struct usb_device, for
      use by the autosuspend framework.  Now if an autosuspend call comes at
      a time when the device isn't busy but hasn't yet been idle for long
      enough, the timer can be set to exactly the desired value.  And we
      will be ready to handle things like HID drivers, which can't maintain
      a useful usage count and must rely on the time-of-last-use to decide
      when to autosuspend.
      The patch also makes some related minor improvements:
      	Move the calls to the autosuspend condition-checking routine
      	into usb_suspend_both(), which is the only place where it
      	really matters.
      	If the autosuspend timer is already running, don't stop
      	and restart it.
      	Replace immediate returns with gotos so that the optional
      	debugging ouput won't be bypassed.
      	If autoresume is disabled but the device is already awake,
      	don't return an error for an autoresume call.
      	Don't try to autoresume a device if it isn't suspended.
      	(Yes, this undercuts the previous change -- so sue me.)
      	Don't duplicate existing code in the autosuspend work routine.
      	Fix the kerneldoc in usb_autopm_put_interface(): If an
      	autoresume call fails, the usage counter is left unchanged.
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
    • Kay Sievers's avatar
      USB: make usbdevices export their device nodes instead of using a separate class · 9f8b17e6
      Kay Sievers authored
      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
      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
        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:
      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. :)
      Signed-off-by: default avatarKay Sievers <kay.sievers@vrfy.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
    • Alan Stern's avatar
      USB: separate autosuspend from external suspend · 6b157c9b
      Alan Stern authored
      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: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
    • Dan Williams's avatar
      dev_dbg: check dev_dbg() arguments · 404d5b18
      Dan Williams authored
      Duplicate what Zach Brown did for pr_debug in commit
      [akpm@linux-foundation.org: fix a couple of things which broke]
      Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
  7. 09 Mar, 2007 2 commits
  8. 23 Feb, 2007 1 commit
  9. 16 Feb, 2007 2 commits
  10. 07 Feb, 2007 1 commit
  11. 22 Jan, 2007 1 commit
  12. 07 Dec, 2006 3 commits
  13. 05 Dec, 2006 1 commit
  14. 01 Dec, 2006 7 commits
    • Alan Stern's avatar
      usbcore: remove unused argument in autosuspend · 94fcda1f
      Alan Stern authored
      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: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
    • Alan Stern's avatar
      USB: keep count of unsuspended children · ee49fb5d
      Alan Stern authored
      This patch (as818b) simplifies autosuspend processing by keeping track
      of the number of unsuspended children of each USB hub.  This will
      permit us to avoid a good deal of unnecessary work all the time; we
      will no longer have to create a bunch of workqueue entries to carry
      out autosuspend requests, only to have them fail because one of the
      hub's children isn't suspended.
      The basic idea is simple.  There already is a usage counter in the
      usb_device structure for preventing autosuspends.  The patch just
      increments that counter for every unsuspended child.  There's only one
      tricky part: When a device disconnects we need to remember whether it
      was suspended at the time (leave the counter alone) or not (decrement
      the counter).
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
    • Alan Stern's avatar
      USB hub: simplify remote-wakeup handling · d25450c6
      Alan Stern authored
      This patch (as817) simplifies the remote-wakeup processing in the hub
      driver.  Now instead of using a specialized code path, it relies on
      the standard USB resume routines.  The hub_port_resume() function does
      an initial get_port_status() to see whether the port has already
      resumed itself (as it does when a remote-wakeup request is sent).
      This will slow down handling of other resume events slightly, but not
      enough to matter.
      The patch also changes the hub_port_status() routine, making it return
      an error if a short reply is received.
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
    • Alan Stern's avatar
      USB: Add autosuspend support to the hub driver · 40f122f3
      Alan Stern authored
      This patch (as742b) adds autosuspend/autoresume support to the USB hub
      driver.  The largest aspect of the change is that we no longer need a
      special flag for root hubs that want to be resumed.  Now every hub is
      autoresumed whenever khubd needs to access it.
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
    • Greg Kroah-Hartman's avatar
      USB: create a new thread for every USB device found during the probe sequence · c066475e
      Greg Kroah-Hartman authored
      Might speed up some systems.  If nothing else, a bad driver should not
      take the whole USB subsystem down with it.
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
    • Alan Stern's avatar
      USB: Move private hub declarations out of public header file · 1bb5f66b
      Alan Stern authored
      This patch (as809b) moves the declaration of the hub driver's private
      data structure from hub.h into the hub.c source file.  Lots of other
      files import hub.h; they have no need to know about the details of the
      hub driver's private data.
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
    • inaky@linux.intel.com's avatar
      usb hub: fix root hub code so it takes more than 15 devices per root hub · 88fafff9
      inaky@linux.intel.com authored
      Wireless USB Host Controllers accept a large number of devices per
      host, which shows up as a large number of ports in its root hub.
      When the number of ports in a hub device goes over 16, the activation
      of the hub fails with the cryptic message in klogd.
      hub 2-0:1.0: activate --> -22
      Following this further, it was seen that:
          generates pipe number
          pseudo allocates buffer 'maxp' bytes in size using usb_maxpacket()
            The endpoint descriptor for a root hub interrupt endpoint is
            declared in
            drivers/usb/core/hcd.c:hs_rh_config_descriptor and declares it
            to be size two (supporting 15 devices max).
                urb->pipe is neither int nor ctl, so it errors out
                    Returns -EINVAL because the buffer length is smaller
                    than the minimum needed to report all the hub port
                    bits as in accordance with USB2.0[11.12.3]. There has
                    to be trunc((PORTS + 1 + 7) / 8) bytes of space at
      Alan Stern confirmed that the reason for reading maxpktsize and not
      the right amount is because some hubs are known to return more data
      and thus cause overflow. 
      So this patch simply changes the code to make the interrupt endpoint's
      max packet size be at least the minimum required by USB_MAXCHILDREN
      (instead of a fixed magic number) and add documentation for that. This
      way we are always ahead of the limit.
      Signed-off-by: default avatarInaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
  15. 22 Nov, 2006 1 commit
  16. 03 Nov, 2006 1 commit
  17. 05 Oct, 2006 1 commit
    • David Howells's avatar
      IRQ: Maintain regs pointer globally rather than passing to IRQ handlers · 7d12e780
      David Howells authored
      Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
      of passing regs around manually through all ~1800 interrupt handlers in the
      Linux kernel.
      The regs pointer is used in few places, but it potentially costs both stack
      space and code to pass it around.  On the FRV arch, removing the regs parameter
      from all the genirq function results in a 20% speed up of the IRQ exit path
      (ie: from leaving timer_interrupt() to leaving do_IRQ()).
      Where appropriate, an arch may override the generic storage facility and do
      something different with the variable.  On FRV, for instance, the address is
      maintained in GR28 at all times inside the kernel as part of general exception
      Having looked over the code, it appears that the parameter may be handed down
      through up to twenty or so layers of functions.  Consider a USB character
      device attached to a USB hub, attached to a USB controller that posts its
      interrupts through a cascaded auxiliary interrupt controller.  A character
      device driver may want to pass regs to the sysrq handler through the input
      layer which adds another few layers of parameter passing.
      I've build this code with allyesconfig for x86_64 and i386.  I've runtested the
      main part of the code on FRV and i386, though I can't test most of the drivers.
      I've also done partial conversion for powerpc and MIPS - these at least compile
      with minimal configurations.
      This will affect all archs.  Mostly the changes should be relatively easy.
      Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
      	struct pt_regs *old_regs = set_irq_regs(regs);
      And put the old one back at the end:
      Don't pass regs through to generic_handle_irq() or __do_IRQ().
      In timer_interrupt(), this sort of change will be necessary:
      	-	update_process_times(user_mode(regs));
      	-	profile_tick(CPU_PROFILING, regs);
      	+	update_process_times(user_mode(get_irq_regs()));
      	+	profile_tick(CPU_PROFILING);
      I'd like to move update_process_times()'s use of get_irq_regs() into itself,
      except that i386, alone of the archs, uses something other than user_mode().
      Some notes on the interrupt handling in the drivers:
       (*) input_dev() is now gone entirely.  The regs pointer is no longer stored in
           the input_dev struct.
       (*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking.  It does
           something different depending on whether it's been supplied with a regs
           pointer or not.
       (*) Various IRQ handler function pointers have been moved to type
      Signed-Off-By: default avatarDavid Howells <dhowells@redhat.com>
      (cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
  18. 28 Sep, 2006 1 commit
  19. 27 Sep, 2006 2 commits