Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2899009imu; Wed, 7 Nov 2018 01:13:09 -0800 (PST) X-Google-Smtp-Source: AJdET5eTWQvq3SGbBJModzo3ZbK9Fp0fqM4WdRnRXXiFIeDsMIU1J/dRbTUFJ9mKlHRF3TATUdLb X-Received: by 2002:a62:d2c7:: with SMTP id c190-v6mr1120965pfg.26.1541581989009; Wed, 07 Nov 2018 01:13:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541581988; cv=none; d=google.com; s=arc-20160816; b=bNgsrb/y02RlmgPduDtmKX3NWNnrronH40dah4VRwjNrHJwqvL7qhmu+bgd6MrdXz4 ZaxTerEBniWor2r1IUfHEbYQAfEaF1PQpMEuj+a88sYR+AaJRn0rCn9ghWAe9CgCzffV tnKSMmNxZCIMYP4xYsx0YbZH7eCcsPbjfJISuHzZmGSRNUBo2T8BVGSzT4xF27XbXMYV pk/LamjX3dFypeVMXug4382zxV531sGPOwKBSeBtsVvIXlCiE7k733uweVADcwS1Y0QT EUPMYpKe2gz4H4ovd8q2dTGhwF/7yZLU9aRUi4gBdJXlSrA/mQwt7wD5G1UEroJldYuE CwXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:autocrypt:openpgp:from:references:cc:to :subject; bh=K445BTvxcKV6i0VaTISBU8qgAnWZ/20I2Iq/emTK+uk=; b=DPYqq0zSBn9yTrZtaV7qr90mdVlSPuqDDSiElG+MUEYqtGRjED0Q0nD6y/7wfS3aLz zGrmXicU/S7xIBK+vMgnNFfOlXNYWXemiH0ElKWCbq95NS6Kp/IiLr1zFPZo3MRvmLsY pY1Zqs3VxcRv2Y32LFWA5iTqmgu4Ei/6ebovpRyf94GJP8yGA+nrVn3HR2UNk3xSQPZq mVvRM3b9z9nViLlc6tXfQbSOsKiC3rb+2UJqW4x96Wjhlu3Ak2dQL0+T/Xl87wZy2O5b +Advg9noRfc6pzgZX8VIj/2f52NP10K1rTX3D5xU+exLU08nsXihwpD/6h9kgAGLsPcC Qt+w== 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 d126-v6si48378pgc.189.2018.11.07.01.12.53; Wed, 07 Nov 2018 01:13:08 -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 S1730569AbeKGSlu (ORCPT + 99 others); Wed, 7 Nov 2018 13:41:50 -0500 Received: from a.mx.secunet.com ([62.96.220.36]:34518 "EHLO a.mx.secunet.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726218AbeKGSlu (ORCPT ); Wed, 7 Nov 2018 13:41:50 -0500 Received: from localhost (localhost [127.0.0.1]) by a.mx.secunet.com (Postfix) with ESMTP id E0F6B20083; Wed, 7 Nov 2018 10:12:20 +0100 (CET) X-Virus-Scanned: by secunet Received: from a.mx.secunet.com ([127.0.0.1]) by localhost (a.mx.secunet.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LY6g8lrF3dTO; Wed, 7 Nov 2018 10:12:19 +0100 (CET) Received: from mail-essen-01.secunet.de (mail-essen-01.secunet.de [10.53.40.204]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by a.mx.secunet.com (Postfix) with ESMTPS id 8D106201A2; Wed, 7 Nov 2018 10:12:19 +0100 (CET) Received: from [10.182.7.41] (10.182.7.41) by mail-essen-01.secunet.de (10.53.40.204) with Microsoft SMTP Server (TLS) id 14.3.408.0; Wed, 7 Nov 2018 10:12:19 +0100 Subject: Re: USB-C device hotplug issue To: Mathias Nyman , Alan Stern CC: Mathias Nyman , Greg Kroah-Hartman , Ravi Chandra Sadineni , Kuppuswamy Sathyanarayanan , Bin Liu , "Maxim Moseychuk" , Mike Looijmans , Dominik Bozek , USB list , Kernel development list References: From: Dennis Wassenberg Openpgp: preference=signencrypt Autocrypt: addr=dennis.wassenberg@secunet.com; keydata= xsFNBFQyoZsBEADLlGbEluiB13Wfj7pxrAq+BRYNMEaYUDElpI4GWIWhWzPlBC1xTadtEOYK fcU/KNp6PKjVhztn7sX1arPnbRXsh9A7fPV3dfLIs9cE1F44UHqiHTDS03/9asMt9RGz6x5+ 9upGA3FMyyFB1m/+80kpLitH2ymxBeBcSFNALMwNHjWvjca++jObo/lCFH0aEObblkAwLX5F Ww+7B1K7jRwijQJu7ttxG6C6JVXXY8xUZA4wittMHa4oGkaxln2KNSdYRS5yK41PCUYQxuvQ 5g0kKd3IggW8RDBplF0jXEh0n5Z49xtZOR+v/y7i8RHpaUCIxISipB0ZZoL9Qs2amjwd3I7T nKqS8BhDIXGxPq5dg4YLV99pBG/Gc0IztQol6lGHE/0JSHB3HD+qdUWT36FBHs6ha0Dn43R4 2vZUD5c8YypqvUyTV79J8w957eYwqZ67unX9e76tw0up1arBDB4ucn6URlzo7edLbjVG7WD2 Rt0XU/wGAqcgYmDbkViAxLBZRq8oq863vYrm3wtDBt/ZIA15qBpLGP1OxMkMBdHRFXmDw/en w56pHdu+/BYM2OKatO/qrN8Dfuc4NwBoF2AbQ7FDzxvu7hzEi70YbI1MbVovhEK/S29yI2X5 zcaK54ejeYJiRzcmq6yrIwX0kqyuw6Rc5FcaCS6+RZy+Y3X1mwARAQABzTFEZW5uaXMgV2Fz c2VuYmVyZyA8ZGVubmlzLndhc3NlbmJlcmdAc2VjdW5ld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At4hlmGlcnjxIf0bT3rq2gXbVdmmBJ10aQ75fajOmM YPsSSSBN/R6Xmw== Organization: secunet Security Networks AG Message-ID: <4140fee5-8935-daed-8438-d04d7f1198b2@secunet.com> Date: Wed, 7 Nov 2018 10:08:10 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 8bit X-G-Data-MailSecurity-for-Exchange-State: 0 X-G-Data-MailSecurity-for-Exchange-Error: 0 X-G-Data-MailSecurity-for-Exchange-Sender: 23 X-G-Data-MailSecurity-for-Exchange-Server: d65e63f7-5c15-413f-8f63-c0d707471c93 X-EXCLAIMER-MD-CONFIG: 2c86f778-e09b-4440-8b15-867914633a10 X-G-Data-MailSecurity-for-Exchange-Guid: 39CE2921-8922-441C-996C-5FE46B308C13 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05.11.18 16:35, Mathias Nyman wrote: > On 26.10.2018 17:07, Alan Stern wrote: >> On Fri, 26 Oct 2018, Dennis Wassenberg wrote: >> >>>>> --- a/drivers/usb/core/hub.c >>>>> +++ b/drivers/usb/core/hub.c >>>>> @@ -2815,7 +2815,9 @@ static int hub_port_reset(struct usb_hub *hub, int port1, >>>>>                       USB_PORT_FEAT_C_BH_PORT_RESET); >>>>>               usb_clear_port_feature(hub->hdev, port1, >>>>>                       USB_PORT_FEAT_C_PORT_LINK_STATE); >>>>> -            usb_clear_port_feature(hub->hdev, port1, >>>>> + >>>>> +            if (!warm) >>>>> +                usb_clear_port_feature(hub->hdev, port1, >>>>>                       USB_PORT_FEAT_C_CONNECTION); >>>>>                 /* >>>> >>>> The key fact is that connection events can get lost if they happen to >>>> occur during a port reset. >>> Yes. >>>> >>>> I'm not entirely certain of the logic here, but it looks like the >>>> correct test to add should be "if (udev != NULL)", not "if (!warm)". >>>> Perhaps Mathias can confirm this > > Sorry about the late response, got distracted while performing git > archeology. > > "if (udev != NULL)" would seem more reasonable. > > Logs show that clearing the FEAT_C_CONNECTION was originally added > after a hot reset failed, and before issuing a warm reset to a SS.Inactive > link.  (see 10d674a USB: When hot reset for USB3 fails, try warm reset.) > > Apparently all the change flags needed to be cleared for some specific > host + device combination before issuing a warm reset for the enumeration > to work properly. > > The change to always clear FEAT_C_CONNECTION for USB3 was done later in patch: > a24a607 USB: Rip out recursive call on warm port reset. > > Motivation was: > > "In hub_port_finish_reset, unconditionally clear the connect status >  change (CSC) bit for USB 3.0 hubs when the port reset is done.  If we >  had to issue multiple warm resets for a device, that bit may have been >  set if the device went into SS.Inactive and then was successfully warm >  reset." > >>> I don't know if clearing the USB_PORT_FEAT_C_CONNECTION bit is >>> correct in case of a non warm reset. In my case I always observed a >>> warm reset because of the link state change. >>> Thats why I checked the warm variable to not change the behavoir for >>> cases a didn't checked for the first shot. >> >> (The syntax of that last sentence is pretty mangled; I can't understand >> it.) >> >> Think of it this way: >> >>     If a device was not attached before the reset, we don't want >>     to clear the connect-change status because then we wouldn't >>     recognize a device that was plugged in during the reset. >> >>     If a device was attached before the reset, we don't want any >>     connect-change status which might be provoked by the reset to >>     last, because we don't want the core to think that the device >>     was unplugged and replugged when all that happened was a reset. >> >> So the important criterion is whether or not a device was attached to >> the port when the reset started.  It's something of a coincidence that >> you only observe warm resets when there's nothing attached. >> >>> During the first run of usb_hub_reset the udev is NULL because in >>> this situation the device is not attached logically. >>> >>> [  112.889810] usb 4-1-port1: XXX: port_event: portstatus: 0x2c0, portchange: 0x40! >>> [  113.201192] usb 4-1-port1: XXX: hub_port_reset: udev:            (nil)! >>> [  113.201198] usb 4-1-port1: XXX: hub_port_reset (not clearing USB_PORT_FEAT_C_CONNECTION): 0x203, portchange: 0x1! >>> [  113.253612] usb 4-1-port1: XXX: port_event: portstatus: 0x203, portchange: 0x1! >>> [  113.377208] usb 4-1-port1: XXX: hub_port_reset: udev: ffff88046b302800! >>> [  113.377214] usb 4-1-port1: XXX: hub_port_reset (not clearing USB_PORT_FEAT_C_CONNECTION): 0x203, portchange: 0x0! >>> [  113.429478] usb 4-1.1: new SuperSpeed USB device number 7 using xhci_hcd >>> [  113.442370] usb 4-1.1: New USB device found, idVendor=0781, idProduct=5596 >>> [  113.442376] usb 4-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3 >>> [  113.442381] usb 4-1.1: Product: Ultra T C >>> [  113.442385] usb 4-1.1: Manufacturer: SanDisk >>> [  113.442388] usb 4-1.1: SerialNumber: 4C530001131013121031 >>> >>> Or maybe we can skip clearing the USB_PORT_FEAT_C_CONNECTION bit in >>> case of hub_port_reset completely without any other check? >> >> See above. > > Checking for udev sounds reasonable to me. > Not sure if we should worry about the specific host+device combo that needed flags > cleared before warm reset. See patch: > > 10d674a USB: When hot reset for USB3 fails, try warm reset. > https://marc.info/?l=linux-usb&m=131603549603799&w=2 > > -Mathias Checking for udev works well too in my case. So there is no need to check the warm flag. Regarding the other point about the specific host+device combo which needs the flags cleared, I don't know how to proceed. Best regards, Dennis