Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp189449imd; Fri, 26 Oct 2018 07:08:46 -0700 (PDT) X-Google-Smtp-Source: AJdET5dFi9EvEcZlGLLLHunEMk0h4NwU2YhFoW4iNMse82OqIJPIQTRKJbnWXSpc2VvmJf272Q/c X-Received: by 2002:a62:a116:: with SMTP id b22-v6mr3785769pff.99.1540562926379; Fri, 26 Oct 2018 07:08:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540562926; cv=none; d=google.com; s=arc-20160816; b=PlPsupWM1KnmgYsgvIog5pBr5PMrze7aee7YjVRNweLFdwbqQ6LaWt+Vqw1QarBJUe 40DrzpEFY6fjuKcAWlnyeQcoB4j8fSaNhk21louB3/eL6Lr6VhHVfr4SD4tpcb2zy++5 RlxWcEj93i+BRoXLQl8+rJIHZDokUaDPCqMm5BztSbay3lPf06X+GP8R56Da3ENJty0A qnuUsJQ/SJyuS4DmI3MU72VoVkOJ/Vopl6Tdh6b4Yc0anXZYPeOdiyzDtH1XCRHy+EoS d5hPyjOUo4U19D3U+VXsL0yCNSNa/5c5zDr7U50wnpCaV6edDGaUp/O+tu+D+8c04CFU I7IA== 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=ETMXg6F3VS5ffoXh80Suf/l/zrwObDdz7TsGwZqJ9ZA=; b=Fvxo3jrS4hjknjQitMya2qpjqEhJ1jkt6OLHmSyLYIppk5ee9uzJwjcvIMA5YsPZeg C2vDvwNlE7Y0NWzk7cXEwkn9KOcVx3jGzpwhXB2Bb3DmgzYa5bzpoCZKsgfoVxcYjF5f LuHYr5gIABzgWyYdvvF9Z5SHL8nbVP98CnlieqZqZmrOgiVdkB6/sXGw+liT2DySIe2M kBdqF/uVxER9QjoMVKwfrx7JmzA3ARGmplFLNEy8kkjyVo/0XdyiZ0WuCUqxicUtCsTb rnxcXb41cjRrPaygkG//cxiABnXQ+vdCxj7KjCE1TkSuLRVwdl3njMelzhSsp60N8fCD P4AQ== 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 c1-v6si10909985pgp.376.2018.10.26.07.08.29; Fri, 26 Oct 2018 07:08:46 -0700 (PDT) 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 S1726763AbeJZWpG (ORCPT + 99 others); Fri, 26 Oct 2018 18:45:06 -0400 Received: from iolanthe.rowland.org ([192.131.102.54]:42750 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1726014AbeJZWpG (ORCPT ); Fri, 26 Oct 2018 18:45:06 -0400 Received: (qmail 2386 invoked by uid 2102); 26 Oct 2018 10:07:52 -0400 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 26 Oct 2018 10:07:52 -0400 Date: Fri, 26 Oct 2018 10:07:52 -0400 (EDT) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Dennis Wassenberg cc: Mathias Nyman , Greg Kroah-Hartman , Ravi Chandra Sadineni , Kuppuswamy Sathyanarayanan , Bin Liu , Maxim Moseychuk , Mike Looijmans , Dominik Bozek , USB list , Kernel development list Subject: Re: USB-C device hotplug issue In-Reply-To: <8e750341-8fe5-9c66-0653-3c92d4a60505@secunet.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 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 > 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. Alan Stern