Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp4459669ybz; Tue, 28 Apr 2020 11:39:26 -0700 (PDT) X-Google-Smtp-Source: APiQypIAUumOpPpY63YFcfoOKL6gWZKwCZgqNmB6EYGNJrcacZIRuDy0oFDNC/LW63VrLwOKDagh X-Received: by 2002:a17:907:1199:: with SMTP id uz25mr25537051ejb.131.1588099165901; Tue, 28 Apr 2020 11:39:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588099165; cv=none; d=google.com; s=arc-20160816; b=Pz6EDEfvmkgcjg8lLuMAi0zGLckMy0MHrzXhiaQfbT/6O3fMTEdsfG8HK1x9nlYqnH XFEf7QftFHAzJW7ErBETOoUpg12trly/vC+vVP0U+4EEMMsNIUOJuh/T++cCshjB7vcM WfaHC5+UJbMrlmvatkgj7DjMZKi7hjpxjh5W6lRnXoWr9cunMjDV2HcEjXuzsDF38wF+ 3zDQH+Gt9ajVTq+P0ELQ6t3/EAzfoDW3y2pr8rcmlg27Ygy6NaEz0CR17pBiM9oHVlEV Ytx0ql/qq3EruCnLgwClZkAhf9VV47cWQ38ifo2u4xSNiOGGN5hbWBwS28GmM29Hn6Ys k6Bw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Q73o0UwP41uCMw5CAlWN+A5VpeBgnijSQZ2QHN01/ow=; b=t8jxW9TKmkOVW9XRoATf01tkoQydPmxhJPlH966BEDW+5Tfymf7R3Jc3ba+dEUOW53 HwaPyBImSzRBwFvTGczQPrrklFrKPDPIc7ViCGJiYo2NKQwPHhYPEOlpMZgSdepeKFZ+ FlQO7N/ZWlLwHnZW65X0sX9+2x+H4aWqZU6DMeq+gp6YcmjCDA16Ra1gitbS7TzoNI8T 1vns7l9oie/8A6zEq9LWgwx5FC/ZYL6I0qr4+vrKbpU66CnaszXtj8VrCR6pQDmvonEE ibt/7R2Y9DwYBB72k9577mPQBUFbx6vt77NrmKJ7+1b1Qj8B6cbob/262hbfv7nwTPqX 8TvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YdmLdoNb; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d9si2502058ejb.387.2020.04.28.11.39.01; Tue, 28 Apr 2020 11:39:25 -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; dkim=pass header.i=@kernel.org header.s=default header.b=YdmLdoNb; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729295AbgD1Sg2 (ORCPT + 99 others); Tue, 28 Apr 2020 14:36:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:53728 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730369AbgD1SgT (ORCPT ); Tue, 28 Apr 2020 14:36:19 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5CA5B20730; Tue, 28 Apr 2020 18:36:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588098978; bh=hVGd1XVXIQixtTCRrA9xVPLTqm8xr2yA0JSWE2QJe5Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YdmLdoNbH5rGjLvIzjirr4YUeSpd6lkRncOzyGACKtvKzRywEgPHYn46FFKvAv77h 1APf155bI3qzDp4Wl8VR6k84zG20YTC2ImtiC+M5mVGyUTOSSRbJG1mz/pC4SWsYYO bhC2NjAwatk7pAToacCNaymwsDM66qavgwIK1bKs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kai-Heng Feng , Mathias Nyman , Sasha Levin Subject: [PATCH 5.4 041/168] xhci: Ensure link state is U3 after setting USB_SS_PORT_LS_U3 Date: Tue, 28 Apr 2020 20:23:35 +0200 Message-Id: <20200428182237.018243861@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200428182231.704304409@linuxfoundation.org> References: <20200428182231.704304409@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Kai-Heng Feng [ Upstream commit eb002726fac7cefb98ff39ddb89e150a1c24fe85 ] The xHCI spec doesn't specify the upper bound of U3 transition time. For some devices 20ms is not enough, so we need to make sure the link state is in U3 before further actions. I've tried to use U3 Entry Capability by setting U3 Entry Enable in config register, however the port change event for U3 transition interrupts the system suspend process. For now let's use the less ideal method by polling PLS. [use usleep_range(), and shorten the delay time while polling -Mathias] Signed-off-by: Kai-Heng Feng Signed-off-by: Mathias Nyman Link: https://lore.kernel.org/r/20200312144517.1593-7-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/host/xhci-hub.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c index af92b2576fe91..712cd44f05ace 100644 --- a/drivers/usb/host/xhci-hub.c +++ b/drivers/usb/host/xhci-hub.c @@ -1322,7 +1322,16 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, xhci_set_link_state(xhci, ports[wIndex], link_state); spin_unlock_irqrestore(&xhci->lock, flags); - msleep(20); /* wait device to enter */ + if (link_state == USB_SS_PORT_LS_U3) { + int retries = 16; + + while (retries--) { + usleep_range(4000, 8000); + temp = readl(ports[wIndex]->addr); + if ((temp & PORT_PLS_MASK) == XDEV_U3) + break; + } + } spin_lock_irqsave(&xhci->lock, flags); temp = readl(ports[wIndex]->addr); -- 2.20.1