Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3818366ybi; Mon, 29 Jul 2019 13:13:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqwy+rASHnyJvYT5wV3Hd4tPnQCihxJrMbPbjVtnr+c0VA4N6fMPxHueHdbP6k46JN5NLxQV X-Received: by 2002:aa7:8102:: with SMTP id b2mr38755926pfi.105.1564431210653; Mon, 29 Jul 2019 13:13:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564431210; cv=none; d=google.com; s=arc-20160816; b=ONR1uFkOvHqSAqkzmteP8B8k5ZVAePJZjZ+XudlLo0rV/H7dZDC1EGL3WRXycA4r1v TMdHvfijWFcFAoNdV22PEFOZHrpOSROUAwzec3KzuYI4lV6eyaYEUqBO7hGBbxQAdLFB sM7AErv1uqPPKUj74sMu20gNo0McPI5wu4MM53YuuiSasrkjtrBDGSWTsCS8floJsR9X 8t1f8ioKwmBjtNxKTSHuRaPec2WRyzs83D62y1SoUGii73rQLjXACo8Vcc9Zd27ZACBW lJYUmtzw00zRiBjg/fykuxJRGkicM2NXYVRiHNt3c6ehLTz1Jfarg4n3/PQyxbUERDkx q8og== 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=5aeLXTe8XlbIn7byUHYxtYpnG+NROjh4l6wyLlFCUec=; b=AztNH49C/IuvocPki+cMe7CVfJxFcFVe3iAAjl3RV7tOo0OcW3AGFFs+97UE9AHLVc KCpYbbIntBg3lQw0mVCUgJtnzoiQOyzgK/qRtlqKbofgLVGG7fEVrCzY+Q0iAR0ch+sw Bk8iqnCY6Wf0tr73ocCJvyGbxIC44cYw63QE2OU7OriUWNNTTbRuscxBQxN0iNC3Jpvl 7ASRs9NUy3tCIBc3OfCPaxWtg7AhxC5P5It+83OcTAO8MhD1yaNhTRc8C83BWLKTOFsC KjgUqI2gk6HgyMFZKXDNfYyWYxYVR3/mdXzCckw8GIF0tKG9H55dTL2FgoxDMV7tlLf2 Fa5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@kernel.org header.s=default header.b=wjkDVj0b; 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 n6si26270912pjb.73.2019.07.29.13.13.15; Mon, 29 Jul 2019 13:13:30 -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=wjkDVj0b; 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 S1728825AbfG2UMB (ORCPT + 99 others); Mon, 29 Jul 2019 16:12:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:46104 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729269AbfG2Tcd (ORCPT ); Mon, 29 Jul 2019 15:32:33 -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 389D1217D4; Mon, 29 Jul 2019 19:32:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564428752; bh=HFU/DbYWq2H2LL/Ks3RT4dJnz4zgG/Hmhvvi2tRXXQg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wjkDVj0bESS8Quf1mHX5+0jQ2oYc6bjzzVmrzvbTV3LSlAk9qL+Qm0R4I8YUiEfY3 a5NWWNqQ4Q2fGeh49vkMtRh/RVOeIeDE1OBv+I9/uanu5edisSBP15zBQvXgsIE3++ Sr2u+S2amZczkQwctO7PqnQzFCrpiiOvuiJZEi+0= 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.14 174/293] usb: Handle USB3 remote wakeup for LPM enabled devices correctly Date: Mon, 29 Jul 2019 21:21:05 +0200 Message-Id: <20190729190837.847991420@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190820.321094988@linuxfoundation.org> References: <20190729190820.321094988@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 @@ -3532,6 +3532,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; @@ -3541,9 +3542,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; }