Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1188976ybi; Fri, 2 Aug 2019 10:48:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqztVJkBpIUvkR5G30a7ceTqVAyuVpNaRnjdwwLiYo7a9ZPaFj6capF+kT+wTPAGni/oQfSi X-Received: by 2002:a17:902:3081:: with SMTP id v1mr135200542plb.169.1564768107195; Fri, 02 Aug 2019 10:48:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564768107; cv=none; d=google.com; s=arc-20160816; b=prSS+f92sV/4asTvMBRcC8p1fh9jxpPoXbYtfKnF4wrFJEIKEdDUPuZsmhq2FMuX6E YA3mmJXri8910mhYYSHvneg/tOlcWoVyLhtYlZheZAZm0r+ASlPK56YEJ8bCKvcpiarP rI3dtx73pqyn3lUb8m+5dIHi5MULTsk1lHFH2NjCaw6zrQ3UVLlEt8H04dp9N4wJ46CR wbxXzICWHld5KcTmLTMmjIIpQIQExPwXOM4ajTqTOFVOWhsAgbejvQOgOl3I3L8ONUjJ uq8jeW8Sv75OJjhsCcqYLT5L+qG2jgg8u/TkVVkJeJcph2G4SR3vVIAtFBUIpcv+mRpW 41vw== 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=kEmb3kdB2WdjG3G8O55zenICl5kFwLczEJTMHp/Pa70=; b=byIpFr/0Tn1c3j1gwI7hjGg0cVy1IFHpBd+5kgwyTOI7O2LGrvEtFH17aC+Pg/2Tfh FPigxI3AShYo0bCS2lUsy1ectlDM4rH8j5h9VVUNWBhl7UriH0CVRnh69PKMAlfYiaHE qfW8cz975kcYkC8tKSgmuRGh+PEjVR8cawTsBrgQVqd5ISZECD84awew9Cxp6kSuC/Mc tyPh5cf0/rbbSTCsAHcVYhpLqiw2DHoGDQ7ro6X+0SL0aWFKvgcIyysWFhnNHBolagPV atJUAhv3oLEbLedxg3vCKYrZKB5ulCNUlfynEw7o3Uj1/hMJf2jygJPB37ZNRKzO7zOu k2zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@kernel.org header.s=default header.b=D+fCngFY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m35si7143284pje.84.2019.08.02.10.48.12; Fri, 02 Aug 2019 10:48:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@kernel.org header.s=default header.b=D+fCngFY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405868AbfHBJui (ORCPT + 99 others); Fri, 2 Aug 2019 05:50:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:49184 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405439AbfHBJp1 (ORCPT ); Fri, 2 Aug 2019 05:45:27 -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 307B420679; Fri, 2 Aug 2019 09:45:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564739126; bh=gRUh7r/2kagW87k821dT4UvIbhIkwAbcPWIlzXVFqa4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D+fCngFYz/49lC13YeSkVHBbzSIwLtDzgtKrz0QsZLiKqCkf9nKNXGCMbpcEhHCnx QK0m1q29M8Qa5jeMipAppzrXn9GhDs/R/ohLu7lv3Ma+EWWj6i/Sb+BIdUv7Zu4GJd XDypqNwYij+6G4Mjx8NkvVpmNhbOj8p4L2veGDbA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Lee, Chiasheng" , Mathias Nyman , Lee@vger.kernel.org Subject: [PATCH 4.9 123/223] usb: Handle USB3 remote wakeup for LPM enabled devices correctly Date: Fri, 2 Aug 2019 11:35:48 +0200 Message-Id: <20190802092247.109782285@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802092238.692035242@linuxfoundation.org> References: <20190802092238.692035242@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: Lee, Chiasheng commit e244c4699f859cf7149b0781b1894c7996a8a1df upstream. With Link Power Management (LPM) enabled USB3 links transition to low power U1/U2 link states from U0 state automatically. Current hub code detects USB3 remote wakeups by checking if the software state still shows suspended, but the link has transitioned from suspended U3 to enabled U0 state. As it takes some time before the hub thread reads the port link state after a USB3 wake notification, the link may have transitioned from U0 to U1/U2, and wake is not detected by hub code. Fix this by handling U1/U2 states in the same way as U0 in USB3 wakeup handling This patch should be added to stable kernels since 4.13 where LPM was kept enabled during suspend/resume Cc: # v4.13+ Signed-off-by: Lee, Chiasheng Signed-off-by: Mathias Nyman Signed-off-by: Greg Kroah-Hartman --- drivers/usb/core/hub.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -3535,6 +3535,7 @@ static int hub_handle_remote_wakeup(stru struct usb_device *hdev; struct usb_device *udev; int connect_change = 0; + u16 link_state; int ret; hdev = hub->hdev; @@ -3544,9 +3545,11 @@ static int hub_handle_remote_wakeup(stru return 0; usb_clear_port_feature(hdev, port, USB_PORT_FEAT_C_SUSPEND); } else { + link_state = portstatus & USB_PORT_STAT_LINK_STATE; if (!udev || udev->state != USB_STATE_SUSPENDED || - (portstatus & USB_PORT_STAT_LINK_STATE) != - USB_SS_PORT_LS_U0) + (link_state != USB_SS_PORT_LS_U0 && + link_state != USB_SS_PORT_LS_U1 && + link_state != USB_SS_PORT_LS_U2)) return 0; }