Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp246792ybc; Tue, 19 Nov 2019 00:19:40 -0800 (PST) X-Google-Smtp-Source: APXvYqybaXAFf4TFZdoD0jACpVCpPUpioHCCVWKIU2Psyq0JIV3dyZmyckteeu85CFbxxlviGU+p X-Received: by 2002:a17:906:f209:: with SMTP id gt9mr32919171ejb.241.1574151580411; Tue, 19 Nov 2019 00:19:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574151580; cv=none; d=google.com; s=arc-20160816; b=Fvmg13Tf1Gl7QmyMri9MUV9P9pN1PegMxHnrBAArQb/dfSU182GDr9iKiHk/xGII4o D9MKDpvYK9OcokMZucWE6lPauYLx5aZi2N8sYmRSSlxjRpDN+uJrmRSBO5gOIStKgJ4a p0O5hmYT2mtmBjcG7qBIFzfPjJklLU8pIydbqy9wi8RmYpW7sFPtfICqWxDhCpeH4Mbj DFi9q9CgQfohSy4gkoAy0So6ODC3TuwpUK6cUEl6VDtYcPR9LZakTIChgyAj4mIIGemh SzczKLhPxhoceBgqHXejnCvdwB9UAQZztG9wCv0MB6DYcpLOnaLZVUt/+1KVVuAxUE4v Rx5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:dkim-signature:mime-version:references :in-reply-to:message-id:date:subject:cc:from; bh=/dz65ouF3p3rkWuNiDcmHPJD+qhAi8LaaR3WIWv8tGU=; b=GMkYB8Tecqrlk14itz0XyXRcaPDFMbK0XnE8Gn6y0Or1jQltlHatFqpsMa2nbhx42A KAAkSdMnb+S+3rdUKY1XPqyomim+PoWb4cP/tVw1s9IE6/ybVm0BfPAUXE/br0hkQjSn wb5EGz3eEK5e1ZDkmZ87imC0yT5lR0lvZk7Y/yzlLato1aeGjFDTFZ18TB3IJ5qBgOE5 TctvGP7ldiAUAG+XTqeLR8nyEle0dTieAnh1Pb+ELYYszKLsfsXiClta2rF1WdoroqQ0 xCFKWhaacbvCp4vVzOYLHb/1/ctbnvjyQMP8FhqvhVLjXstgJZ1bGKhM5Ljn/bekUAgV MTfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nvidia.com header.s=n1 header.b=hEPBFDfT; 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=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l15si13297560ejp.114.2019.11.19.00.19.15; Tue, 19 Nov 2019 00:19:40 -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=fail header.i=@nvidia.com header.s=n1 header.b=hEPBFDfT; 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=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727994AbfKSIRm (ORCPT + 99 others); Tue, 19 Nov 2019 03:17:42 -0500 Received: from hqemgate14.nvidia.com ([216.228.121.143]:15577 "EHLO hqemgate14.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727736AbfKSIRW (ORCPT ); Tue, 19 Nov 2019 03:17:22 -0500 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate14.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Tue, 19 Nov 2019 00:17:24 -0800 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Tue, 19 Nov 2019 00:17:21 -0800 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Tue, 19 Nov 2019 00:17:21 -0800 Received: from HQMAIL109.nvidia.com (172.20.187.15) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 19 Nov 2019 08:17:21 +0000 Received: from rnnvemgw01.nvidia.com (10.128.109.123) by HQMAIL109.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Tue, 19 Nov 2019 08:17:21 +0000 Received: from henryl-tu10x.nvidia.com (Not Verified[10.19.109.104]) by rnnvemgw01.nvidia.com with Trustwave SEG (v7,5,8,10121) id ; Tue, 19 Nov 2019 00:17:20 -0800 From: Henry Lin CC: Henry Lin , Mathias Nyman , Greg Kroah-Hartman , , Subject: [PATCH v3] usb: xhci: only set D3hot for pci device Date: Tue, 19 Nov 2019 16:16:56 +0800 Message-ID: <20191119081656.8746-1-henryl@nvidia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191113014927.11915-1-henryl@nvidia.com> References: <20191113014927.11915-1-henryl@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 Content-Type: text/plain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1574151444; bh=/dz65ouF3p3rkWuNiDcmHPJD+qhAi8LaaR3WIWv8tGU=; h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:X-NVConfidentiality:MIME-Version: Content-Type; b=hEPBFDfToGhVFoFGE4TVNU/yu8Xdvew4XbeVurxD7ZiiqVVIv0DWeXBJ70sJbpg1C NcQdaEOlZi6KGZjIfM+FhBTelNsNYTddGpAu03leo+2kLZil9U+vLzjUR9QavW8UIz T+f705H2bOoHsHv+dNNKiJayiKp0X2MwAr84iU8Vq/D3IY76cet5J0MiLphTQt1qon Mic+1624+m0+UquawL5jzT0Ugpy48Rg0SQepurInszUK/18qX62WpkF9JflEZXYi2E A9bJcYiVm7cYv5hwE0IKqUY7Iy2wSaNNQFZzps3Zd0LJIc1ovIRLKOCqTc1QW6ce+A lksZwUeAe1mvw== To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Signed-off-by: Henry Lin --- drivers/usb/host/xhci-pci.c | 13 +++++++++++++ drivers/usb/host/xhci.c | 6 +----- drivers/usb/host/xhci.h | 1 + 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c index 1e0236e90687..1904ef56f61c 100644 --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c @@ -519,6 +519,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 */ @@ -554,6 +566,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 6c17e3fe181a..e59346488f64 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -770,7 +770,7 @@ static void xhci_stop(struct usb_hcd *hcd) * * This will only ever be called with the main usb_hcd (the USB3 roothub). */ -static void xhci_shutdown(struct usb_hcd *hcd) +void xhci_shutdown(struct usb_hcd *hcd) { struct xhci_hcd *xhci = hcd_to_xhci(hcd); @@ -789,10 +789,6 @@ static 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.sysdev), PCI_D3hot); } #ifdef CONFIG_PM diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index f9f88626a57a..973d665052a2 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -2050,6 +2050,7 @@ int xhci_start(struct xhci_hcd *xhci); int xhci_reset(struct xhci_hcd *xhci); int xhci_run(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); int xhci_disable_slot(struct xhci_hcd *xhci, u32 slot_id); -- 2.17.1