1. 27 7月, 2021 2 次提交
  2. 21 7月, 2021 2 次提交
  3. 12 7月, 2021 2 次提交
  4. 21 6月, 2021 1 次提交
  5. 15 6月, 2021 1 次提交
    • P
      usb: dwc3: core: fix kernel panic when do reboot · 4bf584a0
      Peter Chen 提交于
      When do system reboot, it calls dwc3_shutdown and the whole debugfs
      for dwc3 has removed first, when the gadget tries to do deinit, and
      remove debugfs for its endpoints, it meets NULL pointer dereference
      issue when call debugfs_lookup. Fix it by removing the whole dwc3
      debugfs later than dwc3_drd_exit.
      
      [ 2924.958838] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000002
      ....
      [ 2925.030994] pstate: 60000005 (nZCv daif -PAN -UAO -TCO BTYPE=--)
      [ 2925.037005] pc : inode_permission+0x2c/0x198
      [ 2925.041281] lr : lookup_one_len_common+0xb0/0xf8
      [ 2925.045903] sp : ffff80001276ba70
      [ 2925.049218] x29: ffff80001276ba70 x28: ffff0000c01f0000 x27: 0000000000000000
      [ 2925.056364] x26: ffff800011791e70 x25: 0000000000000008 x24: dead000000000100
      [ 2925.063510] x23: dead000000000122 x22: 0000000000000000 x21: 0000000000000001
      [ 2925.070652] x20: ffff8000122c6188 x19: 0000000000000000 x18: 0000000000000000
      [ 2925.077797] x17: 0000000000000000 x16: 0000000000000000 x15: 0000000000000004
      [ 2925.084943] x14: ffffffffffffffff x13: 0000000000000000 x12: 0000000000000030
      [ 2925.092087] x11: 0101010101010101 x10: 7f7f7f7f7f7f7f7f x9 : ffff8000102b2420
      [ 2925.099232] x8 : 7f7f7f7f7f7f7f7f x7 : feff73746e2f6f64 x6 : 0000000000008080
      [ 2925.106378] x5 : 61c8864680b583eb x4 : 209e6ec2d263dbb7 x3 : 000074756f307065
      [ 2925.113523] x2 : 0000000000000001 x1 : 0000000000000000 x0 : ffff8000122c6188
      [ 2925.120671] Call trace:
      [ 2925.123119]  inode_permission+0x2c/0x198
      [ 2925.127042]  lookup_one_len_common+0xb0/0xf8
      [ 2925.131315]  lookup_one_len_unlocked+0x34/0xb0
      [ 2925.135764]  lookup_positive_unlocked+0x14/0x50
      [ 2925.140296]  debugfs_lookup+0x68/0xa0
      [ 2925.143964]  dwc3_gadget_free_endpoints+0x84/0xb0
      [ 2925.148675]  dwc3_gadget_exit+0x28/0x78
      [ 2925.152518]  dwc3_drd_exit+0x100/0x1f8
      [ 2925.156267]  dwc3_remove+0x11c/0x120
      [ 2925.159851]  dwc3_shutdown+0x14/0x20
      [ 2925.163432]  platform_shutdown+0x28/0x38
      [ 2925.167360]  device_shutdown+0x15c/0x378
      [ 2925.171291]  kernel_restart_prepare+0x3c/0x48
      [ 2925.175650]  kernel_restart+0x1c/0x68
      [ 2925.179316]  __do_sys_reboot+0x218/0x240
      [ 2925.183247]  __arm64_sys_reboot+0x28/0x30
      [ 2925.187262]  invoke_syscall+0x48/0x100
      [ 2925.191017]  el0_svc_common.constprop.0+0x48/0xc8
      [ 2925.195726]  do_el0_svc+0x28/0x88
      [ 2925.199045]  el0_svc+0x20/0x30
      [ 2925.202104]  el0_sync_handler+0xa8/0xb0
      [ 2925.205942]  el0_sync+0x148/0x180
      [ 2925.209270] Code: a9025bf5 2a0203f5 121f0056 370802b5 (79400660)
      [ 2925.215372] ---[ end trace 124254d8e485a58b ]---
      [ 2925.220012] Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b
      [ 2925.227676] Kernel Offset: disabled
      [ 2925.231164] CPU features: 0x00001001,20000846
      [ 2925.235521] Memory Limit: none
      [ 2925.238580] ---[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b ]---
      
      Fixes: 8d396bb0 ("usb: dwc3: debugfs: Add and remove endpoint dirs dynamically")
      Cc: Jack Pham <jackp@codeaurora.org>
      Tested-by: NJack Pham <jackp@codeaurora.org>
      Signed-off-by: NPeter Chen <peter.chen@kernel.org>
      Link: https://lore.kernel.org/r/20210608105656.10795-1-peter.chen@kernel.org
      (cherry picked from commit 2a042767)
      Link: https://lore.kernel.org/r/20210615080847.GA10432@jackp-linux.qualcomm.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4bf584a0
  6. 11 6月, 2021 1 次提交
  7. 09 6月, 2021 3 次提交
    • S
      usb: dwc3: support 64 bit DMA in platform driver · 45d39448
      Sven Peter 提交于
      Currently, the dwc3 platform driver does not explicitly ask for
      a DMA mask. This makes it fall back to the default 32-bit mask which
      breaks the driver on systems that only have RAM starting above the
      first 4G like the Apple M1 SoC.
      
      Fix this by calling dma_set_mask_and_coherent with a 64bit mask.
      Reviewed-by: NArnd Bergmann <arnd@arndb.de>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NSven Peter <sven@svenpeter.dev>
      Link: https://lore.kernel.org/r/20210607061751.89752-1-sven@svenpeter.devSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      45d39448
    • P
      usb: dwc3: core: fix kernel panic when do reboot · 2a042767
      Peter Chen 提交于
      When do system reboot, it calls dwc3_shutdown and the whole debugfs
      for dwc3 has removed first, when the gadget tries to do deinit, and
      remove debugfs for its endpoints, it meets NULL pointer dereference
      issue when call debugfs_lookup. Fix it by removing the whole dwc3
      debugfs later than dwc3_drd_exit.
      
      [ 2924.958838] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000002
      ....
      [ 2925.030994] pstate: 60000005 (nZCv daif -PAN -UAO -TCO BTYPE=--)
      [ 2925.037005] pc : inode_permission+0x2c/0x198
      [ 2925.041281] lr : lookup_one_len_common+0xb0/0xf8
      [ 2925.045903] sp : ffff80001276ba70
      [ 2925.049218] x29: ffff80001276ba70 x28: ffff0000c01f0000 x27: 0000000000000000
      [ 2925.056364] x26: ffff800011791e70 x25: 0000000000000008 x24: dead000000000100
      [ 2925.063510] x23: dead000000000122 x22: 0000000000000000 x21: 0000000000000001
      [ 2925.070652] x20: ffff8000122c6188 x19: 0000000000000000 x18: 0000000000000000
      [ 2925.077797] x17: 0000000000000000 x16: 0000000000000000 x15: 0000000000000004
      [ 2925.084943] x14: ffffffffffffffff x13: 0000000000000000 x12: 0000000000000030
      [ 2925.092087] x11: 0101010101010101 x10: 7f7f7f7f7f7f7f7f x9 : ffff8000102b2420
      [ 2925.099232] x8 : 7f7f7f7f7f7f7f7f x7 : feff73746e2f6f64 x6 : 0000000000008080
      [ 2925.106378] x5 : 61c8864680b583eb x4 : 209e6ec2d263dbb7 x3 : 000074756f307065
      [ 2925.113523] x2 : 0000000000000001 x1 : 0000000000000000 x0 : ffff8000122c6188
      [ 2925.120671] Call trace:
      [ 2925.123119]  inode_permission+0x2c/0x198
      [ 2925.127042]  lookup_one_len_common+0xb0/0xf8
      [ 2925.131315]  lookup_one_len_unlocked+0x34/0xb0
      [ 2925.135764]  lookup_positive_unlocked+0x14/0x50
      [ 2925.140296]  debugfs_lookup+0x68/0xa0
      [ 2925.143964]  dwc3_gadget_free_endpoints+0x84/0xb0
      [ 2925.148675]  dwc3_gadget_exit+0x28/0x78
      [ 2925.152518]  dwc3_drd_exit+0x100/0x1f8
      [ 2925.156267]  dwc3_remove+0x11c/0x120
      [ 2925.159851]  dwc3_shutdown+0x14/0x20
      [ 2925.163432]  platform_shutdown+0x28/0x38
      [ 2925.167360]  device_shutdown+0x15c/0x378
      [ 2925.171291]  kernel_restart_prepare+0x3c/0x48
      [ 2925.175650]  kernel_restart+0x1c/0x68
      [ 2925.179316]  __do_sys_reboot+0x218/0x240
      [ 2925.183247]  __arm64_sys_reboot+0x28/0x30
      [ 2925.187262]  invoke_syscall+0x48/0x100
      [ 2925.191017]  el0_svc_common.constprop.0+0x48/0xc8
      [ 2925.195726]  do_el0_svc+0x28/0x88
      [ 2925.199045]  el0_svc+0x20/0x30
      [ 2925.202104]  el0_sync_handler+0xa8/0xb0
      [ 2925.205942]  el0_sync+0x148/0x180
      [ 2925.209270] Code: a9025bf5 2a0203f5 121f0056 370802b5 (79400660)
      [ 2925.215372] ---[ end trace 124254d8e485a58b ]---
      [ 2925.220012] Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b
      [ 2925.227676] Kernel Offset: disabled
      [ 2925.231164] CPU features: 0x00001001,20000846
      [ 2925.235521] Memory Limit: none
      [ 2925.238580] ---[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b ]---
      
      Fixes: 5ff90af9 ("usb: dwc3: debugfs: Add and remove endpoint dirs dynamically")
      Cc: Jack Pham <jackp@codeaurora.org>
      Tested-by: NJack Pham <jackp@codeaurora.org>
      Signed-off-by: NPeter Chen <peter.chen@kernel.org>
      Link: https://lore.kernel.org/r/20210608105656.10795-1-peter.chen@kernel.orgSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2a042767
    • M
      usb: dwc3: ep0: fix NULL pointer exception · d0088908
      Marian-Cristian Rotariu 提交于
      There is no validation of the index from dwc3_wIndex_to_dep() and we might
      be referring a non-existing ep and trigger a NULL pointer exception. In
      certain configurations we might use fewer eps and the index might wrongly
      indicate a larger ep index than existing.
      
      By adding this validation from the patch we can actually report a wrong
      index back to the caller.
      
      In our usecase we are using a composite device on an older kernel, but
      upstream might use this fix also. Unfortunately, I cannot describe the
      hardware for others to reproduce the issue as it is a proprietary
      implementation.
      
      [   82.958261] Unable to handle kernel NULL pointer dereference at virtual address 00000000000000a4
      [   82.966891] Mem abort info:
      [   82.969663]   ESR = 0x96000006
      [   82.972703]   Exception class = DABT (current EL), IL = 32 bits
      [   82.978603]   SET = 0, FnV = 0
      [   82.981642]   EA = 0, S1PTW = 0
      [   82.984765] Data abort info:
      [   82.987631]   ISV = 0, ISS = 0x00000006
      [   82.991449]   CM = 0, WnR = 0
      [   82.994409] user pgtable: 4k pages, 39-bit VAs, pgdp = 00000000c6210ccc
      [   83.000999] [00000000000000a4] pgd=0000000053aa5003, pud=0000000053aa5003, pmd=0000000000000000
      [   83.009685] Internal error: Oops: 96000006 [#1] PREEMPT SMP
      [   83.026433] Process irq/62-dwc3 (pid: 303, stack limit = 0x000000003985154c)
      [   83.033470] CPU: 0 PID: 303 Comm: irq/62-dwc3 Not tainted 4.19.124 #1
      [   83.044836] pstate: 60000085 (nZCv daIf -PAN -UAO)
      [   83.049628] pc : dwc3_ep0_handle_feature+0x414/0x43c
      [   83.054558] lr : dwc3_ep0_interrupt+0x3b4/0xc94
      
      ...
      
      [   83.141788] Call trace:
      [   83.144227]  dwc3_ep0_handle_feature+0x414/0x43c
      [   83.148823]  dwc3_ep0_interrupt+0x3b4/0xc94
      [   83.181546] ---[ end trace aac6b5267d84c32f ]---
      Signed-off-by: NMarian-Cristian Rotariu <marian.c.rotariu@gmail.com>
      Cc: stable <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20210608162650.58426-1-marian.c.rotariu@gmail.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d0088908
  8. 04 6月, 2021 4 次提交
    • N
      usb: dwc3-meson-g12a: fix usb2 PHY glue init when phy0 is disabled · 4d2aa178
      Neil Armstrong 提交于
      When only PHY1 is used (for example on Odroid-HC4), the regmap init code
      uses the usb2 ports when doesn't initialize the PHY1 regmap entry.
      
      This fixes:
      Unable to handle kernel NULL pointer dereference at virtual address 0000000000000020
      ...
      pc : regmap_update_bits_base+0x40/0xa0
      lr : dwc3_meson_g12a_usb2_init_phy+0x4c/0xf8
      ...
      Call trace:
      regmap_update_bits_base+0x40/0xa0
      dwc3_meson_g12a_usb2_init_phy+0x4c/0xf8
      dwc3_meson_g12a_usb2_init+0x7c/0xc8
      dwc3_meson_g12a_usb_init+0x28/0x48
      dwc3_meson_g12a_probe+0x298/0x540
      platform_probe+0x70/0xe0
      really_probe+0xf0/0x4d8
      driver_probe_device+0xfc/0x168
      ...
      
      Fixes: 013af227 ("usb: dwc3: meson-g12a: handle the phy and glue registers separately")
      Reviewed-by: NMartin Blumenstingl <martin.blumenstingl@googlemail.com>
      Signed-off-by: NNeil Armstrong <narmstrong@baylibre.com>
      Cc: stable <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20210601084830.260196-1-narmstrong@baylibre.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4d2aa178
    • C
      usb: dwc3: meson-g12a: Disable the regulator in the error handling path of the probe · 1d0d3d81
      Christophe JAILLET 提交于
      If an error occurs after a successful 'regulator_enable()' call,
      'regulator_disable()' must be called.
      
      Fix the error handling path of the probe accordingly.
      
      The remove function doesn't need to be fixed, because the
      'regulator_disable()' call is already hidden in 'dwc3_meson_g12a_suspend()'
      which is called via 'pm_runtime_set_suspended()' in the remove function.
      
      Fixes: c9999337 ("usb: dwc3: Add Amlogic G12A DWC3 glue")
      Reviewed-by: NMartin Blumenstingl <martin.blumenstingl@googlemail.com>
      Acked-by: NNeil Armstrong <narmstrong@baylibre.com>
      Signed-off-by: NChristophe JAILLET <christophe.jaillet@wanadoo.fr>
      Link: https://lore.kernel.org/r/79df054046224bbb0716a8c5c2082650290eec86.1621616013.git.christophe.jaillet@wanadoo.fr
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1d0d3d81
    • A
      Revert "usb: dwc3: core: Add shutdown callback for dwc3" · 8f11fe7e
      Alexandru Elisei 提交于
      This reverts commit 568262bf.
      
      The commit causes the following panic when shutting down a rockpro64-v2
      board:
      
      [..]
      [   41.684569] xhci-hcd xhci-hcd.2.auto: USB bus 1 deregistered
      [   41.686301] Unable to handle kernel NULL pointer dereference at virtual address 00000000000000a0
      [   41.687096] Mem abort info:
      [   41.687345]   ESR = 0x96000004
      [   41.687615]   EC = 0x25: DABT (current EL), IL = 32 bits
      [   41.688082]   SET = 0, FnV = 0
      [   41.688352]   EA = 0, S1PTW = 0
      [   41.688628] Data abort info:
      [   41.688882]   ISV = 0, ISS = 0x00000004
      [   41.689219]   CM = 0, WnR = 0
      [   41.689481] user pgtable: 4k pages, 48-bit VAs, pgdp=00000000073b2000
      [   41.690046] [00000000000000a0] pgd=0000000000000000, p4d=0000000000000000
      [   41.690654] Internal error: Oops: 96000004 [#1] PREEMPT SMP
      [   41.691143] Modules linked in:
      [   41.691416] CPU: 5 PID: 1 Comm: shutdown Not tainted 5.13.0-rc4 #43
      [   41.691966] Hardware name: Pine64 RockPro64 v2.0 (DT)
      [   41.692409] pstate: 60000005 (nZCv daif -PAN -UAO -TCO BTYPE=--)
      [   41.692937] pc : down_read_interruptible+0xec/0x200
      [   41.693373] lr : simple_recursive_removal+0x48/0x280
      [   41.693815] sp : ffff800011fab910
      [   41.694107] x29: ffff800011fab910 x28: ffff0000008fe480 x27: ffff0000008fe4d8
      [   41.694736] x26: ffff800011529a90 x25: 00000000000000a0 x24: ffff800011edd030
      [   41.695364] x23: 0000000000000080 x22: 0000000000000000 x21: ffff800011f23994
      [   41.695992] x20: ffff800011f23998 x19: ffff0000008fe480 x18: ffffffffffffffff
      [   41.696620] x17: 000c0400bb44ffff x16: 0000000000000009 x15: ffff800091faba3d
      [   41.697248] x14: 0000000000000004 x13: 0000000000000000 x12: 0000000000000020
      [   41.697875] x11: 0101010101010101 x10: 7f7f7f7f7f7f7f7f x9 : 6f6c746364716e62
      [   41.698502] x8 : 7f7f7f7f7f7f7f7f x7 : fefefeff6364626d x6 : 0000000000000440
      [   41.699130] x5 : 0000000000000000 x4 : 0000000000000000 x3 : 00000000000000a0
      [   41.699758] x2 : 0000000000000001 x1 : 0000000000000000 x0 : 00000000000000a0
      [   41.700386] Call trace:
      [   41.700602]  down_read_interruptible+0xec/0x200
      [   41.701003]  debugfs_remove+0x5c/0x80
      [   41.701328]  dwc3_debugfs_exit+0x1c/0x6c
      [   41.701676]  dwc3_remove+0x34/0x1a0
      [   41.701988]  platform_remove+0x28/0x60
      [   41.702322]  __device_release_driver+0x188/0x22c
      [   41.702730]  device_release_driver+0x2c/0x44
      [   41.703106]  bus_remove_device+0x124/0x130
      [   41.703468]  device_del+0x16c/0x424
      [   41.703777]  platform_device_del.part.0+0x1c/0x90
      [   41.704193]  platform_device_unregister+0x28/0x44
      [   41.704608]  of_platform_device_destroy+0xe8/0x100
      [   41.705031]  device_for_each_child_reverse+0x64/0xb4
      [   41.705470]  of_platform_depopulate+0x40/0x84
      [   41.705853]  __dwc3_of_simple_teardown+0x20/0xd4
      [   41.706260]  dwc3_of_simple_shutdown+0x14/0x20
      [   41.706652]  platform_shutdown+0x28/0x40
      [   41.706998]  device_shutdown+0x158/0x330
      [   41.707344]  kernel_power_off+0x38/0x7c
      [   41.707684]  __do_sys_reboot+0x16c/0x2a0
      [   41.708029]  __arm64_sys_reboot+0x28/0x34
      [   41.708383]  invoke_syscall+0x48/0x114
      [   41.708716]  el0_svc_common.constprop.0+0x44/0xdc
      [   41.709131]  do_el0_svc+0x28/0x90
      [   41.709426]  el0_svc+0x2c/0x54
      [   41.709698]  el0_sync_handler+0xa4/0x130
      [   41.710045]  el0_sync+0x198/0x1c0
      [   41.710342] Code: c8047c62 35ffff84 17fffe5f f9800071 (c85ffc60)
      [   41.710881] ---[ end trace 406377df5178f75c ]---
      [   41.711299] Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b
      [   41.712084] Kernel Offset: disabled
      [   41.712391] CPU features: 0x10001031,20000846
      [   41.712775] Memory Limit: none
      [   41.713049] ---[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b ]---
      
      As Felipe explained: "dwc3_shutdown() is just called dwc3_remove()
      directly, then we end up calling debugfs_remove_recursive() twice."
      
      Reverting the commit fixes the panic.
      
      Fixes: 568262bf ("usb: dwc3: core: Add shutdown callback for dwc3")
      Acked-by: NFelipe Balbi <balbi@kernel.org>
      Signed-off-by: NAlexandru Elisei <alexandru.elisei@arm.com>
      Link: https://lore.kernel.org/r/20210603151742.298243-1-alexandru.elisei@arm.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8f11fe7e
    • J
      usb: dwc3: debugfs: Add and remove endpoint dirs dynamically · 8d396bb0
      Jack Pham 提交于
      The DWC3 DebugFS directory and files are currently created once
      during probe.  This includes creation of subdirectories for each
      of the gadget's endpoints.  This works fine for peripheral-only
      controllers, as dwc3_core_init_mode() calls dwc3_gadget_init()
      just prior to calling dwc3_debugfs_init().
      
      However, for dual-role controllers, dwc3_core_init_mode() will
      instead call dwc3_drd_init() which is problematic in a few ways.
      First, the initial state must be determined, then dwc3_set_mode()
      will have to schedule drd_work and by then dwc3_debugfs_init()
      could have already been invoked.  Even if the initial mode is
      peripheral, dwc3_gadget_init() happens after the DebugFS files
      are created, and worse so if the initial state is host and the
      controller switches to peripheral much later.  And secondly,
      even if the gadget endpoints' debug entries were successfully
      created, if the controller exits peripheral mode, its dwc3_eps
      are freed so the debug files would now hold stale references.
      
      So it is best if the DebugFS endpoint entries are created and
      removed dynamically at the same time the underlying dwc3_eps are.
      Do this by calling dwc3_debugfs_create_endpoint_dir() as each
      endpoint is created, and conversely remove the DebugFS entry when
      the endpoint is freed.
      
      Fixes: 41ce1456 ("usb: dwc3: core: make dwc3_set_mode() work properly")
      Cc: stable <stable@vger.kernel.org>
      Reviewed-by: NPeter Chen <peter.chen@kernel.org>
      Signed-off-by: NJack Pham <jackp@codeaurora.org>
      Link: https://lore.kernel.org/r/20210529192932.22912-1-jackp@codeaurora.orgSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8d396bb0
  9. 02 6月, 2021 3 次提交
    • J
      usb: dwc3: gadget: Bail from dwc3_gadget_exit() if dwc->gadget is NULL · 03715ea2
      Jack Pham 提交于
      There exists a possible scenario in which dwc3_gadget_init() can fail:
      during during host -> peripheral mode switch in dwc3_set_mode(), and
      a pending gadget driver fails to bind.  Then, if the DRD undergoes
      another mode switch from peripheral->host the resulting
      dwc3_gadget_exit() will attempt to reference an invalid and dangling
      dwc->gadget pointer as well as call dma_free_coherent() on unmapped
      DMA pointers.
      
      The exact scenario can be reproduced as follows:
       - Start DWC3 in peripheral mode
       - Configure ConfigFS gadget with FunctionFS instance (or use g_ffs)
       - Run FunctionFS userspace application (open EPs, write descriptors, etc)
       - Bind gadget driver to DWC3's UDC
       - Switch DWC3 to host mode
         => dwc3_gadget_exit() is called. usb_del_gadget() will put the
      	ConfigFS driver instance on the gadget_driver_pending_list
       - Stop FunctionFS application (closes the ep files)
       - Switch DWC3 to peripheral mode
         => dwc3_gadget_init() fails as usb_add_gadget() calls
      	check_pending_gadget_drivers() and attempts to rebind the UDC
      	to the ConfigFS gadget but fails with -19 (-ENODEV) because the
      	FFS instance is not in FFS_ACTIVE state (userspace has not
      	re-opened and written the descriptors yet, i.e. desc_ready!=0).
       - Switch DWC3 back to host mode
         => dwc3_gadget_exit() is called again, but this time dwc->gadget
      	is invalid.
      
      Although it can be argued that userspace should take responsibility
      for ensuring that the FunctionFS application be ready prior to
      allowing the composite driver bind to the UDC, failure to do so
      should not result in a panic from the kernel driver.
      
      Fix this by setting dwc->gadget to NULL in the failure path of
      dwc3_gadget_init() and add a check to dwc3_gadget_exit() to bail out
      unless the gadget pointer is valid.
      
      Fixes: e81a7018 ("usb: dwc3: allocate gadget structure dynamically")
      Cc: <stable@vger.kernel.org>
      Reviewed-by: NPeter Chen <peter.chen@kernel.org>
      Signed-off-by: NJack Pham <jackp@codeaurora.org>
      Link: https://lore.kernel.org/r/20210528160405.17550-1-jackp@codeaurora.orgSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      03715ea2
    • W
      usb: dwc3: gadget: Disable gadget IRQ during pullup disable · 82129373
      Wesley Cheng 提交于
      Current sequence utilizes dwc3_gadget_disable_irq() alongside
      synchronize_irq() to ensure that no further DWC3 events are generated.
      However, the dwc3_gadget_disable_irq() API only disables device
      specific events.  Endpoint events can still be generated.  Briefly
      disable the interrupt line, so that the cleanup code can run to
      prevent device and endpoint events. (i.e. __dwc3_gadget_stop() and
      dwc3_stop_active_transfers() respectively)
      
      Without doing so, it can lead to both the interrupt handler and the
      pullup disable routine both writing to the GEVNTCOUNT register, which
      will cause an incorrect count being read from future interrupts.
      
      Fixes: ae7e8610 ("usb: dwc3: Stop active transfers before halting the controller")
      Signed-off-by: NWesley Cheng <wcheng@codeaurora.org>
      Link: https://lore.kernel.org/r/1621571037-1424-1-git-send-email-wcheng@codeaurora.orgSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      82129373
    • J
      usb: dwc3: debugfs: Add and remove endpoint dirs dynamically · 5ff90af9
      Jack Pham 提交于
      The DWC3 DebugFS directory and files are currently created once
      during probe.  This includes creation of subdirectories for each
      of the gadget's endpoints.  This works fine for peripheral-only
      controllers, as dwc3_core_init_mode() calls dwc3_gadget_init()
      just prior to calling dwc3_debugfs_init().
      
      However, for dual-role controllers, dwc3_core_init_mode() will
      instead call dwc3_drd_init() which is problematic in a few ways.
      First, the initial state must be determined, then dwc3_set_mode()
      will have to schedule drd_work and by then dwc3_debugfs_init()
      could have already been invoked.  Even if the initial mode is
      peripheral, dwc3_gadget_init() happens after the DebugFS files
      are created, and worse so if the initial state is host and the
      controller switches to peripheral much later.  And secondly,
      even if the gadget endpoints' debug entries were successfully
      created, if the controller exits peripheral mode, its dwc3_eps
      are freed so the debug files would now hold stale references.
      
      So it is best if the DebugFS endpoint entries are created and
      removed dynamically at the same time the underlying dwc3_eps are.
      Do this by calling dwc3_debugfs_create_endpoint_dir() as each
      endpoint is created, and conversely remove the DebugFS entry when
      the endpoint is freed.
      
      Fixes: 41ce1456 ("usb: dwc3: core: make dwc3_set_mode() work properly")
      Reviewed-by: NPeter Chen <peter.chen@kernel.org>
      Signed-off-by: NJack Pham <jackp@codeaurora.org>
      Link: https://lore.kernel.org/r/20210529192932.22912-1-jackp@codeaurora.orgSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5ff90af9
  10. 27 5月, 2021 1 次提交
  11. 21 5月, 2021 1 次提交
  12. 13 5月, 2021 1 次提交
  13. 10 5月, 2021 10 次提交
  14. 23 4月, 2021 2 次提交
  15. 22 4月, 2021 3 次提交
  16. 14 4月, 2021 3 次提交