From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f180.google.com ([209.85.192.180]:32806 "EHLO mail-pf0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755530AbcBQDmy (ORCPT ); Tue, 16 Feb 2016 22:42:54 -0500 Date: Wed, 17 Feb 2016 11:38:51 +0800 From: Peter Chen To: Oliver Neukum Cc: linux-usb@vger.kernel.org, gregkh@linuxfoundation.org, stern@rowland.harvard.edu, stable@vger.kernel.org Subject: Re: [PATCH] usb: retry reset if a device times out Message-ID: <20160217033851.GA16778@shlinux2> References: <1455100398-28229-1-git-send-email-oneukum@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1455100398-28229-1-git-send-email-oneukum@suse.com> Sender: stable-owner@vger.kernel.org List-ID: On Wed, Feb 10, 2016 at 11:33:18AM +0100, Oliver Neukum wrote: > Some devices I got show an inability to operate right after > power on if they are already connected. They are beyond recovery > if the descriptors are requested multiple times. So in case of > a timeout we rather bail early and reset again. But it must be > done only on the first loop lest we get into a reset/time out > spiral that can be overcome with a retry. > > This patch is a rework of a patch that fell through the cracks. > http://www.spinics.net/lists/linux-usb/msg103263.html > > Signed-off-by: Oliver Neukum > CC: stable@vger.kernel.org > --- > drivers/usb/core/hub.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c > index f912fe6..e4e46f6 100644 > --- a/drivers/usb/core/hub.c > +++ b/drivers/usb/core/hub.c > @@ -4496,7 +4496,13 @@ hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1, > r = -EPROTO; > break; > } > - if (r == 0) > + /* > + * Some devices time out if they are powered on > + * when already connected. They need a second > + * reset. But only on the first attempt, > + * lest we get into a time out/reset loop > + */ > + if (r == 0 || (r == -ETIMEDOUT && j == 0)) > break; > } > udev->descriptor.bMaxPacketSize0 = > -- > 2.1.4 > I remembered you agreed with using outer loop counter (i) as the quit condition. -- Best Regards, Peter Chen