1. 18 5月, 2017 1 次提交
    • J
      usb: chipidea: udc: fix NULL pointer dereference if udc_start failed · aa1f058d
      Jisheng Zhang 提交于
      Fix below NULL pointer dereference. we set ci->roles[CI_ROLE_GADGET]
      too early in ci_hdrc_gadget_init(), if udc_start() fails due to some
      reason, the ci->roles[CI_ROLE_GADGET] check in  ci_hdrc_gadget_destroy
      can't protect us.
      
      We fix this issue by only setting ci->roles[CI_ROLE_GADGET] if
      udc_start() succeed.
      
      [    1.398550] Unable to handle kernel NULL pointer dereference at
      virtual address 00000000
      ...
      [    1.448600] PC is at dma_pool_free+0xb8/0xf0
      [    1.453012] LR is at dma_pool_free+0x28/0xf0
      [    2.113369] [<ffffff80081817d8>] dma_pool_free+0xb8/0xf0
      [    2.118857] [<ffffff800841209c>] destroy_eps+0x4c/0x68
      [    2.124165] [<ffffff8008413770>] ci_hdrc_gadget_destroy+0x28/0x50
      [    2.130461] [<ffffff800840fa30>] ci_hdrc_probe+0x588/0x7e8
      [    2.136129] [<ffffff8008380fb8>] platform_drv_probe+0x50/0xb8
      [    2.142066] [<ffffff800837f494>] driver_probe_device+0x1fc/0x2a8
      [    2.148270] [<ffffff800837f68c>] __device_attach_driver+0x9c/0xf8
      [    2.154563] [<ffffff800837d570>] bus_for_each_drv+0x58/0x98
      [    2.160317] [<ffffff800837f174>] __device_attach+0xc4/0x138
      [    2.166072] [<ffffff800837f738>] device_initial_probe+0x10/0x18
      [    2.172185] [<ffffff800837e58c>] bus_probe_device+0x94/0xa0
      [    2.177940] [<ffffff800837c560>] device_add+0x3f0/0x560
      [    2.183337] [<ffffff8008380d20>] platform_device_add+0x180/0x240
      [    2.189541] [<ffffff800840f0e8>] ci_hdrc_add_device+0x440/0x4f8
      [    2.195654] [<ffffff8008414194>] ci_hdrc_usb2_probe+0x13c/0x2d8
      [    2.201769] [<ffffff8008380fb8>] platform_drv_probe+0x50/0xb8
      [    2.207705] [<ffffff800837f494>] driver_probe_device+0x1fc/0x2a8
      [    2.213910] [<ffffff800837f5ec>] __driver_attach+0xac/0xb0
      [    2.219575] [<ffffff800837d4b0>] bus_for_each_dev+0x60/0xa0
      [    2.225329] [<ffffff800837ec80>] driver_attach+0x20/0x28
      [    2.230816] [<ffffff800837e880>] bus_add_driver+0x1d0/0x238
      [    2.236571] [<ffffff800837fdb0>] driver_register+0x60/0xf8
      [    2.242237] [<ffffff8008380ef4>] __platform_driver_register+0x44/0x50
      [    2.248891] [<ffffff80086fd440>] ci_hdrc_usb2_driver_init+0x18/0x20
      [    2.255365] [<ffffff8008082950>] do_one_initcall+0x38/0x128
      [    2.261121] [<ffffff80086e0d00>] kernel_init_freeable+0x1ac/0x250
      [    2.267414] [<ffffff800852f0b8>] kernel_init+0x10/0x100
      [    2.272810] [<ffffff8008082680>] ret_from_fork+0x10/0x50
      
      Cc: stable <stable@vger.kernel.org>
      Fixes: 3f124d23 ("usb: chipidea: add role init and destroy APIs")
      Signed-off-by: NJisheng Zhang <jszhang@marvell.com>
      Signed-off-by: NPeter Chen <peter.chen@nxp.com>
      aa1f058d
  2. 14 4月, 2017 1 次提交
    • P
      usb: chipidea: core: add sysfs group · a932a804
      Peter Chen 提交于
      Sometimes, the user needs to adjust some properties for controllers, eg
      the role for controller, we add sysfs group for them.
      
      The attribute 'role' is used to switch host/gadget role dynamically, the
      uewr can read the current role, and write the other role compare to
      current one to finish the switch.
      Signed-off-by: NPeter Chen <peter.chen@nxp.com>
      a932a804
  3. 23 3月, 2017 1 次提交
  4. 15 3月, 2017 1 次提交
  5. 20 1月, 2017 2 次提交
  6. 16 11月, 2016 1 次提交
    • P
      usb: chipidea: move the lock initialization to core file · a5d906bb
      Peter Chen 提交于
      This can fix below dump when the lock is accessed at host
      mode due to it is not initialized.
      
      [   46.119638] INFO: trying to register non-static key.
      [   46.124643] the code is fine but needs lockdep annotation.
      [   46.130144] turning off the locking correctness validator.
      [   46.135659] CPU: 0 PID: 690 Comm: cat Not tainted 4.9.0-rc3-00079-g4b75f1d #1210
      [   46.143075] Hardware name: Freescale i.MX6 SoloX (Device Tree)
      [   46.148923] Backtrace:
      [   46.151448] [<c010c460>] (dump_backtrace) from [<c010c658>] (show_stack+0x18/0x1c)
      [   46.159038]  r7:edf52000
      [   46.161412]  r6:60000193
      [   46.163967]  r5:00000000
      [   46.165035]  r4:c0e25c2c
      
      [   46.169109] [<c010c640>] (show_stack) from [<c03f58a4>] (dump_stack+0xb4/0xe8)
      [   46.176362] [<c03f57f0>] (dump_stack) from [<c016d690>] (register_lock_class+0x4fc/0x56c)
      [   46.184554]  r10:c0e25d24
      [   46.187014]  r9:edf53e70
      [   46.189569]  r8:c1642444
      [   46.190637]  r7:ee9da024
      [   46.193191]  r6:00000000
      [   46.194258]  r5:00000000
      [   46.196812]  r4:00000000
      [   46.199185]  r3:00000001
      
      [   46.203259] [<c016d194>] (register_lock_class) from [<c0171294>] (__lock_acquire+0x80/0x10f0)
      [   46.211797]  r10:c0e25d24
      [   46.214257]  r9:edf53e70
      [   46.216813]  r8:ee9da024
      [   46.217880]  r7:c1642444
      [   46.220435]  r6:edcd1800
      [   46.221502]  r5:60000193
      [   46.224057]  r4:00000000
      
      [   46.227953] [<c0171214>] (__lock_acquire) from [<c01726c0>] (lock_acquire+0x74/0x94)
      [   46.235710]  r10:00000001
      [   46.238169]  r9:edf53e70
      [   46.240723]  r8:edf53f80
      [   46.241790]  r7:00000001
      [   46.244344]  r6:00000001
      [   46.245412]  r5:60000193
      [   46.247966]  r4:00000000
      
      [   46.251866] [<c017264c>] (lock_acquire) from [<c096c8fc>] (_raw_spin_lock_irqsave+0x40/0x54)
      [   46.260319]  r7:ee1c6a00
      [   46.262691]  r6:c062a570
      [   46.265247]  r5:20000113
      [   46.266314]  r4:ee9da014
      
      [   46.270393] [<c096c8bc>] (_raw_spin_lock_irqsave) from [<c062a570>] (ci_port_test_show+0x2c/0x70)
      [   46.279280]  r6:eebd2000
      [   46.281652]  r5:ee9da010
      [   46.284207]  r4:ee9da014
      
      [   46.286810] [<c062a544>] (ci_port_test_show) from [<c0248d04>] (seq_read+0x1ac/0x4f8)
      [   46.294655]  r9:edf53e70
      [   46.297028]  r8:edf53f80
      [   46.299583]  r7:ee1c6a00
      [   46.300650]  r6:00000001
      [   46.303205]  r5:00000000
      [   46.304273]  r4:eebd2000
      [   46.306850] [<c0248b58>] (seq_read) from [<c039e864>] (full_proxy_read+0x54/0x6c)
      [   46.314348]  r10:00000000
      [   46.316808]  r9:c0a6ad30
      [   46.319363]  r8:edf53f80
      [   46.320430]  r7:00020000
      [   46.322986]  r6:b6de3000
      [   46.324053]  r5:ee1c6a00
      [   46.326607]  r4:c0248b58
      
      [   46.330505] [<c039e810>] (full_proxy_read) from [<c021ec98>] (__vfs_read+0x34/0x118)
      [   46.338262]  r9:edf52000
      [   46.340635]  r8:c0107fc4
      [   46.343190]  r7:00020000
      [   46.344257]  r6:edf53f80
      [   46.346812]  r5:c039e810
      [   46.347879]  r4:ee1c6a00
      [   46.350447] [<c021ec64>] (__vfs_read) from [<c021fbd0>] (vfs_read+0x8c/0x11c)
      [   46.357597]  r9:edf52000
      [   46.359969]  r8:c0107fc4
      [   46.362524]  r7:edf53f80
      [   46.363592]  r6:b6de3000
      [   46.366147]  r5:ee1c6a00
      [   46.367214]  r4:00020000
      [   46.369782] [<c021fb44>] (vfs_read) from [<c0220a4c>] (SyS_read+0x4c/0xa8)
      [   46.376672]  r8:c0107fc4
      [   46.379045]  r7:00020000
      [   46.381600]  r6:b6de3000
      [   46.382667]  r5:ee1c6a00
      [   46.385222]  r4:ee1c6a00
      
      [   46.387817] [<c0220a00>] (SyS_read) from [<c0107e20>] (ret_fast_syscall+0x0/0x1c)
      [   46.395314]  r7:00000003
      [   46.397687]  r6:b6de3000
      [   46.400243]  r5:00020000
      [   46.401310]  r4:00020000
      
      Cc: <stable@vger.kernel.org>
      Fixes: 26c696c6 ("USB: Chipidea: rename struct
      	       	ci13xxx variables from udc to ci")
      Signed-off-by: NPeter Chen <peter.chen@nxp.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a5d906bb
  7. 14 11月, 2016 1 次提交
  8. 03 11月, 2016 2 次提交
  9. 14 9月, 2016 6 次提交
  10. 09 9月, 2016 1 次提交
    • C
      usb: chipidea: udc: fix NULL ptr dereference in isr_setup_status_phase · 6f3c4fb6
      Clemens Gruber 提交于
      Problems with the signal integrity of the high speed USB data lines or
      noise on reference ground lines can cause the i.MX6 USB controller to
      violate USB specs and exhibit unexpected behavior.
      
      It was observed that USBi_UI interrupts were triggered first and when
      isr_setup_status_phase was called, ci->status was NULL, which lead to a
      NULL pointer dereference kernel panic.
      
      This patch fixes the kernel panic, emits a warning once and returns
      -EPIPE to halt the device and let the host get stalled.
      It also adds a comment to point people, who are experiencing this issue,
      to their USB hardware design.
      
      Cc: <stable@vger.kernel.org> #4.1+
      Signed-off-by: NClemens Gruber <clemens.gruber@pqgruber.com>
      Signed-off-by: NPeter Chen <peter.chen@nxp.com>
      6f3c4fb6
  11. 19 8月, 2016 1 次提交
  12. 04 3月, 2016 1 次提交
  13. 29 2月, 2016 1 次提交
  14. 24 12月, 2015 3 次提交
  15. 02 12月, 2015 1 次提交
  16. 18 11月, 2015 1 次提交
  17. 15 9月, 2015 1 次提交
    • P
      usb: chipidea: udc: using the correct stall implementation · 56ffa1d1
      Peter Chen 提交于
      According to spec, there are functional and protocol stalls.
      
      For functional stall, it is for bulk and interrupt endpoints,
      below are cases for it:
      - Host sends SET_FEATURE request for Set-Halt, the udc driver
      needs to set stall, and return true unconditionally.
      - The gadget driver may call usb_ep_set_halt to stall certain
      endpoints, if there is a transfer in pending, the udc driver
      should not set stall, and return -EAGAIN accordingly.
      These two kinds of stall need to be cleared by host using CLEAR_FEATURE
      request (Clear-Halt).
      
      For protocol stall, it is for control endpoint, this stall will
      be set if the control request has failed. This stall will be
      cleared by next setup request (hardware will do it).
      
      It fixed usbtest (drivers/usb/misc/usbtest.c) Test 13 "set/clear halt"
      test failure, meanwhile, this change has been verified by
      USB2 CV Compliance Test and MSC Tests.
      
      Cc: <stable@vger.kernel.org> #3.10+
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Cc: Felipe Balbi <balbi@ti.com>
      Signed-off-by: NPeter Chen <peter.chen@freescale.com>
      56ffa1d1
  18. 14 8月, 2015 2 次提交
  19. 05 8月, 2015 1 次提交
  20. 03 8月, 2015 1 次提交
  21. 29 7月, 2015 1 次提交
  22. 08 4月, 2015 1 次提交
    • L
      usb: chipidea: udc: bypass pullup DP when gadget connect in OTG fsm mode · 9b6567e1
      Li Jun 提交于
      By pass pullup DP in OTG fsm mode when do gadget connect, to let it handled
      by OTG state machine.
      
      This patch can fix the problem you found with my HNP polling patchset after
      below 3 patches introduced:
      467a78c8 usb: chipidea: udc: apply new usb_udc_vbus_handler interface
      628ef0d2 usb: udc: add usb_udc_vbus_handler
      dfea9c94 usb: udc: store usb_udc pointer in struct usb_gadget
      
      Problem:
      - Connect USB cable and MicroAB cable between two boards
      - Boot up two boards
      - load g_mass_storage at B-device side, the enumeration will success,
      and A will see a usb mass-storage device
      - load g_mass_storage at A-device side, the problem has occurred, the
      connection will be lost at the beginning, then connect again.
      
      This patch is based on
      commit eff933c1d3a2e046492b3dfc86db813856553a29
      (chipidea: pci: make it depends on NOP_USB_XCEIV)
      on branch peter-usb-dev of
      git://git.kernel.org/pub/scm/linux/kernel/git/peter.chen/usb.gitSigned-off-by: NLi Jun <jun.li@freescale.com>
      Signed-off-by: NPeter Chen <peter.chen@freescale.com>
      9b6567e1
  23. 20 3月, 2015 1 次提交
  24. 18 3月, 2015 2 次提交
    • S
      usb: chipidea: Add errata for revision 2.40a · 06bdfcdb
      Sanchayan Maity 提交于
      At chipidea revision 2.40a, there is a below errata:
      
      9000531823  B2-Medium  Adding a dTD to a Primed Endpoint May Not Get Recognized
      
      Title: Adding a dTD to a Primed Endpoint May Not Get Recognized
      
      Impacted Configuration: All device mode configurations.
      
      Description:
      There is an issue with the add dTD tripwire semaphore (ATDTW bit in USBCMD register)
      that can cause the controller to ignore a dTD that is added to a primed endpoint.
      When this happens, the software can read the tripwire bit and the status bit at '1'
      even though the endpoint is unprimed.
      
      After executing a dTD, the device controller endpoint state machine executes a final
      read of the dTD terminate bit to check if the application added a dTD to the linked
      list at the last moment. This read is done in the finpkt_read_latest_next_td (44) state.
      After the read is performed, if the terminate bit is still set, the state machine moves
      to unprime the endpoint. The decision to unprime the endpoint is done in the
      checkqh_decision (59) state, based on the value of the terminate bit.
      Before reaching the checkqh_decision state, the state machine traverses the
      writeqhtd_status (57), writeqh_status (56), and release_prime_mask (42) states.
      As shown in the waveform, the ep_addtd_tripwire_clr signal is not set to clear
      the tripwire bit in these states.
      
      Workaround:
      The software must implement a periodic poll cycle, and check for each dTD
      pending on execution (Active = 1), if the enpoint is primed. It can do this by reading
      the corresponding bits in the ENDPTPRIME and ENDPTSTAT registers. If these bits are
      read at 0, the software needs to re-prime the endpoint by writing 1 to the corresponding
      bit in the ENDPTPRIME register. This can be done for every microframe, every frame or
      with a larger interval, depending on the urgency of transfer execution for the application.
      Tested-by: NStefan Agner <stefan@agner.ch>
      Signed-off-by: NPeter Chen <peter.chen@freescale.com>
      Signed-off-by: NSanchayan Maity <maitysanchayan@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      06bdfcdb
    • P
      usb: chipidea: udc: return immediately if re-enable non-empty endpoint · d5d1e1be
      Peter Chen 提交于
      Some gadget driver (like uac1) will try to enable endpoint again even
      the ep is not empty, it will cause the ep reset again and may affect
      the dTD list which has already queued.
      
      It returns -EBUSY immediately, and indicate the endpoint is in use.
      In this way, the ep's behavior will not be affected, and the gadget
      driver is also notified.
      
      Cc: Xuebing Wang <xbing6@gmail.com>
      Signed-off-by: NPeter Chen <peter.chen@freescale.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d5d1e1be
  25. 15 3月, 2015 1 次提交
    • L
      usb: chipidea: otg: add a_alt_hnp_support response for B device · d20f7807
      Li Jun 提交于
      This patch adds response to a_alt_hnp_support set feature request from legacy
      A device, that is, B-device can provide a message to the user indicating that
      the user needs to connect the B-device to an alternate port on the A-device.
      A device sets this feature indicates to the B-device that it is connected
      to an A-device port that is not capable of HNP, but that the A-device does have
      an alternate port that is capable of HNP.
      
      [Peter]
      Without this patch, the OTG B device can't be enumerated on
      non-HNP port at A device, see below log:
      [    2.287464] usb 1-1: Dual-Role OTG device on non-HNP port
      [    2.293105] usb 1-1: can't set HNP mode: -32
      [    2.417422] usb 1-1: new high-speed USB device number 4 using ci_hdrc
      [    2.460635] usb 1-1: Dual-Role OTG device on non-HNP port
      [    2.466424] usb 1-1: can't set HNP mode: -32
      [    2.587464] usb 1-1: new high-speed USB device number 5 using ci_hdrc
      [    2.630649] usb 1-1: Dual-Role OTG device on non-HNP port
      [    2.636436] usb 1-1: can't set HNP mode: -32
      [    2.641003] usb usb1-port1: unable to enumerate USB device
      
      Cc: stable <stable@vger.kernel.org>
      Acked-by: NPeter Chen <peter.chen@freescale.com>
      Signed-off-by: NLi Jun <b47624@freescale.com>
      Signed-off-by: NPeter Chen <peter.chen@freescale.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d20f7807
  26. 30 1月, 2015 1 次提交
  27. 27 11月, 2014 1 次提交
  28. 11 11月, 2014 1 次提交
  29. 04 11月, 2014 1 次提交