Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3921900imu; Mon, 7 Jan 2019 11:59:31 -0800 (PST) X-Google-Smtp-Source: AFSGD/VSqI8C2gnCZILLh9md9ENQxhM//TihsLb9mmLp5gOdICGCweZpxaTTQaMgmBO97JCupb0N X-Received: by 2002:a62:5182:: with SMTP id f124mr64712980pfb.238.1546891171870; Mon, 07 Jan 2019 11:59:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546891171; cv=none; d=google.com; s=arc-20160816; b=0LiXaG1XQKKSQBsME593PsIMoKGxpKrm50TSd/yIv56L4bsk8BTn2lh0mgDjq/UA67 GT8AE5fSaDRnxef6RZRxfMLJ2MxSImU6tXZvJBbvjTjSD4a0nqipfnOKWrmEsXjXljQb 8XCefx8+5hr09XAcFX1zFsfW4VNa7IOdwNuRh4S9fS9GuK4H0gHpttRSjTU/UsQBk1+z yuUHLy7k/qcKC6FXpSSsLeyl+jjlHiLidvZ2YTap6NQ+YC5eMFHt/Kq9rlbqQhZOTDnw NPRlThzezA3fIi8Ic/q8HEvUdo5t85Tci7WrDVqNRInPmSrXy2uPRx9DfHKg8c8XoZtW PmjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:in-reply-to :subject:cc:to:from:date; bh=96DSebHGg1mqUeMtcvT2rIZ8jY+eUs4rs3vCRhfj2nU=; b=B7bnXK7b5mV1mwvFWTDQ31MNeMl8QVroJRDXzCgFj7V39jTHanIXyne+RqeM6bg4pA ChajyqjeNz33Xmtta9xIg5lOWASLZB8RiW4BixtADVfn/yCUeLgGs8F+pEPHxzzK8Gk0 b79+++BMZMO0+kA+LZrzzURvUOxEoX7KLqMKsfbhqB9sscqdGrBYf6SGjzGzPOOd4opS bi1E4KY0LVPLQS86FroWpeu+Z+nnO98BkRlgO5BPUnuwCFSUNSoojr+dwFqwlDyKf1Dc zeDksCs3sUkbDnqRoL+MQ06UzRcRs+ttsMb5LDbIN8O1dxtg2IBw/NMXNqdq1593bQR5 69PA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o11si16966715pll.160.2019.01.07.11.59.16; Mon, 07 Jan 2019 11:59:31 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729113AbfAGS7x (ORCPT + 99 others); Mon, 7 Jan 2019 13:59:53 -0500 Received: from iolanthe.rowland.org ([192.131.102.54]:57964 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1729018AbfAGS7V (ORCPT ); Mon, 7 Jan 2019 13:59:21 -0500 Received: (qmail 4933 invoked by uid 2102); 7 Jan 2019 13:59:20 -0500 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 7 Jan 2019 13:59:20 -0500 Date: Mon, 7 Jan 2019 13:59:20 -0500 (EST) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Greg KH cc: Nicolas Saenz Julienne , , , Subject: Re: [PATCH v3] usb: hub: add retry routine after intr URB submit error In-Reply-To: <20190107163310.GA17519@kroah.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 7 Jan 2019, Greg KH wrote: > On Tue, Nov 20, 2018 at 03:34:38PM +0100, Nicolas Saenz Julienne wrote: > > The hub sends hot-plug events to the host trough it's interrupt URB. The > > driver takes care of completing the URB and re-submitting it. Completion > > errors are handled in the hub_event() work, yet submission errors are > > ignored, rendering the device unresponsive. All further events are lost. > > > > It is fairly hard to find this issue in the wild, since you have to time > > the USB hot-plug event with the URB submission failure. For instance it > > could be the system running out of memory or some malfunction in the USB > > controller driver. Nevertheless, it's pretty reasonable to think it'll > > happen sometime. One can trigger this issue using eBPF's function > > override feature (see BCC's inject.py script). > > > > This patch adds a retry routine to the event of a submission error. The > > HUB driver will try to re-submit the URB once every second until it's > > successful or the HUB is disconnected. > > > > As some USB subsystems already take care of this issue, the > > implementation was inspired from usbhid/hid_core.c's. > > > > Signed-off-by: Nicolas Saenz Julienne > > > > --- > > What ever happened to this patch? Is it still needed? Oliver and Alan, > any objections about it anymore? I have just one very minor nit to pick (see below). Mostly I've been waiting to hear from Oliver. Alan Stern > > thanks, > > greg k-h > > > > > v3: As per Oliver's request: > > - Take care of race condition between disconnect and irq > > > > v2: as per Alan's and Oliver's comments: > > - Rename timer > > - Delete the timer on disconnect > > - Don't reset HUB nor exponential slowdown the timer, 1s fixed retry > > period > > - Check for -ESHUTDOWN prior kicking the timer > > > > drivers/usb/core/hub.c | 45 ++++++++++++++++++++++++++++++++++++------ > > drivers/usb/core/hub.h | 2 ++ > > 2 files changed, 41 insertions(+), 6 deletions(-) > > > > diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c > > index c6077d582d29..630490a35301 100644 > > --- a/drivers/usb/core/hub.c > > +++ b/drivers/usb/core/hub.c > > @@ -607,6 +607,38 @@ static int hub_port_status(struct usb_hub *hub, int port1, > > status, change, NULL); > > } > > > > +static void hub_resubmit_irq_urb(struct usb_hub *hub) > > +{ > > + unsigned long flags; > > + int status; > > + > > + spin_lock_irqsave(&hub->irq_urb_lock, flags); > > + > > + if (hub->quiescing) { > > + spin_unlock_irqrestore(&hub->irq_urb_lock, flags); > > + return; > > + } > > + > > + status = usb_submit_urb(hub->urb, GFP_ATOMIC); > > + if (status && status != -ENODEV && status != -EPERM && > > + status != -ESHUTDOWN) { > > + dev_err(hub->intfdev, "resubmit --> %d\n", status); > > + mod_timer(&hub->irq_urb_retry, > > + jiffies + msecs_to_jiffies(MSEC_PER_SEC)); This can be written more simply as: mod_timer(&hub->irq_urb_retry, jiffies + HZ);