Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp585638img; Wed, 20 Mar 2019 06:55:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqx/xW6+cPxfZwGJdecXtxUh/KMfGvey79rNLmVbG72ua3MR3FHSW+kvuvb+AOwCuE/yILGN X-Received: by 2002:a62:12d0:: with SMTP id 77mr7870545pfs.15.1553090100135; Wed, 20 Mar 2019 06:55:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553090100; cv=none; d=google.com; s=arc-20160816; b=L6C0wsGf1odQONzqFLTsoj9lLzBY/vKyFeAVC5gs8vmJ3pyokWycnxusoNGKnRDnP9 v2XtmLzRIofthyBlL/cHON5qnS8eA44zKaTDZ2DDu38w/GaiGXbAC+rDjLKJKpTsPBcq ohMWYI1VERMPWBEkFjs/6s4UDOWJorSo3l9uyGn2SVS8JdhwyvETe73tLjtzvKd07Q+N b5D9CjvbWkMd5O6u4xiv59+cFLXrMOPbELXDU5PzzQkq8PGL/ZVnMhuCJ2f/d9TSfwhm esISn4lta176GuUrMg9bKIXvD5tybhh1p9btQ1Gn0oGXAv20vDKYw7OcNd29XjWlaoqs e56A== 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:from:references:cc:to:subject; bh=/L2168RrIfxLJLiHmEnrOcj4XUJ9ogsEID3g4nUzXck=; b=tKYov6BW0har1DAzrKFK0UmWIxyO/kZ/M+qFvn96N7WRuI7Nh8tVRSSMPdCRai1xkG odcfqD8XqjMyX1jRDbnEn75OvBpJMt0MmVn4Mg88lyIxWgsus0sbw1Tfab3lTAKnA1v0 wPoQ2qCZxJ61dEPrFMzDpyMrgrs0OjpY8DM7ChpiuUlVPHeHUmbu4JQeU28RhVxgf9My G6khDMnOhvliACiE7DRJd9TXRJqbxwg361KdNQe9ZJxZDfo0EZeLnTwZl58ncrlT8JWe fFucrWlAU/EUQlrwQP8XVrWjL+IjhzOK8mfmCgPE1ErCLga3R7AB1/lvi83h60zIJ1Nt uxHg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g1si1705974pgd.495.2019.03.20.06.54.44; Wed, 20 Mar 2019 06:55:00 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727622AbfCTNww (ORCPT + 99 others); Wed, 20 Mar 2019 09:52:52 -0400 Received: from mga17.intel.com ([192.55.52.151]:22797 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726239AbfCTNww (ORCPT ); Wed, 20 Mar 2019 09:52:52 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Mar 2019 06:52:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,249,1549958400"; d="scan'208";a="124260986" Received: from mattu-haswell.fi.intel.com (HELO [10.237.72.164]) ([10.237.72.164]) by orsmga007.jf.intel.com with ESMTP; 20 Mar 2019 06:52:49 -0700 Subject: Re: [RFC] xhci: clear port_remote_wakeup on device disconnection To: Nicolas Saenz Julienne , Oliver Neukum , Mathias Nyman Cc: Greg Kroah-Hartman , linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org References: <20190318170038.23914-1-nsaenzjulienne@suse.de> <1552993288.14757.23.camel@suse.com> <82718bec37e4e16e0a08b3b7a00452f99adc707b.camel@suse.de> From: Mathias Nyman Message-ID: Date: Wed, 20 Mar 2019 15:55:02 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <82718bec37e4e16e0a08b3b7a00452f99adc707b.camel@suse.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 19.3.2019 16.54, Nicolas Saenz Julienne wrote: > Hi Oliver, thanks for the review! > > On Tue, 2019-03-19 at 12:01 +0100, Oliver Neukum wrote: >> On Mo, 2019-03-18 at 18:00 +0100, Nicolas Saenz Julienne wrote: >>> This patch clears "port_remote_wakeup" upon detecting a device >>> disconnection. Making sure the above mentioned situation doesn't trigger >>> a PM busyloop. >> >> Hi, >> >> that is an interesting race condition. >> Turns out that port_remote_wakeup was only properly cleared in case of a successful resume where port stays in U0, or in case of an error where port goes to inactive state. In all other cases port_remote_wakeup bit was left uncleared. >>> Signed-off-by: Nicolas Saenz Julienne >>> --- >>> drivers/usb/host/xhci-hub.c | 3 +++ >>> 1 file changed, 3 insertions(+) >>> >>> diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c >>> index e2eece693655..bea853f45aec 100644 >>> --- a/drivers/usb/host/xhci-hub.c >>> +++ b/drivers/usb/host/xhci-hub.c >>> @@ -942,6 +942,9 @@ static void xhci_get_usb3_port_status(struct xhci_port >>> *port, u32 *status, >>> bus_state->suspended_ports &= ~(1 << portnum); >>> } >>> >>> + if (!(portsc & PORT_CONNECT)) >>> + bus_state->port_remote_wakeup &= ~(1 << portnum); >>> + A check like this should cover the failing resume cases, thanks We also saw a case when a successful resume was missed as port went into U1 Link power save state (resume->U0->U1) before xhci driver read the port status. A patch adding U1 and U2 to successful resume states is pending in my for-usb-linus branch for this. >> >> Why are you putting that logic into xhci_get_usb3_port_status()? >> It looks to me like there is already something related in the caller > > You're right, xhci_get_usb3_port_status() is not the ideal spot I'll move the > code there. > Sounds good, thanks -Mathias