Skip to content

Commit d51a76b

Browse files
larsclausenZhengShunQian
authored andcommitted
usb: gadget: ffs: Let setup() return USB_GADGET_DELAYED_STATUS
[ Upstream commit 946ef68 ] Some UDC drivers (like the DWC3) expect that the response to a setup() request is queued from within the setup function itself so that it is available as soon as setup() has completed. Upon receiving a setup request the function fs driver creates an event that is made available to userspace. And only once userspace has acknowledged that event the response to the setup request is queued. So it violates the requirement of those UDC drivers and random failures can be observed. This is basically a race condition and if userspace is able to read the event and queue the response fast enough all is good. But if it is not, for example because other processes are currently scheduled to run, the USB host that sent the setup request will observe an error. To avoid this the gadget framework provides the USB_GADGET_DELAYED_STATUS return code. If a setup() callback returns this value the UDC driver is aware that response is not yet available and can uses the appropriate methods to handle this case. Since in the case of function fs the response will never be available when the setup() function returns make sure that this status code is used. This fixed random occasional failures that were previously observed on a DWC3 based system under high system load. Signed-off-by: Lars-Peter Clausen <[email protected]> Signed-off-by: Felipe Balbi <[email protected]> Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 553f62e commit d51a76b

File tree

1 file changed

+1
-1
lines changed
  • drivers/usb/gadget/function

1 file changed

+1
-1
lines changed

drivers/usb/gadget/function/f_fs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3020,7 +3020,7 @@ static int ffs_func_setup(struct usb_function *f,
30203020
__ffs_event_add(ffs, FUNCTIONFS_SETUP);
30213021
spin_unlock_irqrestore(&ffs->ev.waitq.lock, flags);
30223022

3023-
return 0;
3023+
return USB_GADGET_DELAYED_STATUS;
30243024
}
30253025

30263026
static void ffs_func_suspend(struct usb_function *f)

0 commit comments

Comments
 (0)