From patchwork Fri Jul 12 18:54:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13732168 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 47F1B241E7; Fri, 12 Jul 2024 18:54:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720810465; cv=none; b=bn7dgYvW82AtEX7YB0ygFSo5lpWNEYVTXEjrzHxWgX7LVAOCuVDLNVeECQCEf6gyfdqLFJ9GfeHonkxL7IgUt6EtO5Dun0MuQGvxdFoWyi1MD0wb1A4OzO75dxTF8xCd2mH+DLnJySBqrYqAAKOhvQVpDYkvTEhVtYyqK4jq1SE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720810465; c=relaxed/simple; bh=fG9IiyCcL3Ebv60rQWnWxvQudEMjgzV3wRXhFlyF4fk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MutV/kJXmksrvS/iFnPKCXooKpIVJBeQxe8/YD4ram1dwkxbO5B1XAU8jzm5wSMvyh2HCQoq1CqAu9qD3m/rZGL1xoy6gU1MtvuKhboNNCfOXai8+G5sXTCd4D19xmt0QN8/WRyknkzVOkdu0o1E9lNxhY1iiGIR6mHqTicJUSM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RCQZWp4q; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RCQZWp4q" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 23DB6C4AF09; Fri, 12 Jul 2024 18:54:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720810463; bh=fG9IiyCcL3Ebv60rQWnWxvQudEMjgzV3wRXhFlyF4fk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RCQZWp4q/kdtgklWXIkvqgYLNZD5vBWcfmK46Xyfzpx6ErYgOTOQPXqWZhpvIX8NY czxSHS1wh7Rz6Bw+ATdlqGJuosihI8ST7lU+bLmKA6R3l5ALYbIRhagQF7BmXuefk+ 9rj+fhIBL1hoGsA/8XhIihxFYxxjEZRNDsQGHiI8cucvyZJG0FyYqUZVUQg9TRlMl/ yDzAQOeXIq1hmnRHR6TTbrJZDAnNi9zryu5NpQhu/i9FLKZPoj491C3dc5itE0CoK1 mi1+N86JeDRqD94bMVY0uAOonHvzYkQNiA9dmJjzcr9rLYHH08UeNSxnqXL9mYgNWH lMRy5oFl8rfYw== From: superm1@kernel.org To: Mathias Nyman , Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org (open list:USB XHCI DRIVER), linux-kernel@vger.kernel.org (open list), Kai-Heng Feng , mika.westerberg@linux.intel.com, Mario Limonciello Subject: [PATCH 1/2] xhci: pci: If no ports have wakeup enabled then disable PCI device at S4 Date: Fri, 12 Jul 2024 13:54:17 -0500 Message-ID: <20240712185418.937087-2-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240712185418.937087-1-superm1@kernel.org> References: <20240712185418.937087-1-superm1@kernel.org> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Mario Limonciello If a port on an XHCI controller hasn't been marked for wakeup at S4, then leaving it at D0 will needlessly consume power than necessary. Explicitly check ports configured for wakeup and if none are found then put the controller into D3hot before hibernate. Signed-off-by: Mario Limonciello --- drivers/usb/host/xhci-pci.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c index 05881153883ec..4408d4caf66d2 100644 --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c @@ -823,6 +823,7 @@ static int xhci_pci_poweroff_late(struct usb_hcd *hcd, bool do_wakeup) struct usb_device *udev; u32 portsc; int i; + bool wakeup = false; /* * Systems with XHCI_RESET_TO_DEFAULT quirk have boot firmware that @@ -860,6 +861,14 @@ static int xhci_pci_poweroff_late(struct usb_hcd *hcd, bool do_wakeup) port->rhub->hcd->self.busnum, port->hcd_portnum + 1); portsc = xhci_port_state_to_neutral(portsc); writel(portsc | PORT_PE, port->addr); + wakeup = true; + } + + if (!wakeup) { + struct pci_dev *pdev = to_pci_dev(hcd->self.controller); + + xhci_shutdown(hcd); + pci_set_power_state(pdev, PCI_D3hot); } return 0; From patchwork Fri Jul 12 18:54:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13732169 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3B1AF34CDE; Fri, 12 Jul 2024 18:54:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720810466; cv=none; b=c7W66MUMYpCxhMJBWFtZarO3GTTvDBhgU0oT00YhFRsx00Ccdh3L2oq8wGvm7Q9jzM6QcPPZubsKfIK+mTnEjXaAEtMVQ6dD4FBoFu+G1nsX2yOG/QjCzSLNQIyGV3yQ8DkHuLpAclFDDcBRb+bmB2t8BAyAyAI+Zl1vDFG4nBo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720810466; c=relaxed/simple; bh=J1DNbBBTExsAUZSMBP3xp+b4hG2tRJP8mnBGnoOsLo8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SzB0NNINk8Vpc6ALWW3sZIMRpQ8OuQDQBlk5JEtVhYn4DGbvYCPhseGQt9NLcbNplS5s4Hm+QKm6iEtLYPes6c3cDGcsYFdWjvFeDQqePrKkjkE6+w3rDbiAHWletPChAW73mkuGLKKyB1OFVXOibbVqq5hkkToE7fBr0mm2T3Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HGohTt/h; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="HGohTt/h" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1DC0BC4AF0C; Fri, 12 Jul 2024 18:54:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720810464; bh=J1DNbBBTExsAUZSMBP3xp+b4hG2tRJP8mnBGnoOsLo8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HGohTt/hD1qZY9CVG/KMkv+ywhnivo/vy/94wkGmblTIds+xUoliAN5351xZXQmbz vJbJho+CmpIUZd8Oc9Y0lrvjxwyCQQzAFeKc++wSiW9cb7cE3ei4qtF/X/cWRfFTqN vJxw7o/if/Pxd+Mf1bApjFV0kswkzogp60UW+6k+yDuykz56XPHFyldOYt4d6x3N/D WYQZ4Tu90jj4Ql/GhnBKU84xJFX1UuU+VBfbEjgZlSypmYitMiGsbIHFcg0pKaMGil c7Dj0+58d10D5G6SF5UcrwpomWWc1L5gTWjYeaCvfBwvjtVGGMHo7EMScUv2wmd8fl FJD6bqO3uzlGQ== From: superm1@kernel.org To: Mathias Nyman , Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org (open list:USB XHCI DRIVER), linux-kernel@vger.kernel.org (open list), Kai-Heng Feng , mika.westerberg@linux.intel.com, Mario Limonciello Subject: [PATCH 2/2] xhci: pci: Put XHCI controllers into D3hot at shutdown Date: Fri, 12 Jul 2024 13:54:18 -0500 Message-ID: <20240712185418.937087-3-superm1@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240712185418.937087-1-superm1@kernel.org> References: <20240712185418.937087-1-superm1@kernel.org> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Mario Limonciello A workaround was put in place for Haswell systems with spurious events to put XHCI controllers into D3hot at shutdown. This solution actually makes sense for all XHCI controllers though because XHCI controllers left in D0 by the OS may remain in D0 when the SoC goes into S5. Explicitly put all XHCI controllers into D3hot at shutdown and when module is unloaded. Signed-off-by: Mario Limonciello --- drivers/usb/host/xhci-pci.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c index 4408d4caf66d2..dde5e4a210719 100644 --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c @@ -667,9 +667,7 @@ static void xhci_pci_remove(struct pci_dev *dev) xhci->shared_hcd = NULL; } - /* Workaround for spurious wakeups at shutdown with HSW */ - if (xhci->quirks & XHCI_SPURIOUS_WAKEUP) - pci_set_power_state(dev, PCI_D3hot); + pci_set_power_state(dev, PCI_D3hot); usb_hcd_pci_remove(dev); } @@ -882,9 +880,7 @@ static void xhci_pci_shutdown(struct usb_hcd *hcd) xhci_shutdown(hcd); xhci_cleanup_msix(xhci); - /* Yet another workaround for spurious wakeups at shutdown with HSW */ - if (xhci->quirks & XHCI_SPURIOUS_WAKEUP) - pci_set_power_state(pdev, PCI_D3hot); + pci_set_power_state(pdev, PCI_D3hot); } /*-------------------------------------------------------------------------*/