Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751736AbdG0JLz (ORCPT ); Thu, 27 Jul 2017 05:11:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47604 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751122AbdG0JLx (ORCPT ); Thu, 27 Jul 2017 05:11:53 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3FF7ACE63C Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=zkabelac@redhat.com Subject: Re: USB disk speed regression WD Elements - with bisect result 22547c4cc4fe20698a6a85a55b8788859134b8e4 To: Alan Stern Cc: USB list , LKML , dianders@chromium.org, linux@roeck-us.net, gregkh@linuxfoundation.org References: From: Zdenek Kabelac Organization: Red Hat Message-ID: Date: Thu, 27 Jul 2017 11:11:49 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=iso-8859-2; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 27 Jul 2017 09:11:53 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4015 Lines: 100 Dne 27.7.2017 v 03:03 Alan Stern napsal(a): > [Added linux-usb mailing list to CC:] > > Short description of bug: In 4.12 or later, when Zdenek's Western > Digital disk is attached to an EHCI controller, it ends up connecting > at full speed to the companion UHCI controller instead. But when > commit 22547c4cc4fe ("usb: hub: Wait for connection to be reestablished > after port reset") is reverted, the disk connects correctly at high > speed. > > On Wed, 26 Jul 2017, Zdenek Kabelac wrote: > >> Dne 25.7.2017 v 21:50 Alan Stern napsal(a): >>> On Tue, 25 Jul 2017, Zdenek Kabelac wrote: >>> >>> >>> 08:18 usb 2-2: USB disconnect, device number 2 >>> 08:25 usb 2-2: new high-speed USB device number 3 using ehci-pci >>> 08:26 usb 2-2: new high-speed USB device number 4 using ehci-pci >>> >>> If the drive were working entirely correctly, it wouldn't do that. >>> >>> We could continue futzing around with hardware and driver tests for a >>> long time. But there may be a shortcut: If you have a USB hub, you >>> could try attaching the drive through it. It's entirely possible that >>> this will fix the problem. >>> >>> If not, you'll have to start doing some very detailed tests. As a >>> start, you can enable debugging for the usbcore and ehci_hcd drivers >>> immediately before the test: >>> >>> echo 'module usbcore =p' >/sys/kernel/debug/dynamic_debug/control >>> echo 'module ehci_hcd =p' >/sys/kernel/debug/dynamic_debug/control >>> dmesg -C >>> >>> Then after the test, see what shows up in the dmesg output. And again, >>> we'll want to do a comparison. In fact, 4.12 with and without the >>> commit you identified would make a better comparison than 4.12 vs. 4.8. >>> >> >> >> Hi >> >> >> So here we go with traces - made with freshly compiled recent 4.13-rc2. >> OK trace is with revert patch applied. >> BAD trace is the one with it (essentially vaniala master). >> >> Trace also has KOBJECT debugging enabled - I think difference is >> nicely visible between them - but I've no explanation for it. >> >> Both traces start with cable detach followed with attachment. > > Okay, I figured out the cause. > > The USB stack assumes that if a high-speed device initialization fails > and the device is still connected, it means that the device can't run > properly at high speed and the computer needs to try again at full > speed. See commit 90da096ee46b ("USB: force handover port to companion > when hub_port_connect_change fails"). > > In Zdenek's case, the device really does disconnect itself before the > second port reset. If 22547c4cc4fe is present, it causes an extra > delay -- some 200 ms -- long enough for the device to reconnect again. > So we appear to be in the situation described above, and the connection > is switched over to the companion controller. > > If 22547c4cc4fe is not present, the kernel sees that the device is not > connected at the end of the second reset and gives up trying to > initialize the device. When the device reconnects about 140 ms later, > the kernel treats it as a new connection and successfully negotiates a > high-speed link. > > Zdenek, you check this explanation by commenting out these last two > lines at the end of hub_port_connect() in drivers/usb/core/hub.c: > > if (hcd->driver->relinquish_port && !hub->hdev->parent) > hcd->driver->relinquish_port(hcd, port1); > > That should prevent the connection from being handed over to the UHCI > companion, allowing the device to operate at high speed. > Hi Yep - seems this helped - I've dropped revert and commented those 2 lines and I've used the very same kernel - and speed was all good: usb 2-2: new high-speed USB device number 2 using ehci-pci usb 2-2: new high-speed USB device number 3 using ehci-pci usb 2-2: New USB device found, idVendor=1058, idProduct=10a8 usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3 So while I'm not sure if this is final fix for USB - this solution surely solved my WD Element disk attachment issue. Regards Zdenek