From patchwork Wed Apr 18 05:41:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: leiwan@codeaurora.org X-Patchwork-Id: 10347393 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A8C8E60216 for ; Wed, 18 Apr 2018 05:41:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 98D03284FF for ; Wed, 18 Apr 2018 05:41:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8D19E28515; Wed, 18 Apr 2018 05:41:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 15337284FF for ; Wed, 18 Apr 2018 05:41:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752580AbeDRFlr (ORCPT ); Wed, 18 Apr 2018 01:41:47 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:58472 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752560AbeDRFlq (ORCPT ); Wed, 18 Apr 2018 01:41:46 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 1E39D60500; Wed, 18 Apr 2018 05:41:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1524030106; bh=UKyLtrCviwYyJYfemy7d9Jx20KHjhZ2jbhnwFQfy+38=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=GM8ikjSxNi8D2rxHoY0VHZrSdVb5kj6OkuAvs4LGNhS4odK1OzNYaS8KrTuTV3RIZ lAbsOLCqU/YgBbLwn+NnUu4gQVLJBPSwHCLdvISWAofELBT4LKYOY9DyPEmxCboHrf YOsmdbO0TMiA4aEFRCAyvk5DkcE+XyVOGGV9KvPE= Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id 52AC460600; Wed, 18 Apr 2018 05:41:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1524030105; bh=UKyLtrCviwYyJYfemy7d9Jx20KHjhZ2jbhnwFQfy+38=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=XPGiiglXvvqAtQ/dTtE5+iQMUJ+a5kNLwMjTVg7qZTe9pIwhRt1XPwfgKsQPkRvoJ Cs38bQ8SdWD738+PxLLYn5o+fHcMCubkQxjM0W7wzgOCteLNW1KerPEN461w3Bc8rT p7G8aiIYTm2mgZ+1E8FKi37SocETPK6hF55WwncY= MIME-Version: 1.0 Date: Wed, 18 Apr 2018 13:41:45 +0800 From: leiwan@codeaurora.org To: Greg KH Cc: mathias.nyman@intel.com, ghackmann@google.com, linux-usb@vger.kernel.org Subject: Re: refine xhci-plat-Fix-xhci_plat-shutdown-sequence In-Reply-To: <20180417103226.GA8445@kroah.com> References: <20180417103226.GA8445@kroah.com> Message-ID: <51bb6bb92f402921e935cae62792d827@codeaurora.org> X-Sender: leiwan@codeaurora.org User-Agent: Roundcube Webmail/1.2.5 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On 2018-04-17 18:32, Greg KH wrote: > On Tue, Apr 17, 2018 at 11:32:42AM +0800, leiwan@codeaurora.org wrote: >> >> xhci-plat Shutdown callback should check HCD_FLAG_HW_ACCESSIBLE >> before accessing any register. This should avoid hung with access >> controllers which support runtime suspend >> >> This can fix for issue of https://patchwork.kernel.org/patch/10339317/ >> corresponding upload in CAF: >> https://source.codeaurora.org/quic/la/kernel/msm-4.4/commit/?h=LV.HB.1.1.5-03810-8x96.0&id=a7a5307ee04ad349d365ad50f304605a9cd9bd0a >> >> full patch refer attachment. >> diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c >> index 9b27798..bdf914d 100644 >> --- a/drivers/usb/host/xhci.c >> +++ b/drivers/usb/host/xhci.c >> @@ -702,6 +702,10 @@ static void xhci_shutdown(struct usb_hcd *hcd) >> usb_disable_xhci_ports(to_pci_dev(hcd->self.sysdev)); >> >> spin_lock_irq(&xhci->lock); >> + if (!HCD_HW_ACCESSIBLE(hcd)) { >> + spin_unlock_irq(&xhci->lock); >> + return; >> + } >> xhci_halt(xhci); > > A blank line after the if statement? >> [lei]I checked other code in this file, seems we do not neeed a blank >> line after if here. > > What about all of the other places in this driver that you should also > check for this? Look at the other host controllers, shouldn't you > mirror what they are doing? >> [lei] The issue here is when shutdown called, xhci-host driver will >> try to access >> usb register which may be in runtime suspend state, this lead to a >> hang up. >> Similar as what xhci-host suspend workflow has done, we need check >> HW_ACCESS. > And this needs a Fixes: tag, along with a cc: stable so as to properly > get backported as this is broken in some stable kernels right now. >> [lei] Added Cc and Fixes part in commit message > > thanks, > > greg k-h From c03697fa259ab38d1002598ec2ccfac37607ca0b Mon Sep 17 00:00:00 2001 From: Lei wang Date: Tue, 17 Apr 2018 10:55:35 +0800 Subject: [PATCH v2] xhci: plat: Fix xhci_plat shutdown hung xhci-plat Shutdown callback should check HCD_FLAG_HW_ACCESSIBLE before accessing any register. This should avoid hung with access controllers which support runtime suspend Fixes: b07c12517f2a ("xhci: plat: Register shutdown for xhci_plat") Cc: Signed-off-by: Lei wang --- drivers/usb/host/xhci.c | 4 ++++ 1 file changed, 4 insertions(+) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 9b27798..bdf914d 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -702,6 +702,10 @@ static void xhci_shutdown(struct usb_hcd *hcd) usb_disable_xhci_ports(to_pci_dev(hcd->self.sysdev)); spin_lock_irq(&xhci->lock); + if (!HCD_HW_ACCESSIBLE(hcd)) { + spin_unlock_irq(&xhci->lock); + return; + } xhci_halt(xhci); /* Workaround for spurious wakeups at shutdown with HSW */ if (xhci->quirks & XHCI_SPURIOUS_WAKEUP)