Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp269988ybg; Tue, 9 Jun 2020 23:46:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwAUJGH+/iWPbFEpE7XfAFyj67BeW7VWcaQdflwPzKwX/EWr0QbKFG95xgzrR7tUenBOyFx X-Received: by 2002:a17:906:2584:: with SMTP id m4mr2029833ejb.328.1591771608977; Tue, 09 Jun 2020 23:46:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591771608; cv=none; d=google.com; s=arc-20160816; b=sCPXyg6eAo6a+jaVd4U8/12es6O2ONAm7GoWJbSIuIB90T+ZDw7CKyUpyOcuctwwez IhadP8rqpbgr0DWptIcz/wL6dHZnzpK07czy3gf2pxwTAQ5bfmKvM2HfQdlR8I4CsJpg WDSmQlRuLdLKFiqZZSLH4z8kE3tA7jrzrqCHu4QUm4qbdPXAOq2pQi3RSN30cv4HXAXg vG/n8wQBR2UriSCSTZaMSrnwcbxlMXQJcPArb+kKRrXUZyEaWvMVDQIBpxJK34gyvXTJ iUh7xDhN/ZRNYpUUmbCQxeRKqxAFyGwZu4fwhQTm3ly4W9a6wXvIs32VDMoeEm+uz8Yc 8L4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=jEmcvoPAhCYk414w4rzi5X/RyXhmjG4IYYmJ88TrJ1I=; b=DMJGU5nJmNCvsHDGy05QOtVmBrfrfXAgLVYy5h/kiVXsEENMdLrPfD291dH20kkWPD GWGFQYzXBT/EdQhRO2vBFiTy1VahDzmbwrdos8A4+vfo7OpbicxeILPVCKVODT3rZTU5 ehkZVFHQLLJlcv356864AzdK//KaL3+NAvM+pv+4EIRjce7s8/vSlycKtdyRF2MuR9qQ uwyBaM3MXLLQ9bmOIW+Zdpz5FAdGuTBA3qInbbWEhKQ70+NMgBQGhZ6D8xCBMCBSaMFf Z+U8uYmuCdTqlAy0b17O88C91w6nPAWy5OK2mzmi940dKfY7hebixT7UULAMpb22EPYj 67sA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dt16si16429696ejc.525.2020.06.09.23.46.25; Tue, 09 Jun 2020 23:46:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726249AbgFJGmk (ORCPT + 99 others); Wed, 10 Jun 2020 02:42:40 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:51343 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726109AbgFJGmk (ORCPT ); Wed, 10 Jun 2020 02:42:40 -0400 Received: from 61-220-137-37.hinet-ip.hinet.net ([61.220.137.37] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jiuRX-0001Se-Lm; Wed, 10 Jun 2020 06:42:36 +0000 From: Kai-Heng Feng To: mathias.nyman@intel.com Cc: Kai-Heng Feng , Greg Kroah-Hartman , linux-usb@vger.kernel.org (open list:USB XHCI DRIVER), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 1/2] xhci: Suspend ports to U3 directly from U1 or U2 Date: Wed, 10 Jun 2020 14:42:30 +0800 Message-Id: <20200610064231.9454-1-kai.heng.feng@canonical.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org xHCI spec "4.15.1 Port Suspend" states that port can be put to U3 as long as Enabled bit is set and from U0, U1 or U2 state. Currently only USB_PORT_FEAT_LINK_STATE puts port to U3 directly, let's do the same for USB_PORT_FEAT_SUSPEND and bus suspend case. This is particularly useful for USB2 devices, which may take a very long time to switch USB2 LPM on and off. Suggested-by: Mathias Nyman Signed-off-by: Kai-Heng Feng --- drivers/usb/host/xhci-hub.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c index f37316d2c8fa..f9375b77d17d 100644 --- a/drivers/usb/host/xhci-hub.c +++ b/drivers/usb/host/xhci-hub.c @@ -1196,15 +1196,6 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, /* FIXME: What new port features do we need to support? */ switch (wValue) { case USB_PORT_FEAT_SUSPEND: - temp = readl(ports[wIndex]->addr); - if ((temp & PORT_PLS_MASK) != XDEV_U0) { - /* Resume the port to U0 first */ - xhci_set_link_state(xhci, ports[wIndex], - XDEV_U0); - spin_unlock_irqrestore(&xhci->lock, flags); - msleep(10); - spin_lock_irqsave(&xhci->lock, flags); - } /* In spec software should not attempt to suspend * a port unless the port reports that it is in the * enabled (PED = ‘1’,PLS < ‘3’) state. @@ -1645,8 +1636,10 @@ int xhci_bus_suspend(struct usb_hcd *hcd) xhci_dbg(xhci, "Bus suspend bailout, port over-current detected\n"); return -EBUSY; } - /* suspend ports in U0, or bail out for new connect changes */ - if ((t1 & PORT_PE) && (t1 & PORT_PLS_MASK) == XDEV_U0) { + /* suspend ports in U0/U1/U2, or bail out for new connect changes */ + if ((t1 & PORT_PE) && ((t1 & PORT_PLS_MASK) == XDEV_U0 || + (t1 & PORT_PLS_MASK) == XDEV_U1 || + (t1 & PORT_PLS_MASK) == XDEV_U2)) { if ((t1 & PORT_CSC) && wake_enabled) { bus_state->bus_suspended = 0; spin_unlock_irqrestore(&xhci->lock, flags); -- 2.17.1