Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp653957iog; Thu, 30 Jun 2022 07:45:31 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uzGevadrE59KGZiShywGq6krNPAmP/f8fT4cyDiJ0BwcpKi3wYzYswLAe9zt2XdCqimYI2 X-Received: by 2002:a17:902:da87:b0:16a:54e1:3426 with SMTP id j7-20020a170902da8700b0016a54e13426mr14644858plx.157.1656600331708; Thu, 30 Jun 2022 07:45:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656600331; cv=none; d=google.com; s=arc-20160816; b=NNiiMJLU2wRbh3IeBAIBJAX4Lugd9QfziwSh1KBDkN76RhoKhAyENSr2aP1As8gM6W qiL+PsIZNYliaMZ5eElHGKyvtwmgLyol76OWWSGiKpPJZbxRe/lGmvibygo327u2gVaU a0nB1s53kIB6EEm6bT+3CpYUK3CKJ2LDP8GMGzEzH0G1zPBwtqDQkoC1YToENZULUN11 DyeFOwuWPUIcvcZSMyM64zeyivxh1jHdW6VgreQ0UHsrTqmGlDFe6E44ht/R/jVvl8g3 5b05FDLHdVnyyAFeJHb8dA630G0UHr4maRRbpw11J6jseRYkLUj2BauvMdUaBce/48Iw f/5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=njUyVjVnjKRbQwOb1loF+NvTXcOgAEr+Qvek+7L+9fk=; b=r5Ouep7DXCprf6TaINOi8JZbhm8gpVl9cljRvHs49cafj/AV90pijmFc+/5CK3pSh0 Cnp/ltAR0mpqlP1jONrYXF/W1CnQq2MBGmk3Q5+WU2cbtNGINxedrhkvo/KVnue7ag97 SIsKPy2F6ygzertk7+Ss8pYBYcLe9zP6iyhzQioJoIHMX5LEhtHnVfN8Y91AmoUi03qF 5Wn8GT4tQXWvspx7FVDgphioKpbe0+TQ1KqQOfCE12paDd5vpGHYo0M1pmaD6b4ZiCv7 zcusMFGTFByFEOzrYM38jzwLjTiiFJ41ldlfQu9VW6e/QjBWGF5NygSD/jkN9vhnDUAW zbjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Q7WNcxP1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id me1-20020a17090b17c100b001ec92216b35si3520946pjb.160.2022.06.30.07.45.16; Thu, 30 Jun 2022 07:45:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Q7WNcxP1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236132AbiF3OBb (ORCPT + 99 others); Thu, 30 Jun 2022 10:01:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236452AbiF3N6p (ORCPT ); Thu, 30 Jun 2022 09:58:45 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6DB15726F; Thu, 30 Jun 2022 06:51:47 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3ED76620ED; Thu, 30 Jun 2022 13:51:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 48B81C34115; Thu, 30 Jun 2022 13:51:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656597083; bh=Z/K9iGNGKjun6Pwhwsu8HaUDt3qlLF2xHSIBy2pz45M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q7WNcxP1oKQRhcEuUwIeUXSa/Bu+vrd9ODpRYmaH8HlTb6BlrxzXzMmoZ8QW8vabc Ia9YKlwijwiKLoGGu1BrzbBxNYq8MteHNMxk/GL+VzWLR11b2DTqJkj9gZ4cixfaFx 2oJRrZRIpJLZSMau4bAHLvb6div54s2rZvBHqzQg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mathias Nyman Subject: [PATCH 4.19 22/49] xhci: turn off port power in shutdown Date: Thu, 30 Jun 2022 15:46:35 +0200 Message-Id: <20220630133234.557073875@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220630133233.910803744@linuxfoundation.org> References: <20220630133233.910803744@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mathias Nyman commit 83810f84ecf11dfc5a9414a8b762c3501b328185 upstream. If ports are not turned off in shutdown then runtime suspended self-powered USB devices may survive in U3 link state over S5. During subsequent boot, if firmware sends an IPC command to program the port in DISCONNECT state, it will time out, causing significant delay in the boot time. Turning off roothub port power is also recommended in xhci specification 4.19.4 "Port Power" in the additional note. Cc: stable@vger.kernel.org Signed-off-by: Mathias Nyman Link: https://lore.kernel.org/r/20220623111945.1557702-3-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci-hub.c | 2 +- drivers/usb/host/xhci.c | 15 +++++++++++++-- drivers/usb/host/xhci.h | 2 ++ 3 files changed, 16 insertions(+), 3 deletions(-) --- a/drivers/usb/host/xhci-hub.c +++ b/drivers/usb/host/xhci-hub.c @@ -565,7 +565,7 @@ struct xhci_hub *xhci_get_rhub(struct us * It will release and re-aquire the lock while calling ACPI * method. */ -static void xhci_set_port_power(struct xhci_hcd *xhci, struct usb_hcd *hcd, +void xhci_set_port_power(struct xhci_hcd *xhci, struct usb_hcd *hcd, u16 index, bool on, unsigned long *flags) { struct xhci_hub *rhub; --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -774,6 +774,8 @@ static void xhci_stop(struct usb_hcd *hc void xhci_shutdown(struct usb_hcd *hcd) { struct xhci_hcd *xhci = hcd_to_xhci(hcd); + unsigned long flags; + int i; if (xhci->quirks & XHCI_SPURIOUS_REBOOT) usb_disable_xhci_ports(to_pci_dev(hcd->self.sysdev)); @@ -789,12 +791,21 @@ void xhci_shutdown(struct usb_hcd *hcd) del_timer_sync(&xhci->shared_hcd->rh_timer); } - spin_lock_irq(&xhci->lock); + spin_lock_irqsave(&xhci->lock, flags); xhci_halt(xhci); + + /* Power off USB2 ports*/ + for (i = 0; i < xhci->usb2_rhub.num_ports; i++) + xhci_set_port_power(xhci, xhci->main_hcd, i, false, &flags); + + /* Power off USB3 ports*/ + for (i = 0; i < xhci->usb3_rhub.num_ports; i++) + xhci_set_port_power(xhci, xhci->shared_hcd, i, false, &flags); + /* Workaround for spurious wakeups at shutdown with HSW */ if (xhci->quirks & XHCI_SPURIOUS_WAKEUP) xhci_reset(xhci, XHCI_RESET_SHORT_USEC); - spin_unlock_irq(&xhci->lock); + spin_unlock_irqrestore(&xhci->lock, flags); xhci_cleanup_msix(xhci); --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -2145,6 +2145,8 @@ int xhci_hub_control(struct usb_hcd *hcd int xhci_hub_status_data(struct usb_hcd *hcd, char *buf); int xhci_find_raw_port_number(struct usb_hcd *hcd, int port1); struct xhci_hub *xhci_get_rhub(struct usb_hcd *hcd); +void xhci_set_port_power(struct xhci_hcd *xhci, struct usb_hcd *hcd, u16 index, + bool on, unsigned long *flags); void xhci_hc_died(struct xhci_hcd *xhci);