Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3023236ybt; Mon, 29 Jun 2020 13:10:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyS+3TcBXay0J8jr6IfDRkeKlOgDEmyArHJbUySZuN8Y2fTcUYuYhGZ5e+CDxQpo1rSMiIo X-Received: by 2002:a17:906:e294:: with SMTP id gg20mr14775441ejb.521.1593461438840; Mon, 29 Jun 2020 13:10:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593461438; cv=none; d=google.com; s=arc-20160816; b=vF+ROKhAhyAB26KvsYBOlQCZ6UqXH8gZUT0GehB+vw3+ns85aakzjcc5cmuEOux45o CsM/q5+z6S/mxsmYpnqGE/8jC8rxiHk+4r3quzl6pkkeQXG9y3JCiIWHv5Elv/r4I0AE rtbhfhGgKjlFKqmuRSATOlifxe2Vq7Vb55QjfISUkxrtAgBaJ+18a7kjOFdrm3yUUcOj P1akUfRlRRwEWV81Wficg64kT62bCDY8YhsZsOSSC3p8YPAK6KZRSMeU1qa1pUXJsSXx nH7uj5yBEaR6dnjrL/TYhHj4pjZRPVfF58BsiB4A34POYIb8nHel6cRFvOOdUIi0znFl ofgw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9F3mEemEL8IXXJa23GX0czDSTldll5I6jPKOU9iSspw=; b=rW9WaBRcecLxIF1k4M+GlTrNzzvXtDsh0J0f3J4E3smdcoMQk+ZX+QdrvWQfV0f0fd kpgk0QIAdHXoD0TDXf2axzaAMyKmlIe4G0VXZtk0jIKfSvBZfPTpg8+l3qKvAIfGYWXS kCaYqXU8R0LGyJUPcn+4SbXlHzZeCzGTu2giL/kLolCkNuBrvDr2Lya3k44cDLSGGpH1 YZul00jItAyvSw3SK4a9ORfhMzm90J2z5Cz72n1nZ1mf7gPmvWbCp6ZxRNCm8iDY8nSX I0kRm0PyWtDbG0KW8QpLETm/cZnrQk8lpHC3wQPFl2AWatjYh5Z/VMQi3Mzm/Zhsa9oS SBBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YOHQevzk; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lu12si373909ejb.269.2020.06.29.13.10.16; Mon, 29 Jun 2020 13:10:38 -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=YOHQevzk; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726855AbgF2UJU (ORCPT + 99 others); Mon, 29 Jun 2020 16:09:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:40592 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732921AbgF2TaW (ORCPT ); Mon, 29 Jun 2020 15:30:22 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 079F22520D; Mon, 29 Jun 2020 15:35:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1593444948; bh=WcwcWtLCHVk5avc1l8MLwJSQ8mF0Qpzh/HG6UIJq678=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YOHQevzkBC6VSdmfnmmJSl0WoCVEdOIqEa+BwkYyzdUDx03eD/094ahbzQV5oWUYo dke7lkzp8LYLxC/cYZXrKe7sDUT8P0dH5woFZoWRTt0WZ1jPP1atw7asQcsEAKLTOy w5uemuEHdTNOYNnwuY1BhJwLs2QG4WyRFXH1DTHA= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Kai-Heng Feng , Mathias Nyman , Greg Kroah-Hartman Subject: [PATCH 4.19 046/131] xhci: Poll for U0 after disabling USB2 LPM Date: Mon, 29 Jun 2020 11:33:37 -0400 Message-Id: <20200629153502.2494656-47-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200629153502.2494656-1-sashal@kernel.org> References: <20200629153502.2494656-1-sashal@kernel.org> MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.19.131-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-4.19.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 4.19.131-rc1 X-KernelTest-Deadline: 2020-07-01T15:34+00:00 X-stable: review X-Patchwork-Hint: Ignore 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 commit b3d71abd135e6919ca0b6cab463738472653ddfb upstream. USB2 devices with LPM enabled may interrupt the system suspend: [ 932.510475] usb 1-7: usb suspend, wakeup 0 [ 932.510549] hub 1-0:1.0: hub_suspend [ 932.510581] usb usb1: bus suspend, wakeup 0 [ 932.510590] xhci_hcd 0000:00:14.0: port 9 not suspended [ 932.510593] xhci_hcd 0000:00:14.0: port 8 not suspended .. [ 932.520323] xhci_hcd 0000:00:14.0: Port change event, 1-7, id 7, portsc: 0x400e03 .. [ 932.591405] PM: pci_pm_suspend(): hcd_pci_suspend+0x0/0x30 returns -16 [ 932.591414] PM: dpm_run_callback(): pci_pm_suspend+0x0/0x160 returns -16 [ 932.591418] PM: Device 0000:00:14.0 failed to suspend async: error -16 During system suspend, USB core will let HC suspends the device if it doesn't have remote wakeup enabled and doesn't have any children. However, from the log above we can see that the usb 1-7 doesn't get bus suspended due to not in U0. After a while the port finished U2 -> U0 transition, interrupts the suspend process. The observation is that after disabling LPM, port doesn't transit to U0 immediately and can linger in U2. xHCI spec 4.23.5.2 states that the maximum exit latency for USB2 LPM should be BESL + 10us. The BESL for the affected device is advertised as 400us, which is still not enough based on my testing result. So let's use the maximum permitted latency, 10000, to poll for U0 status to solve the issue. Cc: stable@vger.kernel.org Signed-off-by: Kai-Heng Feng Signed-off-by: Mathias Nyman Link: https://lore.kernel.org/r/20200624135949.22611-6-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index b4177287d7d0f..b02b83a38dca1 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -4385,6 +4385,9 @@ static int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd, mutex_lock(hcd->bandwidth_mutex); xhci_change_max_exit_latency(xhci, udev, 0); mutex_unlock(hcd->bandwidth_mutex); + readl_poll_timeout(ports[port_num]->addr, pm_val, + (pm_val & PORT_PLS_MASK) == XDEV_U0, + 100, 10000); return 0; } } -- 2.25.1