Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp2334302ybz; Thu, 23 Apr 2020 16:13:35 -0700 (PDT) X-Google-Smtp-Source: APiQypL3h9QL3iiwQRyCzDvpjkJTcAMPOgqK0k97GWvkaNJfNNuJf+74y3BN8lK9IPx8imMbJc4q X-Received: by 2002:a05:6402:6cb:: with SMTP id n11mr4959788edy.210.1587683615488; Thu, 23 Apr 2020 16:13:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587683615; cv=none; d=google.com; s=arc-20160816; b=rcZTUXeoPbeiUdV1PxjVEvbjaitrPo0oumvQw+G0hXkTRw+9ZynQOVMk8YrBVeCHE+ Kclk5R1GZ8HC0su4W+sLt6diorBfXDrsJj9Mqu/huUWddRJUzSxlKbQcq0jkNT9HXDd0 2KsyEssPzaJSWaJkj7HUTsQf54HszXvbf4bbT1I51/wudI2/lwCOwVVuv/2cyqkPHrsh cJyzWwUDfAKTv6lrzrzwY5h0m+vVys72FKHcbDWHeCszBXIRpUnb+POojMu7bR7zcp19 3oTiq5EW4k8TL+u5+pJm+v6/omZkE9lgpBXBw/NdnXX6KJ/Es2tPBH3sseLqmgB1sk2b h1AA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=o+pQ2FnGcG6U4gIS11Lbafa8927Tcm4hgWxk6wDJUqo=; b=SGZX7+p8R3cSHDclghrj9b7kmLuc0exjPx9ROtzn2AdcQhpMXWSg0qK8mmWOxMRVWz Y8JHAMysAlYCuF2iq/D0NerHdIxAgQAW83R9R4tOkM9TJ851aiyBSZlNJ+hOymzsBwJ2 LaEPjpVXD/DS+JwDJITjZwFjOZ3GwW+6Ah5nwKWEYM5GOdqzWw3tOm/DzPxIUj/d/I/y 5mP4KZ1mekX/LWCevDM3Taj55aLgx7osci4YMli+jNjh8Y04ETdlxU4nDobCuYxkTArJ +JorEzcLOqFlFxry34Q03oisjTkTGLN7F3CkanZlEgcAZepf70JzRBD0NY7xxo3KwBMC BoMg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u3si2119087edo.526.2020.04.23.16.13.12; Thu, 23 Apr 2020 16:13:35 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729174AbgDWXKj (ORCPT + 99 others); Thu, 23 Apr 2020 19:10:39 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:50354 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728598AbgDWXGx (ORCPT ); Thu, 23 Apr 2020 19:06:53 -0400 Received: from [192.168.4.242] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1jRkvd-0004lP-Sz; Fri, 24 Apr 2020 00:06:46 +0100 Received: from ben by deadeye with local (Exim 4.93) (envelope-from ) id 1jRkvW-00E6wh-Ml; Fri, 24 Apr 2020 00:06:38 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, Denis Kirjanov , "Greg Kroah-Hartman" , "Alan Stern" , "Keiya Nobuta" Date: Fri, 24 Apr 2020 00:06:52 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) X-Patchwork-Hint: ignore Subject: [PATCH 3.16 185/245] usb: core: hub: Improved device recognition on remote wakeup In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.242 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.83-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Keiya Nobuta commit 9c06ac4c83df6d6fbdbf7488fbad822b4002ba19 upstream. If hub_activate() is called before D+ has stabilized after remote wakeup, the following situation might occur: __ ___________________ / \ / D+ __/ \__/ Hub _______________________________ | ^ ^ ^ | | | | Host _____v__|___|___________|______ | | | | | | | \-- Interrupt Transfer (*3) | | \-- ClearPortFeature (*2) | \-- GetPortStatus (*1) \-- Host detects remote wakeup - D+ goes high, Host starts running by remote wakeup - D+ is not stable, goes low - Host requests GetPortStatus at (*1) and gets the following hub status: - Current Connect Status bit is 0 - Connect Status Change bit is 1 - D+ stabilizes, goes high - Host requests ClearPortFeature and thus Connect Status Change bit is cleared at (*2) - After waiting 100 ms, Host starts the Interrupt Transfer at (*3) - Since the Connect Status Change bit is 0, Hub returns NAK. In this case, port_event() is not called in hub_event() and Host cannot recognize device. To solve this issue, flag change_bits even if only Connect Status Change bit is 1 when got in the first GetPortStatus. This issue occurs rarely because it only if D+ changes during a very short time between GetPortStatus and ClearPortFeature. However, it is fatal if it occurs in embedded system. Signed-off-by: Keiya Nobuta Acked-by: Alan Stern Link: https://lore.kernel.org/r/20200109051448.28150-1-nobuta.keiya@fujitsu.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Ben Hutchings --- drivers/usb/core/hub.c | 1 + 1 file changed, 1 insertion(+) --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -1125,6 +1125,7 @@ static void hub_activate(struct usb_hub * PORT_OVER_CURRENT is not. So check for any of them. */ if (udev || (portstatus & USB_PORT_STAT_CONNECTION) || + (portchange & USB_PORT_STAT_C_CONNECTION) || (portstatus & USB_PORT_STAT_OVERCURRENT) || (portchange & USB_PORT_STAT_C_OVERCURRENT)) set_bit(port1, hub->change_bits);