From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.linuxfoundation.org ([140.211.169.12]:48812 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731068AbeGRRFT (ORCPT ); Wed, 18 Jul 2018 13:05:19 -0400 Date: Wed, 18 Jul 2018 18:26:36 +0200 From: Greg KH To: Kai-Heng Feng Cc: mathias.nyman@intel.com, linux-stable@vger.kernel.org, Mathias Nyman , stable@vger.kernel.org Subject: Re: [PATCH] xhci: Fix perceived dead host due to runtime suspend race with event handler Message-ID: <20180718162636.GA26902@kroah.com> References: <20180718162322.9518-1-kai.heng.feng@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180718162322.9518-1-kai.heng.feng@canonical.com> Sender: stable-owner@vger.kernel.org List-ID: On Thu, Jul 19, 2018 at 12:23:22AM +0800, Kai-Heng Feng wrote: > From: Mathias Nyman > > commit 229bc19fd7aca4f37964af06e3583c1c8f36b5d6 upstream. > > Don't rely on event interrupt (EINT) bit alone to detect pending port > change in resume. If no change event is detected the host may be suspended > again, oterwise roothubs are resumed. > > There is a lag in xHC setting EINT. If we don't notice the pending change > in resume, and the controller is runtime suspeded again, it causes the > event handler to assume host is dead as it will fail to read xHC registers > once PCI puts the controller to D3 state. > > [ 268.520969] xhci_hcd: xhci_resume: starting port polling. > [ 268.520985] xhci_hcd: xhci_hub_status_data: stopping port polling. > [ 268.521030] xhci_hcd: xhci_suspend: stopping port polling. > [ 268.521040] xhci_hcd: // Setting command ring address to 0x349bd001 > [ 268.521139] xhci_hcd: Port Status Change Event for port 3 > [ 268.521149] xhci_hcd: resume root hub > [ 268.521163] xhci_hcd: port resume event for port 3 > [ 268.521168] xhci_hcd: xHC is not running. > [ 268.521174] xhci_hcd: handle_port_status: starting port polling. > [ 268.596322] xhci_hcd: xhci_hc_died: xHCI host controller not responding, assume dead > > The EINT lag is described in a additional note in xhci specs 4.19.2: > > "Due to internal xHC scheduling and system delays, there will be a lag > between a change bit being set and the Port Status Change Event that it > generated being written to the Event Ring. If SW reads the PORTSC and > sees a change bit set, there is no guarantee that the corresponding Port > Status Change Event has already been written into the Event Ring." > > Cc: > Signed-off-by: Mathias Nyman > Signed-off-by: Greg Kroah-Hartman > Signed-off-by: Kai-Heng Feng > --- > drivers/usb/host/xhci.c | 40 +++++++++++++++++++++++++++++++++++++--- > drivers/usb/host/xhci.h | 4 ++++ > 2 files changed, 41 insertions(+), 3 deletions(-) Any specific reason you sent this old patch that is already in Linus's tree out again to everyone? confused, greg k-h