linux/drivers/usb
Jack Pham 505d41dcf1 FROMGIT: usb: dwc3: debugfs: Add and remove endpoint dirs dynamically
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: 41ce1456e1 ("usb: dwc3: core: make dwc3_set_mode() work properly")
Cc: stable <stable@vger.kernel.org>
Reviewed-by: Peter Chen <peter.chen@kernel.org>
Signed-off-by: Jack Pham <jackp@codeaurora.org>
Link: https://lore.kernel.org/r/20210529192932.22912-1-jackp@codeaurora.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 8d396bb0a5
 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-next)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I9fd3416cbec6722f1ab1dac95c225aec6136a135
2021-06-07 06:15:04 +00:00
..
atm
c67x00
cdns3 usb: cdns3: fix NULL pointer dereference on no platform data 2021-03-11 14:17:26 +01:00
chipidea usb: chipidea: ci_hdrc_imx: add missing put_device() call in usbmisc_get_init_data() 2021-01-12 20:18:19 +01:00
class cdc-wdm: untangle a circular dependency between callback and softint 2021-05-19 10:13:16 +02:00
common FROMGIT: usb: common: move function's kerneldoc next to its definition 2021-03-08 16:15:00 +01:00
core Merge 5.10.42 into android12-5.10 2021-06-03 18:47:38 +02:00
dwc2 usb: dwc2: Fix gadget DMA unmap direction 2021-05-19 10:13:15 +02:00
dwc3 FROMGIT: usb: dwc3: debugfs: Add and remove endpoint dirs dynamically 2021-06-07 06:15:04 +00:00
early usb: early: ehci-dbgp: convert to readl_poll_timeout_atomic() 2020-09-25 16:29:09 +02:00
gadget FROMGIT: usb: gadget: f_fs: Ensure io_completion_wq is idle during unbind 2021-06-04 14:50:06 +00:00
host UPSTREAM: xhci: Fix 5.12 regression of missing xHC cache clearing command after a Stall 2021-05-30 13:59:45 +02:00
image USB: microtek: use set_host_byte() 2020-09-16 12:42:10 +02:00
isp1760 usb: isp1760-hcd: convert to readl_poll_timeout_atomic() 2020-09-25 16:30:05 +02:00
misc USB: trancevibrator: fix control-request direction 2021-06-03 09:00:34 +02:00
mon
mtu3 usb: mtu3: fix memory corruption in mtu3_debugfs_regset() 2020-12-26 16:02:38 +01:00
musb usb: musb: Fix an error message 2021-05-19 10:13:13 +02:00
phy usb: phy: phy-ab8500-usb: fix spello of "function" 2020-10-02 09:57:41 +03:00
renesas_usbhs usb: renesas_usbhs: Clear PIPECFG for re-enabling pipe with other EPNUM 2021-03-17 17:06:29 +01:00
roles usb: roles: Call try_module_get() from usb_role_switch_find_by_fwnode() 2021-05-14 09:49:55 +02:00
serial USB: serial: pl2303: add device id for ADLINK ND-6530 GC 2021-06-03 09:00:35 +02:00
storage usb-storage: Add quirk to defeat Kindle's automatic unload 2021-03-25 09:04:14 +01:00
typec FROMGIT: usb: typec: tcpm: Correct the responses in SVDM Version 2.0 DFP 2021-06-07 06:12:48 +00:00
usbip usbip: vudc: fix missing unlock on error in usbip_sockfd_store() 2021-05-14 09:50:19 +02:00
Kconfig
Makefile
usb-skeleton.c