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: 812473 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;