Received: by 10.223.185.116 with SMTP id b49csp6345831wrg; Wed, 28 Feb 2018 07:57:27 -0800 (PST) X-Google-Smtp-Source: AH8x226gWPsypbc8xcmgmFTeTPOvbggpJFPI160b9MH3UpAt3nRd/Nb0QYDre6R0bHYxZffi3DQY X-Received: by 2002:a17:902:d81:: with SMTP id 1-v6mr17516406plv.324.1519833447132; Wed, 28 Feb 2018 07:57:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519833447; cv=none; d=google.com; s=arc-20160816; b=L7vpMRtOtheofGaNb7JZR85jVLUmNx8cjx9fEbOkxI99AjOf48fl/+LvXsJpdJ//BX nIzHtMT1I37akcdz/R8NxXrli5F09f/dJ8c6I4onei07N/R+gDP4ViSsXf90ck9nVvU0 ClCO1bMG9Jshm4S+9nGK+7QZj8U1qsNQwoDFqt4vgfKW55biEyU9euDeMXAk3BLYH5Z0 a0guk8vK7Nfh1x1hXvcluKwl/MzoYWpp1e1OleD9vb6eMMhSbxHkMke1N57t+SeJ4arS 1SynFBQalbWDCHnmmELECbaSMJJK/i6NyV5VV/3I8dhPlx2JiAybZ8eIk3mqUkSr5nXl D+5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=3KCPpi5Hc409SCXpDGXiCh6f++DVQwjeBsfB1mZJdvU=; b=NDkqDrWeF2UHNVzkDGsHWQ/JZZHxTCLJP3e/tlYUk21FnB2I95UlK7RVDmdz4o1abQ DWfT9Sk4ZOtLSREHHWX+PzLok/BQDZNSwwCzWePCzX3WB9TDR0LnpExt2++TQhXgNuz3 WInCJ2PBO9j17yCYgMPX5YCidOz9/rvb2IzHeU17Ih5uQnOxDs1Y51eoyIFBDfmNN4Xm LHR9IgxkLIV6s3wBi1yFEMKFj4aGNtYQnC8sqNg0vXwkJSnCO1CbU2695JMscyYbf39/ g+kfU6HgIiyoHKTwI7x0Fg5lYxSJU6or2wNzU2wvSJpuagWG2eGtkN9VrA1yjN6QTrDT aLpg== 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 e68si1402186pfa.94.2018.02.28.07.57.12; Wed, 28 Feb 2018 07:57:27 -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 S933984AbeB1PxR (ORCPT + 99 others); Wed, 28 Feb 2018 10:53:17 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:34437 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933975AbeB1PxJ (ORCPT ); Wed, 28 Feb 2018 10:53:09 -0500 Received: from [2a02:8011:400e:2:6f00:88c8:c921:d332] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1er3Yu-0006Xj-Q4; Wed, 28 Feb 2018 15:22:32 +0000 Received: from ben by deadeye with local (Exim 4.90_1) (envelope-from ) id 1er3Yd-0008O2-Ii; Wed, 28 Feb 2018 15:22:15 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Alan Stern" , "Mike Looijmans" , "Greg Kroah-Hartman" Date: Wed, 28 Feb 2018 15:20:18 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 024/254] usb: hub: Cycle HUB power when initialization fails In-Reply-To: X-SA-Exim-Connect-IP: 2a02:8011:400e:2:6f00:88c8:c921:d332 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.55-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Mike Looijmans commit 973593a960ddac0f14f0d8877d2d0abe0afda795 upstream. Sometimes the USB device gets confused about the state of the initialization and the connection fails. In particular, the device thinks that it's already set up and running while the host thinks the device still needs to be configured. To work around this issue, power-cycle the hub's output to issue a sort of "reset" to the device. This makes the device restart its state machine and then the initialization succeeds. This fixes problems where the kernel reports a list of errors like this: usb 1-1.3: device not accepting address 19, error -71 The end result is a non-functioning device. After this patch, the sequence becomes like this: usb 1-1.3: new high-speed USB device number 18 using ci_hdrc usb 1-1.3: device not accepting address 18, error -71 usb 1-1.3: new high-speed USB device number 19 using ci_hdrc usb 1-1.3: device not accepting address 19, error -71 usb 1-1-port3: attempt power cycle usb 1-1.3: new high-speed USB device number 21 using ci_hdrc usb-storage 1-1.3:1.2: USB Mass Storage device detected Signed-off-by: Mike Looijmans Acked-by: Alan Stern Signed-off-by: Greg Kroah-Hartman Signed-off-by: Ben Hutchings --- drivers/usb/core/hub.c | 9 +++++++++ 1 file changed, 9 insertions(+) --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -4792,6 +4792,15 @@ loop: usb_put_dev(udev); if ((status == -ENOTCONN) || (status == -ENOTSUPP)) break; + + /* When halfway through our retry count, power-cycle the port */ + if (i == (SET_CONFIG_TRIES / 2) - 1) { + dev_info(&port_dev->dev, "attempt power cycle\n"); + usb_hub_set_port_power(hdev, hub, port1, false); + msleep(2 * hub_power_on_good_delay(hub)); + usb_hub_set_port_power(hdev, hub, port1, true); + msleep(hub_power_on_good_delay(hub)); + } } if (hub->hdev->parent || !hcd->driver->port_handed_over ||