Take g_ncm for instance. It enqueues a few BULK URBs on receive side and
an INTR URB. Now we remove the g_ncm module. This starts with
usb_gadget_disconnect() which disables the UDC. Now lets say the timer
expires and dummy_timer() is invoked. It can't find a pair between the
UDC endpoint and URB's address in find_endpoint() because the
is_active() is no longer true. So we start a cleanup of URBs.
The BULK URBs usually don't make a scene. They re-submit the complete
queue length in BH so we have a little time in between. The INTR URB is
more evil because usbnet's intr_complete() causes to re-submitt it
immediately. That means we hardly do any progress and end up in a
busy loop.
This patch changes the status code for URBs which can not be assigned to
an endpoint (because the UDC is in pulldown) are now given back with
-ESHUTDOWN. The BULK endpoints in ncm are re-submitted in batches of 10
in BH but the INTR URB will never be re-submitted. This gives us somes
air to make some progress and remove the gadget.

An alternative approach would be to not accept any new URBs once the
port is not active. Something similar is already done on the UDC side.

Signed-off-by: Sebastian Andrzej Siewior <[email protected]>
---
 drivers/usb/gadget/dummy_hcd.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c
index afdbb1c..dfb2f0d 100644
--- a/drivers/usb/gadget/dummy_hcd.c
+++ b/drivers/usb/gadget/dummy_hcd.c
@@ -1740,7 +1740,7 @@ restart:
                        dev_dbg(dummy_dev(dum_hcd),
                                "no ep configured for urb %p\n",
                                urb);
-                       status = -EPROTO;
+                       status = -ESHUTDOWN;
                        goto return_urb;
                }
 
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to