1. 08 1月, 2009 2 次提交
  2. 30 10月, 2008 1 次提交
    • A
      USB: fix crash when URBs are unlinked after the device is gone · cde217a5
      Alan Stern 提交于
      This patch (as1151) protects usbcore against drivers that try to
      unlink an URB after the URB's device or bus have been removed.  The
      core does not currently check for this, and certain drivers can cause
      a crash if they are running while an HCD is unloaded.
      
      Certainly it would be best to fix the guilty drivers.  But a little
      defensive programming doesn't hurt, especially since it appears that
      quite a few drivers need to be fixed.
      
      The patch prevents the problem by grabbing a reference to the device
      while an unlink is in progress and using a new spinlock to synchronize
      unlinks with device removal.  (There's no need to acquire a reference
      to the bus as well, since the device structure itself keeps a
      reference to the bus.)  In addition, the kerneldoc is updated to
      indicate that URBs should not be unlinked after the disconnect method
      returns.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Cc: stable <stable@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      cde217a5
  3. 18 10月, 2008 1 次提交
  4. 22 8月, 2008 1 次提交
    • A
      USB: automatically enable RHSC interrupts · b5fb454f
      Alan Stern 提交于
      This patch (as1069c) changes the way OHCI root-hub status-change
      interrupts are enabled.  Currently a special HCD method,
      hub_irq_enable(), is called when the hub driver is finished using a
      root hub.  This approach turns out to be subject to races, resulting
      in unnecessary polling.
      
      The patch does away with the method entirely.  Instead, the driver
      automatically enables the RHSC interrupt when no more status changes
      are present.  This scheme is safe with controllers using
      level-triggered semantics for their interrupt flags.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      b5fb454f
  5. 22 7月, 2008 2 次提交
  6. 07 7月, 2008 1 次提交
  7. 30 5月, 2008 1 次提交
    • A
      USB: EHCI: suppress unwanted error messages · 3a31155c
      Alan Stern 提交于
      This patch (as1096) fixes an annoying problem: When a full-speed or
      low-speed device is plugged into an EHCI controller, it fails to
      enumerate at high speed and then is handed over to the companion
      controller.  But usbcore logs a misleading and unwanted error message
      when the high-speed enumeration fails.
      
      The patch adds a new HCD method, port_handed_over, which asks whether
      a port has been handed over to a companion controller.  If it has, the
      error message is suppressed.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      CC: David Brownell <david-b@pacbell.net>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      3a31155c
  8. 25 4月, 2008 4 次提交
    • A
      USB: don't explicitly reenable root-hub status interrupts · e8721549
      Alan Stern 提交于
      This patch (as1069b) changes the way OHCI root-hub status-change
      interrupts are enabled.  Currently a special HCD method,
      hub_irq_enable(), is called when the hub driver is finished using a
      root hub.  This approach turns out to be subject to races, resulting
      in unnecessary polling.
      
      The patch does away with the method entirely.  Instead, the driver
      automatically enables the RHSC interrupt when no more status changes
      are present.  This scheme is safe with controllers using
      level-triggered semantics for their interrupt flags.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      e8721549
    • A
      USB: clarify usage of hcd->suspend/resume methods · 7be7d741
      Alan Stern 提交于
      The .suspend and .resume method pointers in struct usb_hcd have not
      been fully understood by host-controller driver writers.  They are
      meant for use with PCI controllers; other platform-specific drivers
      generally should not refer to them.
      
      To try and clarify matters, this patch (as1065) renames those methods
      to .pci_suspend and .pci_resume.  It eliminates corresponding dead code
      and bogus references in the ohci-ssb and u132-hcd drivers.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      7be7d741
    • A
      USB: root hubs don't lie about their number of TTs · 7329e211
      Alan Stern 提交于
      Currently EHCI root hubs enumerate with a bDeviceProtocol code
      indicating that they possess a Transaction Translator.  However the
      vast majority of controllers do not; they rely on a companion
      controller to handle full- and low-speed communications.  This patch
      (as1064) changes the root-hub device descriptor to match the actual
      situation.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      7329e211
    • D
      USB: defines for USB "Link Power Management" (LPM) ECN · dbe0dbb7
      David Brownell 提交于
      There's a new PM-related change notice for the USB 2.0 specification
      called "Link Power Management" (LPM).  It defines a new "L1 Suspend"
      state which resembles the current (L2) suspend state, except that it
      can be entered and exited much more quickly.  It should thus be more
      useful for runtime PM, even though it doesn't mandate reduced power
      draw from VBUS.
      
      This patch provides the relevant #defines for usbcore.  Actually
      implementing these mechanisms requires host silicon that can generate
      new USB packets, plus hubs handling some new requests and peripherals
      which understand the new packets.
      Signed-off-by: NDavid Brownell <dbrownell@users.sourceforge.net>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      dbe0dbb7
  9. 02 2月, 2008 3 次提交
  10. 13 10月, 2007 6 次提交
    • A
      USB: mutual exclusion for EHCI init and port resets · 32fe0198
      Alan Stern 提交于
      This patch (as999) fixes a problem that sometimes shows up when host
      controller driver modules are loaded in the wrong order.  If ehci-hcd
      happens to initialize an EHCI controller while the companion OHCI or
      UHCI controller is in the middle of a port reset, the reset can fail
      and the companion may get very confused.  The patch adds an
      rw-semaphore and uses it to keep EHCI initialization and port resets
      mutually exclusive.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Acked-by: NDavid Brownell <david-b@pacbell.net>
      Cc: David Miller <davem@davemloft.net>
      Cc: Dely L Sy <dely.l.sy@intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      32fe0198
    • A
      USB: break apart flush_endpoint and disable_endpoint · 95cf82f9
      Alan Stern 提交于
      This patch (as988) breaks usb_hcd_endpoint_disable() apart into two
      routines.  The first, usb_hcd_flush_endpoint() does the -ESHUTDOWN
      unlinking of all URBs in the endpoint's queue and waits for them to
      complete.  The second, usb_hcd_disable_endpoint() -- renamed for
      better grammatical style -- merely calls the HCD's endpoint_disable
      method.  The changeover is easy because the routine currently has only
      one caller.
      
      This separation of function will be exploited in the following patch:
      When a device is suspended, the core will be able to cancel all
      outstanding URBs for that device while leaving the HCD's
      endpoint-related data structures intact for later.
      
      As an added benefit, HCDs no longer need to check for existing URBs in
      their endpoint_disable methods.  It is now guaranteed that there will
      be none.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      95cf82f9
    • A
      USB: Eliminate urb->status usage! · 4a00027d
      Alan Stern 提交于
      This patch (as979) removes the last vestiges of urb->status from the
      host controller drivers and the root-hub emulator.  Now the field
      doesn't get set until just before the URB's completion routine is
      called.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      CC: David Brownell <david-b@pacbell.net>
      CC: Olav Kongas <ok@artecdesign.ee>
      CC: Yoshihiro Shimoda <shimoda.yoshihiro@renesas.com>
      CC: Tony Olech <tony.olech@elandigitalsystems.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      4a00027d
    • A
      USB: reorganize urb->status use in usbmon · 9347d51c
      Alan Stern 提交于
      This patch (as978) reorganizes the way usbmon uses urb->status.  It
      now accepts the status value as an argument.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Acked-by: NPete Zaitcev <zaitcev@redhat.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      9347d51c
    • A
      USB: make HCDs responsible for managing endpoint queues · e9df41c5
      Alan Stern 提交于
      This patch (as954) implements a suggestion of David Brownell's.  Now
      the host controller drivers are responsible for linking and unlinking
      URBs to/from their endpoint queues.  This eliminates the possiblity of
      strange situations where usbcore thinks an URB is linked but the HCD
      thinks it isn't.  It also means HCDs no longer have to check for URBs
      being dequeued before they were fully enqueued.
      
      In addition to the core changes, this requires changing every host
      controller driver and the root-hub URB handler.  For the most part the
      required changes are fairly small; drivers have to call
      usb_hcd_link_urb_to_ep() in their urb_enqueue method,
      usb_hcd_check_unlink_urb() in their urb_dequeue method, and
      usb_hcd_unlink_urb_from_ep() before giving URBs back.  A few HCDs make
      matters more complicated by the way they split up the flow of control.
      
      In addition some method interfaces get changed.  The endpoint argument
      for urb_enqueue is now redundant so it is removed.  The unlink status
      is required by usb_hcd_check_unlink_urb(), so it has been added to
      urb_dequeue.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      CC: David Brownell <david-b@pacbell.net>
      CC: Olav Kongas <ok@artecdesign.ee>
      CC: Tony Olech <tony.olech@elandigitalsystems.com>
      CC: Yoshihiro Shimoda <shimoda.yoshihiro@renesas.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      e9df41c5
    • I
      usb: add the concept of default authorization to USB hosts · 5234ce1b
      Inaky Perez-Gonzalez 提交于
      This introduces /sys/bus/devices/usb*/authorized_default; it dictates
      what is going to be the default authorization state for devices
      connected to the host. User space can set that using the sysfs file.
      
      We hook to the root hub instead of to the device controller as it is
      quite easy to get to it in sysfs from the device structure (device
      5-4.3 is usb5) vs. backtracking to the controller device.
      
      By default it is set to be 'authorized' (!0) for normal, wired USB
      devices and 'unauthorized' (0) for Wireless USB devices.
      
      As suggested by Adrian Bunk, make authorized_default static
      Signed-off-by: NInaky Perez-Gonzalez <inaky@linux.intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      5234ce1b
  11. 13 7月, 2007 1 次提交
    • A
      USB: separate root and non-root suspend/resume · 686314cf
      Alan Stern 提交于
      This patch (as916) completes the separation of code paths for suspend
      and resume of root hubs as opposed to non-root devices.  Root hubs
      will be power-managed through their bus_suspend and bus_resume
      methods, whereas normal devices will use usb_port_suspend() and
      usb_port_resume().
      
      Changes to the hcd_bus_{suspend,resume} routines mostly represent
      motion of code that was already present elsewhere.  They include:
      
      	Adding debugging log messages,
      
      	Setting the device state appropriately, and
      
      	Adding a resume recovery time delay.
      
      Changes to the port-suspend and port-resume routines in hub.c include:
      
      	Removal of checks for root devices (since they will never
      	be triggered), and
      
      	Removal of checks for NULL or invalid device pointers (these
      	were left over from earlier kernel versions and aren't needed
      	at all).
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      686314cf
  12. 28 4月, 2007 1 次提交
    • A
      USB: separate autosuspend from external suspend · 6b157c9b
      Alan Stern 提交于
      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: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      6b157c9b
  13. 08 2月, 2007 1 次提交
  14. 05 10月, 2006 1 次提交
    • D
      IRQ: Maintain regs pointer globally rather than passing to IRQ handlers · 7d12e780
      David Howells 提交于
      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
      handling.
      
      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:
      
      	set_irq_regs(old_regs);
      
      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
           irq_handler_t.
      Signed-Off-By: NDavid Howells <dhowells@redhat.com>
      (cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
      7d12e780
  15. 28 9月, 2006 5 次提交
    • A
      usbcore: remove usb_suspend_root_hub · 02c399ee
      Alan Stern 提交于
      This patch (as740) removes the existing support for autosuspend of
      root hubs.  That support fit in rather awkwardly with the rest of
      usbcore and it was used only by ohci-hcd.  It won't be needed any more
      since the hub driver will take care of autosuspending all hubs, root
      or external.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      02c399ee
    • A
      usbcore: trim down usb_bus structure · 17200583
      Alan Stern 提交于
      As part of the ongoing program to flatten out the HCD bus-glue layer,
      this patch (as771b) eliminates the hcpriv, release, and kref fields
      from struct usb_bus.  hcpriv and release were not being used for
      anything worthwhile, and kref has been moved into the enclosing
      usb_hcd structure.
      
      Along with those changes, the patch gets rid of usb_bus_get and
      usb_bus_put, replacing them with usb_get_hcd and usb_put_hcd.
      
      The one interesting aspect is that the dev_set_drvdata call was
      removed from usb_put_hcd, where it clearly doesn't belong.  This means
      the driver private data won't get reset to NULL.  It shouldn't cause
      any problems, since the private data is undefined when no driver is
      bound.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      
      17200583
    • A
      USB: remove struct usb_operations · a6d2bb9f
      Alan Stern 提交于
      All of the currently-supported USB host controller drivers use the HCD
      bus-glue framework.  As part of the program for flattening out the glue
      layer, this patch (as769) removes the usb_operations structure.  All
      function calls now go directly to the HCD routines (slightly renamed
      to remain within the "usb_" namespace).
      
      The patch also removes usb_alloc_bus(), because it's not useful in the
      HCD framework and it wasn't referenced anywhere.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      a6d2bb9f
    • I
      wusb: hub code recognizes wusb ports · 0165de09
      Inaky Perez-Gonzalez 提交于
      This patch enables the USB stack to recognize WUSB devices (from a
      WUSB HCD) and assigns them the proper speed setting
      (USB_SPEED_VARIABLE).
      
      1. Introduce usb_hcd->wireless to mark a host controller instance as
         being wireless, and thus having wireless 'fake' ports. 
      
         [discarded previous model of using a reserved bit in the port_stat
         struct to do this; thanks to Alan Stern for indicating the
         proper way to do it].
      
      2. Introduce hub.c:hub_is_wusb() that tests if a hub is a WUSB root
         hub (WUSB doesn't have non-root hubs).
      
      New code being pushed to linuxuwb.org requires this patch to connect WUSB
      devices.
      Signed-off-by: NInaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      
      0165de09
    • A
      USB: Properly unregister reboot notifier in case of failure in ehci hcd · 64a21d02
      Aleksey Gorelov 提交于
      If some problem occurs during ehci startup, for instance, request_irq fails,
      echi hcd driver tries it best to cleanup, but fails to unregister reboot
      notifier, which in turn leads to crash on reboot/poweroff.
      
      The following patch resolves this problem by not using reboot notifiers
      anymore, but instead making ehci/ohci driver get its own shutdown method.  For
      PCI, it is done through pci glue, for everything else through platform driver
      glue.
      
      One downside: sa1111 does not use platform driver stuff, and does not have its
      own shutdown hook, so no 'shutdown' is called for it now.  I'm not sure if it
      is really necessary on that platform, though.
      Signed-off-by: NAleks Gorelov <dared1st@yahoo.com>
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Cc: David Brownell <david-b@pacbell.net>
      Signed-off-by: NAndrew Morton <akpm@osdl.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      64a21d02
  16. 21 3月, 2006 2 次提交
  17. 05 1月, 2006 1 次提交
  18. 30 11月, 2005 1 次提交
    • B
      [PATCH] USB: Fix USB suspend/resume crasher (#2) · 8de98402
      Benjamin Herrenschmidt 提交于
      This patch closes the IRQ race and makes various other OHCI & EHCI code
      path safer vs. suspend/resume.
      I've been able to (finally !) successfully suspend and resume various
      Mac models, with or without USB mouse plugged, or plugging while asleep,
      or unplugging while asleep etc... all without a crash.
      
      Alan, please verify the UHCI bit I did, I only verified that it builds.
      It's very simple so I wouldn't expect any issue there. If you aren't
      confident, then just drop the hunks that change uhci-hcd.c
      
      I also made the patch a little bit more "safer" by making sure the store
      to the interrupt register that disables interrupts is not posted before
      I set the flag and drop the spinlock.
      
      Without this patch, you cannot reliably sleep/wakeup any recent Mac, and
      I suspect PCs have some more sneaky issues too (they don't frankly crash
      with machine checks because x86 tend to silently swallow PCI errors but
      that won't last afaik, at least PCI Express will blow up in those
      situations, but the USB code may still misbehave).
      Signed-off-by: NBenjamin Herrenschmidt <benh@kernel.crashing.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      8de98402
  19. 29 10月, 2005 5 次提交