Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5449130ybi; Tue, 4 Jun 2019 06:54:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqxhaWx58ruM6iiXJLSbbMYg7vik/jXA40nh4SDXuvikSZI9219H+P4wW+niWTLojSYesIec X-Received: by 2002:a17:902:968b:: with SMTP id n11mr2768802plp.120.1559656441749; Tue, 04 Jun 2019 06:54:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559656441; cv=none; d=google.com; s=arc-20160816; b=Qbg+cznDcAmFihBoskc3sNGiOYZ+mskjIR3+d9y2zrihtTy2kQbVadBcdIF8Y3zbQm Q2qNKhlRQ63pWF736hoI67mD1MZLw+7HfUDGvAmSEqSyVeunjGCK3qGRnJIYvNtPUIjz HwawlIvJZ7MX3ciwRkzuoy9oYVp7MXq7aqLTVJgzZMMkhwxbNemVq/GsxqwhDk3kW+LB YzqHX/YKcSUJ2nupY+oPw+VkoJOBPi+aL79HdYNHfAle2LPeuL8GUWNNXunxOBjISgB7 INMPDX+SfWXJ+i3pN4pRSQzxZd1KJpsb1gLXAW5gzoDJTH7EEIziJHvPodTJuJBuoIX6 qyTA== 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=ptq4qs2OVuZGdLxgSgLiXpl/BfVMRUiUluX1VEoDOzw=; b=ytxna0HuiZTE/qKCJ0g5Y+WSJi5sM1INfu1SpJl1OTlYU3YkFLdKHxSnasdS9vzk7L nzApAPVuugMjBn8QdIK/F7Y7a9M1s0ywOH2oCXoQdSaEcNb4P08seM73lvu7foAGh/IS PoveZIOo7fvehcmn3R8J1rLqWAPvQMYH+wBRX2/FAH6XD/u6bZgjgVZUMcupyR53p4cF JDrqopHtU8yEfPyQkhWErzMnImNogTlUnbHKkjPt40Ugenp2ObHiKMjppEVG+J9YkU4y i/EdwWhsmWTtBj8+zvvvDVgGLTeIPxCNaeLxeAKkvs05nBIIM0kgi4GZru3hDm+yEGNC qiAg== 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 a1si6702797pgh.196.2019.06.04.06.53.43; Tue, 04 Jun 2019 06:54:01 -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 S1727608AbfFDNux (ORCPT + 99 others); Tue, 4 Jun 2019 09:50:53 -0400 Received: from mga02.intel.com ([134.134.136.20]:39344 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727129AbfFDNux (ORCPT ); Tue, 4 Jun 2019 09:50:53 -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 orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Jun 2019 06:50:52 -0700 X-ExtLoop1: 1 Received: from mattu-haswell.fi.intel.com (HELO [10.237.72.164]) ([10.237.72.164]) by orsmga007.jf.intel.com with ESMTP; 04 Jun 2019 06:50:50 -0700 Subject: Re: [PATCH] xhci: clear port_remote_wakeup after resume failure To: Nicolas Saenz Julienne , Mathias Nyman Cc: oneukum@suse.com, Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org References: <20190524145231.6605-1-nsaenzjulienne@suse.de> From: Mathias Nyman Message-ID: <9286ec05-d2a2-bd23-3397-b6a3623cad8f@linux.intel.com> Date: Tue, 4 Jun 2019 16:53:37 +0300 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: 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 27.5.2019 14.28, Nicolas Saenz Julienne wrote: > Hi Matthias, > thanks for the review. > > On Mon, 2019-05-27 at 14:16 +0300, Mathias Nyman wrote: >> On 24.5.2019 17.52, Nicolas Saenz Julienne wrote: >>> This was seen on a Dell Precision 5520 using it's WD15 dock. The dock's >>> Ethernet device interfaces with the laptop through one of it's USB3 >>> ports. While idle, the Ethernet device and HCD are suspended by runtime >>> PM, being the only device connected on the bus. Then, both are resumed on >>> behalf of the Ethernet device, which has remote wake-up capabilities. >>> >>> The Ethernet device was observed to randomly disconnect from the USB >>> port shortly after submitting it's remote wake-up request. Probably a >>> weird timing issue yet to be investigated. This causes runtime PM to >>> busyloop causing some tangible CPU load. The reason is the port gets >>> stuck in the middle of a remote wake-up operation, waiting for the >>> device to switch to U0. This never happens, leaving "port_remote_wakeup" >>> enabled, and automatically triggering a failure on any further suspend >>> operation. >>> >>> This patch clears "port_remote_wakeup" upon detecting a device with a >>> wrong resuming port state (see Table 4-9 in 4.15.2.3). Making sure the >>> above mentioned situation doesn't trigger a PM busyloop. >>> >> >> There was a similar case where the USB3 link had transitioned to a >> lower power U1 or U2 state after resume, before driver read the state, >> leaving port_remote_wakeup flag uncleared. >> >> This was fixed in 5.1 kernel by commit: >> >> 6cbcf59 xhci: Fix port resume done detection for SS ports with LPM enable >> >> Can you check if you have it? >> It should be in recent stable releases as well. > > I was aware of that patch, unfortunately it doesn't address the same issue. In > my case I never get a second port status event (so no PLC == 1 or any state > change seen in PLS). The device simply disconnects from the bus. > I see, ok, then we need to clear the flag in the hub thread. But to me it looks like this patch could cause a small race risk in the successful device initiated resume cases. If the hub thread, i.e. the get_port_status() function, notices the U0 state before the interrupt handler, i.e. handle_port_status() function, then port_remote_wakeup flag is cleared in the hub thread and the wakeup notification is never called from handle_port_status(). Would it be enough to just check for (port_remote_wakeup flag && !PORT_CONNECT) in the hub thread? USB3 PORT_CONNECT bit is lost in most error cases. -Mathias