Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2902724iog; Mon, 27 Jun 2022 05:26:01 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sTL01Hr5G0NQxT7i2HEt2Qyk+wnEOjCOn+R+pxHBCNTHuntjOQGmezwp01x/fhBOZqvIYg X-Received: by 2002:a17:902:cec9:b0:16a:644a:6019 with SMTP id d9-20020a170902cec900b0016a644a6019mr14104540plg.82.1656332761218; Mon, 27 Jun 2022 05:26:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656332761; cv=none; d=google.com; s=arc-20160816; b=bFV2xgXBPu4Ev0YC0BlniA3KITSAVlfokR0foh25fy/E6+b+XqsW0z5o/5F8nUdWN6 XPA5fdO/vxvFPfJKx9UVhZg4iku8RHmf+xd/Bp5+vjMJ3VVF+VAP1Uh/6UA+fb1ZuIyM HYrEsM111A5bPq97hcXNGYN/6gwMtLwUyM3vGd5lh7sVHMPbtagvqbVaLRuREHJxoDtp /HjWjRnO4I4fSofU+tf0Rd/ui5OxKAV1WeCcM8tskZ8r01tgk7XFkW3rSGez9JUck6ys OTp8fmGtsB+Nd7Or3TkLzXjU05RxHvCUZN9UytMBRKR0h8O1KTjdAMXv+62J4NPd1Qk0 ak9A== 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=HlsGygZtHxHXbNSfYsnpsc2yKX9mS97/5qV+QOLO2Es=; b=U2tqleJaQuhhYR3LQdrFmNoPcJ3zPcfeV9fvJd3v8tATwfoOpGqTnULcr1yaYATulA +rh5oCGia6f9+uJ6eKvOK9Hnrfo9MjqK2WKTCiEVKoabMp3uLjEGHiu07KXJ1TrqsenW zemK+zVJI68mMnqsVa5qTDi+mMT3yeMtMDEy+Z6C+7Bbzv/m9PtJgCc01iGstTnmA+rZ vsE/+x9mvYhd3nOtlHWadG2tvUtYBZPGQv2biiP39dRmwCCeWIyEKIqMoKUowze7r0lJ MxM5dz2bOt/r4ta/9mpTZtughzvfS8SqdDS0rTKMSBebbKan4Q2Gy6IsYSVKk2j8sgxs mYTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kNzHNNWw; 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 17-20020a630b11000000b0039dad7a82fdsi12393876pgl.632.2022.06.27.05.25.49; Mon, 27 Jun 2022 05:26:01 -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=kNzHNNWw; 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 S234942AbiF0L0x (ORCPT + 99 others); Mon, 27 Jun 2022 07:26:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235027AbiF0L0K (ORCPT ); Mon, 27 Jun 2022 07:26:10 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9651F7674; Mon, 27 Jun 2022 04:25:49 -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 346F56145B; Mon, 27 Jun 2022 11:25:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 39F72C3411D; Mon, 27 Jun 2022 11:25:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656329148; bh=yGaILlkr6t2JBLMbPnHUcYbytbewGGpb8N6xz5lMpUI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kNzHNNWwXQD3uPHK1WHLh6B6m2VpvM80YyKMJTrkFZVFfAow9im4gtfgqOly1A+lS WDrZhsobM/sHpUzerjib5Vx7KU4VWGyleAtQ4Cr7DTFPNbHoNL25rBNSkvWz0IzsJy sEXeQhyKgorguF4tpWsTCM0ghkG2VDpe0U3Jk5aQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mathias Nyman Subject: [PATCH 5.10 066/102] xhci: turn off port power in shutdown Date: Mon, 27 Jun 2022 13:21:17 +0200 Message-Id: <20220627111935.429869653@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220627111933.455024953@linuxfoundation.org> References: <20220627111933.455024953@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 @@ -566,7 +566,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) __must_hold(&xhci->lock) { --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -775,6 +775,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)); @@ -790,12 +792,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 @@ -2162,6 +2162,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);