1. 25 11月, 2014 3 次提交
  2. 18 11月, 2014 2 次提交
    • G
      usb: musb: core: Disable the Interrupts till BABBLE is fully handled · f905bc68
      George Cherian 提交于
      Disable the MUSB interrupts till MUSB is recovered fully from BABBLE
      condition. There are chances that we could get multiple interrupts
      till the time the babble recover work gets scheduled. Sometimes
      this could even end up in an endless loop making MUSB itself unusable.
      Reported-by: NFelipe Balbi <balbi@ti.com>
      Signed-off-by: NGeorge Cherian <george.cherian@ti.com>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      f905bc68
    • S
      usb: musb: core: make sure musb is in RPM_ACTIVE on resume · a1fc1920
      Sebastian Andrzej Siewior 提交于
      On am335x-evm with musb in host mode and using it as a wakeup source the
      following happens once the CPU comes out of suspend to ram:
      |PM: Wakeup source MPU_WAKE
      |PM: noirq resume of devices complete after 15.453 msecs
      |PM: early resume of devices complete after 2.222 msecs
      |PM: resume of devices complete after 507.351 msecs
      |Restarting tasks ...
      |------------[ cut here ]------------
      |WARNING: CPU: 0 PID: 322 at drivers/usb/core/urb.c:339 usb_submit_urb+0x494/0x4c8()
      |URB cc0db380 submitted while active
      |[<c0348e64>] (usb_submit_urb) from [<c0340f94>] (hub_activate+0x2b8/0x49c)
      |[<c0340f94>] (hub_activate) from [<c03411dc>] (hub_resume+0x14/0x1c)
      |[<c03411dc>] (hub_resume) from [<c034be10>] (usb_resume_interface.isra.4+0xdc/0x110)
      |[<c034be10>] (usb_resume_interface.isra.4) from [<c034beb0>] (usb_resume_both+0x6c/0x13c)
      |[<c034beb0>] (usb_resume_both) from [<c034cca4>] (usb_runtime_resume+0x10/0x14)
      |[<c034cca4>] (usb_runtime_resume) from [<c02bbd80>] (__rpm_callback+0x2c/0x60)
      |[<c02bbd80>] (__rpm_callback) from [<c02bbdd4>] (rpm_callback+0x20/0x74)
      |[<c02bbdd4>] (rpm_callback) from [<c02bcc48>] (rpm_resume+0x380/0x548)
      |[<c02bcc48>] (rpm_resume) from [<c02bcb00>] (rpm_resume+0x238/0x548)
      |[<c02bcb00>] (rpm_resume) from [<c02bd08c>] (__pm_runtime_resume+0x64/0x94)
      |[<c02bd08c>] (__pm_runtime_resume) from [<c034b5a4>] (usb_autopm_get_interface+0x18/0x5c)
      |[<c034b5a4>] (usb_autopm_get_interface) from [<c03438b8>] (hub_thread+0x10c/0x115c)
      |[<c03438b8>] (hub_thread) from [<c005a70c>] (kthread+0xbc/0xd8)
      |---[ end trace 036aa5fe78203142 ]---
      |hub 1-0:1.0: activate --> -16
      |hub 2-0:1.0: activate --> -16
      
      The reason for this backtrace is the attempt of the USB code to resume
      the HUB twice and thus enqueue the status URB twice.
      Alan Stern was a great help by explaining how the USB code supposed to
      work and what is most likely the problem. The root problem is that after
      resume the musb runtime-suspend state remains RPM_SUSPENDED.
      According to git log it RPM was added for the omap2430 platform. If I
      understand it correct the omap2430 invokes a get on musb once a cable is
      connected and a put once the cable is gone. In between the device could
      go auto-idle/off. Not sure what happens when the device goes into suspend
      but then I guess it was gadget only.
      On DSPS I see only a get in probe and put in remove function. This would
      forbid RPM from working but then the devices enterns suspended state
      anyway :)
      
      To get rid of this warning, I set the device state to RPM_ACTIVE which
      the expected state.
      
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      a1fc1920
  3. 06 11月, 2014 2 次提交
    • S
      usb: musb: try a race-free wakeup · baadd52f
      Sebastian Andrzej Siewior 提交于
      Attaching a keyboard, using it as a wakeup via
      |for f in $(find /sys/devices/ocp.3/47400000.usb -name wakeup)
      |do
      |	echo enabled > $f
      |done
      
      going into standby
      |  echo standby >  /sys/power/state
      
      and now a wake up by a pressing a key.
      What happens is that the system wakes up but the USB device is dead. The
      USB stack tries to send a few control URBs but nothing comes back.
      Eventually it gaves up and the device remains dead:
      |[  632.559678] PM: Wakeup source USB1_PHY
      |[  632.581074] PM: noirq resume of devices complete after 21.261 msecs
      |[  632.607521] PM: early resume of devices complete after 10.360 msecs
      |[  632.616854] net eth2: initializing cpsw version 1.12 (0)
      |[  632.704126] net eth2: phy found : id is : 0x4dd074
      |[  636.704048] libphy: 4a101000.mdio:00 - Link is Up - 1000/Full
      |[  638.444620] usb 1-1: reset low-speed USB device number 2 using musb-hdrc
      |[  653.713435] usb 1-1: device descriptor read/64, error -110
      |[  669.093435] usb 1-1: device descriptor read/64, error -110
      |[  669.473424] usb 1-1: reset low-speed USB device number 2 using musb-hdrc
      |[  684.743436] usb 1-1: device descriptor read/64, error -110
      |[  690.065097] PM: resume of devices complete after 57450.744 msecs
      |[  690.076601] PM: Finishing wakeup.
      |[  690.076627] Restarting tasks ...
      
      It seems that since we got woken up via MUSB_INTR_RESUME the
      musb_host_finish_resume() callback is executed before the
      resume-callbacks of the PHY and glue layer are invoked. If I delay it
      until the glue layer resumed then I don't see this problem.
      
      I also move musb_host_resume_root_hub() into that callback since I don't
      see any reason in doing anything resume-link if there are still pieces
      not restored.
      Signed-off-by: NSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      baadd52f
    • S
      usb: musb: core: check link status on resume · b87fd2f7
      Sebastian Andrzej Siewior 提交于
      The am335x-evmsk support two kinds of suspend:
      - standby
        the USB device remains powered while the system goes into suspend
      
      - mem
        the USB device becomes powerless while the system goes into suspend.
      
      In the "standby" case the device resumes quickly. In the "mem" case the
      system hangs for a few seconds. It seems to me that the USB-device has
      no address (it was disconnected) and the USB stack thinks that it is
      fully operational and GetPortStatus returns the status from before the
      suspend so it is not a big help here.
      
      This adds a check in the resume path to see if the device mode (A or B)
      and the speed is the same. If the device went missing between
      suspend/resume (VBUS went down) then MUSB seems to go into B mode and
      HS/FS bits are cleared. In that case we clear the port1_status bits and
      assume a disconnect. Once the stack learns this it does a "logical
      disconnect" and removes the USB-device quickly. Should the device remain
      connected during the suspend then MUSB will receives a "CONNECT" interrupt.
      Signed-off-by: NSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      b87fd2f7
  4. 04 11月, 2014 3 次提交
  5. 16 7月, 2014 3 次提交
  6. 01 7月, 2014 1 次提交
    • D
      usb: musb: use is_host_active() to distinguish between host and gadget mode · c03da38d
      Daniel Mack 提交于
      On AM33xx platforms, unplugging a device in the middle of an active
      transfer leads to a drop of MUSB_DEVCTL_HM in MUSB_DEVCTL before the
      system is informed about a disconnect. This consequently makes the musb
      core call the gadget code to handle the interrupt request, which then
      crashes the kernel because the relevant pointers haven't been set up
      for gadget mode.
      
      To fix this, use is_host_active() rather than (devctl & MUSB_DEVCTL_HM)
      in musb_interrupt() and musb_dma_completion() to detect whether the
      controller is in host or peripheral mode. This information is provided
      by the driver logic and does not rely on register contents.
      Signed-off-by: NDaniel Mack <zonque@gmail.com>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      c03da38d
  7. 20 6月, 2014 1 次提交
  8. 22 4月, 2014 1 次提交
  9. 05 3月, 2014 1 次提交
  10. 20 2月, 2014 1 次提交
  11. 19 2月, 2014 4 次提交
    • D
      usb: musb: correct use of schedule_delayed_work() · f2dece44
      Daniel Mack 提交于
      schedule_delayed_work() takes the delay in jiffies, not msecs. Fix the
      caller sites in musb. This bug caused regressions with the cleanups
      that went in for 3.14 (8ed1fb79: "usb: musb: finish suspend/reset
      work independently from musb_hub_control()").
      Signed-off-by: NDaniel Mack <daniel@zonque.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f2dece44
    • D
      usb: musb: do not sleep in atomic context · 73926db3
      Daniel Mack 提交于
      musb_port_reset() is called from musb_hub_control() which in turn holds
      a spinlock, so musb_port_reset() is not allowed to call msleep().
      
      With the asynchronous work helpers in place, this is fortunately easy to
      fix by rescheduling the reset deassertion function to after the time
      when the wait period is finished.
      
      Note, however, that the MUSB_POWER_RESUME bit is only set on AM33xx
      processors under rare conditions such as when to another driver
      reporting an error during suspend. Hence, this didn't hit me yet in
      normal operation.
      Signed-off-by: NDaniel Mack <zonque@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      73926db3
    • D
      usb: musb: do not sleep in atomic context · 30d361bf
      Daniel Mack 提交于
      musb_port_reset() is called from musb_hub_control() which in turn holds
      a spinlock, so musb_port_reset() is not allowed to call msleep().
      
      With the asynchronous work helpers in place, this is fortunately easy to
      fix by rescheduling the reset deassertion function to after the time
      when the wait period is finished.
      
      Note, however, that the MUSB_POWER_RESUME bit is only set on AM33xx
      processors under rare conditions such as when to another driver
      reporting an error during suspend. Hence, this didn't hit me yet in
      normal operation.
      Signed-off-by: NDaniel Mack <zonque@gmail.com>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      30d361bf
    • R
      usb: musb: core: Fix remote-wakeup resume · 33f8d75f
      Roger Quadros 提交于
      During resume don't touch SUSPENDM/RESUME bits of POWER register
      while restoring controller context. These bits might be changed
      by the controller during resume operation and so will be different
      than what they were during suspend.
      
      e.g. SUSPENDM bit is set by software during USB global suspend but
      automatically cleared by the controller during remote wakeup or
      during resume. Setting this bit back while restoring context
      causes undesired behaviour. i.e. Babble interrupt is generated
      and USB is broken.
      Signed-off-by: NRoger Quadros <rogerq@ti.com>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      33f8d75f
  12. 09 1月, 2014 1 次提交
  13. 04 1月, 2014 1 次提交
  14. 27 12月, 2013 1 次提交
  15. 20 12月, 2013 1 次提交
    • D
      usb: musb: finish suspend/reset work independently from musb_hub_control() · 8ed1fb79
      Daniel Mack 提交于
      Currently, resume and reset is completed when the USB core calls back
      the root hub, asking for the port's state. This results in
      unpredictable timing of state assertion, which in turn renders some
      USB devices unusable after resume.
      
      Fix this by moving the logic to end the reset and suspend state out of
      musb_hub_control() into separate functions called from delayed workers.
      GetPortStatus only reports the current state now, without taking any
      real action.
      
      The rh_timeout variable is kept in order to define a minimum time gap
      between reset and resume only.
      
      FWIW, in my case, a Verbatim "STORE N GO" mass storage device won't
      resume cleanly without this patch.
      Signed-off-by: NDaniel Mack <zonque@gmail.com>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      8ed1fb79
  16. 27 11月, 2013 2 次提交
  17. 26 11月, 2013 1 次提交
    • S
      usb: musb: only cancel work if it is initialized · 66fadea5
      Sebastian Andrzej Siewior 提交于
      Since commit c5340bd1 ("usb: musb: cancel work on removal") the workqueue
      is cancelled but then if we bail out before the workqueue is setup we
      get this:
      
      |INFO: trying to register non-static key.
      |the code is fine but needs lockdep annotation.
      |turning off the locking correctness validator.
      |CPU: 0 PID: 708 Comm: modprobe Not tainted 3.12.0+ #435
      |[<c00867bc>] (lock_acquire+0xf0/0x108) from [<c00529d0>] (flush_work+0x38/0x2ec)
      |[<c00529d0>] (flush_work+0x38/0x2ec) from [<c0052d24>] (__cancel_work_timer+0xa0/0x134)
      |[<c0052d24>] (__cancel_work_timer+0xa0/0x134) from [<bf0e4ae4>] (musb_free+0x40/0x60 [musb_hdrc])
      |[<bf0e4ae4>] (musb_free+0x40/0x60 [musb_hdrc]) from [<bf0e5364>] (musb_probe+0x678/0xb78 [musb_hdrc])
      |[<bf0e5364>] (musb_probe+0x678/0xb78 [musb_hdrc]) from [<c0294bf0>] (platform_drv_probe+0x1c/0x24)
      |[<c0294bf0>] (platform_drv_probe+0x1c/0x24) from [<c0293970>] (driver_probe_device+0x90/0x224)
      |[<c0293970>] (driver_probe_device+0x90/0x224) from [<c0291ef0>] (bus_for_each_drv+0x60/0x8c)
      |[<c0291ef0>] (bus_for_each_drv+0x60/0x8c) from [<c02938bc>] (device_attach+0x80/0xa4)
      |[<c02938bc>] (device_attach+0x80/0xa4) from [<c0292b24>] (bus_probe_device+0x88/0xac)
      |[<c0292b24>] (bus_probe_device+0x88/0xac) from [<c0291490>] (device_add+0x388/0x6c8)
      |[<c0291490>] (device_add+0x388/0x6c8) from [<c02952a0>] (platform_device_add+0x188/0x22c)
      |[<c02952a0>] (platform_device_add+0x188/0x22c) from [<bf11ea30>] (dsps_probe+0x294/0x394 [musb_dsps])
      |[<bf11ea30>] (dsps_probe+0x294/0x394 [musb_dsps]) from [<c0294bf0>] (platform_drv_probe+0x1c/0x24)
      |platform musb-hdrc.1.auto: Driver musb-hdrc requests probe deferral
      |musb-hdrc musb-hdrc.1.auto: musb_init_controller failed with status -517
      
      This patch moves the init part to earlier part so it can be cleaned as
      part of the fail3 label because now it is surrounded by the fail4 label.
      Step two is to remove it from musb_free() and add it to the two cleanup
      paths (error path and device removal) separately.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: NSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      66fadea5
  18. 18 10月, 2013 3 次提交
  19. 12 10月, 2013 1 次提交
  20. 11 10月, 2013 2 次提交
    • S
      usb: musb: start musb on the udc side, too · 001dd84a
      Sebastian Andrzej Siewior 提交于
      I have am335x-evm with one port running in OTG mode. Since commit
      fe4cb091 ("usb: musb: gadget: remove hcd initialization") the loaded
      gadget does non pop up on the host. All I see is
      |usb 4-5: new high-speed USB device number 52 using ehci-pci
      |usb 4-5: device descriptor read/64, error -110
      
      Since a later commit 2cc65fea ("usb: musb: add musb_host_setup() and
      musb_host_cleanup()) the gadget shows up on the host again but only
      in OTG mode (because we have the host init code running). It does not
      work in device only mode.
      If running in OTG mode and the gadget is removed and added back (rmmod
      followed by modprobe of a gadget) then the same error is pops up on the
      host side.
      
      This patch ensures that the gadget side also executes musb_start() which
      puts the chip in "connect accept" mode. With this change the device
      works in OTG & device mode and the gadget can be added & removed
      multiple times.
      A device (if musb is in OTG mode acting as a host) is only recognized if
      it is attached during module load (musb_hdrc module). After the device
      unplugged and plugged again the host does not recognize it. We get a
      buch of errors if musb running in OTG mode, attached to a host and no
      gadget is loaded. Bah.
      This is one step forward. Host & device only mode should work. I will
      look at OTG later. I looked at this before commit fe4cb091 and OTG wasn't
      working there perfectly so I am not sure that it is a regression :)
      
      Cc: <stable@vger.kernel.org> # v3.11
      Cc: Daniel Mack <zonque@gmail.com>
      Cc: Peter Korsgaard <jacmet@sunsite.dk>
      Signed-off-by: NSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      001dd84a
    • S
      usb: musb: cancel work on removal · c5340bd1
      Sebastian Andrzej Siewior 提交于
      So I captured this:
      
      |WARNING: CPU: 0 PID: 2078 at /home/bigeasy/work/new/TI/linux/lib/debugobjects.c:260 debug_print_object+0x94/0xc4()
      |ODEBUG: free active (active state 0) object type: work_struct hint: musb_irq_work+0x0/0x38 [musb_hdrc]
      |CPU: 0 PID: 2078 Comm: rmmod Not tainted 3.12.0-rc4+ #338
      |[<c0014d38>] (unwind_backtrace+0x0/0xf4) from [<c001249c>] (show_stack+0x14/0x1c)
      |[<c001249c>] (show_stack+0x14/0x1c) from [<c0037720>] (warn_slowpath_common+0x64/0x84)
      |[<c0037720>] (warn_slowpath_common+0x64/0x84) from [<c00377d4>] (warn_slowpath_fmt+0x30/0x40)
      |[<c00377d4>] (warn_slowpath_fmt+0x30/0x40) from [<c022ae90>] (debug_print_object+0x94/0xc4)
      |[<c022ae90>] (debug_print_object+0x94/0xc4) from [<c022b7e0>] (debug_check_no_obj_freed+0x1c0/0x228)
      |[<c022b7e0>] (debug_check_no_obj_freed+0x1c0/0x228) from [<c00f1f38>] (kfree+0xf8/0x228)
      |[<c00f1f38>] (kfree+0xf8/0x228) from [<c02921c4>] (release_nodes+0x1a8/0x248)
      |[<c02921c4>] (release_nodes+0x1a8/0x248) from [<c028f70c>] (__device_release_driver+0x98/0xf0)
      |[<c028f70c>] (__device_release_driver+0x98/0xf0) from [<c028f840>] (device_release_driver+0x24/0x34)
      |[<c028f840>] (device_release_driver+0x24/0x34) from [<c028ebe8>] (bus_remove_device+0x148/0x15c)
      |[<c028ebe8>] (bus_remove_device+0x148/0x15c) from [<c028d120>] (device_del+0x104/0x1c0)
      |[<c028d120>] (device_del+0x104/0x1c0) from [<c02911e4>] (platform_device_del+0x18/0xac)
      |[<c02911e4>] (platform_device_del+0x18/0xac) from [<c029179c>] (platform_device_unregister+0xc/0x18)
      |[<c029179c>] (platform_device_unregister+0xc/0x18) from [<bf1902fc>] (dsps_remove+0x20/0x4c [musb_dsps])
      |[<bf1902fc>] (dsps_remove+0x20/0x4c [musb_dsps]) from [<c0290d7c>] (platform_drv_remove+0x1c/0x24)
      |[<c0290d7c>] (platform_drv_remove+0x1c/0x24) from [<c028f704>] (__device_release_driver+0x90/0xf0)
      |[<c028f704>] (__device_release_driver+0x90/0xf0) from [<c028f818>] (driver_detach+0xb4/0xb8)
      |[<c028f818>] (driver_detach+0xb4/0xb8) from [<c028e6e8>] (bus_remove_driver+0x98/0xec)
      |[<c028e6e8>] (bus_remove_driver+0x98/0xec) from [<c008fc70>] (SyS_delete_module+0x1e0/0x24c)
      |[<c008fc70>] (SyS_delete_module+0x1e0/0x24c) from [<c000e680>] (ret_fast_syscall+0x0/0x48)
      |---[ end trace d79045419a3e51ec ]---
      
      The workqueue is only scheduled from the ep0 and never canceled in case
      the musb is removed before the work has a chance to run.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: NSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      c5340bd1
  21. 30 7月, 2013 1 次提交
  22. 29 7月, 2013 4 次提交