From patchwork Thu Sep 14 17:49:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Stern X-Patchwork-Id: 9953623 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AEF4E60230 for ; Thu, 14 Sep 2017 17:49:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A1FD6291C2 for ; Thu, 14 Sep 2017 17:49:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8B9DF291C6; Thu, 14 Sep 2017 17:49:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 11407291C0 for ; Thu, 14 Sep 2017 17:49:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751512AbdINRtf (ORCPT ); Thu, 14 Sep 2017 13:49:35 -0400 Received: from netrider.rowland.org ([192.131.102.5]:49519 "HELO netrider.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1751509AbdINRte (ORCPT ); Thu, 14 Sep 2017 13:49:34 -0400 Received: (qmail 13562 invoked by uid 500); 14 Sep 2017 13:49:33 -0400 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 14 Sep 2017 13:49:33 -0400 Date: Thu, 14 Sep 2017 13:49:33 -0400 (EDT) From: Alan Stern X-X-Sender: stern@netrider.rowland.org To: Andrey Konovalov cc: Dmitry Torokhov , Henrik Rydberg , "linux-input@vger.kernel.org" , Felipe Balbi , Greg Kroah-Hartman , Johan Hovold , Peter Chen , Yuyang Du , USB list , LKML , Dmitry Vyukov , Kostya Serebryany , syzkaller Subject: Re: usb/gadget: stalls in dummy_timer In-Reply-To: Message-ID: MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Thu, 14 Sep 2017, Andrey Konovalov wrote: > Looked at this a little more. > > dummy_timer() stucks in an infinite loop. It calls > usb_hcd_giveback_urb(), which in turn calls usbtouch_irq(), which > calls usb_submit_urb(), which calls dummy_urb_enqueue() and puts urb > back into dummy urb queue. dummy_timer() then does goto restart, finds > the urb and calls usb_hcd_giveback_urb() again. And this process goes > on again and again. It seems that something should either process the > urb and set urb->status or it should just expire. There is some throttling code, but it applies only to bulk transfers. Probably because the bandwidth limits for other types are slightly different. However, I don't think we need to worry about this level of detail, since the driver makes a number of other approximations anyway. Try the patch below; it should fix the problem. Alan Stern --- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: usb-4.x/drivers/usb/gadget/udc/dummy_hcd.c =================================================================== --- usb-4.x.orig/drivers/usb/gadget/udc/dummy_hcd.c +++ usb-4.x/drivers/usb/gadget/udc/dummy_hcd.c @@ -1781,7 +1781,6 @@ restart: struct dummy_request *req; u8 address; struct dummy_ep *ep = NULL; - int type; int status = -EINPROGRESS; urb = urbp->urb; @@ -1789,14 +1788,10 @@ restart: goto return_urb; else if (dum_hcd->rh_state != DUMMY_RH_RUNNING) continue; - type = usb_pipetype(urb->pipe); - /* used up this frame's non-periodic bandwidth? - * FIXME there's infinite bandwidth for control and - * periodic transfers ... unrealistic. - */ - if (total <= 0 && type == PIPE_BULK) - continue; + /* Used up this frame's bandwidth? */ + if (total <= 0) + break; /* find the gadget's ep for this request (if configured) */ address = usb_pipeendpoint (urb->pipe);