Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2297580ybl; Thu, 19 Dec 2019 11:11:10 -0800 (PST) X-Google-Smtp-Source: APXvYqw0/1HbRxoLzG0jLKbe6glYEsnT7FESWcXOiIYHLtn0JMUAokNVH2s0Jp2BeYwHVZi8c0C9 X-Received: by 2002:a05:6830:1407:: with SMTP id v7mr10679660otp.58.1576782670277; Thu, 19 Dec 2019 11:11:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576782670; cv=none; d=google.com; s=arc-20160816; b=lLBK0BAHBBHlIxwbcWPnv/8vt13B/NojcH9OZ/NMS/XTmtbrrRg6wvj1cgVEi3TF1t geZ7dpWuwqebO7mjAXkb4Vt+QzA1zVy+DsmMOLM7pBePJz05asPmfoog2tPpq/EagrHi 4cVfYhh/x9mgtgKEkezvfUn8gZ3KSCTATzt/CrAJrhHCmWTvTxulUVwUIWqRuU4NMeve tkikkRusrltAVx8qDiSm2In2uJPocmlEi7k7Qx3Hzwb/UwJareow3Dx5xxzdTyujp9oa gUFk1fucZl2/+ZBH+YmDDZpm1mkOL4dRZGfy0NdvfG74aSKOR/hznuczqT1a+l6ouSiQ 4GZQ== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=FDAP0qXWb7juAiwY1cTPJQGySvPqMgtz5ZlBPIpz/Rc=; b=ilZ69ecMirfgLP0/uBjYTcMsKeFk1yGCUIrGg28iQPRNmBuYTSkjztpFGPSot+lWlB KcY4HWVfMAF4sqQ8MlB84xx5CEx1y4zBQQwm4nz0lBpn9tJpOZS3xdpnHuCNwLZnrptr OZvvvgJZDrjkJOAXYPh6Zz0F4G1c/vuinFUQLU9ueSKuudludjq0bfedEHnR+awX/uQ7 KcIZYzoWSUS10TCb+mKIididHlzqiJRrUJ9YfccnzOXk0Z8CFmxnMW3Z6+4v/a6R2FiR e+dHd2BSte/lw1iaJoKBer/9CqzbWON6K0pZVAIa36E/V1HUzN3Kix3s+rugchBU3w7O 2cwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=NJKppowj; 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 p26si3687837oto.240.2019.12.19.11.10.58; Thu, 19 Dec 2019 11:11:10 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=NJKppowj; 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 S1728336AbfLSSkG (ORCPT + 99 others); Thu, 19 Dec 2019 13:40:06 -0500 Received: from mail.kernel.org ([198.145.29.99]:58626 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728323AbfLSSkC (ORCPT ); Thu, 19 Dec 2019 13:40:02 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 84AC5206D7; Thu, 19 Dec 2019 18:40:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576780802; bh=gRXEjFAfXikEhoAMADE+phBfpxgJ8jYl1DmBHBNGdLE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NJKppowj8z3VOk0DeGAmh2GpZn1KA5bx5OyDQJ3NPUo1zk3feFayaJEcIngLda4lX qD72DXNluh8OcVYwNqjTWVhejnp57lIQY2TjEWWDIJXrUjiVxkLN3nnOB6okwJjKTt LFwuxVQgQL8iSfHyQ73D824ij5m+M8BIXtlUTX4Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Henry Lin , Mathias Nyman , Sasha Levin Subject: [PATCH 4.4 124/162] usb: xhci: only set D3hot for pci device Date: Thu, 19 Dec 2019 19:33:52 +0100 Message-Id: <20191219183215.310756164@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191219183150.477687052@linuxfoundation.org> References: <20191219183150.477687052@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Henry Lin [ Upstream commit f2c710f7dca8457e88b4ac9de2060f011254f9dd ] Xhci driver cannot call pci_set_power_state() on non-pci xhci host controllers. For example, NVIDIA Tegra XHCI host controller which acts as platform device with XHCI_SPURIOUS_WAKEUP quirk set in some platform hits this issue during shutdown. Cc: Fixes: 638298dc66ea ("xhci: Fix spurious wakeups after S5 on Haswell") Signed-off-by: Henry Lin Signed-off-by: Mathias Nyman Link: https://lore.kernel.org/r/20191211142007.8847-4-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/host/xhci-pci.c | 13 +++++++++++++ drivers/usb/host/xhci.c | 5 +---- drivers/usb/host/xhci.h | 1 + 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c index d6e2199bcfe57..bda176fa6e488 100644 --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c @@ -446,6 +446,18 @@ static int xhci_pci_resume(struct usb_hcd *hcd, bool hibernated) } #endif /* CONFIG_PM */ +static void xhci_pci_shutdown(struct usb_hcd *hcd) +{ + struct xhci_hcd *xhci = hcd_to_xhci(hcd); + struct pci_dev *pdev = to_pci_dev(hcd->self.controller); + + xhci_shutdown(hcd); + + /* Yet another workaround for spurious wakeups at shutdown with HSW */ + if (xhci->quirks & XHCI_SPURIOUS_WAKEUP) + pci_set_power_state(pdev, PCI_D3hot); +} + /*-------------------------------------------------------------------------*/ /* PCI driver selection metadata; PCI hotplugging uses this */ @@ -481,6 +493,7 @@ static int __init xhci_pci_init(void) #ifdef CONFIG_PM xhci_pci_hc_driver.pci_suspend = xhci_pci_suspend; xhci_pci_hc_driver.pci_resume = xhci_pci_resume; + xhci_pci_hc_driver.shutdown = xhci_pci_shutdown; #endif return pci_register_driver(&xhci_pci_driver); } diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 7a0db7fb731ee..af4e68152776e 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -754,11 +754,8 @@ void xhci_shutdown(struct usb_hcd *hcd) xhci_dbg_trace(xhci, trace_xhci_dbg_init, "xhci_shutdown completed - status = %x", readl(&xhci->op_regs->status)); - - /* Yet another workaround for spurious wakeups at shutdown with HSW */ - if (xhci->quirks & XHCI_SPURIOUS_WAKEUP) - pci_set_power_state(to_pci_dev(hcd->self.controller), PCI_D3hot); } +EXPORT_SYMBOL_GPL(xhci_shutdown); #ifdef CONFIG_PM static void xhci_save_registers(struct xhci_hcd *xhci) diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index b57bee70cdef2..e23e3a381672d 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1833,6 +1833,7 @@ int xhci_run(struct usb_hcd *hcd); void xhci_stop(struct usb_hcd *hcd); void xhci_shutdown(struct usb_hcd *hcd); int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks); +void xhci_shutdown(struct usb_hcd *hcd); void xhci_init_driver(struct hc_driver *drv, const struct xhci_driver_overrides *over); -- 2.20.1