twx-linux/include/linux/usb
Andrey Konovalov 3551ff7c5c usb: gadget: clarify usage of USB_GADGET_DELAYED_STATUS
USB_GADGET_DELAYED_STATUS was introduced in commit 1b9ba000177e ("usb:
gadget: composite: Allow function drivers to pause control transfers").
It was initially intended for the composite framework to allow delaying
completing the status stage of a SET_CONFIGURATION request until all
functions are ready.

Unfortunately, that commit had an unintended side-effect of returning
USB_GADGET_DELAYED_STATUS from the ->setup() call of the composite
framework gadget driver.

As a result of this and the incomplete documentation, some UDC drivers
started relying on USB_GADGET_DELAYED_STATUS to decide when to avoid
autocompleting the status stage for 0-length control transfers. dwc3 was
the first in commit 5bdb1dcc6330 ("usb: dwc3: ep0: handle delayed_status
again"). And a number of other UDC drivers followed later, probably
relying on the dwc3 behavior as a reference.

Unfortunately, this violated the interface between the UDC and the
gadget driver for 0-length control transfers: the UDC driver must only
proceed with the status stage for a 0-length control transfer once the
gadget driver queued a response to EP0.

As a result, a few gadget drivers are partially broken when used with
a UDC that only delays the status stage for 0-length transfers when
USB_GADGET_DELAYED_STATUS is returned from the setup() callback.

This includes Raw Gadget and GadgetFS. For FunctionFS, a workaround was
added in commit 946ef68ad4e4 ("usb: gadget: ffs: Let setup() return
USB_GADGET_DELAYED_STATUS") and commit 4d644abf2569 ("usb: gadget: f_fs:
Only return delayed status when len is 0").

The proper solution to this issue would be to contain
USB_GADGET_DELAYED_STATUS within the composite framework and make all
UDC drivers to not complete the status stage for 0-length requests on
their own.

Unfortunately, there is quite a few UDC drivers that need to get fixed
and the required changes for some of them are not trivial.

For now, update the comments to clarify that USB_GADGET_DELAYED_STATUS
must not be used by the UDC drivers.

The following two commits also add workarounds to Raw Gadget and GadgetFS
to make them compatible with the broken UDC drivers until they are fixed.

Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Andrey Konovalov <andreyknvl@gmail.com>
Link: https://lore.kernel.org/r/7f0ee06c68c7241c844cd50f8565fdd5ead79b1b.1693237258.git.andreyknvl@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-10-02 16:43:04 +02:00
..
audio-v2.h
audio-v3.h
audio.h
c67x00.h
ccid.h
cdc_ncm.h
cdc-wdm.h
cdc.h
ch9.h USB: Remove remnants of Wireless USB and UWB 2023-08-09 14:17:06 +02:00
chipidea.h usb: chipidea: add workaround for chipidea PEC bug 2023-08-09 14:16:06 +02:00
composite.h usb: gadget: clarify usage of USB_GADGET_DELAYED_STATUS 2023-10-02 16:43:04 +02:00
ehci_def.h
ehci_pdriver.h
ehci-dbgp.h
ezusb.h
functionfs.h
g_hid.h
gadget_configfs.h
gadget.h usb: gadget: clarify usage of USB_GADGET_DELAYED_STATUS 2023-10-02 16:43:04 +02:00
hcd.h usb: pci-quirks: handle HAS_IOPORT dependency for AMD quirk 2023-10-02 16:19:12 +02:00
input.h
iowarrior.h
irda.h
isp116x.h
isp1301.h
isp1362.h
m66592.h
midi-v2.h ALSA: usb-audio: Use __le16 for 16bit USB descriptor fields 2023-06-05 16:48:54 +02:00
musb-ux500.h
musb.h ARM/musb: omap2: Remove global GPIO numbers from TUSB6010 2023-05-24 15:01:59 +02:00
net2280.h
of.h
ohci_pdriver.h
onboard_hub.h
otg-fsm.h
otg.h
pd_ado.h
pd_bdo.h
pd_ext_sdb.h
pd_vdo.h usb: pd: Add helper macro to get Type C cable speed 2023-10-02 13:58:59 +02:00
pd.h usb: pd: Exposing the Peak Current value of Fixed Supplies to user space 2023-10-02 16:38:29 +02:00
phy_companion.h
phy.h usb: phy: add usb phy notify port status API 2023-07-26 06:38:14 +02:00
quirks.h
r8a66597.h
r8152.h r8152: add vendor/device ID pair for D-Link DUB-E250 2023-08-28 12:53:40 -07:00
renesas_usbhs.h usb: renesas_usbhs: remove boilerplate from header file 2023-10-02 13:57:07 +02:00
rndis_host.h
role.h Revert "usb: common: usb-conn-gpio: Set last role to unknown before initial detection" 2023-06-15 11:30:35 +02:00
rzv2m_usb3drd.h
serial.h USB: serial: return errors from break handling 2023-06-07 17:00:23 +02:00
sl811.h
storage.h
tcpci.h usb: typec: tcpci: clear the fault status bit 2023-08-22 14:44:52 +02:00
tcpm.h
tegra_usb_phy.h
typec_altmode.h usb: typec: bus: verify partner exists in typec_altmode_attention 2023-08-22 14:44:28 +02:00
typec_dp.h usb: typec: Add Displayport Alternate Mode 2.1 Support 2023-10-02 13:58:58 +02:00
typec_mux.h usb: typec: mux: fix static inline syntax error 2023-06-01 07:09:45 +01:00
typec_retimer.h
typec_tbt.h usb: typec: Add Active or Passive cable defination to cable discover mode VDO 2023-10-02 13:58:59 +02:00
typec.h
uas.h
ulpi.h
usb338x.h
usb_phy_generic.h
usbnet.h
uvc.h
webusb.h
xhci-dbgp.h